-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiscord.rake
More file actions
38 lines (32 loc) · 1.12 KB
/
discord.rake
File metadata and controls
38 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
namespace :discord do
desc "Configure and run the discord bot"
task start_bot: :environment do
bot.run
end
desc "Sends a daily puzzle. Useful for days when the approved puzzles where at 0 when the cron job ran."
task new_puzzle: :environment do
DailyPuzzleJob.perform_now
end
desc "Clear all globally registered bot commands and re-register them"
task reset_commands: :environment do
# Fetch and delete all existing commands
commands = bot.get_application_commands
commands.each do |command|
bot.delete_application_command(command.id)
end
puts "✅ Cleared all global commands. Now re-registering..."
# Register the commands again
bot.register_application_command(:set_channel, "Set a channel for bot to be used in.")
bot.register_application_command(:help, "Get help on how to use the bot.")
puts "✅ Re-registered commands!"
end
end
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
end