#Can someone help my crash loop?

31 messages · Page 1 of 1 (latest)

wicked ravine
#

my crash loop is non stop when im trying to make a bot what am i doing wrong?

grave wraithBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
round ospreyBOT
#

Tag suggestion for @wicked ravine:
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined

  • All SCREAMING_SNAKE_CASE enums have been changed to PascalCase
  • Intents: Intents.FLAGS.GUILD_MESSAGES -> GatewayIntentBits.GuildMessages
  • Permissions: Permissions.FLAGS.SEND_MESSAGES -> PermissionFlagsBits.SendMessages
wicked ravine
#

let me just show my scripts

#

my package.json "name": "The-Green-Mooser",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"start": "node ."
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/node": "^18.0.6",
"discord.js": "^14.14.1",
"express": "^4.18.2",
"node-fetch": "^3.2.6"
},
"devDependencies": {
"node": "^16.20.2"
},
"description": ""
}

#

and my index.js const express = require("express");
const app = express();

app.listen(3000, () => {
console.log("Project is running!");
})

app.get("/", (req, res) => {
res.send("Hello world!");
})

const Discord = require("discord.js");
const client = new Discord.Client({intents: ["GUILDS", "GUILD_MESSAGES" ]});

client.on("message", message => {
if(message.content === "ping") {
message.channel.send("pong")
}
})

client.login(process.env.token);

round ospreyBOT
#

To share long code snippets, use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks or files.

queen musk
#

You're using v14 but your code is still v13, so you'd need to make some changes

round ospreyBOT
#

guide Additional Information: Updating from v13 to v14
read more

wicked ravine
#

like what?

queen musk
#

You'd also need MessageContent intent if you wanna access the message's content

round ospreyBOT
#

If you aren't getting content, embeds or attachments of a message, make sure you have the MessageContent intent enabled in the Developer Portal and provide it to your client:

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
    intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
wicked ravine
#

it is enabled

queen musk
wicked ravine
#

so in index.js?

queen musk
#

Yes, if that's where your client constructor is

wicked ravine
queen musk
#

Alright, now make the changes I said

wicked ravine
#

i did ima refresh the page so it recinizes

#

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});

#

didnt copy hold on

#

/home/runner/The-Green-moose-bot/index.js:18
const client = new Discord.Client({intents: ["GUILDS", "GUILD_MESSAGES" ]});
^

SyntaxError: Identifier 'client' has already been declared
at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1288:20)
at Module._compile (node:internal/modules/cjs/loader:1340:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49

Node.js v20.10.0

#

there

queen musk
#

You shouldn't just blindly copy-paste, you have 2 clients, so get rid of the one you had

wicked ravine
#

there i replaced it

#

with new one should i try now?

queen musk
#

Yes

wicked ravine
#

IT WORKED THX

queen musk
#

You're welcome, please mark the post as solved