0
votes

I have a bot in a discord server that when they type a command called hello, the bot will respond from a random choice in a list.

I'm trying to get the bot to respond a different way if it is a very specific user id.

This is not working,

@bibi.command()
async def hello():
    if message.author.id == ('279460450637185024'):
        choicesa = ('get away', 'dont greet me', 'youre wasting my time', 'Hallo', 'oh god its you', '....' , 'dude go away' , 'WHAT DO YOU WANT' , 'HIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII' , 'i dont talk to democrats')
        await bibi.say(random.choice(choicesa))
    elif message.author.id == ('80971950054187008'):
        choicesl = ('lauren...', 'hi. lauren.')
        await bibi.say(random.choice(choicesl))

It's saying message is not defined, and now I understand that, I thought it was defined in discords library but its not.

How can I do this?

3

3 Answers

0
votes

I know it will mess up with all your other commands, but if you do it like I did it below, it will work.

@client.event
async def on_message():
if message.content == "hello":
  if message.author.id == ('279460450637185024'):
    choicesa = ('get away', 'dont greet me', 'youre wasting my time', 'Hallo', 'oh god its you', '....' , 'dude go away' , 'WHAT DO YOU WANT' , 'HIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII' , 'i dont talk to democrats')
    await bibi.say(random.choice(choicesa))
  elif message.author.id == ('80971950054187008'):
    choicesl = ('lauren...', 'hi. lauren.')
    await bibi.say(random.choice(choicesl))
0
votes

Just try adding ctx as your parameter in the function and then add it as your starter.

@bibi.command(pass_context=True)
 async def hello(ctx):
       if ctx.message.author.id == '279460450637185024':
           choicesa=['hi','hello','okay?']
           await bibi.say(random.choice(choicesa))
0
votes

If you are using rewrite version of d.py you have to pass ctx argument to hello by doing async def hello(ctx):. Then in rewrite you can't use bot.say (or bibi.say). You have to use ctx.send(message) instead of bibi.say(message).