python - 如何使自定义状态discord.py

为什么我的代码不起作用?

@bot.event
async def on_ready():
    print('Bot is now working!')
    await bot.change_presence(activity=discord.CustomActivity(name='Custom status' ,emoji='?️'))

并给我一个错误。

Ignoring exception in on_ready
Traceback (most recent call last):
  File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/discord/client.py", line 270, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 30, in on_ready
    await bot.change_presence(activity=discord.CustomActivity(name='Custom status' ,emoji='?️'))
AttributeError: module 'discord' has no attribute 'CustomActivity'

错误如何修复?

最佳答案

我迟到了, WayToDoor 是正确的,机器人不能使用自定义状态,我发现他们“可以使用它”但它是不可见的,除非机器人可以看到它是自定义状态并且您将在机器人配置文件上看到“自定义状态”。

机器人可以播放、观看、收听和流式传输没问题

您现在也可以选择使用类型 5 的“竞争”。我还没有在文档中看到它,所以我假设它还没有实现。

#this is how "Competing in" is set.
discord.Activity(name="Test", type=5)

这应该有效。

https://stackoverflow.com/questions/60055037/

相关文章:

scala - 玩json库和sbt assembly合并报错

bash - 如何在 bash 中循环遍历 jq 唯一数组?

css - 如何为 Material UI 按钮 'startIcon' 分配自定义图标?

mongodb - 使用 mongodb 中的条件将字段添加到集合

node.js - 使用具有 root 访问权限的 nodejs 执行 shell 命令

r - 确定一周中的某一天是否是 R 中每月的第 2/3 等星期一/星期二/等

arduino - ESP32 - 软件序列库

google-cloud-platform - 共享 VPC 和 VPC 对等组合

sql - Oracle 12c - 插入到选择查询中的列不明确,ORA-00918

python - 如何在 XGBoost 库的 plot_tree 函数中包含特征名称?