discord.py emoji表情所有服务器bot [英] discord.py emoji all servers bot in

查看:159
本文介绍了discord.py emoji表情所有服务器bot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个机器人可以发送包含每个嵌入特定表情符号的嵌入,并且在我上传了表情的测试服务器上效果很好,但由于这些服务器没有自定义表情,因此它们不会显示在其他服务器上

I have a bot that sends embeds that include emojis specific to each embed and it works great on my test server where I uploaded the emojis but they don't show up on other servers since those servers don't have the custom emoji.

使用:

emoji = get(ctx.message.guild.emojis, name='emojinamehere')

它在其中的服务器上当然可以工作,但是有没有办法从该机器人所在的任何服务器上获取和使用所有表情符号?

works of course for the server it's in but is there a way to get and use all emojis from any servers the bot is in?

推荐答案

因为您专门使用了 ctx.message.guild.emojis ,所以您尝试从上下文公会中获取表情符号(可能没有).

Because you're specifically using ctx.message.guild.emojis aka you're trying to get the emoji from the context guild (which might not have it).

您可以摆脱按名称查找的 get ,而只需使用

You can get rid of get finding by name and just use bot.get_emoji() where bot is your bot/client object.

您的机器人会将所有公会的所有表情符号存储在内部缓存中,而 get_emoji()将从那里取回它,因此它将适用于所有公会.

Your bot will store all emojis from all the guilds in internal cache and get_emoji() will retrieve it from there so it will work for all guilds.

您将需要表情符号ID(整数)来执行此操作,而不是像您当前所获得的那样命名.您可以按名称获取,然后获取其ID,但这只是不必要的步骤.

You will need emoji ID (integer) to do this, not name as you're currently getting. You could get by name and then get its ID but that's just unnecessary steps.

只需使用表情符号ID,因为它们是唯一的且不能更改(名称既可以重复也可以更改,因此您在按名称获取时会遇到麻烦).

Just use emoji ID as those are unique and can't change (names can both be duplicate and can change so you can get into problems getting by name).

您可以使用Discord客户端应用程序快速获取表情符号ID:

You can quickly get emoji ID by using Discord client app:

  • 在文本框中输入自定义表情符号
  • 在表情符号前输入 \
  • 发送消息进行聊天
  • 消息将转换为类似<:emoji_name:emoji_id>
  • 的内容

这篇关于discord.py emoji表情所有服务器bot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