【发布时间】:2020-10-03 15:08:55
【问题描述】:
这个脚本不是我的。该脚本是有效的,但它只适用于一个用户。我希望它对任何用户在某个频道内发送的所有消息做出反应。我认为问题出在 message.author.id 事情上,我尝试完全删除该行,但它最终破坏了整个事情并且它不会启动不和谐机器人。非常感谢任何帮助。
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 ("welcome_msg")
async def react(message):
custom_emojis = [
":like:",
":emoji:",
":emoji:"
]
guild_emoji_names = [str(guild_emoji) for guild_emoji in message.guild.emojis]
for emoji in custom_emojis:
if emoji in guild_emoji_names:
await message.add_reaction(emoji)
@bot.event
async def on_message(message):
if message.channel.id == 721485450790830111 and \
message.author.id == 721483699719241748:
await react(message)```
【问题讨论】:
-
如果您将条件更改为
if message.channel.id == 721485450790830111:,它应该可以工作。您可能只是格式错误。
标签: python discord.py discord.py-rewrite