For some reason the bot is posting in the discord more than once. I am unsure how to fix this at this moment. I’ve exhausted all options and even restarted the code and the bot itself and I am not to sure where to go on from here.
You can find my code below:
const Discord = require('discord.js'); const fs = require('fs'); const client = new Discord.client(); const prefix = '-'; client.commands = new Discord.Collection(); const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js')); for (const file of commandFiles){ const command = require(`./commands/${file}`); client.commands.set(command.name, command); } client.once('ready', () => { console.log('United is online'); }); client.on('message', message =>{ if(!message.content.startsWith(prefix) || message.author.bot ) return; const args = message.content.slice(prefix.length).split(/ +/); const command = args.shift().toLowerCase(); if(command === 'youtube'){ client.commands.get('youtube').execute(message, args); } else if (command == 'twitter'){ message.channel.send('https://twitter.com/UnitedPeoplesTV'); } });
youtube.js
module.exports = { name: 'youtube', description: "displays youtube channel!", execute(message, args){ message.channel.send('https://youtube.com/unitedpeoplestv?sub_confirmation=1'); } }
Advertisement
Answer
I would suggest that you kick the bot from the server, restart your computer (or stop your hosting service – making sure for example if you’re using pm2 that it isnt running multiple instances), and try again. Invite the bot back again from the discord applications webpage once you have completed that.