我的不和谐py机器人不会触发“加入会员”事件。其他的都很好。我有其他正常触发的事件方法。我做错什么了?当人们加入时,它甚至不打印console语句。你知道吗
# Libs
import discord # Version 1.2.5
from discord.ext import commands
# set discord API token
token = "MASKED"
# Initiate used objects
bot = commands.Bot(command_prefix="!")
@bot.event
async def on_member_join(member):
print(f"{member} has joined the server.")
for channel in member.server.channels:
if str(channel) == "general":
await bot.send_message(f"""Welcome to the server
{member.mention}""")
bot.run(token)
这是我使用的脚本,我已经添加了我的机器人最上面的部分,以显示它去了哪里。你知道吗
如果我是对的,问题是用户在你的机器人启动之前加入了。 假设您使用备用帐户加入服务器进行测试, 您应该尝试在bot启动后打印消息,然后加入服务器。 您可以通过以下代码来实现这一点。 https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready
因此,在打印登录后,您可以加入服务器并查看它是否工作。你知道吗
我希望这能解决你的问题!你知道吗
相关问题 更多 >
编程相关推荐