S
S
sqtr2020-12-22 08:35:42
Node.js
sqtr, 2020-12-22 08:35:42

Not responding to Discord JS commands. How to fix?

Reading commands:

const Discord = require('discord.js');
const fs = require('fs');
const robot = new Discord.Client();
const config = require("./config.json");
robot.commands = new Discord.Collection()

let token = config.token;

fs.readdir('./commands', (err, files) => {
  if (err) console.log(err)

  let jsfile = files.filter(f => f.split('.').pop() === 'js')
  if (jsfile.length <= 0) return console.log('Команды не найдены!')

  console.log(`Loaded ${jsfile.length} commands`)
  jsfile.forEach((f, i) => {
      let props = require(`./commands/${f}`)
      robot.commands.get(props.help.name, props)
  })
})

In the console, it displays that the commands are found, but the bot does not respond to them.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-12-22
@sqtr

try replacing robot.commands.get()withrobot.commands.set()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question