I am trying to make a discord bot that creates a role when someone sends a message. For some reason, It keeps saying 'ctx' is not defined. How would I fix this error?
@client.event
async def on_message(message):
server=ctx.message.server
perms=discord.Permissions(administrator=true)
await client.create_role(server,name='testrole', colour=discord.Colour(0x0000FF),permissions=perms)
when i change
async def on_message(message):
to
async def on_message(ctx):
it says 'message' is not defined. I do not understand how I could define both of these because when I add the undefined part as shown below, It still says 'ctx' is not defined or 'message' is not defined.
async def on_message(message,ctx):
async def on_message(ctx,message):
update: I didn't have (pass_context=True) but now I know more
on_message
does not havectx
.ctx
. You can get the guild (not server) or the channel for themessage
object. Also read the docs - InsertCheesyLine