Skip to content

Commit 98e2f62

Browse files
authored
Merge pull request #4 from ombulabs/IIRR-14-help-command
[IIRR-14] Help command
2 parents d0a3849 + b7c0cfc commit 98e2f62

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module Discord
2+
module Events
3+
# This class listens and handles the event triggered when the help command is triggered.
4+
class HelpCommand
5+
def initialize(bot)
6+
@bot = bot
7+
end
8+
9+
def listen
10+
@bot.application_command(:help) { |event| handle(event) }
11+
end
12+
13+
def handle(event)
14+
event.respond(content: "", embeds: [ help_message ], ephemeral: true)
15+
end
16+
17+
private
18+
19+
def help_message
20+
embed = Discordrb::Webhooks::Embed.new(
21+
title: "Is it Ruby or Rails?",
22+
description: "I'm here to test your knowledge on whether something is Ruby or Rails! Every day I'll send a question to see if you can guess correctly. Good luck!",
23+
color: 0xe60000
24+
)
25+
embed.add_field(name: "🧩 Daily Puzzles", value: "You can only answer a question once, but you can revisit older questions you haven't answered yet.")
26+
embed.add_field(name: "❓Immediate Feedback", value: "As soon as you give your answer, I'll let you know if you're right or wrong and why.")
27+
embed.add_field(name: "🏆 Leaderboard", value: "I'll send you a leaderboard at the end of each week, so you know who's the Ruby or Rails expert of the week!")
28+
embed.add_field(name: "⚙️ Admin Commands", value: "")
29+
embed.add_field(name: "/set_channel", value: "Specify which channel I should post to within the server.")
30+
embed
31+
end
32+
end
33+
end
34+
end

app/models/discord_server.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# To house data and logic related to the discord servers that the bot is added to.
2+
class DiscordServer < ApplicationRecord
3+
end

lib/tasks/discord.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace :discord do
1616

1717
# Register the commands again
1818
bot.register_application_command(:set_channel, "Set a channel for bot to be used in.")
19+
bot.register_application_command(:help, "Get help on how to use the bot.")
1920

2021
puts "✅ Re-registered commands!"
2122
end

0 commit comments

Comments
 (0)