discord.js - Imagine a 👻

DIA

discord.js - Imagine a 👻

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

Join

djs-questions

djs-voice

I don't know how to make a conditional "if" in setTimeout() (related to roles)

Hi!!! So, i was trying to make a mute command, and the good thing is i was able to creating it. However, i use the function setTimeout() to create a cooldown when the role "MUTEADO" (muted) deletes automatically at a specific time. The problem is that if i make a conditional, checking if user has "MUTEADO" role, always says something is not a function, or similar. Ive tried so many things, so tell me any ideas to make the conditional on line 50 work fine. Thank you!

How will djs handle bot tags, since they're not switching to the new username system?

I read on the Discord dev server that they decided not to switch bot users over to the new username system (yet), and they abandoned the idea to give all unverified bots a random username for now. Does this mean .tag can still be used for bot users? Two systems being used at the same time confuses me, because it seems we'll have to continue using deprecated features to show the differences between bot usernames. So can .tag and .discriminator still be used for bot users, or will .globalname function like .tag does for bot users?...

[Registering slash commands]

for now I register slash commands by the official guide from https://discordjs.guide/creating-your-bot/command-deployment.html#command-registration and once I hit the rate limit per day(100 times), the whole rest day I couldn't test my new commands on that bot. I read discord.js website and found that put() refreshes all the commands every time. As now I have at least 10 commands and some times I'll adjust something like the options and .put() many times. So, Is there any way to simply register only one command? I can't find other functions to do registering and I also found client.application.commands.create(), but if not necessary I don't want to do that (though it wont take much time, perhaps)...

Select menu weird bahavior

(reposted from #djs-help-v14 due to no respond for 10 minutes) Hello guys, I am back I have a problem getting my dynamic select menu mapping function to work Here's the error ```[12-06-2023 12:42:22] Uncaught error...

Need help debugging an error

Can anyone help me debug this please? I've looked all around my code but there's nothing about ID. Any lines regarding something.id have been commented out but it still occurs. ``` [06:15:30/ERROR] Cannot read properties of null (reading 'id') Trace: [06:15:30/TRACE] TypeError: Cannot read properties of null (reading 'id') at new Context (C:\Users\andyj\Documents\GitHub\gamecord\client\node_modules\gcommands\dist\lib\structures\contexts\Context.js:8:42)...

Finding a role

Im using command option to get a user, for instance /addrole @name, i created a member value but cant figure out how to get a role Everytime i try to execute the command it gives roles undefined I use " member.roles.add(OCS)" to add the role...

displayName

I want to get the profile name on the current server of the user. currently I use it as following:
channelName.replace('{user}', `${member.displayName}`);
channelName.replace('{user}', `${member.displayName}`);
(<newstate>.member.displayName) The new update takes the username instead of the displayName it used to be....

component collector

can i collect two different components? for example, i am using a button that leads me into a string select menu...

if one user is already using a slash command, other users are unable to create their own instances

I made a quiz bot recently and when more than 1 person is trying to use the commands at a time the bot responds with "this command failed" when they try to enter the loop for the quiz. Is there some reason it doesn't support multiple instances?...

Detecting role removal

```js client.on('guildMemberUpdate', (oldMember, newMember) => { const roleID = '899870393282752542'; const removedRoles = oldMember.roles.cache.filter(role => !newMember.roles.cache.has(role.id));...

Differences between UserManager cache and GuildMemberManager cache

What's the difference between the UserManager cache and the GuildMemberManager cache? I understand the difference between a user and a GuildMember, but if the user cache is disabled does that mean guildMember.user wouldn't exist? or would it simply stop things like client.users? Ping on reply Additionally, cache only applies when you access things in the cache right? for instance, if a interaction request comes in and I have the UserManager cache disabled, I can still do intr.user. or intr.client.user correct?...

Pagination

Hello, I'm currently experiencing an issue with pagination in my Discord.js bot, specifically related to updating the content of pages. Here's a brief overview of the problem: I have implemented a pagination system that allows users to navigate through a list of items using previous and next buttons. Each page displays a limited number of items (let's say 5). The initial setup works fine, with the first page displaying the correct items. The second page displays the same objects as the first one and the third page shows the items 6-10 eventough i have 11 items so there's one item missing, which is showed when clicking on the previous page button to go back to page 2. However, when I delete an item on the last page, and the page becomes empty, the buttons for previous and next still appear, and the content of the page doesn't update accordingly. As a result, the pagination becomes inconsistent and doesn't reflect the actual state of the data....

I cant use my anycommand

Even if I fix my internet connection problem I got this error

Calling a DM function from outside Discord.js

Heya, I was wondering if anyone has insight to how i can call for a DM event via a outside function, My bot is running in-junction with a Fastify server, that runs authentication for a database, and when handing out access to this, I want the bot to DM the user their randomly generated key. I would assume there's a way to go about doing this, obviously, but i don't know how i would go about doing this, do i register a event in the event handler or something similar? Or can I just make a function to do this?...

my bot is not working

so i wanted to make a bot for my comunity but its not working i use replit in my browser to edit the code i have 2files the index.js and config.json thats have { "prefix": "!", "token": "someone told me to not show the token but its here", "botOwnerId": "969939887723782218" }...

button question

is it possible for me to make a button where when its clicked i can send a message back to the bot that will make it do something else?

GuildMemberRemove not working

client.on(Events.GuildMemberRemove, async (member) => {
console.log(`GuildMemberRemove: ${member}`);
});
client.on(Events.GuildMemberRemove, async (member) => {
console.log(`GuildMemberRemove: ${member}`);
});
...

Cannot Edit Interaction

Trying to make a verification system, but the other file doesn't mention it as a message. (the index.js code is through an express endpoint which validates the oauth token, my module & everything else works perfectly fine)

throw err; ^Error: Cannot find module '../commands/fun/avatar.js'Require stack:

Main.js File ```const { Client, Intents, Collection } = require('discord.js'); const Discord = require("discord.js")...