根据MessageEmbed中的用户在线状态使用自定义表情符号 [英] Using a custom emoji based on the user presence status in a MessageEmbed

查看:74
本文介绍了根据MessageEmbed中的用户在线状态使用自定义表情符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为我的机器人执行了userinfo命令,但使用自定义表情符号似乎遇到了一些麻烦,这些表情符号会根据用户的存在而显示不同。 (在线,离开,免打扰,离线)。我很好奇如何做到这一点。有人有什么建议吗?

Making a userinfo command for my bot, but I seem to be running into some trouble with using custom emojis that will display differently depending on the user's presence. (Online, Away, DND, Offline). I'm curious as to how this could be accompolished. Anyone have any tips?

推荐答案

I:检查是否存在

您可以通过简单地检查 User.presence.status ,可以是在线 空闲 dnd 离线

You can do this by simply checking User.presence.status, that can be either "online", "idle", "dnd" or "offline"

II:使用自定义表情符号

要使用自定义表情符号,您需要知道其名称或ID(如果可能,ID更好,您可以可以通过编写表情符号并在其之前添加 \ 并发送消息来获得它)

To use a custom emoji you need to know its name or its id (if possible the id is better, you can get it by writing the emoji, adding a \ before it & sending the message)

let emoji = guild.emojis.get(your_emoji_id_as_a_string); //if you have the id OR
let emoji = guild.emojis.find("name", your_name_as_a_string) //if you have the name (but if you change this in the server it won't work)
//create your embed like a normal one and when you have to use an emoji, just type it like a variable
let str = `The user is ${emoji}`; //== "The user is " + emoji

这篇关于根据MessageEmbed中的用户在线状态使用自定义表情符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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