-1
if message.content.startswith('Привет'):
    print('[command]: Задан вопрос3 ')
    await message.channel.send('Привет ' + random.choice(list2) + '!')
if(messageAuthor == "Бот-Бобот#0869"):
    return

我希望 discord bot 响应消息“Hello”,但响应中还包含单词“Hello”如何防止 bot 响应自身?

4

1 回答 1

1

您可以检查消息的作者是否是机器人本身。你可以这样做:

if not message.author.bot:
   do_stuff()
else:
   pass # author is bot, just ignore

试试这是否适合你

if message.author.bot:
    return
    
# we will reach this point if and only if the author is NOT a bot
if message.content.startswith('Привет'):
    print('[command]: Задан вопрос3 ')
    await message.channel.send('Привет ' + random.choice(list2) + '!')
于 2021-08-19T06:52:48.413 回答