【问题标题】:Member.Activities always returns an empty list | discord.pyMember.Activity 总是返回一个空列表 |不和谐.py
【发布时间】:2020-10-22 04:14:54
【问题描述】:

我正在尝试编写一个机器人命令来检查用户的活动。但是,它总是返回一个空列表。

@bot.command
async def status(ctx):
  await ctx.send(ctx.author.activities)

我尝试了其他方法,例如获取作者的姓名,并且可行,但状态和活动之类的方法不起作用。

【问题讨论】:

  • 你的 discord.py 版本是多少?
  • @Nurqm 版本:1.5.0

标签: python discord.py


【解决方案1】:

在新版本的 discord.py(1.5.x) 中,[Intents] 有一些变化。你需要定义它来使用一些东西,比如获取成员、频道、活动。所以你需要在定义bot = discord.Bot()之前定义Intents

import discord

intents = discord.Intents().all()
bot = discord.Bot(prefix='', intents=intents)

如果您只想启用以获取活动,您可以执行intents = discord.Intents().presences,但我宁愿启用所有。更多信息,您可以查看API references

【讨论】:

    猜你喜欢
    • 2017-04-13
    • 2016-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-03
    相关资源
    最近更新 更多