Y
Y
Yasemenchik2021-10-21 23:04:38
Node.js
Yasemenchik, 2021-10-21 23:04:38

How to fix "Client is not defined" error?

const Discord = require('discord.js');
const robot = new Client({intents: [Intents.FLAGS.GUILDS]});
const comms = require("./comms.js");
const fs = require('fs');  
let config = require('./config.json');
let token = config.token;
let prefix = config.prefix;

robot.on("ready", function() {
  console.log(robot.user.username + " запустился!");
});

robot.on('message', (msg) =>{
  if (msg.author.username != robot.user.username && msg.author.discriminator != robot.user.discriminator) {
    var comm = msg.content.trim() + " ";
    var comm_name = comm.slice(0, comm.indexOf(" "));
    var messArr = comm.split(" ");
    for (comm_count in comms.comms) {
      var comm2 = prefix + comms.comms[comm_count].name;
      if (comm2 == comm_name) {
        comms.comms[comm_count].out(robot, msg, messArr);
      }
    }
  }
});


robot.login(token);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Semin, 2021-10-21
@rus_anonym

const { Client } = require('discord.js');
Or

const robot = new Discord.Client({intents: [Intents.FLAGS.GUILDS]});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question