- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 on_member_join 似乎不起作用。我希望我的机器人说出加入服务器的成员的姓名,但它不会检测是否有人加入或离开。
import discord
from discord.ext import commands
client = commands.Bot(command_prefix = '.')
@client.event
async def on_ready():
print("bot is ready ")
@client.event
async def on_member_join(member):
print(f'{member.name} has joined this server')
@client.event
async def on_member_remove(member):
print(f'{member}was removed')
client.run('*************************')
它正在终端上打印“bot is ready”,所以 bot 正在工作。但是没有检测到成员离开或加入请帮忙。
最佳答案
你可能正在使用 discord python 1.5.0 或更高版本,这是一个常见的错误,你只需要 Intents .如果出现错误,您应该阅读它,它会将您重定向到 Discord 开发门户中的机器人,在那里您可以激活特权网关意图 check this out
并将其添加到您的代码中
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='.', intents=intents)
关于python - Discord 'on_member_join' 功能不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64348389/
我的 on_member_join 似乎不起作用。我希望我的机器人说出加入服务器的成员的姓名,但它不会检测是否有人加入或离开。 import discord from discord.ext impo
我正在尝试使用 Discord.py 库制作一个不和谐的机器人。带有 @client.command() 装饰器的命令对我来说很好用,但我尝试过的事件都不起作用。 @client.event asyn
我开始使用 discord.py (不是 discord.ext 命令,只有 import discord )。最近做了一个 channel , channel 名称显示公会成员人数,每次有人加入或离
这个问题已经有答案了: discord.py: Why isn't my join message working? (2 个回答) 已关闭 2 年前。 我的不和谐 py 机器人不会触发“on_mem
这就是我所拥有的: @client.command(pass_context=True) @client.event async def on_member_join(ctx, member):
我是一名优秀的程序员,十分优秀!