Python 不一致py bot未在成员加入函数上触发

Python 不一致py bot未在成员加入函数上触发,python,discord,discord.py,Python,Discord,Discord.py,我的discord py机器人不会触发“on_member_join”事件。其他一切都很好。我有其他正常触发的事件方法。我做错了什么?当人们加入时,它甚至不打印控制台语句 # Libs import discord # Version 1.2.5 from discord.ext import commands # set discord API token token = "MASKED" # Initiate used objects bot = commands.Bot(comman

我的discord py机器人不会触发“on_member_join”事件。其他一切都很好。我有其他正常触发的事件方法。我做错了什么?当人们加入时,它甚至不打印控制台语句

# 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启动后尝试打印消息,然后加入服务器。 您可以通过以下代码实现这一点。

#在bot就绪时打印“登录”
@机器人事件
_ready()上的异步定义:
打印('已登录')
因此,在打印登录后,您可以加入服务器并查看它是否工作

我希望这能解决你的问题

from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time
import random
from discord import Game


Client=discord.client
client=commands.Bot(command_prefix='^')
Clientdiscord=discord.Client()
client.remove_command("help")

@client.event
async def on_member_join(member):
    print(f'Recognised that a member called {member} joined')
    await member.send(".")
    print('Sent message to ' + member.name)


这是我使用的脚本,我已经添加了bot的最上面部分来显示它的去向。

Discord当前正在经历严重的IO延迟,API非常笨拙,即使今天on_member_join事件也不会触发。然后我不知道原因-至少打印应该可以工作(
member.server
bot.send\u message
不再是一件事了)。您的其他打印是否正确显示?抱歉,我省略了其余的代码。我确实有一个on\u ready()事件,让我知道bot何时已连接。bot还使用我的前缀响应调用的命令。但是,即使今天再次测试,on_member_join事件仍然不会触发。那么,恐怕我帮不了你,抱歉!它对我有效,但。。。