![](/img/trans.png)
[英]discord.js v14 trying to do that my bot status will be the amount of servers that the bot is in them
[英]Is it possible to make my discord.js bot ignore certain users? More like adding them to a json file by a command and ignoring all of them
如何让我的机器人在执行命令时忽略某些用户?
我没有代码显示,因为我不知道从哪里开始,搜索后没有找到任何东西。
如果您有一组用户ID被列入黑名单执行命令,您只需执行以下操作:
const arrayOfUsersIds = ['8794328794879328794897', '789438729489732789', '764327969748632978'];
for (let i = 0; i < arrayOfUsersIds.length; i++) {
if (message.author.id === arrayOfUsersIds[i]) return message.reply('You are on the blacklist!');
};
只需在此数组中添加名为arrayOfUsersIds
所有用户ID ,并且不再允许所有这些用户执行命令。
您可以使用用户名执行相同的操作! 只需在名为arrayOfUsersnames
的数组中arrayOfUsersnames
您不希望在数组中执行命令的所有用户名,然后就不再允许它们执行命令了!
const arrayOfUsersNames = ['Monkeyyy11', 'Tden', 'Zenoo'];
for (let i = 0; i < arrayOfUsersNames.length; i++) {
if (message.author.username.toLowerCase() === arrayOfUsersNames[i].toLowerCase()) return message.reply('You are on the blacklist!');
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.