Skip to content
Advertisement

JS- SyntaxError: Identifier ‘Client’ has already been declared [closed]

'user strict';

const { Discord, Client, MessageAttachment } = require('discord.js');

const client = new Discord.Client();

client.on('ready', () => {
  console.log('I am ready!');
});
//reply to certain messages... start...
client.on('message', message => {
 if (message.content === 'ping') {
   message.send('pong');
  }
});

client.on('message', message => {
  if (message.content === 'ding') {
    message.channel.send('dong');
  }
});
//...end

//avatar url... start...
client.on('message', message => {
  if (message.content === 'qavatar') {
    message.reply(message.author.displayAvatarURL());
  }
});
//...end

//attachment images... start...
const { Client, MessageAttachment } = require('discord.js')

client.on('message', message => {
  if (message.content === 'qrip') {
    const attachment = new MessageAttachment('https://i.imgur.com/VyiVReC.jpg');
    message.channel.send(attachment);
  }
});

client.login('My Token');

I am trying to create a discord bot, but each time I try to execute the code, I get the error in the title… I am new to JavaScript and Discord Js… I am sorry if this seems silly, but I would be happy if someone could help…

Advertisement

Answer

You are destructing the Client again in const { Client, MessageAttachment } = require('discord.js')

Advertisement