From 087a81634161fe6508c4f6ccd55d03448a2049a1 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Sat, 22 Apr 2023 09:40:01 -0700 Subject: [PATCH] Add role based on reaction in the waiting-room channel --- app/bot.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/app/bot.py b/app/bot.py index d0af243a..1d59c99c 100755 --- a/app/bot.py +++ b/app/bot.py @@ -7,6 +7,7 @@ import os intents = discord.Intents.default() intents.message_content = True intents.members = True +intents.reactions = True bot = commands.Bot(command_prefix="!", intents=intents) bot.remove_command("help") @@ -40,6 +41,45 @@ async def on_ready(): # await bot.register_commands(guild_id=826547484632678450, force=True) +@bot.event +async def on_ready(): + # Waiting-room in zoid's server + # channel = bot.get_channel('1026281775984549958') + blurb = """Welcome to our server! +We have lots of roles you can select based on what kind of games you're here to play. + +Please react to this message with one of the following emojis to be granted the appropriate role: + +🔫 for Tarkov + +👹 for Darktide or Vermintide + +🪖 for Battlefield + +🚀 for Star Citizen + """ + message = await bot.get_channel(1026281775984549958).send(blurb) + + +@bot.event +async def on_raw_reaction_add(payload): + if payload.guild_id is None: + return # Reaction is on a private message + guild = bot.get_guild(payload.guild_id) + + role_map = { + "🔫": "Tarkov Gamers", + "👹": "Dorktide Gamers", + "🪖": "Battlefielders", + "🚀": "Star Citizens", + } + + role = discord.utils.get(guild.roles, name=role_map[payload.emoji.name]) + member = guild.get_member(payload.user_id) + if payload.channel_id == 1026281775984549958: + await member.add_roles(role) + + @bot.listen("on_message") async def fix_cdn_url(ctx): # Ignore images