【发布时间】:2021-05-22 06:20:55
【问题描述】:
我正在尝试将自定义表情符号设置为我的机器人。但是,我收到此错误。
AttributeError: 'str' 对象没有属性 'get'
我该如何解决这个问题?
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
Bot = commands.Bot(command_prefix="&", intents=intents)
@Bot.event
async def on_ready():
await Bot.change_presence(activity=discord.Activity(type=4, emoji="????", name="hello")) # The error is related to this line
print("ready!")
Bot.run(TOKEN)
Ignoring exception in on_ready
Traceback (most recent call last):
File "E:\projects\Virtual Environment\discord-bot\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "E:\projects\discord-bot\base.py", line 114, in on_ready
await Bot.change_presence(activity=discord.Activity(type=4, emoji="????", name="hello"))
File "E:\projects\Virtual Environment\discord-bot\lib\site-packages\discord\activity.py", line 193, in __init__
self.emoji = PartialEmoji.from_dict(emoji)
File "E:\projects\Virtual Environment\discord-bot\lib\site-packages\discord\partial_emoji.py", line 83, in from_dict
animated=data.get('animated', False),
AttributeError: 'str' object has no attribute 'get'
【问题讨论】:
标签: python python-3.x discord discord.py emoji