Help me please, I don't know what I'm doing bad

Can you help me creating my discord bot? I’m creating it with js.

Hi @PKT-Pol !

Welcome to the forum!

I feel like it should be

client.login(process.env['TOKEN']);

Also, make sure you added your token bot to the secrets tab in replit.

I am looking at the documentation and it looks like you are missing some lines of code at the top.

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

I haven’t built a bot using javascript but I would look into the docs to help you troubleshoot some of the errors.

Hope that helps!

Hi, and thanks, it continous not working it says:
Error: Cannot find module ‘node:events’
Require stack:

  • /home/runner/PKT-or-BOT/node_modules/discord.js/src/client/BaseClient.js
  • /home/runner/PKT-or-BOT/node_modules/discord.js/src/index.js
  • /home/runner/PKT-or-BOT/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object. (/home/runner/PKT-or-BOT/node_modules/discord.js/src/client/BaseClient.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions…js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)Hint: hit control+c anytime to enter REPL.

What I have to do?

It would help if you linked to your Replit.

Not sure if it’s related to the error or not, but you likely have to downgrade the version of discordjs to 12 as 13 requires Node 16.6.0 and Replit runs Node v12.16.1.

here you are https://replit.com/join/vhbxcmhizf-pktpol

As I said, you can’t use that version of discord with Replit. Downgrade to 12.

Change the version in package.json

  "dependencies": {
    "discord.js": "12.5.3"
  }

Edit: also did you actually add the token to the environment variables?

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.