Discord.py on_member_join not working, no error message(Discord.py on_member_join 不起作用,没有错误消息)
问题描述
我正在尝试使用 Discord.py 库制作一个不和谐机器人.带有 @client.command() 装饰器的命令对我来说工作正常,但我尝试过的事件都没有工作.
I am trying to make a discord bot with the Discord.py library. The commands with the @client.command() decorator work fine for me, but none of the event ones that I tried work.
@client.event
async def on_member_join(member):
channel = client.get_channel(ChannelId) #I did define channel Id in my code
await channel.send("someone has joined")
@client.event
async def on_member_remove(member):
print("Someone has left")
我希望这会输出到终端或我输入的频道 ID,但什么也没有出现,甚至没有错误消息.
I would expect this to output to the terminal or in the channel id I put in, but nothing appears, not even an error message.
*我用过客户端.对于所有功能.*我在 mac 上做这个.
*I used client. for all functions. *I am doing this on mac.
我不太确定它为什么起作用,我没有收到任何错误消息,而且我似乎找不到其他人遇到这个问题.
Im not quite sure why its working, I do not get any error messages, and I cant seem to find anyone else with this problem.
提前致谢
推荐答案
使用版本 >1.5.0 你可以这样做:
With version >1.5.0 you can do something like this:
import discord
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
@client.event
async def on_member_join(member):
await member.send("Welcome!")
这篇关于Discord.py on_member_join 不起作用,没有错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Discord.py on_member_join 不起作用,没有错误消息
基础教程推荐
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
