@Dimonpro10

Бот реагирует на все префиксы(Любые буквы, цифры, и тд), в чём может быть ошибка?

Я добавлял команды, и вдруг бот стал реагировать на все префиксы, в чём может быть проблема?

spoiler
const Discord = require('discord.js');

const mongoose = require('mongoose')
const db = require('quick.db')
const fs = require("fs");
const prefix = process.env.prefix;

const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] })

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();

client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();

function getDirectories() {
  return fs.readdirSync("./commands").filter(function subFolders(file) {
    return fs.statSync("./commands/" + file).isDirectory();
  });
}
const commandFiles = fs
  .readdirSync("./commands/")
  .filter((file) => file.endsWith(".js"));
for (const folder of getDirectories()) {
  const folderFiles = fs
    .readdirSync("./commands/" + folder)
    .filter((file) => file.endsWith(".js"));
  for (const file of folderFiles) {
    commandFiles.push([folder, file]);
  }
}
for (const file of commandFiles) {
  let command;
  if (Array.isArray(file)) {
    command = require(`./commands/${file[0]}/${file[1]}`);
  } else {
    command = require(`./commands/${file}`);
  }

  client.commands.set(command.name, command);
  console.log(`✔️ Команда запущена - ${command.name} `);
}
client.on('ready', () => {
  const mongo_url = process.env.mongo_url;
  console.log("Успешно - Бот запущен");
});

client.on('messageCreate', async message => {

  const args = message.content.slice(prefix.length).trim().split(/ +/g);
  const command = args.shift().toLowerCase();
  
  const cmd =
    client.commands.get(command) ||
    client.commands.find((cmd) => cmd.aliases && cmd.aliases.includes(command));
  if (cmd) cmd.run(client, message, args);
  let customCommands = db.get(`guildConfigurations_${message.guild.id}.commands`)
  if (customCommands) {
    let customCommandsName = customCommands.find(x => x.name === command)
    if (customCommandsName) return message.channel.send(customCommandsName.response)
  }

})

client.on('ready', () => {
    client.user.setActivity({"name": `і показує вам – 'help. `}, { type: 'WATCHING' });
});

client.login(process.env.DISCORD_TOKEN);
  • Вопрос задан
  • 50 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы