I used to code discord bots a while back using discord.js, and I wanted to see if they still work (they have before) as I have them saved. I get the bot turned on, but it isn't responding to me when I get it to say something. Can anyone help. (I use VSC and I have tried updating Discord.JS and I had to update Node.js to get the bot turned on).
Here is my code for the bot (I was bored and made a bot that posted a pic of a fish when u asked it to). const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '-';
client.once('ready', () => {
console.log('Discord Bot Is On!');
});
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 === 'fish'){
message.channel.send('Here is a fish', {files: ["fish.png"]});
}
else if (command === 'bluefish'){
message.channel.send('Here is a blue fish', {files: ["bluefish.png"]});
}
else if (command ==='greenfish'){
message.channel.send('Here is a green fish', {files: ["greenfish.png"]});
}
else if (command ==='orangefish'){
message.channel.send('Here is a orange fish', {files: ["orangefish.png"]});
}
else if (command ==='yellowfish'){
message.channel.send('Here is a yellow fish', {files: ["yellowfish.png"]});
}
else if (command ==='violetfish'){
message.channel.send('Here is a violet fish', {files: ["violetfish.png"]});
}
else if (command ==='indigofish'){
message.channel.send('Here is a indigo fish', {files: ["indigofish.png"]});
}
else if (command ==='redfish'){
message.channel.send('Here is a red fish', {files: ["redfish.png"]});
}
});
client.login('Token');
Make sure you have message content privilege intent turned on.
Read more about it on the discord developer website: https://support.discord.com/hc/en-us/articles/360040720412
-- Harvey :)