Skip to content

Commit b18bac7

Browse files
committed
IIRR_12: Turn welcome message into an embed
1 parent 01bec1e commit b18bac7

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ruby-3.4.2
1+
3.4.2

Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ PLATFORMS
389389
aarch64-linux-musl
390390
arm-linux-gnu
391391
arm-linux-musl
392+
arm64-darwin-23
392393
arm64-darwin-24
393394
x86_64-linux
394395
x86_64-linux-gnu

app/lib/discord/bot.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def turn_events_on
3939
event_class = "Discord::Events::#{file.chomp(".rb").camelize}".constantize
4040
event_class.new(@bot).try(:listen)
4141
end
42+
puts "Events registered. Bot is listening..."
4243
end
4344
end
4445
end

app/lib/discord/events/server_create.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,31 @@ def listen
1313
def handle(event)
1414
# Send the introduction message to the main server channel.
1515
server = event.server
16-
admin = server.owner
1716
system_channel = server.system_channel
1817

1918
# Ensure system_channel exists and send a message to the server
2019
if system_channel
21-
system_channel.send_message("Hello #{server.name}! I am the 'Is it Ruby or Rails bot', I will be sending a question every day to see if your users know what is Ruby and what is Rails! Good luck! Admins: You can adjust which channel you want me to ask questions in by using the '/set_channel' command.")
20+
system_channel.send_message("", false, welcome_message(server.name))
2221
else
2322
puts "No suitable channel found to add the bot to."
2423
end
2524
end
2625

2726
private
2827

28+
def welcome_message(server_name)
29+
embed = Discordrb::Webhooks::Embed.new(
30+
title: "Hello #{server_name}!",
31+
description: "I am the 'Is it Ruby or Rails' bot! I will be sending a question every day to see if you know what is Ruby and what is Rails! Good luck!",
32+
color: 0xe60000
33+
)
34+
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.")
35+
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!")
36+
embed.add_field(name: "⚙️ Admin Commands", value: "")
37+
embed.add_field(name: "/set_channel", value: "Specify which channel I should post to within the server.")
38+
embed
39+
end
40+
2941
attr_reader :bot
3042
end
3143
end

0 commit comments

Comments
 (0)