1
votes

I want my bot to make a reaction role when I say p!reactrole [emoji] [role] [message], but it isn't working. No errors or anything.

@client.command()
async def reactrole(ctx, emoji, role: discord.Role, *, message):
  embedVar = discord.Embed(description=message)
  msg = await ctx.channel.send(embed=embedVar)
  await msg.add_reaction(emoji)
  
  with open('reactrole.json') as json_file:
    data = json.load(json_file)

    new_react_role = {
      'role_name':role.name,
      'role_id':role.id,
      'emoji':emoji,
      'message_id':msg.id
    }

    data.append(new_react_role)

  with open('reactrole.json', 'w') as j:
    json.dump(data,j,indent=4)
1
What intents have you enabled?Łukasz Kwieciński
indents to make it look neater?Nicholas Chen
No, gateway intents, that might be the issue, read more about it hereŁukasz Kwieciński
oh ok thanks!!!Nicholas Chen

1 Answers

1
votes

The code looks good but you don't have gateway intents enabled. If your bot is verified, you'll have to email discord at dis.gd/contact. If your bot is not verified, you can enable them in the developer portal under the bot tab. Once you enable the intent, you'll have to also enable them in your code.

intents = discord.Intents.<name of intent or 'all' if you want all intents>()

client = commands.Bot(..., intents=intents)