繁体   English   中英

是否有可能让我的discord.js机器人忽略某些用户? 更像是通过命令将它们添加到json文件并忽略所有这些文件

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM