問題描述
當我使用 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]);
};
});
這篇關于Discord.js 用戶狀態自定義的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!