How to code a DISCORD BOT - Working 2022 Discord.js

How to code a DISCORD BOT - Working 2022 Discord.js

MrJAwesome

2 года назад

46,626 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@MrJAwesomeYT
@MrJAwesomeYT - 24.04.2022 18:55

Leave a comment if you need any help!

Ответить
@MrWoahGaming
@MrWoahGaming - 08.11.2023 02:45

Okay so, I've tried to sent the test command for the bot, but not getting any luck. any help?

Ответить
@tylerplayz7991
@tylerplayz7991 - 25.10.2023 05:52

Im get this when I try start it
How do I fix it?
TypeError: Discord.client is not a constructor
at Object.<anonymous> (C:\Users\tlinz\Desktop\Sandy Shore Roleplay Moderator Bot\index.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47

Ответить
@user-kv2hk2oj8m
@user-kv2hk2oj8m - 22.09.2023 16:44

I wrote node . but it send:
node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:1
+ node .
+ ~~~~
+ CategoryInfo : ObjectNotFound: (node:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Ответить
@matehaba6347
@matehaba6347 - 14.09.2023 19:14

the bot is not online to me

Ответить
@Themplez
@Themplez - 02.09.2023 09:38

when i do "!test" It doesnt say anything help

Ответить
@L.O.Q
@L.O.Q - 29.08.2023 18:55

i cant seem to get the bot to say anything when i do !test.

My code is

const Discord = require(`discord.js`);

const prefix = '!';

const client = new Discord.Client({
allowedMentions: {
parse: [`users`, `roles`],
repliedUser: true,

},
intents: [
"Guilds",
"GuildMessages",
"GuildPresences",
"GuildMembers",
"GuildMessageReactions",
],
});

client.on("ready", () => {
console.log("bot is online!")
})

client.on('message', message => {
if (message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

//test command
if (command === 'test'){
message.channel.send('The bot is currently working 😀')
}
})

client.login("token")

Ответить
@Vuurwerkgd
@Vuurwerkgd - 19.08.2023 04:51

i still got the bitfieldinvalid error after this:

const Discord = require('discord.js');

const prefix = '!';

const client = new Discord.Client({
allowedMentions: {
parse: [`users`, `roles`],
repliedUser: true,

},
intents: [
"Guilds",
"GuildMessages",
"GuildPresences",
"GuildMembers",
"GuildMessageReactions",
],

});


client.on("ready", () => {
console.log("Bot is online")

})


client.login("........")

help

Ответить
@Wiss1ng
@Wiss1ng - 07.08.2023 20:43

"Error: Used disallowed intents"

PLEASE help 🙏

Ответить
@SebStobart
@SebStobart - 02.08.2023 21:04

I checked my code over and over but my prefix commands still don't work. My bot says nothing when I type !test.

Ответить
@gav3xwilliamss593
@gav3xwilliamss593 - 29.07.2023 00:00

The test command doesnt work, I copied everything you did and the bot is online.

Ответить
@docrst
@docrst - 27.07.2023 01:42

did all the code with the newest Discord.js Guilds stuff and the bit connects but will not answer the !test command.

Ответить
@charliedetweiler4298
@charliedetweiler4298 - 25.07.2023 20:05

Note: "client.on('message'..." didn't work for me, but "client.on('messageCreate'..." did.

Ответить
@HiraethSaga
@HiraethSaga - 20.06.2023 16:49

says 'MODULE_NOT_FOUND'

Ответить
@user-hd2fg9rf8j
@user-hd2fg9rf8j - 10.06.2023 23:45

Hello, actually my test command doesn't really work, can you advice what might be wrong?
Typed all code as on video, did node but bot doesn't see a command and doesn't reply, tysm for an answer

Ответить
@PanneThePansy
@PanneThePansy - 10.06.2023 01:32

"Discord client is not a constructor"
Anyone know how to fix this?

Ответить
@realHaze3l
@realHaze3l - 31.05.2023 20:14

Might u send new version of tutorial? I cant find it

Ответить
@Zumsumofficelsec
@Zumsumofficelsec - 14.05.2023 15:16

Node : The term 'Node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Node .
+ ~~~~
+ CategoryInfo : ObjectNotFound: (Node:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Ответить
@KARNXGEx333-_-
@KARNXGEx333-_- - 04.05.2023 08:24

Today I begin my journey of making my discord bot. After looking at multiple series this one seems to be the most helpful one. Thank you

Ответить
@n5xfuls
@n5xfuls - 22.04.2023 21:22

Note: If it isn't working after changing the Intents (Marzuq Mortuzas' comment), add a new intent called "MessageContent" and then it will work.

Ответить
@flouqi
@flouqi - 22.04.2023 19:29

The bot does not send any messages in the chat! Why?

Ответить
@CloakzyWTF
@CloakzyWTF - 20.04.2023 01:20

yo when i run the code all it says is MODULE_NOT_FOUND

Ответить
@7vnOT
@7vnOT - 15.04.2023 19:23

I keep getting this error : ReferenceError: Client is not defined

Ответить
@massobu
@massobu - 11.04.2023 12:20

'BitFieldInvalid' :0

Ответить
@locopsd
@locopsd - 11.04.2023 04:31

im the best at coding here fuckrs

Ответить
@ml4p
@ml4p - 08.04.2023 22:17

On me their come no folders or anything in my folder after running the dms command I also downloaded node ja 64x bit for windows maybe help me :c

Ответить
@jacobmtb6637
@jacobmtb6637 - 26.03.2023 00:09

yo it say npm not recognised

Ответить
@luvgamingplayz
@luvgamingplayz - 19.03.2023 02:53

can i dm u on discord i need help with this

Ответить
@therealadam32
@therealadam32 - 11.03.2023 17:41

how do i do this on mac

Ответить
@dejansimic5655
@dejansimic5655 - 10.03.2023 21:27

Kupio sam dva servera,jel mozs da mi pomognes oko server-statusa na discordu da mogu videti kako videti koje na serveru?

Ответить
@dejansimic5655
@dejansimic5655 - 10.03.2023 21:26

ee druze,nasao sam te :)

Ответить
@alexanderreed1071
@alexanderreed1071 - 06.03.2023 13:44

Scam server

Ответить
@CROSSFIREGAMING69
@CROSSFIREGAMING69 - 05.03.2023 20:56

iam heaving problem while using node . in terminal

Ответить
@mttw5_889
@mttw5_889 - 05.03.2023 19:23

will this work for Mac

Ответить
@Ruggedbeast
@Ruggedbeast - 04.03.2023 17:20

Ty ur a chad :)

Ответить
@BestEli
@BestEli - 26.02.2023 06:38

when I try the test command it doesn't work and no errors come up

Ответить
@joemama4761
@joemama4761 - 23.02.2023 05:56

I do all the steps for the test command but when I do it in discord it does not work

Ответить
@1-Jack
@1-Jack - 19.02.2023 03:42

If i close out of my visual studio code how do i open it back up

Ответить
@CoffeMaker3304
@CoffeMaker3304 - 18.02.2023 23:44

So i tried to adapt this code so i could be learning while also coding, but i only changed some texts like the reply message and the prefix...
Althought this code is mostly aproved there are some intents discord has not allowed and i think that my bot is not replying because of that... it seems like the intens:
"GuildPresences", "GuildMembers" arent allowed and i was just curious to check if others have that problem too in 2023...i mean a lot changed and most of it is broken now :/

Ответить
@fabianrs100
@fabianrs100 - 04.02.2023 11:14

node . doesn't activate anything, can anyone help me? :(

Ответить
@easonyuen1089
@easonyuen1089 - 28.01.2023 18:35

v13 or v14?

Ответить
@aquagaming8749
@aquagaming8749 - 22.01.2023 15:59

I said the test command but it wont respond

Ответить
@aquagaming8749
@aquagaming8749 - 22.01.2023 15:18

Is it possible for slash commands?

Ответить
@SkThePIug
@SkThePIug - 21.01.2023 16:57

It doesn't seem to reply when I try the test command, any fixes?

Ответить
@Gerodoit
@Gerodoit - 20.01.2023 21:18

node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and tr
y again.
At line:1 char:1
+ node .
+ ~~~~
+ CategoryInfo : ObjectNotFound: (node:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Help me

Ответить
@Simple-jo8kz
@Simple-jo8kz - 16.01.2023 23:50

I checked my code over and over but my prefix commands still don't work. My bot says nothing when I type !test.

Ответить
@l6k878
@l6k878 - 14.01.2023 16:38

Anyone got a solution for this??


C:\Users\gerben\Desktop\Test bot\node_modules\discord.js\src\client\Client.js:489
throw new DiscordjsTypeError(ErrorCodes.ClientMissingIntents);
^

TypeError [ClientMissingIntents]: Valid intents must be provided for the Client.
at Client._validateOptions (C:\Users\gerben\Desktop\Test bot\node_modules\discord.js\src\client\Client.js:489:13)
at new Client (C:\Users\gerben\Desktop\Test bot\node_modules\discord.js\src\client\Client.js:78:10)
at Object.<anonymous> (C:\Users\gerben\Desktop\Test bot\index.js:5:16)
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:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'ClientMissingIntents'

Ответить
@lovethepolygon
@lovethepolygon - 13.01.2023 15:21

i can get the bot online but its not running the test command

Ответить
@oliverteesdale2763
@oliverteesdale2763 - 11.01.2023 07:19

whenever i do !test it dont do anything

Ответить
@SilentWraith2678
@SilentWraith2678 - 06.01.2023 18:46

For some reason, My bot doesn't respond to commands at all. I checked its perms and I wrote the code correctly, Its online yet its unresponsive. @MrJAwesome can you help me with this?

Ответить