My Discrod.JS bot is online but not responding. This is the code-
// require the discord.js module
const Discord = require('discord.js');
// create a new Discord client
const client = new Discord.Client();
// when the client is ready, run this code
// this event will only trigger one time after logging in
client.once('ready', () => {
console.log('Ready!');
});
module.exports = function(controller) {
controller.hears(
"!appreciates",
["direct_mention", "mention"],
(bot, message) => {
let response;
let sender = message.user;
let recipient = message.mentions.users
.filter(user => user.bot === false)
.last();
let responses = [
`Hey, ${sender}, I appreciate you! :heart_eyes:`,
`Hey, ${sender}, I appreciate your enthusiasm! :muscle:`,
`Hey, ${sender}, I appreciate your commands! :wink:`,
`Hey, ${sender}, I appreciate your particaption! :grinning:`,
`Hey, ${sender}, I appreciate all your works! :blush:`,
`Hey, ${sender}, I appreciate everything you do. :star_struck:`
];
response = responses[Math.floor(Math.random() * responses.length)];
bot.reply(message, response);
}
);
};
client.login('app token');
There is no error in the console. The only message is “Ready!”.
(node:3362) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (/rbd/pnpm-volume/731183ff-7638-49e9-924e-544b63889d39/node_modules/.registry.npmjs.org/discord.js/12.3.1/node_modules/discord.js/src/client/websocket/WebSocketManager.js:133:26)
at Client.login (/rbd/pnpm-volume/731183ff-7638-49e9-924e-544b63889d39/node_modules/.registry.npmjs.org/discord.js/12.3.1/node_modules/discord.js/src/client/Client.js:222:21)
at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:54:5)
at Function.Module.runMain (internal/modules/cjs/loader.js:828:11)
at internal/main/run_main_module.js:17:11
(node:3362) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3362) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Ready!
(node:3495) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (/rbd/pnpm-volume/731183ff-7638-49e9-924e-544b63889d39/node_modules/.registry.npmjs.org/discord.js/12.3.1/node_modules/discord.js/src/client/websocket/WebSocketManager.js:133:26)
at Client.login (/rbd/pnpm-volume/731183ff-7638-49e9-924e-544b63889d39/node_modules/.registry.npmjs.org/discord.js/12.3.1/node_modules/discord.js/src/client/Client.js:222:21)
at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:54:5)
at Function.Module.runMain (internal/modules/cjs/loader.js:828:11)
at internal/main/run_main_module.js:17:11
(node:3495) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3495) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Ready!
I found that my bot is logging in to Discord as expected even though Glitch is showing me loading screen. However, it is still not responding to messages. By the way, I just made the project public and you can view it here-