Add role based on reaction in the waiting-room channel

This commit is contained in:
Luke Robles 2023-04-22 09:40:01 -07:00
parent 6d43e481ea
commit 087a816341

View File

@ -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