我想在Discord.py上做一个开关盒或elif

2024-04-26 04:53:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我做了一个简单的机器人,在一个不和谐的频道上对来自特定用户的消息进行自动反应,但是现在我想做同样的事情,但是对具有不同表情的多个用户,我尝试了这段代码,但它只在没有elif条件的情况下工作,有什么建议吗

import discord
from discord.ext        import commands
from discord.ext.commands   import Bot
import asyncio

bot = commands.Bot(command_prefix = ",")

@bot.event
async def on_ready():
    print ("Ready...")

@bot.event
async def on_message(message):
      if (message.channel.id == channel_id and message.author.id == user_id):
            await message.add_reaction("😀")
      elif (message.channel.id == channel_id and message.author.id == another_user_id):
            await message.add_reaction("🤪")

bot.run("bot_token")

Tags: 用户fromimporteventidmessageasyncdef