Questions tagged [discord.js]

Discord.js is a node.js module that allows the developer to interact with the Discord API. Use this tag for questions about the usage of discord.js, not for questions regarding the Discord API or Discord in general (for API questions, use the 'discord' tag). Consider also using the 'javascript' tag.

Discord is a proprietary freeware VoIP/chat application designed for communities ranging from gamers to education and businesses.

Node.js is an open-source, cross-platform JavaScript run-time environment for executing JavaScript code server-side.

Discord.js is an object-oriented node.js module used to interact with the Discord API (docs, GitHub).

The official guide of Discord.js can be found here.

Consider also using the and the tag.

10690 questions
29
votes
7 answers

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(author, 'pong'); } }); And the problem is that I…
Gabe
  • 434
  • 1
  • 5
  • 11
25
votes
8 answers

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 them a DM with their hand. bot.on("message",…
adapap
  • 495
  • 1
  • 7
  • 19
20
votes
1 answer

None of my discord.js guildmember events are emitting, my user caches are basically empty, and my functions are timing out?

My code has been working just fine for weeks, but a few events and functions have randomly stopped working! Firstly, my guildMemberAdd, guildMemberRemove, and guildMemberUpdate events simply stopped doing anything. No errors are appearing, and when…
Lioness100
  • 7,179
  • 5
  • 9
  • 43
16
votes
2 answers

New Discord Slash Commands

Recently, discord added support for slash commands for your own application. I read through the documentation for it, and I've tried to search for some videos (however the feature did JUST come out) but I do not understand what I actually have to do…
Shreyas007
  • 349
  • 1
  • 1
  • 10
16
votes
6 answers

How to Play Audio File Into Channel?

How do you play an audio file from a Discord bot? Needs to play a local file, be in JS, and upon a certain message being sent it will join the user who typed the message, and will play the file to that channel.
Nicholas Johnson
  • 822
  • 1
  • 11
  • 33
15
votes
1 answer

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 that voice channel as input for a webpage in a web…
Niellles
  • 843
  • 10
  • 25
12
votes
4 answers

Discord Bot Can't Get Channel by Name

I have been making a discord bot and wanted to make it send a message to a specific "Welcome" channel. Unfortunately, I have been unable to do so. I tried this. const welcomeChannel = bot.channels.get("name",…
Leo
  • 237
  • 1
  • 2
  • 8
12
votes
12 answers

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 = require('discord.js'); const client = new…
Bossa
  • 129
  • 1
  • 1
  • 8
11
votes
2 answers

Get Message By ID: Discord.js

I am doing a report system for a discord bot and I want the player to report a specific message by the id so that the moderators can decide if it is offensive or not. I am struggling to find a way to get the message's text from the given id. Is…
NintendoZaedus
  • 593
  • 2
  • 7
  • 18
11
votes
5 answers

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("Good Job everyone :smirk:"); } As you see, if…
gitgudgithub
  • 137
  • 1
  • 1
  • 6
11
votes
8 answers

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's what I have: //other code else if (command ===…
R. Gillie
  • 695
  • 1
  • 7
  • 19
10
votes
1 answer

discord.js MessageEmbed fields.flat is not a function

I am making a Discord bot using JavaScript and discord.js. There, I want to send a RichEmbed/MessageEmbed (I don't know how it's called) to a channel. Instead of sending an Embed though, it threw an error inside discord.js. TypeError: fields.flat is…
milkwood1
  • 309
  • 3
  • 11
10
votes
1 answer

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) DeprecationWarning: Collection#find: pass a function…
pnda
  • 148
  • 1
  • 1
  • 7
10
votes
3 answers

How to send a message to a specific channel

I'm trying to send a message to a specific channel with my Discord bot, which is in several servers. I want the bot to pick up on a message from one server and send a message to my personal server, in a specific channel, but I can't get it to 'find'…
aandamitchell
  • 105
  • 1
  • 1
  • 8
9
votes
0 answers

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. This is basically the example you have in the…
Rikard
  • 6,609
  • 9
  • 44
  • 80
1
2 3
99 100