๐ŸŒˆ discord.js - Imagine a bot


๐ŸŒˆ discord.js - Imagine a bot

Support server for discord.js, a Node.js module to interact with the Discord bot API.

Join Server

Community questions


Get member "in-server" nickname

How can i properly get the username of a member in a server? I tried to use <Message>.author.displayName under messageCreate callback but it returned the "global" username (in case of a specific member that didn't migrated to the new format yet, the user#0000 format).

How can i safely fetch the user that was set to be use inside the guild?

How fox this?

Help pls

DM user using rest and include file attachment in the embed

I am trying to DM the using using rest request. The DM does work and it does send the embed but it doesn't attach the thumbnail for some reason.

const image = new MessageAttachment(aCorrectPath, 'exampleImage.png');
const embed = new MessageEmbed()

async function getMessageOptions(options)
const body = {
content: options.content,
embeds: options?.emb...

How do this on replit?

Help pls

Shard 0's process exited before its Client became ready

My bot was working fine and then I restarted it to make a small non breaking change and from now on even after reverting the change I get this error message:
Node.js v18.12.1
[INFO]: Shard [0] died
[INFO]: Spawned shard [0]
[INFO]: Error in [0]
[ERR]: Error [ShardingReadyDied]: Shard 0's process exited before its Client became ready.
[INFO]: Shard [0] died
[INFO]: Error in [0]
[ERR]: Error [ShardingReadyDied]: Shard 0's process exited before its Client became ready.

interactive data collection

I have an "interactive" chat with the bot, it asks me questions, I answer them and it saves that information to send it in a single message later on x channel, it worked normally, but I wanted to add some buttons so that depending on what they choose in the buttons the bot will continue a different code, the fact is that with the buttons I could only implement 1 action and the action is continued in a 'client.on('messageCreate', async (message) => {' because if not I won't It worked, but when co...

'message.content.toUpperCase().includes()' it's wrong? or Im missing something

help :9_:
client.on("messageCreate", async (message) => {

    switch (message.content.toUpperCase().includes()) {
        case `CRAZY`:

        message.reply("Crazy? I Was Crazy Once. They Locked Me In A Room. A Rubber Room. A Rubber Room With Rats. And Rats Make Me Crazy.")

Does anyone know how I can fix this in my code, it says it is out of date

Does anyone know how I can fix this in my code, it says it is out of date

Downloading v13 Error

I'm trying to download v13 in Shell, this is my code: const { Client, Intents, MessageEmbed } = require('discord.js');
const client = new Client({
const prefix = '!';

// ... (rest of your code)

client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);

client.on('messageCreate', (message) => {
if (message.author.bot || !message.content.startsWith(prefix)) {
return; // Ignore messages from bots an...

Discoverable servers support

Does D.JS support having a bot on a discoverable server without it actually being there? I mean it works with the API, but does it work in D.JS?

Error with ticket

```TypeError: slashCommand.run is not a function
at Client.<anonymous> (C:\Users\Ohca\Desktop\BotSentencia\src\index.js:74:26)
at Client.emit (node:events:526:35)
at InteractionCreateAction.handle (C:\Users\Ohca\Desktop\BotSentencia\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\Ohca\Desktop\BotSentencia\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketMana...

Slash Command Guild Permission Overwrite

Hello there. I'll make this quick. In sort, I am making a command that applies slash command permission overwrites to servers based on a file it reads. Now, I did manage to write everything that sets up the properties object to be applied to the guild.commands.permissions.set() function, but for some reason, it just does not accept it. Here is an overview of the important chunks of code:
const guildPermissions: {id: string, permissions: ApplicationCommandPermissions[]}[] = []

{ // This...

Unable to import a component from a file to another

Hi, i'm trying to get a select menu exported in a file in order to use it in another one by importing it but i get this error (i tried with buttons and i got the same thing):
When the function is in the same file i don't get the issue
TypeError: (0 , modulesMenu_1.buildSelectMenu) is not a function
at Object.execute (\bot\dist\modules\setup\commands\module.js:52:68)
at handleCommandInteraction (\bot\dist\modules\core\events\client\interactionCreate.js:36:27)
at process.proce...

Bot spams a response that should only be send once and wont play the music it should.

 [6] 48238
pierrekorell@Gott lydiaversuch3 % node bot.js
Debugger attached.
Lydia the allmighty is online
TypeError: MessageButton is not a constructor
    at /Users/pierrekorell/lydiaversuch3/bot.js:60:21
    at Array.map (<anonymous>)
    at Client.<anonymous> (/Users/pierrekorell/lydiaversuch3/bot.js:59:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 

This is the error code. The entire bot code is too long it got moves into that file. Idk how to ch...

get forum channel list of role permissions

I am trying to get a list of role permissions for a specific channel, because I need to get the ID of the 4th role in the list. How would I do this if I have channel = [channelObject]

Bot wont show a status. No errors in the code or displayed.

My bot just wont display a status. Been troubleshooting for hours trying it on my own. My node version is 18.18.0. Never versions didnt work either.

Storing Giveaway information

When making a giveaway bot - How would you store the entries and the users?

Wrong docs..?

Hey, can someone please explain this as I've spent 2+ hours on it lol.

Basically on the docs it says to use
const user = interaction.options.getUser('target'); guild.members.unban(user); When it's completely wrong.

To ban via discordID you should use
const target = interaction.options.getUser('target'); await interaction.guild.bans.remove(target);

Kinda stupid if the only thing that can solve this is AI...