问题描述
当我使用 discord bot 命令时,为了显示特定人员的不和谐状态,假设他的状态设置为请勿打扰",也就是 dnd.我想要这条线:**? Discord 用户名:** ${user.username},假设特定的人在线,我希望它用大写的O"说在线",但它显示为在线".或者dnd"也一样,我希望它是请勿打扰".我将用户定义为: message.mentions.users.first() ||消息作者有什么方法可以帮忙?
When I use a discord bot command, for the purpose of showing the specific person's discord presence, let's say his presence is set on 'Do Not Disturb' a.k.a dnd. I want this line : **? Discord Username:** ${user.username}, lets say that specific person is on online, I want it to say 'Online' with a capital 'O', but it shows it as 'online'. Or the same thing for 'dnd', i want it as 'Do Not Disturb'. I've defined user as : message.mentions.users.first() || message.author Any ways to help?
推荐答案
const Presence = {
"online": "Online",
"dnd": "Do Not Disturb",
"idle": "Idle",
"offline": "Offline"
}
client.on("message", message => {
if (message.author.bot) return false;
if (message.content.toLowerCase() == "-presence") {
const User = message.mentions.users.first() || message.author;
message.channel.send(Presence[User.presence.status]);
};
});
123456亲亲