不能仅从名称中检索自定义应用程序表情符号吗?
有没有办法获取所有应用程序表情符号并将名称与 ID 进行匹配?
我想几年前有人问过这个问题,但从那以后我就再也没有见过任何东西。
get(bot.emojis, name=emoji_name)
这只是在机器人所在的服务器上检索匹配的表情符号,如果服务器没有匹配,则为 null。
await fetch_application_emojis()
会解决这个问题吗?应该是2.5出。
不确定discord.py中是否有办法,但我只是使用了这个:
CUSTOM_EMOJIS = {}
async def fetch_application_emojis():
global CUSTOM_EMOJIS
async with aiohttp.ClientSession() as session:
async with session.get(f"https://discord.com/api/v10/applications/{app_id}/emojis",
headers={f"Authorization": "Bot {app_secret}"}) as resp:
if resp.status == 200:
emojis_response = await resp.json()
emojis = emojis_response.get("items", [])
CUSTOM_EMOJIS = {emoji['name']: int(emoji['id']) for emoji in emojis}