All Questions

Tagged with
Filter by
Sorted by
Tagged with
259 votes
3 answers
634k views

Error [ERR_REQUIRE_ESM]: require() of ES Module not supported [duplicate]

I'm trying to make a Discord bot that just says if someone is online on the game. However I keep getting this message: [ERR_REQUIRE_ESM]: require() of ES Module from not supported. Instead change the ...
N-Man's user avatar
  • 3,449
40 votes
9 answers
224k views

Send a message with Discord.js

I am trying to make a discord bot, but I can't quite understand Discord.js. My code looks like this: client.on('message', function(message) { if (message.content === 'ping') { client.message.send(...
Gabe's user avatar
  • 544
40 votes
8 answers
242k views

Sending private messages to user

I'm using the discord.js library and node.js to create a Discord bot that facilitates poker. It is functional except the hands are shown to everyone, and I need to loop through the players and send ...
adapap's user avatar
  • 665
34 votes
5 answers
158k views

Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported

I'm making a discord bot in TypeScript using discord.js. When I tried to compile code this morning I got this error: C:\SECRET\Kostegator\dist\Util\getMeme.js:17 const node_fetch_1 = __importDefault(...
ProGamer2711's user avatar
26 votes
4 answers
107k views

How do I fix CLIENT_MISSING_INTENTS error?

I started learning about discord.js, but now I am facing this issue. I tried some googling, but I couldn't manage to fix it. const Discord = require('discord.js'); // const Discord = require('discord....
NewJs's user avatar
  • 295
23 votes
9 answers
160k views

Find out if someone has a role

I made a simple quote bot for a server, but the admin only wants mod+ people to be able to add quotes to avoid spam. I went to the documentation and did everything, but I can't get this to work. Here'...
R. Gillie's user avatar
  • 1,403
22 votes
1 answer
35k views

message.content doesn't have any value in Discord.js

With discord v14, I was trying to use the messageCreate event, however, after a user types a message in discord, message.content doesn't have any data as shown below: Message { channelId: '...
user19530601's user avatar
21 votes
5 answers
135k views

Discord.js sending a message to a specific channel

I'm failing to achieve something very simple. I can't send a message to a specific channel. I've browsed trough the documentation and similar threads on stack overflow. client.channels.get().send()...
Danislav Kamenov's user avatar
20 votes
3 answers
35k views

Why am I getting a ReferenceError: AbortController is not defined in Discord.js v13?

