in Education by
I've been trying to get my discord bot to work, but it will only become online on discord and say that it's online in the console. What am I doing wrong here's the code from my index.js const Discord = require('discord.js') const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION" ], intents: ["GUILDS", /* Other intents... */]}); const token = '(token here)'; client.login(token); client.on('ready', () => { console.log('I ARRIVE FROM THE ASHES OF THE EARTH'); }); client.on('message', message => { if (message.content === 'Hello') { message.send('I HAVE A GUN'); } }); client.on('disconnect', () => { console.log('ZE POPCORN IS DEAD'); }); const prefix = '-'; client.on('message', message => { if (message.content === prefix + 'ping') { message.send('Gun').then(message => message.edit('Pong')); } }); client.on('message', message => { if (message.content === prefix + 'shutdown') { if (message.author.id === '262707958646901248') { message.send('Shutting down...').then(message => client.destroy()); } } }); client.on('message', message => { if (message.content.startsWith(prefix)) { const args = message.content.slice(prefix.length).split(/ +/); const command = args.shift().toLowerCase(); if (command === 'ping') { message.send('Gun'); } } }); client.on('message', message => { if (message.content === prefix + 'help') { message.send('figure it out I guess?'); } }); client.on('message', message => { if (message.content === prefix + 'info') { message.send('I made this bot when popcorn "died". I hope you enjoy it.'); } }); client.on('message', message => { if (message.content === 'ping') { message.send('https://tenor.com/view/heavy-tf2-the-rock-rock-the-rock-the-dwayne-johnson-gif-22149531'); } }); I tried all the commands that I put in and such, but it didn't do anything. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Code needs a fair bit of work, primarily in organization. Also please take a minute to get familiar with this entire site as all the different elements of this are here and it is a tool you will use often. discord v13 https://discord.js.org/#/docs/discord.js/v13/general/welcome discord v12 https://discord.js.org/#/docs/discord.js/v12/general/welcome const Discord = require('discord.js') const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION"], intents: ["GUILDS", "GUILD_MESSAGES" /* Other intents... */ ] // make sure GUILD_MESSAGES is in there }); const prefix = '-'; const token = '(token here)'; client.login(token); client.on('disconnect', () => { console.log('ZE POPCORN IS DEAD'); }); client.on('ready', () => { console.log('I ARRIVE FROM THE ASHES OF THE EARTH'); }); client.on('message', async message => { // add async const content = message.content.toLowerCase() // For readability // message.send will not work, it needs to be either message.channel.send() or message.reply() // these will work without prefix if (content === 'hello') { message.reply('I HAVE A GUN'); } else if (content === 'ping') { // Below will just send the link message.reply('https://tenor.com/view/heavy-tf2-the-rock-rock-the-rock-the-dwayne-johnson-gif-22149531'); // Below will send the attachment message.reply({ attachments: 'https://tenor.com/view/heavy-tf2-the-rock-rock-the-rock-the-dwayne-johnson-gif-22149531' }) } // these will require the prefix if (content.startsWith(prefix)) { const args = message.content.slice(prefix.length).split(/ +/); const command = args.shift().toLowerCase(); if (command === 'ping') { message.reply('Gun'); } else if (command === 'shutdown') { if (message.author.id === '262707958646901248') { message.reply('Shutting down...').then(() => client.destroy()); // message not used, so not required } else { message.reply('Not allowed') // added else statement } } else if (command === 'help') { message.reply('figure it out I guess?'); } else if (command === 'info') { message.reply('I made this bot when popcorn "died". I hope you enjoy it.'); } } });

Related questions

0 votes
    I'm using const embed = new Discord.RichEmbed(); for my embeds. How do I reset the Embed values? ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
0 votes
    I need to find a message the bot has previously posted, then see the reactions on it. I don't ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    Designing a registration form, and I get this error when adding in MessageBoxButtons and MessageBoxIcon. The error ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    Designing a registration form, and I get this error when adding in MessageBoxButtons and MessageBoxIcon. The error ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    I am currently following along with a somewhat questionable Django tutorial called A complete blog engine using ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I am currently following along with a somewhat questionable Django tutorial called A complete blog engine using ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I am currently following along with a somewhat questionable Django tutorial called A complete blog engine using ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I'm trying to embed python into a C application. For the moment, I am trying to get the following ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I need to know how to use the delete_channel command in discord.py may someone please post a code sample ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I need to know how to use the delete_channel command in discord.py may someone please post a code sample ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 10, 2022 in Education by JackTerrance
0 votes
    This question's answers are a community effort. Edit existing answers to improve this post. It is not ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I'm trying to do a SQL Server 2008 setup and I've been given a Cross Language Installation failure ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I'm trying to do a SQL Server 2008 setup and I've been given a Cross Language Installation failure ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    What is defined as the ability to compete and thrive in the digital age by quickly responding to market changes and emerging opportunities with innovative business solutions?...
asked Nov 28, 2020 in Technology by JackTerrance
0 votes
    Can anyone tell me how do I become a react JS developer from scratch? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
...