discord.py不能检测到丰富的存在

发布于 2025-02-10 10:15:03 字数 426 浏览 1 评论 0原文

我在我的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三人与歌 2025-02-17 10:15:03

首先,这看起来像是一个错字

channel;client.get.channel(804884691328303115)

,就像是

channel = client.get.channel(804884691328303115)

下一个,channel.activity不是一回事。我假设您正在寻找Member.Activity之类的东西。您将不得不循环浏览所有成员&检查他们的每个活动。

最后,如果您想访问人们的准则/活动,则需要意图。为了使会员在获得成员时正确的准确性,您还需要成员意图。

文档: /a>

确保在代码中启用它&在您在Discord开发人员仪表板上的应用程序中。

First off, this looks like a typo

channel;client.get.channel(804884691328303115)

Looks like it should be

channel = client.get.channel(804884691328303115)

Next, Channel.activity is not a thing. I assume you're looking for something like Member.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文