Main commit
This commit is contained in:
20
src/commands/currency.rb
Normal file
20
src/commands/currency.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
module Commands
|
||||
module Currency
|
||||
extend self
|
||||
|
||||
def register(bot, db)
|
||||
bot.register_application_command(:currency, 'Get your currency', server_id: ENV['TEST_SERVER_ID'])
|
||||
|
||||
bot.application_command(:currency) do |event|
|
||||
# 1. Get the User ID from the event
|
||||
user_id = event.user.id
|
||||
|
||||
# 2. Ask the DB for the balance
|
||||
balance = db.get_currency(user_id)
|
||||
|
||||
# 3. Respond to Discord
|
||||
event.respond(content: "You have #{balance} coins.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
14
src/commands/echo.rb
Normal file
14
src/commands/echo.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module Commands
|
||||
module Echo
|
||||
extend self
|
||||
def register(bot, _db)
|
||||
bot.register_application_command(:echo, 'Repeats what you say', server_id: ENV['TEST_SERVER_ID']) do |cmd|
|
||||
cmd.string('message', 'The text you want the bot to repeat', required: true)
|
||||
end
|
||||
|
||||
bot.application_command(:echo) do |event|
|
||||
event.respond(content: "You said: #{event.options['message']}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
13
src/commands/ping.rb
Normal file
13
src/commands/ping.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Commands
|
||||
module Ping
|
||||
extend self
|
||||
|
||||
def register(bot, _db)
|
||||
bot.register_application_command(:ping, 'Check if the bot is alive')
|
||||
|
||||
bot.application_command(:ping) do |event|
|
||||
event.respond(content: 'Pong!')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user