python - 在成员加入事件消息不起作用 - discord.py
问题描述
我对 discord.py 很陌生,我想学习 python 并为我的服务器制作一个简单的机器人。我想制作一个机器人,当有人加入服务器时发送消息。但机器人不会发送任何消息。我尝试了很多解决方案,但都没有奏效。
控制台没有错误。只是“on_member_join”不起作用;ping 和控制台消息方法有效。
这是我的代码:
import discord
from discord.ext import commands
client = commands.Bot(command_prefix='*')
TOKEN = '----my token here----'
@client.event
async def on_ready():
print('Bot is ready')
@client.event
async def on_member_join(member):
channel = client.get_channel(764960656553934879)
await channel.send('Hello')
@client.command()
async def ping(ctx):
await ctx.send('Pong!')
client.run(TOKEN)
解决方案
推荐阅读
- python - 如何在 pyqt5 应用程序中更改绘图大小及其图例
- arrays - 可以使用迭代合并排序来计算倒置吗?
- python - 如何从 CSV 文件中正确创建 DataFrame?
- c# - 无法从 vs2019 发布到 aws beanstalk
- r - R中的随机数模拟
- python - 错误:找不到“文章详细信息”的反向。'article-detail' 不是有效的视图函数或模式名称
- python - Python 脚本在 pycharm 之外运行时停止工作
- encryption - 保留类型信息的加密
- java - RestTemplate GET 调用给出不完整的响应
- ios - 在 SwiftUI 中使用 List 时如何使用 NavigationLink isActive 绑定?