Я изменил ваш код, чтобы уменьшить количество повторяющихся частей и упростить создание новых команд и добавление новых правил. Однако вместо того, чтобы набирать что-то вроде !rule3
, вам нужно набрать !rule 3
.
Для получения дополнительной информации о том, как расширить возможности вашего бота, прочитайте Discord. js руководство .
const prefix = '!';
const rules = [
"**Don\'t be annoying.**",
"**Leaving the server during your crypt sentence will result in a permanent ban. 3 strikes and you\'re out.**",
"**Watch your language.**",
"**No NSFW content of any kind.**",
"**No racism, homophobia, or other hate speech is allowed whatsoever.**",
"**Moderators\' discretion.**",
"**Don\'t randomly ping roles or people for no reason.**",
"**No spam allowed whatsoever.** Spam will result in a delete and warn, and a crypt sentence if continued.",
"**Please speak English at all times! Non-English messages are subject to deletion.**",
"**Please avoid talking about triggering topics.**",
"**Please censor all personally identifiable info from images and text.**",
"**Please keep bot commands in <#620789282226962464>.**",
"**Posting gore is an instant deletion of your message(s) and permanent ban.**",
"**YOU MUST BE 13 YEARS OF AGE OR OLDER TO USE THIS SERVER.**",
"**Politics are strictly banned from the server.**",
"**Don\'t name yourself stupid things.**",
"**No bright flashing media of any kind, including emotes.**",
"**No Gacha edits.**",
"**Keep conversation civil and appropriate.**",
"**No edgy, dark or offensive jokes or memes.**",
"**No threats or considerations of ||self-harm|| or ||suicide|| in the server.**",
"**Anything that violates Discord TOS will get you immediately banned.**",
"**Do not sexualize/ship any of the moderators, or any members of the server for that matter.**"
];
client.on('message', message => {
if (message.author.bot || !message.content.startsWith(prefix)) return;
const args = message.content.slice(prefix.length).trim().split(/\s+/g);
const command = args.shift().toLowercase();
switch (command) {
case 'rule':
if (!args[0]) return message.reply('**usage:** `!rule <rule number>`.');
args[0] = Number(args[0]);
if (!(args[0] > 0 && args[0] <= rules.length)) return message.reply(`please enter a number between 1 and ${rules.length}.`);
message.channel.send(`Rule ${args[0]}: ${rules[args[0] - 1]}`);
break;
case 'strikeappeal':
message.channel.send('If you would like to appeal a strike, you can DM <@738765589748645908>. Simply explain why you got that strike, why you think it should be removed, and apologize.');
break;
default:
message.reply(`the command \`${command}\` was not recognized.`);
});