Skip to content

Commit 00ee509

Browse files
committed
Add log-level control through env var
1 parent c00c22a commit 00ee509

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

app/jobs/application_job.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
910
end

app/lib/discord/bot.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff 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

app/lib/discord/configuration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Configuration
55

66
def initialize
77
@token = nil
8+
@log_mode = :normal
89
end
910
end
1011
end

lib/tasks/discord.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)