Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions app/jobs/puzzle_inventory_check_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions app/lib/discord/bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/lib/discord/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Configuration

def initialize
@token = nil
@log_mode = :normal
end
end
end
1 change: 1 addition & 0 deletions lib/tasks/discord.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down