Discord.js 用户状态自定义

时间:2023-02-10
本文介绍了Discord.js 用户状态自定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 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模板网!

上一篇:获取 SyntaxError:词法声明不能出现在单语句上下文 下一篇:Discord bot 不是从 heroku 开始的

相关文章

最新文章