Skip to content

Commit

Permalink
Fix direct messages breaking due to missing server name
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbuker committed May 24, 2024
1 parent 762bf58 commit 1f32a47
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/discord_bot/bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ def initialize
]
end

def run(skip_motd: false)
def run(skip_motd: false, fast_boot: false)
Logger.info 'Initializing bot'
pull_default_model
delete_unused_commands
register_commands
unless fast_boot
pull_default_model
delete_unused_commands
register_commands
end
initialize_callbacks
motd unless skip_motd
# at_exit { @bot.stop }
Expand Down Expand Up @@ -186,7 +188,7 @@ def register_commands
end

def handle_message(message)
Logger.info "Message received (#{message.server.name} \##{message.channel.name}):\n#{message.content}"
Logger.info "Message received (#{message.from}):\n#{message.content}"
if message.content.start_with?('!prompt ')
set_system_prompt_from_chat(message)
elsif message.content.include?('(╯°□°)╯︵ ┻━┻')
Expand Down
8 changes: 8 additions & 0 deletions lib/discord_bot/events/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ def server
@event.server
end

def from
if server.present?
"#{server.name} \##{channel.name}"
else
"<@#{user.id}> @#{channel.name} \"#{name}\""
end
end

def name
if @event.user.nickname.present?
@event.user.nickname
Expand Down

0 comments on commit 1f32a47

Please sign in to comment.