1

So this is the code:

const {
  Client,
  Attachment
} = require('discord.js');
const bot = new Client();

const cheerio = require('cheerio');

const request = require('request');

const token = 'My Token was here uwu';
const PREFIX = '//';

bot.on('ready', () => {
  console.log('Oy lad the bot is online!');
  bot.user.setActivity('users', { type: 'WATCHING' }).catch(console.error);
})

bot.on('message', message => {

  let args = message.content.substring(PREFIX.length).split(" ");

  switch (args[0]) {
    case 'ping':
      message.channel.send('other stuff')
      break;

    case 'cmds':
      const Embed = new Discord.MessageEmbed()
        .setColor(0x000000)
        .setTitle("Comenzi:")
        .setDescription("stuff")
      message.channel.send(Embed);
      message.channel.send('2.0')
      break;

When I run my code, the bot starts but crashes when I type //cmds, with the following error (note that it was just a piece of the code)

const Embed = new Discord.MessageEmbed() ^

ReferenceError: Discord is not defined

4

1 回答 1

0

You did not define Discord.
There are 2 solutions for this.

First soulution:
Line 1: const Discord = require("discord.js");

Second soulution:
Line 1: const {Client, Attachment, MessageEmbed} = require('discord.js'); Line 33: const Embed = new MessageEmbed()
Hope this helped you solving your Problem!

于 2020-06-08T09:52:25.660 回答