diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index 16d96d8..85f52aa 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -4,6 +4,7 @@ class ApplicationJob < ActiveJob::Base def bot @bot ||= Discord::Bot.configure do |config| config.token = ENV.fetch("DISCORD_BOT_TOKEN", "") + config.log_mode = ENV.fetch("DISCORD_LOG_MODE", "normal").to_sym end end end diff --git a/app/jobs/puzzle_inventory_check_job.rb b/app/jobs/puzzle_inventory_check_job.rb index e7d0bf0..656e42c 100644 --- a/app/jobs/puzzle_inventory_check_job.rb +++ b/app/jobs/puzzle_inventory_check_job.rb @@ -19,7 +19,7 @@ def send_low_inventory_notification(count) def send_message(message, channel_id:) SlackClient::Client.instance.chat_postMessage(channel: channel_id, blocks: message) - rescue Slack::Web::Api::Errors::SlackError - head :unprocessable_entity + rescue Slack::Web::Api::Errors::SlackError => e + Rails.logger.error "Failed to send Slack message: #{e.message} #{e.response_metadata}" end end diff --git a/app/lib/discord/bot.rb b/app/lib/discord/bot.rb index 360b09a..9250321 100644 --- a/app/lib/discord/bot.rb +++ b/app/lib/discord/bot.rb @@ -18,10 +18,9 @@ def configure delegate :send_message, to: :bot def initialize(configuration) - @bot = Discordrb::Bot.new(token: configuration.token) + @bot = Discordrb::Bot.new(token: configuration.token, log_mode: configuration.log_mode) @bot.ready do Rails.logger.info "✅ Bot is online and connected to Discord!" - puts "✅ Bot is online and connected to Discord!" setup end end diff --git a/app/lib/discord/configuration.rb b/app/lib/discord/configuration.rb index ffa7ac4..5374079 100644 --- a/app/lib/discord/configuration.rb +++ b/app/lib/discord/configuration.rb @@ -5,6 +5,7 @@ class Configuration def initialize @token = nil + @log_mode = :normal end end end diff --git a/lib/tasks/discord.rake b/lib/tasks/discord.rake index 02104aa..d6b9e39 100644 --- a/lib/tasks/discord.rake +++ b/lib/tasks/discord.rake @@ -26,6 +26,7 @@ def bot @bot ||= begin bot_wrapper = Discord::Bot.configure do |config| config.token = ENV.fetch("DISCORD_BOT_TOKEN") + config.log_mode = ENV.fetch("DISCORD_LOG_MODE", "normal").to_sym end bot_wrapper.bot end