Skip to content Skip to sidebar Skip to footer

Nameerror In A Discord Bot Program

I started writing my first Discord bot, but I ran into a little problem. Why is my code not working ? @bot.command() async def msg(user : str, text : str): s = message.server

Solution 1:

The message in message.server is the message command, which doesn't have a server. (That's what the error is telling you) You should pass the invocation context into the command with pass_context=True

@FiveStarBot.command(pass_context=True)asyncdefmessage(ctx, member: discord.Member, *, text : str):
    await FiveStarBot.send_message(member, text)

This takes advantage of a discord.py converter to do the name lookup for you

Post a Comment for "Nameerror In A Discord Bot Program"