Discord Bot is Not Working

Hello!

I tried coding a Discord bot which counts my Members!

I open cmd and go to my discordbot file by typing: ,cd desktop’’ and then ,cd discordbot’’
And as soon as I try to start the bot by typing ,node .’’ in cmd, it says:

Error: Cannot find module ‘discord.js’
Require stack:

  • C:\Users\nexyo\Desktop\DiscordBot\bot.js
    e[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)e[39m
    e[90m at Function.Module._load (internal/modules/cjs/loader.js:841:27)e[39m
    e[90m at Module.require (internal/modules/cjs/loader.js:1025:19)e[39m
    e[90m at require (internal/modules/cjs/helpers.js:72:18)e[39m
    at Object. (C:\Users\nexyo\Desktop\DiscordBot\bot.js:1:17)
    e[90m at Module._compile (internal/modules/cjs/loader.js:1137:30)e[39m
    e[90m at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10)e[39m
    e[90m at Module.load (internal/modules/cjs/loader.js:985:32)e[39m
    e[90m at Function.Module._load (internal/modules/cjs/loader.js:878:14)e[39m
    e[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)e[39m {
    code: e[32m’MODULE_NOT_FOUND’e[39m,
    requireStack: [ e[32m’C:\Users\nexyo\Desktop\DiscordBot\bot.js’e[39m ]
    }

Could someone help me? (I am using VSC for the Bot)

Open the command prompt and cd to the folder that you have your bots code in. When you are in that folder, run npm i discord.js

1 Like

I did it, my bot is online, But whenever I type: ,node .’’ I get this message:

(node:8316) UnhandledPromiseRejectionWarning: TypeError: client.guilds.get is not a function
at Client. (C:\Users\nexyo\Desktop\DiscordBot\bot.js:9:33)
at Client.emit (events.js:315:20)
at WebSocketManager.triggerClientReady (C:\Users\nexyo\Desktop\DiscordBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:431:17)
at WebSocketManager.checkShardsReady (C:\Users\nexyo\Desktop\DiscordBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:415:10)
at WebSocketShard. (C:\Users\nexyo\Desktop\DiscordBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:197:14)
at WebSocketShard.emit (events.js:315:20)
at WebSocketShard.checkReady (C:\Users\nexyo\Desktop\DiscordBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:475:12)
at WebSocketShard.onPacket (C:\Users\nexyo\Desktop\DiscordBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:447:16)
at WebSocketShard.onMessage (C:\Users\nexyo\Desktop\DiscordBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\nexyo\Desktop\DiscordBot\node_modules\ws\lib\event-target.js:125:16)
(node:8316) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8316) [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.