File tree Expand file tree Collapse file tree 5 files changed +6
-4
lines changed Expand file tree Collapse file tree 5 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ class ApplicationJob < ActiveJob::Base
44 def bot
55 @bot ||= Discord ::Bot . configure do |config |
66 config . token = ENV . fetch ( "DISCORD_BOT_TOKEN" , "" )
7+ config . log_mode = ENV . fetch ( "DISCORD_LOG_MODE" , "normal" ) . to_sym
78 end
89 end
910end
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def send_low_inventory_notification(count)
1919
2020 def send_message ( message , channel_id :)
2121 SlackClient ::Client . instance . chat_postMessage ( channel : channel_id , blocks : message )
22- rescue Slack ::Web ::Api ::Errors ::SlackError
23- head :unprocessable_entity
22+ rescue Slack ::Web ::Api ::Errors ::SlackError => e
23+ Rails . logger . error "Failed to send Slack message: #{ e . message } #{ e . response_metadata } "
2424 end
2525end
Original file line number Diff line number Diff line change @@ -18,10 +18,9 @@ def configure
1818 delegate :send_message , to : :bot
1919
2020 def initialize ( configuration )
21- @bot = Discordrb ::Bot . new ( token : configuration . token )
21+ @bot = Discordrb ::Bot . new ( token : configuration . token , log_mode : configuration . log_mode )
2222 @bot . ready do
2323 Rails . logger . info "✅ Bot is online and connected to Discord!"
24- puts "✅ Bot is online and connected to Discord!"
2524 setup
2625 end
2726 end
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ class Configuration
55
66 def initialize
77 @token = nil
8+ @log_mode = :normal
89 end
910 end
1011end
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ def bot
2626 @bot ||= begin
2727 bot_wrapper = Discord ::Bot . configure do |config |
2828 config . token = ENV . fetch ( "DISCORD_BOT_TOKEN" )
29+ config . log_mode = ENV . fetch ( "DISCORD_LOG_MODE" , "normal" ) . to_sym
2930 end
3031 bot_wrapper . bot
3132 end
You can’t perform that action at this time.
0 commit comments