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
4
4
def bot
5
5
@bot ||= Discord ::Bot . configure do |config |
6
6
config . token = ENV . fetch ( "DISCORD_BOT_TOKEN" , "" )
7
+ config . log_mode = ENV . fetch ( "DISCORD_LOG_MODE" , "normal" ) . to_sym
7
8
end
8
9
end
9
10
end
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def send_low_inventory_notification(count)
19
19
20
20
def send_message ( message , channel_id :)
21
21
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 } "
24
24
end
25
25
end
Original file line number Diff line number Diff line change @@ -18,10 +18,9 @@ def configure
18
18
delegate :send_message , to : :bot
19
19
20
20
def initialize ( configuration )
21
- @bot = Discordrb ::Bot . new ( token : configuration . token )
21
+ @bot = Discordrb ::Bot . new ( token : configuration . token , log_mode : configuration . log_mode )
22
22
@bot . ready do
23
23
Rails . logger . info "✅ Bot is online and connected to Discord!"
24
- puts "✅ Bot is online and connected to Discord!"
25
24
setup
26
25
end
27
26
end
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ class Configuration
5
5
6
6
def initialize
7
7
@token = nil
8
+ @log_mode = :normal
8
9
end
9
10
end
10
11
end
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ def bot
26
26
@bot ||= begin
27
27
bot_wrapper = Discord ::Bot . configure do |config |
28
28
config . token = ENV . fetch ( "DISCORD_BOT_TOKEN" )
29
+ config . log_mode = ENV . fetch ( "DISCORD_LOG_MODE" , "normal" ) . to_sym
29
30
end
30
31
bot_wrapper . bot
31
32
end
You can’t perform that action at this time.
0 commit comments