Can someone help my crash loop?

my crash loop is non stop when im trying to make a bot what am i doing wrong?
No description
23 Replies
d.js toolkit
d.js toolkit12mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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
d.js docs
d.js docs12mo ago
Tag suggestion for @Ranner: 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
~·N·~
~·N·~OP12mo ago
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);
d.js docs
d.js docs12mo ago
To share long code snippets, use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks or files.
Danial
Danial12mo ago
You're using v14 but your code is still v13, so you'd need to make some changes
d.js docs
d.js docs12mo ago
guide Additional Information: Updating from v13 to v14 read more
~·N·~
~·N·~OP12mo ago
like what?
~·N·~
~·N·~OP12mo ago
SourceBin
package.json
Instantly share your code with the world.
Danial
Danial12mo ago
This, and the event name is messageCreate now, not message You'd also need MessageContent intent if you wanna access the message's content
d.js docs
d.js docs12mo ago
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]
});
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
~·N·~
~·N·~OP12mo ago
it is enabled
Danial
Danial12mo ago
You also need to put the intent in your client constructor like so
~·N·~
~·N·~OP12mo ago
so in index.js?
Danial
Danial12mo ago
Yes, if that's where your client constructor is
~·N·~
~·N·~OP12mo ago
heres my index.js just in case. https://sourceb.in/d7Ldu1qmDf
SourceBin
index.js
Instantly share your code with the world.
Danial
Danial12mo ago
Alright, now make the changes I said
~·N·~
~·N·~OP12mo ago
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
Danial
Danial12mo ago
You shouldn't just blindly copy-paste, you have 2 clients, so get rid of the one you had
~·N·~
~·N·~OP12mo ago
there i replaced it with new one should i try now?
Danial
Danial12mo ago
Yes
~·N·~
~·N·~OP12mo ago
IT WORKED THX
Danial
Danial12mo ago
You're welcome, please mark the post as solved
~·N·~
~·N·~OP12mo ago
got it
Want results from more Discord servers?
Add your server