Today (7.8.2021) Discord.js v13 has been released. So I upgraded my previous Discord.js installation with npm i discord.js@latest and then adapted my basic index.js file to this state (I followed ...
Behemoth's user avatar
  • 8,356
19 votes
1 answer
209k views

How can a Discord bot create a hyperlink in a Discord message in an embed or in general? [closed]

Today I did a lot of research on hyperlinks and how to use them. But everything I found didn't work as they were probably outdated… How can my Discord.js bot send a message with a hyperlink? I know I ...
pragmatrick's user avatar
18 votes
3 answers
34k views

Discord.js get an array of all messages in a channel

I am coding a Discord bot in which I want to do the command !quote and it will pull a random message of of out of a specific channel with id quotesID (that may or may not be a different channel that !...
Jared Cohen's user avatar
18 votes
3 answers
52k views

How to solve error "SyntaxError: Unexpected token '?'"

I'm not sure what's wrong. I deleted my code and downloaded it then uploaded it again and now I get this error. Code: https://replit.com/@hi12167pies/webcord#index.js (Click code for code and output ...
hi12167pies's user avatar
17 votes
1 answer
9k views

How to setup a virtual mic and pipe audio to it from node.js

Summary of what I am trying to achieve: I'm currently doing some work on a Discord bot. I'm trying to join a voice channel, which is the easy part, and then use the combined audio of the speakers in ...
Niellles's user avatar
  • 868
16 votes
1 answer
79k views

Discord.js Bot [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted Error

I'm having issues with Discord.js Bot on v13+. I'm getting [DISALLOWED_INTENTS] error. How can I fix this? Thanks. (node:16060) UnhandledPromiseRejectionWarning: Error [DISALLOWED_INTENTS]: Privileged ...
Kingz Empire's user avatar
14 votes
6 answers
19k views

discord.js bot replies to itself

I am currently coding my first discord bot, it can already play YouTube music. if (message.content.includes("Good Job") || message.content.includes("good job")) { message.channel.sendMessage(...
gitgudgithub's user avatar
14 votes
3 answers
43k views

Checking if a message is a DM. (Discord.js and discord.js-commando)

How can I check if a message is a DM in Discord.js? I have tried several ways on how to test against this, I have tried these methods: if (msg.channel.isDM) ... Produced undefined if (msg.isDM) ... ...
William's user avatar
  • 1,185
14 votes
14 answers
97k views

Change user nickname with discord.js

I wonder if you can help (I search it and nothing...) I am learning how to work with discord.js node and I want to change my user nickname (not the username itself) My code is const Discord = ...
Bossa's user avatar
  • 159
13 votes
1 answer
32k views

Event messageCreate not firing/emitting when I send a DM to my bot (discord.js v13)

I made this code for logging the DMs that are sent to my bot: client.on('messageCreate', async message => { if (message.author.bot) return; const attachment = message.attachments.first() ...
claire.png's user avatar
13 votes
3 answers
24k views

Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'

I am declaring the following variables using TypeScript: const BOT_PREFIX: string = process.env.PREFIX; const BOT_TOKEN: string = process.env.TOKEN; I get the following error: Type 'string | ...
Adonys's user avatar
  • 135
13 votes
1 answer
50k views

Error when requiring discordjs: "cannot find module 'node:events'" [duplicate]

I'm trying to develop a bot to disagree. I installed the npm install discord.js --save library. But it is giving an error when importing it. How can I fix it? Command: node . internal/modules/cjs/...
Bjorn Ruiz's user avatar
13 votes
2 answers
42k views

Cannot find node module 'node:fs' when using js and trying to deploy to my personal server that runs linux

Error: Cannot find module 'node:fs' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module....
Doge's user avatar
  • 131
13 votes
1 answer
22k views

TypeError: Object.hasOwn is not a function

I tried to code a bot with the new discord.js version but when I try to log in, it's prompting me this error /home/max/Schreibtisch/Discord Bots/Perplex/node_modules/discord.js/src/util/Util.js:279 ...
gokimax's user avatar
  • 131
13 votes
0 answers
958 views

Wav to Opus convertion with Discord.js/opus fails silently

I am trying to convert a WAV file to Opus, using Node's fs.readFile and passing that buffer to @Discord/opus converter. I get neither the result or a error thrown with a explanation of what is wrong. ...
Rikard's user avatar
  • 7,645
12 votes
7 answers
216k views

How to set bot's status

So I'm trying to make my bot's streaming to be with depression but I've tried multiple things and they don't work. I've tried these methods: client.user.setPresence({ game: { name: 'with depression' }...
Modular's user avatar
  • 149
12 votes
16 answers
120k views

Node.js node:internal/modules/cjs/loader:936 error while trying to use discord.js

I'm trying to make a discord bot with the command prefix "*" but when I try to get the bot online/run it, it gives me this error: node:internal/modules/cjs/loader:936 node:internal/modules/...
coder's user avatar
  • 121
12 votes
3 answers
38k views

Get last message sent to channel

I already have a variable containing a specific channel, but how can I obtain the last message sent to the channel? I want to make my bot only perform an action if the last message to the channel wasn'...
clubby789's user avatar
  • 2,623
12 votes
4 answers
32k views

MongooseError: Model.findOne() no longer accepts a callback at Function

I've encountered a problem while setting up mongoose. Here is my code: const { SlashCommandBuilder } = require('@discordjs/builders'); const testSchema = require(`../../Schemas.js/test`); module....
akim's user avatar
  • 121
11 votes
4 answers
48k views

How do I mention a role with Discord.js?

I am making a bot and I am trying to Ping a certain role. Here is the relevant code: let msga = msg.author; msg.channel.send("@NES Found one!! " + msga); @NES is the role I am trying to ping/...
RtHAitP30D's user avatar
11 votes
1 answer
100k views

Discord API valid intents must be provided for the client [duplicate]

I am programming a Discord bot. When I try to run a node, I get this in the CMD window: C:\Users\utente\Desktop\bouncerBot\node_modules\discord.js\src\client\Client.js:544 throw new TypeError('...
Conta's user avatar
  • 186
11 votes
3 answers
15k views

When using 'npm' it requires me to login to github

Problem When i try to use npm in any way, ex: npm update or npm i package it immediatly gives me a github login prompt. What i tried using npm with i, install, and even giving it git directly git://. ...
Syber's user avatar
  • 411
11 votes
3 answers
43k views

TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function

I have this little problem here: events.js:200 throw new errors.ERR_INVALID_ARG_TYPE('listener', 'Function', listener); ^ TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of ...
Shino's user avatar
  • 121
10 votes
5 answers
78k views

Discord Bot can't find channel by name or id

I'm trying to make a discord bot with DiscordJS I want to fetch a specific channel : const Discord = require('discord.js'); var bot = new Discord.Client(); var myToken = 'NDQ2OTQ1............
Portevent's user avatar
  • 724
10 votes
2 answers
59k views

How to detect if the author of a message was a Discord bot?

The title explains my question. This question might sound stupid, but how do I detect if the author of a message was a Discord bot? Thanks.
Brandon's user avatar
  • 409
10 votes
1 answer
53k views

How do I get a bot to mention a channel?

I am making a welcome message but I can’t seem to make it say the rule channel. I want the bot to say #rules and make it so you can click it to go to the rules channel. I know you can do this with a ...
Pruina Tempestatis's user avatar
10 votes
4 answers
14k views

discord.js - How do I add the "TRY MY COMMANDS" feature to my bot?

I looked at some bot's profile and apparently, Discord added a "try out my commands" feature to bots. I tried looking everywhere and did not find anything. How do I add this feature to my ...
bolekinds's user avatar
  • 119
10 votes
2 answers
84k views

Discord.js Delete Single Message

I am currently working on creating a Discord bot using Discord.js, and I want to have a command that you can tell it ||say Hello or something and it will delete your comment, then say what you told it ...
jcb1032's user avatar
  • 627
10 votes
2 answers
46k views

How to fix Must use import to load ES Module discord.js

I am working on a bot i made a roast command i am getting this error internal/modules/cjs/loader.js:1089 throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath); ^ Error [...
CaptainBeasst's user avatar
10 votes
1 answer
16k views

DeprecationWarning: Collection#find: pass a function instead

I'm quite a newbie to node.js and I'm currently using discord.js to make a Discord bot. As soon as any bot command gets used the console prints a DeprecationWarning. for example: (node:15656) ...
pnda's user avatar
  • 196
9 votes
2 answers
35k views

Slash Commands "unknown interaction"

it was a silly error ( " } " in the wrong position ), whoever is interested in this handler I upgraded to v13 is very simple but it works well with it. https://github.com/Inkeee/Tutorial-...
Noah's user avatar
  • 99
9 votes
2 answers
76k views

How to stop the error 'read ECONNRESET' from happening

I've made a lot of bots, hosted some on my personal laptop, and some on Heroku, but in both, I received this error that terminated node.js, so I used bot.on('error', console.error) to view the error ...
GamesProSeif's user avatar
9 votes
1 answer
18k views

How can you create a pop-up window in Discord that accepts an input from the user?

It's my first time seeing this feature from a Discord bot. I tried looking everywhere but it seems that I have failed. There's this feature from Captcha.bot Discord bot where you can accept input from ...
Cif's user avatar
  • 173
9 votes
3 answers
18k views

TypeORM cannot use cli with configuration

I have my (typescript) Project (Its a discord bot if that is important), which contains a "ormconfig.json" file. This file contains my configuration for TypeORM, see as follows: { "...
PlayWolfYT's user avatar
9 votes
1 answer
1k views

Adding 'silent frames' to a Node.js stream when no data is received

I am creating a Discord.js bot using Node.js that records the audio of users in a voice channel. It joins a channel and starts listening to each user separately. It records to a .pcm file (so only the ...
JasperJ's user avatar
  • 91
8 votes
7 answers
99k views

Discord.js Ping Command

I was trying to make a ping command for my bot here is my Code client.on('message', message => { if (message.content === '+ping') { message.channel.send(`🏓Latency is ${m.createdTimestamp - ...
Lallu's user avatar
  • 168
8 votes
1 answer
5k views

Discord app error R10 when deploying with Heroku

I tried to deploy my discord bot made with Node.js to Heroku, the build is successful but the app crashes and throws an error: Error R10 (Boot timeout) Web process failed to bind to $PORT within 60 ...
YVND's user avatar
  • 379
8 votes
8 answers
99k views

Deleting all messages in discord.js text channel

Ok, so I searched for a while, but I couldn't find any information on how to delete all messages in a discord channel. And by all messages I mean every single message ever written in that channel. Any ...
Johannes's user avatar
  • 397
8 votes
4 answers
14k views

Discord.js On message command not working

Discord.js Problem I should point out I am not experienced at discord.js. I have the following code which is supposed to change the users requested sum or expression into the actual answer and message ...
user avatar
8 votes
5 answers
113k views

Welcome message when joining discord Server using discord.js

I am making a discord bot using node.js and discord.js, and I am currently trying to make it so that when a user joins the discord server, a custom welcome message is sent. Here is my code: bot.on("...
user avatar
8 votes
2 answers
13k views

What is the difference between a User and a GuildMember in discord.js?

I've gotten many errors in my code that I believe has been the result of mix-ups between GuildMembers and Users. Can someone explain the difference? const user = message.mentions.users.first(); // ...
Lioness100's user avatar
  • 8,376
8 votes
1 answer
18k views

Discord.js v13 code breaks when upgrading to v14

I've just updated my discord.js from v13 to v14 and there are many errors. Errors with message and interaction events: Neither message nor interaction events fire. Errors with intents: const client = ...
Zsolt Meszaros's user avatar

1
2 3 4 5
165