discord.py不能检测到丰富的存在
我在我的Discord Bot上遇到了麻烦,它应该检测到一个玩特定游戏的人,然后在频道中发送消息,但它没有检测到或者
在到目前为止向Heres发送我的代码:
@client.event
async def get_all_members(channel):
games = ["osu!"]
#add code later to make ping work
if channel.activity and channel.activity.name.lower() in games:
channel;client.get.channel(804884691328303115)
await channel.send("playing osu is not ok")
如果有人可以帮助您非常感谢,谢谢
im having trouble with this bit of code for my discord bot its suppose to detect a person playing a specific game and then send a message in a channel, but its not detecting nor sending
heres my code so far:
@client.event
async def get_all_members(channel):
games = ["osu!"]
#add code later to make ping work
if channel.activity and channel.activity.name.lower() in games:
channel;client.get.channel(804884691328303115)
await channel.send("playing osu is not ok")
if anyone can help that will be very much appreciated, thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,这看起来像是一个错字
,就像是
下一个,
channel.activity
不是一回事。我假设您正在寻找Member.Activity
之类的东西。您将不得不循环浏览所有成员&检查他们的每个活动。最后,如果您想访问人们的准则/活动,则需要意图。为了使会员在获得成员时正确的准确性,您还需要成员意图。
文档: /a>
确保在代码中启用它&在您在Discord开发人员仪表板上的应用程序中。
First off, this looks like a typo
Looks like it should be
Next,
Channel.activity
is not a thing. I assume you're looking for something likeMember.activity
. You'll have to loop through all members & check each of their activities.Lastly, if you want to have access to people's precenses/activities, you need the Presence Intent. For proper accuracy when getting the members you'll also need the Members Intent.
Docs: https://discordpy.readthedocs.io/en/stable/intents.html
Make sure to enable it both in code & in your application on the Discord Developers dashboard.