discord.js - Imagine an app

DIA

discord.js - Imagine an app

Support server for discord.js, a Node.js module to interact with Discord's apps API.

Join

djs-questions

djs-voice

Bare bones d.js setup with bun, can't find types for bun?

Currently setting up a new d.js project with bun. I don't even have d.js code in here yet lol. Vscode keeps complaining that it can't find the types for bun and console, however I have both the bun and typescript extensions installed. I'm pretty certain it's a typescript config issue, but afaik the default bun typescript config should work just fine. Am I missing something here with my vscode config?

How should my project be structured?

I've been working on a discord.js bot of considerable size for a long while now, but I'm starting to notice some issues with how I've structured my typescript codebase. I have multiple modules for managing different 'core parts', such as my discord server, the client, logs, etc. I've noticed however that these modules and everything using them often have eachother as dependencies, creating many circle imports. In addition with top-level awaits, this causes great delays in performance and reaction time. I've just learned about dependency injection to avoid circle imports with my logs module, as this was causing most issues, but now I'm wondering how the project should be structured in general. How should logs (discord chat based), clients, event listeners, etc interact with eachother and be initialized? I need a guideline to work towards since my project is currently quite a bit of an import-await spiderweb....
No description

fetch all guilds?

Hey guys, I'm creating a dashboard for my Discord bot, but ran into some issues. I'm trying to get a list of all id's from all servers my discord bot is in. I'm currently using this: ```javascript const promise = (async (): Promise<{ data: Guild[] }> => {...

Disable button on "end"

Heyo, I hope this is a quick one: I have a leaderboard with a couple buttons for navigation and toggling some properties for that board. In order to change those properties I need to update the LB after each interaction, so it goes through an interaction.on('collect', ... to update meaning the buttons can't be in scope when it reaches the interaction.on('end', ... block. What options do I have to disable the buttons when the interaction "expires" so users don't try to click the button of an expired message? (Perhaps a built in discordJS feature, or can I get and update the button using its ID?)...

Question Guild Tags

Can a Discord bot get a guild tag from a user, so that if the tag is set, the bot will assign a role, if it removes the tag, the role will be removed
No description

Lookup Error

Hey! I upgraded to the newest discordjs and one of my commands are not working anymore. I build in logs & that is the output: ```...

Error to create thread on my bot embed.

Hi everyone, I have a problem with the "startThread" option, which is normally suppose to allow me to create a thread on a message that I specify. The problem is that my IDE (VS Code) return me an error that's say "startThread in not a function" how can I start a thread without this error ?
No description

AuditLogEntryCreate event handling

https://sourceb.in/aDrJQ7PuLm is my code currently for this gateway event but I am sure there has to be a better way to handle the data from this event and format it properly. Instead of switching to handling each tracked event in its own event handler file.

How to get text from TextDisplayBuilder (Components v2)

I need help with getting the text from TextDisplayBuilder which is inside of a ContainerBuilder. For example this is how you get text from embeds description: const originalText = interaction.message.embeds[0].description; and i need to do the same for TextDisplayBuilder which is inside of a ContainerBuilder. Thanks for every answer...

TypeError: Cannot read properties of undefined (reading 'cache')

This error is very rare, it only happened once, today ```ts const member = await ButtonInteraction<"cached">#guild.members.fetch(memberId); member.roles.cache...

Example?

Where can I find example codes? thanks...

Components v2

How many containers can there be in an embed?

Double registering

Discord double registers my commands. Basically I edited my code (the commands file code) and instead of replacing it, it created a new one and kept the old one. index.js: https://sourceb.in/MRyhH8VDc7 commands.js: https://sourceb.in/l9Bh6VBaSZ commands/lawcodes.js: https://sourceb.in/3xuIfoH583 ...

buttons inside embeds

how is it possible to get buttons INSIDE a discord embed??
No description

Multiple images in embed

You can send multiple embeds that share the same url property but have different image.url values but is there any new update to embed builders to make this easier?

Components V2 question

I was wondering if there is a way to create inline fields like in normal embeds using components v2? I have tried looking on discords api.

interaction.reply error handling

Hello. I want handle every interaction.reply error by the interactionReplyErrorHandler function. Is it possible to do this without writing after each execution .catch((err) => interactionReplyErrorHandler(err, interaction))? I tried to create a wrapper class, but can't understand how to do this universal, not HandledChatInputCommand, HandledUserContextCommand etc. and may exist more native methods...

Ask about discord.js and typescript

I have an event handler call message-delete.ts Which type should I use when message is using as function args? Here's my code. ```ts import { Events } from "discord.js"...

I have a problem with member.roles.cache.fetch()

```js import { Client, GatewayIntentBits } from 'discord.js'; const TEST_TOKEN = ''; const TEST_GUILD_ID = '';...
No description

i have problems with the slash command

im new with the bots and been following the guide and everything, been trying to make the slash command, but is not working not even showing the option to use it here's the code screenshoot...
No description