Reputation: 39
I'm trying to make my bot give a role after a user reacts to a message but every time I get the same error. I don't understand what the error means. Can anybody help? This is the code:
import discord
from discord.ext import commands
from discord import Member
from discord.ext.commands import has_permissions
from discord.ext import tasks
#sets the command prefix
Client = commands.Bot(command_prefix = "!")
#print Nuggie is ready in the console when the bot is activeted
@Client.event
async def on_ready():
print("Bot is ready")
@Client.event
async def on_ready(ctx):
myRole = Role.id("Member")
channel = discord.utils.get(ctx.guild.channels, name=input("What is the name of the channel? "))
channel_id = channel.id
channel = Client.get_channel(channel_id)
role = discord.utils.get(message.server.roles, name=myRole)
message = await Client.send_message(channel, "React with the tick to get access to the server!")
while True:
reaction = await Client.wait_for_reaction(emoji="✔", message=message)
await Client.add_roles(reaction.message.author, role)
And the error I get is:
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\me\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
TypeError: on_ready() missing 1 required positional argument: 'ctx'
Upvotes: 0
Views: 5489
Reputation: 1398
The function on_ready is defined twice and the first one is eliminated when the second one is defined. The error is telling you that the function call requires an argument to be passed to it (ctx)
Read the discord docs: https://discordpy.readthedocs.io/en/latest/quickstart.html#a-minimal-bot. The on_ready method must be defined without any arguments.
Upvotes: 1