I'm trying to create a reactroles function for my server, I've gone through hundreds of stack overflow and reddit forums to find bits and pieces to make this work but nothing has fixed this last error.
The roles are present on my server and properly defined (as far as i know) in the code but still returns error 10011 Unknown Role
async def on_reaction_add(reaction, user):
ChID = '1018712244843970610'
ctx = await bot.get_context(reaction.message)
#user = ctx.reaction.author
Channel = bot.get_channel(1018712244843970610)
if reaction.message.channel != Channel:
await Channel.send("this is a test for ChID not....")
return
if reaction.emoji == "":
await ctx.channel.purge(limit=1)
this_member = ctx.message.author
mem = str(this_member.display_name)
await Channel.send(mem+" - this is a test for running....")
print(this_member)
this_guild = this_member.guild
this_role = discord.utils.get(this_guild.roles, id=1018802229341327370)
await this_member.add_roles(this_member, this_role)
if reaction.emoji == "":
await ctx.channel.purge(limit=1)
this_member = ctx.message.author
mem = str(this_member.display_name)
await Channel.send(mem+" - this is a test for hammer....")
this_guild = this_member.guild
this_role = discord.utils.get(this_guild.roles, id=1018802151679602798)
await this_member.add_roles(this_member, this_role)
if reaction.emoji == "":
await ctx.channel.purge(limit=1)
this_member = ctx.message.author
mem = str(this_member.display_name)
await Channel.send(mem+" - this is a test for duck....")
this_guild = this_member.guild
this_role = discord.utils.get(this_guild.roles, id=1018802188555927572)
await this_member.add_roles(this_member, this_role)
if reaction.emoji == "❤️":
await ctx.channel.purge(limit=1)
this_member = ctx.message.author
mem = str(this_member.display_name)
await Channel.send(mem+" - this is a test for heart....❤️")
this_guild = this_member.guild
this_role = discord.utils.get(this_guild.roles, id=1018802188555927572)
await this_member.add_roles(this_member, this_role)
I have tried replacing the ctx in ct.message.author with reaction.message.author but then throws the error 'reaction' has no attribute 'content'
I thought maybe the definition of this_member was the cause of it not being able to define the role but it doesnt seem to be the issue