I've been trying to create a set up where there is one permanent message in a text channel that users could react to in order to receive a specific role. From what I can tell, I've come across a way of doing this but I'm missing something that will allow it to work. Here's what I have so far:
import discord
from discord.ext.commands import Bot
from discord.ext import commands
from discord.utils import get
bot_prefix = "r!"
bot = commands.Bot(command_prefix=bot_prefix)
@bot.event
async def on_ready():
print("Bot Online!")
print("Name: {}".format(bot.user.name))
print("ID: {}".format(bot.user.id))
await bot.change_presence(game=discord.Game(name='Visit the roles channel!'))
class Main_Commands():
def __init__(self, bot):
self.bot = bot
# r!ping
@bot.command(pass_context=True)
async def ping(ctx):
await bot.say("Pong!")
@bot.event
async def on_reaction_add(reaction, user):
role = discord.utils.get(WHAT GOES HERE, name="463359356281421844")
roleChannelId = "463374724702142464"
if reaction.message.channel.id != roleChannelId:
return
if str(reaction.emoji) == u"\U0001F534":
await bot.add_roles(user, role)
bot.run("TOKEN")
I can't seem to figure out what exactly I need to list as my iterable. I know it needs to get the roles from the server, I just don't know how. In addition, I've come to understand that on_reaction_add
really only works if the message is sent after the bot is booted, which is no good for many reasons. Can you iterable I'm looking for and is there a way to avoid the pitfall of on_reaction_add
?