В настоящее время я работаю над ботом Discord.js и пытаюсь написать систему, в которой только заданные идентификаторы в JSON могут выполнять команду. Я не знаю, как запросить это в if
заявлении.
if (message.author.id === config.admin) {
if (cmd === 'mode') {
let mode = args[0];
if (mode === 'maintenance') {
bot.user.setActivity(config.maintenanceGame);
config.mode = 'maintenance';
const embed = new Discord.RichEmbed()
.setAuthor("Gorded Media Ltd. - Maintenance", 'http://imageurl/logo.png')
.setColor(color.red)
.setDescription("The mode was set to `Maintenance`. All users can't use the commands in this mode.");
message.channel.send(embed);
}
if (mode === 'online') {
bot.user.setActivity(config.defaultGame);
config.mode = 'online';
const embed = new Discord.RichEmbed()
.setAuthor("Gorded Media Ltd. - Maintenance", 'http://imageurl/logo.png')
.setColor(color.lime)
.setDescription("The mode was set to `Online`. All users can use the commands in this mode.");
message.channel.send(embed);
}
console.log(`[` + date + `] ` + config.consoleprefix + ` User ${message.author.tag} set the mode to ${config.mode}`);
}
} else {
message.channel.send(no_perms)
}
Это структура файла JSON, проанализированного в config
:
"admin": [
"Discord Client ID",
"Discord Client ID",
"Discord Client ID"
]