#CAN SOMEONE HELP ME WITH THIS DONT KNOW WHATS WRONG

109 messages · Page 1 of 1 (latest)

pallid forge
#

js```js// Require the necessary discord.js classes
const { Client, Events, GatewayIntentBits } = require('discord.js');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

// When the client is ready, run this code (only once)
// We use 'c' for the event parameter to keep it separate from the already defined 'client'
client.once(Events.ClientReady, c => {
console.log(Ready! Logged in as ${c.user.tag});
});

// Log in to Discord with your client's token

client.on('message', message => {
if (message.content === '!pine tree macro') {
message.channel.send('PINE TREE MACRO:\n\nREQUIRED:\n12 buoyant bees\n7+ tads\nLvl 14 and higher\nHave to be blue hive\nGet ready to send screenshot\nMax players 4 DO NOT INVITE then message this https://web.roblox.com/games/1537690962?privateServerLinkCode=00980789330504404425989787220420
');
}
});

client.login('changed for privacy');```

#

i use vs code

#

error message jhsInvalid or unexpected token

modest oasis
#

Is that the entire error message????

pallid forge
#

no

modest oasis
#

Could you share the whole thing

pallid forge
# modest oasis Is that the entire error message????

SyntaxError: Invalid or unexpected token
at internalCompileFunction (node:internal/vm:74:18)
at wrapSafe (node:internal/modules/cjs/loader:1141:20)
at Module._compile (node:internal/modules/cjs/loader:1182:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
at node:internal/main/run_main_module:23:47

#

any ideas

modest oasis
#

You have a new line at the end of line 18. The final ' of your string must be on the same line as the string.

#

This is what I'm referring to.

#

What's on line 19 is supposed to be the very end of line 18.

pallid forge
#

all of line 19

modest oasis
#

The error message didn't help at all lol

#

Yes

pallid forge
#

new error

#

jsReferenceError: js is not defined at Object.<anonymous> (C:\Users\ \discord.test.bot.wip\index.js:1:1) at Module._compile (node:internal/modules/cjs/loader:1218:14) at Module._extensions..js (node:internal/modules/cjs/loader:1272:10) at Module.load (node:internal/modules/cjs/loader:1081:32) at Module._load (node:internal/modules/cjs/loader:922:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12) at node:internal/main/run_main_module:23:47

#

i took out om imformation

#

information

pallid forge
modest oasis
#

You're trying to access a variable named js which doesn't exist, on the very first line

pallid forge
#

so delete the first ;ine

#

line

modest oasis
#

Do you know JavaScript???

pallid forge
#

i am very new

#

like started last week 😅

#

i researched watch vids and stuff on this

modest oasis
#

Can you explain what the first line is doing?

pallid forge
#

i followed a tutorial i had some help someone and they tpld me to do that

#

srry i am not being much help

modest oasis
#

But can you explain what the first line does?

#

Assuming it's the same code you shared here it's this line

js// Require the necessary discord.js classes
pallid forge
#

i had a diffrent one he told me it was out dated and to put that at the top so idk

modest oasis
#

Forget all the rest of the code. What do you think that one line is doing?

#

If you can explain the line of code you can easily fix the issue.

#

If you don't understand a part of the line I can help you learn what it is

modest oasis
#

What specifically do you not understand about that line?

#

There's two parts to the line.

#

Do you know what the // does?

pallid forge
#

i am a complete noob at this

modest oasis
#

The // is a comment. So JavaScript ignores those two slashes and everything after them on that line.

#

So do you know what the js is doing?

#

It's the only part of the line that does anything

pallid forge
#

is it for node.jsjs

#

is it to access that

modest oasis
#

JavaScript is interpreting it as a variable name access. It thinks you want the value from a variable named js.

pallid forge
#

soo what can i do to fix this and to make it work

modest oasis
#

Since it's line 1 there's no variables yet, so you get an error when you try to access a variable.

pallid forge
#

have u made a discord bot before??

modest oasis
#

Just get rid of the variable access

#

I made our Discord bot. I made a discord bot for my other discord server. I wrote a gateway and API wrapper for the Discord application API. So yeah.

pallid forge
#

omgggggg

#

u dont understand i have been working on this all day and all week it finally works tysm!!!!!!!!!!!

#

TYYYYYYYYYYYYYYYYYYYYY

modest oasis
#

Np

pallid forge
#

discord.test.bot.wip> node .
Ready! Logged in as Macro bot#2420

modest oasis
#

Try understanding what the lines do.

pallid forge
#

hey one more thing

modest oasis
#

Make sure you're using a text editor that highlights syntax errors.

pallid forge
#

how did u learn to code javascript

modest oasis
#

A massive book in 2006

pallid forge
#

lol

#

hey

#

its not responding to my message in discord

#

its online

modest oasis
#

Where you have client.on('message' change message to messageCreate

pallid forge
#

K

modest oasis
#

You'll also need the messages intent

#

And it'll need to be enabled in the developer portal

pallid forge
#

I on mobile give me like 5min to respond

#

K let me try

#

made the chamges

#

stillo not responding

#

@modest oasis srry for ping any idea

modest oasis
#

Did you enable the messages intent on the developer portal?

#

Looks like you're missing the messages intent

#

You should be able to Google for instructions on how to do both of those things

pallid forge
modest oasis
#

Ok, so you need to address the second thing I mentioned

pallid forge
#

I did both thing u said

modest oasis
#

You added the messages intent into your code?

pallid forge
#

This

#

??

modest oasis
#

The code you shared only has the guilds intent

pallid forge
#

What do I do?

modest oasis
#

!google discord.js messages intent

modest oasis
#

That's a good answer

pallid forge
#

so should i add those to my code

#

js```const { Client, Events, GatewayIntentBits } = require('discord.js');

// Create a new client instance
const client = new Client({ intents: [
GatewayIntentBits.DirectMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
] });

// When the client is ready, run this code (only once)
// We use 'c' for the event parameter to keep it separate from the already defined 'client'
client.once(Events.ClientReady, c => {
console.log(Ready! Logged in as ${c.user.tag});
});

// Log in to Discord with your client's token

client.on('messageCreate', message => {
if (message.content === '!pine tree macro') {
message.channel.send('PINE TREE MACRO:\n\nREQUIRED:\n12 buoyant bees\n7+ tads\nLvl 14 and higher\nHave to be blue hive\nGet ready to send screenshot\nMax players 4 DO NOT INVITE then message this https://web.roblox.com/games/1537690962?privateServerLinkCode=00980789330504404425989787220420');

}

});

client.login('privacy
');```

#

ill try this

#

it works tysmmmmmm

#

u spent like an hour helping me which was very nice of u have a great rest of your day. happy holidays @modest oasis again tysm

modest oasis
#

Haha good job!

pallid forge
#

@modest oasis srry for ping u really know your stuff any idead what to do here

#

js```const { Client, Events, GatewayIntentBits } = require('discord.js');

// Create a new client instance
const client = new Client({ intents: [
GatewayIntentBits.DirectMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
] });

// When the client is ready, run this code (only once)
// We use 'c' for the event parameter to keep it separate from the already defined 'client'
client.once(Events.ClientReady, c => {
console.log(Ready! Logged in as ${c.user.tag});
});

// Log in to Discord with your client's token

client.on('message', message => {
// Ignore messages that are not in the specified channel
if (message.channel.id !== '10538239712687760') return;

// Delete the message
message.delete();
});

client.login('MTA1NDIxNzQ3NDA5MjA0NDI5OA.G9vpFl.3-ubzvXhCHANGED');

// Set up a loop to delete all messages in the channel every 10 minutes
setInterval(() => {
// Get all messages in the channel
client.channels.fetch('1053823971268776')
.then(channel => channel.messages.fetch())
.then(messages => {
// Delete all messages
messages.forEach(message => message.delete());
});
}, 600000); // 10 minutes in milliseconds```

#

jsError: Cannot find module 'C:\Users\J\discord delete bot\index.js'. Please verify that the package.json has a valid "main" entry at tryPackage (node:internal/modules/cjs/loader:409:19) at Module._findPath (node:internal/modules/cjs/loader:651:18) at resolveMainPath (node:internal/modules/run_main:16:25) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:24) at node:internal/main/run_main_module:23:47 { code: 'MODULE_NOT_FOUND', path: 'C:\\Users\\\\discord delete bot\\package.json', requestPath: 'C:\\Users\\\\Desktop\\discord delete bot'

#

error message

modest oasis
#

That error message is telling you it can't find your code. It's looking for a file C:\Users\J\discord delete bot\index.js

#

You need to figure out why your package.json is referencing an index file that doesn't exist

pallid forge
#

it is tho

#

js```const { Client, Events, GatewayIntentBits } = require('discord.js');

// Create a new client instance
const client = new Client({
intents: [
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping
]
});

// When the client is ready, run this code (only once)
// We use 'c' for the event parameter to keep it separate from the already defined 'client'
client.once(Events.ClientReady, c => {
console.log(Ready! Logged in as ${c.user.tag});
});

// Log in to Discord with your client's token

client.on('message', message => {
// Ignore messages that are not in the specified channel
if (message.channel.id !== '105382397126016') return;

// Delete the message
message.delete();
});

client.login('MTA1NDIxNzQ3NDA5MjA0NDI5OA.G9vpFl.3-ubzvXhoGZg6GBoka1CCoFkKPua0');

// Set up a loop to delete all messages in the channel every 10 minutes
setInterval(() => {
// Get all messages in the channel
setInterval(() => {
client.channels.fetch('105382397176016')
.then(channel => channel.bulkDelete(100))
.catch(console.error);
}, 600000); // 10 minutes in milliseconds``` does this look good

pallid forge
#

i fixed it but new error

#

yntaxError: Unexpected end of input

#

hello?

#

nevermind i figured it out