I'm trying to write a discord.py bot that will add a thumbs up to a message which, when clicked, will give the user the role "test". Here is my code I'm using:
import discord
from discord.ext import commands
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
messageIDs = [759721500579463219]
@client.event
async def on_raw_reaction_add(payload):
global messageIDs
for messageID in messageIDs:
if messageID == payload.message_id:
user = payload.member
role = "Test"
await user.add_roles(discord.utils.get(user.guild.roles, name = role))
@client.command()
async def addMessage(ctx, messageID):
global messageIDs
emoji = "👍"
channel = ctx.message.channel
try:
msg = await channel.fetch_message(messageID)
except:
await ctx.send("Invalid Message ID!")
return
await msg.add_reaction(emoji)
messageIDs.append(messageID)
bot.run("Not gonna reveal this")
However, when I run the code, I get this error:
Traceback (most recent call last): File "C:\Users\james\Desktop\Random Codes\CustomBot.py", line 22, in @client.command() AttributeError: 'Client' object has no attribute 'command'
Please can someone tell me what I'm doing wrong, and if possible, rewrite the code with the corrections made, as sometimes I find it hard to work out what people mean by their answers.
Thank you in advance.