#djs-help-v14
78874 messages · Page 22 of 79
Thats on you then. Make a handler formthem
Just like you did for your commands
but now for components
but yeah u gave me an idea, ill just make a secondary event handler inside my interactioncreate and make files for every component
you can set up your selectMenu handler just like the slash command handler...then make handler files just like slash command files
i already have an event handler, im asking about a better way to resolve that , but thx anyway
An event handler isnt a command or component handler
guide suggestion for @prisma ruin:
Creating Your Bot: Command handling
read more
when did i say command handler man?
You didnt. Thats your issue
no issue in sight because im not talking about a command handler, im talking about an event handler
Use a handler similar to the command handler for your select menus
If you refuse to use one, yes, you're forced to put everything in your interactionCreate file, thats a you issue then
.
Thats not an event handler then
Event handker handles events
You are looking to make a handler to handle select menus
Those are not events
Those are message components
im looking to make an event handler to handle all event in a way that i can clearly separate them, i just gave selectmenus as an example
or dont handle them with interactionCreate at all and only use collectors and handle them in your command files
So this then
yeah i dont think u got it
Just edit it to use select menus
but ok i already figured it out
i use this to copy pictures from a message but it's look like this
user.send({files:msg.attachments.map(x=>x)})
happens to all attachments
hii, could you help me? I want to add the button in that container: https://sourceb.in/QK33AuZVtr
put the button in an action row and then use this method
ContainerBuilder#addActionRowComponents() discord.js@14.19.3
Adds action row components to this container.
thank you so much
Neich question, if the bot has the GuildVoiceStates intent, will it know of all users in a voice channel, or do I need to fetch members prior?
All members in voicechannel will be sent to your bot on login. So unless you limit cache it will know
Cool, and after login? say 5 people join a VC, is it pushed those changes into the cache?
Same Q for disconnections?
that intent gives you all relevant data, you dont need to fetch anything
Sweet, sounds good, thanks both
hello guys, is possible to check if user have a tag? (i mean the tag near to the username - in my case SCLB)
Its not documented by discord, thus not supported in discord.js
You can however fetch the user manually via the API which includes tag data.
what would cause shardCreate to be called almost every minute? (same shard keeps recreating)
it worked before but started freaking out tonight, can‘t see any errors or vps issues
getTextInputValue()
Returns an empty string for non-existing fields right?
No, it throws an error
ah damn
actually not too bad i can just simply not call the function if I don't need it
If a field exists but is empty, that one will be an empty string tho, If I remember correctly
logically
What no it doesn't?!
I'm basing my answer off the docs and the linked code, and it definitely should
Only you calling ShardingManager#spawn with the same shardId (either an array having the same id several times or several calls of spawn)
Yes, it does
That wasn't the question though
I could have sworn it didn't
we are talking about non existant fields
not empty fields
Oh my bad
although I could have sworn there was the ability to provide a boolean to that function so it doesnt error in earlier versions
This should work I guess
//...
async createCommonPost(interaction, category, fields, baseData) {
const { client } = interaction;
const isForHire = category === Categories.ForHire;
const workExamples = isForHire ? fields.getTextInputValue('workExamplesInput') : null; // <-- Avoid erroring if modal doesen't contain work example (non-for-hire)
const imageRegex = //...;
const postData = {
...baseData,
title: fields.getTextInputValue('titleInput'),
description: fields.getTextInputValue('descriptionInput'),
payment: fields.getTextInputValue('paymentInput'),
other: fields.getTextInputValue('otherInput') || null, // <-- Empty optional fields are empty strings afaik
...{ work_examples: workExamples },
};
//...
That condition makes it kinda messy
But probably bad practice to call a function if we literally don't need it anyway
My code hasn‘t changed at all and it‘s from the guide, worked for a year but suddenly it spams. Is that really the reason? I only have shard 0.
And safer actually. That way I can be sure non-for-hire posts will never contain a work example, If someone manages to slip one through
Idk if Discord does that logic on the client or server, if someone could just send fields which the modal doesent initially contain
How do you start your code? node directly or some kind of process manager that restarts on error?
Wait sorry, it's not shardCreate that is being called every minute, it's shardReady
On what exact discord.js version?
14.18.0
Update to 14.20.1
I only have 14.20.0 and 15.0.0-dev versions to pick from
I know its kind of a ritual that we release hotfixes directly after a bigger release, but 14.20.1 doesn't exist yet :P
Oh, mb, 14.20.0 then 
There are no breaking changes from .18.0 to .20.0 I suppose?
breaking changes would change the 14 to a 15 :P
Awesome, thanks I'll try that
is it possible for my discord.js bot to relay a voice message from one channel to another?
Yes, but only by using raw API, since sending voice messages isn't documented by discord
why doesn't this work?
You tell us - do you get an error?
no, i do not get an error but the image is the same
There's a whole lot of context missing then
Better question would be: why do you mix builder and JSON like that?
what do i use to control the discord bot though a rest api without using the full discord.js? i forgot what you call it, where the bot status is not shown
How can I check what guild tag a user has? Can I check what guild it is?
discord.js does not support features until they are officially documented.
While there might be a way for these features to work, it can change at any time without any notice
One of my friend want to start a new project with bun and I was wondering if discordjs run well under it?
tag suggestion for @royal atlas:
HTTP-only applications receive interactions through HTTP webhooks instead of the Discord Gateway. Bots that are not connected to the Gateway, but use HTTP interactions appear as online without a status. Discord.js does not support HTTP interactions. Use discord-interactions instead.
hey is it possible to get the tag server of a user with djs or not again ?
Its not a documented feature by discord, thus not available in djs.
You can fetch the user from the api directly tho, there its included.
avaible by the api so ? but not again in djs ? thanks !
Its available in the API but not documented by discord, yes.
uhhh does anyone know what error gets thrown if the server emoji limit is reached and the bot tries to create a new emoji?
is there any way to decrease the size of the img?
hello how can i able to make this command option to be multiple roles?
ex:
/security whitelist:@role1 @role2
Use a role select menu
Error code 30008 "Maximum number of emojis reached" or 30018 "Maximum number of animated emojis reached" most likely
additional it could be 30056 " Maximum number of premium emojis reached (25)"
Opcodes and Status Codes - JSON
Along with the HTTP error code, our API can also return more detailed error codes through a code key in the JSON error response. The response will also contain a message key containing a more friendly error string. Some of these errors may include additional details in the form of Error Messages...
read more
re, i found the property but how can i know when someone change his tag ? userUpdate event is not emitted
like I said, its not supported in djs, thus the event wont work
thank you
DJS does not emit events for undocumented changes. It automatically strips that information from the data sent to you as it's unreliable and unpredictable information.
Either set up your own websocket event emitter for the data or wait until it's documented (documented means it is unlikely to change, thus reliable enough to be added to the library)
im trying this sir, userUpdate doesn't list the tag, im trying with guildMemberUpdate
edit : good with guildMemberUpdate
i’m not sure why you’re not quite understanding that the user guild tag isn’t documented nor available in d.js
you need to request it on your own through a rest request
we can’t keep repeating the same thing
Also I don't think servers tags would be part of guildMemberUpdate, even after it's documented, as you can't set your tag on a per-server basis
it wouldn’t yeah since again, it’s not documented nor available in d.js
i think there is a misunderstanding, i just did it with the ws
that’s what we were trying to say from the beginning
all is good sir
keep going
w move, thanks for the help
It is, because user is part of the guild member, so changes of it also emit guildMemberUpdate gateway event
discord logic
maybe because it's tag from server
Oh sick, I wasn't sure if User only data emitted the guildMemberUpdate...that's helpful for the future
Well, the raw discord event does. DJS kinda cheats you on that one by faking a userUpdate instead (which the gateway only sends for changes of the bot user)
Oh ok. That's what I was talking about in particular. The DJS event, not the raw one
anyone knows how I can do a raw api call to get back the user data so I can check if they have a guild tag or not?
last part I don't really care, just on how to do a raw api call, I can figure the rest out >.<
client.rest.get(...)
Thank you! I appreciate it 🫡
Hello, does reaction.emoji get converted to an actual emoji when concatenated inside a string
the api sends it as an object
djs doesn't do that conversion
but if you have an emoji string and you want the api object you can use resolvePartialEmoji()
it's used by builders
Ah Ic, thank you
Yes, that is correct. You can't edit the ephemeral status of a reply
You'd have to deferReply ephemerally already
Or deleteReply and then followUp ephemerally
ok thanks
user can be a userId?
FetchBanOptions#user discord.js@14.19.3
The ban to fetch
UserResolvable discord.js@14.19.3
Data that resolves to give a User object. This can be:* A User object* A Snowflake* A Message object (resolves to the message author)* A GuildMember object* A ThreadMember object
So: yes
UserResolvable can always be a userId ?
i'm not sure what you mean, if you looked at the sentence 2 above yours
Hello, I took the liberty of contacting you to find out if with djs we could manage who took the guild tag?
Server tags are still undocumented thus not supported by DJS.
👆
Okay, no worries.
Thanks for your feedback
Hi,
I suddenly can't figure out how to reply to a modal after a deferral without it saying "something went wrong", I tried reply, editReply, update, followUp... What's wrong ? Thanks
you cant
you cannot defer and show a modal
No, after the user submits the modal
then you defer and editReply as usual
if you get the 'something went wrong' message, you arent even reaching that defer
Oh I just forgot () inside Promise.allSettled 🤦
Thanks
why am I seeing too many errors using djs functions?
you tell us
we dont know what your code does
hey everyone, is there api support for bots to toggle or apply the new gradient/holographic styles?
not documented yet
thank u <3
what's inside $djsEval[] is what I'm trying to make it work
but is ctx an actual message object
what ios ctx
we cant just guess
Let me guess: you don't actually code in js but a weird wrapper language built on top of it
it just say everything isn't defined 
Without code you won't be able to get help here
well you haven’t shared any of your code to us either 
showing vague screenshots is not gonna help
not everything is "defined" 😔
if you want help, show your code
and it also looks like you did not actually code this at all
because thats just basic js
The code is inside $djsEval[]
okay
and what code is djseval
it wont magically do something
I think that is aoi.js
no
No. That's not JS code. That's you using some weird non-djs stuff
will that actually work if I used DJs
Alr ty
bye
if you write good code for it, sure
If you actually wrote djs code it might
Forgescript
alr ty
bai
Then try asking in its support server
It does not seem to be djs related
hi guys, there is anyway to put an image in a container like as author of embed?
no
thx
yo
can someone help me please with my discord
i can stream but there is no sound
tag suggestion for @snow pike:
We are not Discord, just some nerds who develop Discord bots!
- /report appeals and age updates
- /howtoreport reports (harassment/hacking/spam/abuse)
- /support anything Discord related
- /billing payment/nitro
- /feedback feedback/feature requests
you are in the wrong server for discord issues
Can we disable buttons when the collector ends inside a container?
sure, editReply with the button being disabled
I am hoping this is a Quick oversight on my part but for some reason I have not been able to get the "Ban Reason" to show up in our logs. All of the other details are correct it just appear that the reason keeps coming back with undefined
The guildBanAdd event looks like the following
//...
async run(guildBan) {
try{
// ---------------------- Send Log Message ------------------------------
const embed = new EmbedBuilder()
.setColor(this.ee.color.leave)
.setTitle('New Ban Added')
.addFields(
{ name: 'User', value: `${guildBan.user} (${guildBan.user.id})`, inline: true },
{ name: 'Ban Reason', value: `${guildBan.reason}`, inline: true },
)
.setTimestamp();
await this.sendBotLogMessageEmbed(this.name, null, guildBan.guild, embed);
}
catch(err) {
this.client.errorHandler(err);
}
}
//...
Any help is much appreciated.
What's the value of guildBan? Did you log it? Do you pass client as an arg in your event handler?
Ill have to re-fire an event to get the values console logged, one moment but yes the client is passed in as an arg so the event handler has access to it.
make sure it's not the first argument
otherwise guildBan will be a Client
Is there a way to do a small text like this:
-# Hey
in discord.js ?
(You do this using -# at start of sentence)
you answered yourself
if you want a method:
subtext discord.js@14.19.3
Formats the content into a subtext.
but it simply appends -# at the start
the ...args broken out and assigned in my Event Class so the client is not the first argument, The guildBan appears to output 2 values guild and user for some reason the other properties don't seem to exist in the console output.
Fwiw you can access client as a property of any d.js structure, so passing it as an arg is unnecessary
npm ls discord.js please
`-- discord.js@14.19.3
So one version behind current
That doesn't agree with the docs
(event) Client#guildBanAdd discord.js@14.19.3
Emitted whenever a member is banned from a guild.
What are the values you get in the event
^
Regardless, it’s not sent
If i have this in the event
console.log(guildBan)
Then i get the following
GuildBan {
guild: <ref *1> Guild {
id: '634896097612922890',
name: 'PrivateTestBotServer',
icon: '790a1195596694209d3273e46369d3da',
features: [
'GUESTS_ENABLED',
'WELCOME_SCREEN_ENABLED',
'MEMBER_VERIFICATION_GATE_ENABLED',
'COMMUNITY',
'NEWS',
'PREVIEW_ENABLED',
'THREADS_ENABLED'
],
commands: GuildApplicationCommandManager {
permissions: [ApplicationCommandPermissionsManager],
guild: [Circular *1]
},
members: GuildMemberManager { guild: [Circular *1] },
channels: GuildChannelManager { guild: [Circular *1] },
bans: GuildBanManager { guild: [Circular *1] },
roles: RoleManager { guild: [Circular *1] },
presences: PresenceManager {},
voiceStates: VoiceStateManager { guild: [Circular *1] },
stageInstances: StageInstanceManager { guild: [Circular *1] },
invites: GuildInviteManager { guild: [Circular *1] },
scheduledEvents: GuildScheduledEventManager { guild: [Circular *1] },
autoModerationRules: AutoModerationRuleManager { guild: [Circular *1] },
soundboardSounds: GuildSoundboardSoundManager { guild: [Circular *1] },
available: true,
shardId: 0,
splash: null,
{REDACTEDED EXTRA}......
},
user: User {
id: '308378500140892162',
bot: false,
{Redacted Extra}......
}
}
It's still wrong
Based on this, i figured i would be able to access the reason property https://discord.js.org/docs/packages/discord.js/14.19.3/GuildBan:Class
It's nullable, so it's not always present
But then it should be null if not sent
hi so for some reason my user install broke did i do something wrong?
yeah doesn't look like it's set as null if not present
broke how?
should be fixed ig
Ah bless, it's the library
You do .type but you need to deploy the contexts and integration_types
So if i understand, there are a couple of things wrong. 1) The documentation isn't 100% in line with the actions of the library, and 2) I still need to figure out why if i do provide a reason its not being passed back to the event.
you were told about it
^^
call #fetch(), if you have the appropiate permission
and technically it is 100% in line, it says it's nullable or missing
Ok ill accept that answer, I don't understand fully so will have to read some more about it.
it's missing an explanation as to which case is which though, since missing fields aren't that common in the lib
ahhhh i see
const votingMessage = await interaction.reply({ content: `Org ?vote <@${forg.id}> \n <#${channel.id}> \n-#Vote put up by <@${deputy.id}>`, fetchReply: true });
Space after the -#
1m
Thank you.
Np
LoadEmojis(): void {
const emojiDirectory = `${process.cwd()}/assets/emojis/*`
glob(path.join(emojiDirectory), (err, files) => {
files.forEach(file => {
const emojiName = path.parse(file).name;
if (!this.application?.emojis.cache.find(emoji => emoji.name === emojiName)) {
this.application?.emojis.create({ attachment: file, name: emojiName })
}
});
console.log(`Loaded ${files.length} emojis`);
});
}```
any1 knows why my bot isnt creating the emojis?
btw as a sidenote, all rendering is done by the discord app, so if a given format (bold, strikethrough, etc) doesn't work, it's on discord's side, or your usage is wrong (like in this case)
tag suggestion for @prisma ruin:
If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops.
- Once you do, log relevant values and if-conditions
- More sophisticated debugging methods are breakpoints and runtime inspections: learn more
they execute
up to what point though? that's what the tag tries to suggest
you put logs or breakpoints to see where it doesn't execute anymore
the only issue I'm seeing is that .create() isn't being awaited, all promises will be sent in "parallel", but that shouldn't be an issue, not that you can await a forEach either way
could be that its not being awaited, everything is ran ive done checkpoints through everything
its not that, just tested
also it'll still run them in "parallel" since forEach doesn't await the callback
you'd have to use a for of
for...of
The for...of statement executes a loop that operates on a sequence of values sourced from an iterable object. Iterable objects include instances of built-ins such as Array, String, TypedArray, Map, Set, NodeList (and other DOM collections), as well as the arguments object, generators produced by generator functions, and user-defined iterables.
same stuff, changed to a for
share your code
async LoadEmojis(): Promise<void> {
const emojiDirectory = `${process.cwd()}/assets/emojis/*`
glob(path.join(emojiDirectory), async (err, files) => {
for(const file of files) {
const emojiName = path.parse(file).name;
if (!this.application?.emojis.cache.find(emoji => emoji.name === emojiName)) {
await this.application?.emojis.create({ attachment: file, name: emojiName })
}
}
console.log(`Loaded ${files.length} emojis`);
});
}```
and which checkpoints did you test?
just ran inside that if(!...) some logs and always ran
even with the await? can you place them back, share what is being logged?
Alr ty for lmk
isn't there a way for glob to return the files?
wym?
am i doing it wrong or something? i just pass in the file like that
i think i need to make it a buffer, just searched it
why glob
im just used to it , should i switch to something else?
hey so i'm trying to get autocorrect for discord.js to work and it is not sort of working
autocorrect is a type of interaction, you need to route your interaction events to the autocomplete field of your command file
can you share your command file and your interactionCreate listener?
disregard, i misread that...i read autocorrect as autocomplete aka as part of a command....
you're talking about intellisense... correct?
idk what that is
can you specify what you mean by "autocorrect"
a photo, an example, something
youre talking about this?
something like that
specifically... (why not exactly that)?
that is called IntelliSense...JavaScript doesn't support it natively, you have to either use TypeScript or use JSDocs which simulates it (without error messages...just autocomplete)
i want something that can autocomplete code
do you want it to write code (like entire lines), or do you want it to suggest methods and fields
so CoPilot?
suggest not write
Intellisense is probably what youre after, and works best with Typescript
suggest entire lines then?
You otherwise have to write JSdoc for all your custom functions so that VSC knows what classes are being passed in
like this
no reason I guess, I just use node's native fs stuff
ok, ya that's IntelliSense...which again doesn't really work in JavaScript
sounds good, do you know a way to convert file into buffer using fs?
you can do this (which is JSDocs) which adds autocomplete by setting the type of params or variables
that's not what they're suggesting
idk which one to take:
they're suggesting that you get the emojis' paths with fs
As in load a file from a filepath into a buffer?
I mean you can do both lol
yeah but I think they're going in the wrong direction as to what their issue is
readdir to get file paths, supports recursivity, readFile to get files into Buffers (if needed)
XY?
idk which one to take?
given djs accepts filepaths, explicitly getting the buffer should not be needed
Samtino answered you, I don't think you need a specific extension
also #1081585952654360687 would probably be a better place
What do you mean which one? None of these. Its not an extension
yes
fs.readFile
If you dont specify a text encoding, it reads into a Buffer
did that, still not creating my emojis
Can we go back to your code
Are you just rate limited or something
yes
yeah i get that slowmode and i tab and only remember it like 2 mins later lmao
he meant whether your bot is rate limited
can check with client.rest.on('rateLimited', console.log)
and see if anything logs
not rate limited
where did you place it specifically?
and also does, "Loaded X emojis" log?
Or Loading for that matter
yes, both log
and "Loading emoji:"?
ah
can you console.log(this.application) just in case
Yeah thats what I was looking for
Not a good spot for optional chaining
yeah you need to use that after your client is logged in, not before
it's not erroring because of the optional chaining, like monbrey said
did a .then after logging in, now im finally getting an error
just duplicate emoji name, will do a check for that, thx for the help m8s
btw, is there a way to download all the emojis that my bot has to its cache? @rose tangle
do you want to download the buffers, or just fill the cache with the data (name, id, etc)?
fill it with data
ApplicationEmojiManager#fetch() discord.js@14.19.3
Obtains one or more emojis from Discord, or the emoji cache if they're already available.
// Fetch all emojis from the application
application.emojis.fetch()
.then(emojis => console.log(`There are ${emojis.size} emojis.`))
.catch(console.error);
appreciate it
just curious, when you do member.displayName, if they have no displayname, does it resort to the username or null?
"The nickname of this member, or their user display name if they don't have one"
GuildMember#displayName discord.js@14.19.3
The nickname of this member, or their user display name if they don't have one
thanks
Message#author discord.js@14.19.3
The author of the message
@finite leaf please use #app-commands for private use (or use the hide option)
shi didnt see the channel mb gng
im having with unregistering the commands. when i start the bot all the comamnd has been registered and when the blacklist is applied the commands is still registered.
First of all, you should not register your commands every time your bot starts. Second, youd deploy global commands, not guild commands, so setting that to an empty array wont do anything, since there are none to begin witg
If you have blacklisted guilds, make the bot leave them
Or just check the id when receiving the interaction
For slashcommand registration, i will just use a command to register all of these for example (,registercmd)?
Our guide just suggests having the code in a separate script
No reason to tie it to your main process at all
Hi, is it possible to know which "server tag" is activated by a member with discordjs ?
Its not a documented feature by discord, thus not available in djs.
You can fetch the user from the api directly tho, there its included.
ok thx, will it be available soon ?
Thats something you have to ask discord xD
Ok thx, I'll try to get it directly from the API until you get it here. Thanks for your awesome work !!!
I need to fetch systemChannelId when added a guild
Guild#systemChannelId discord.js@14.19.3
The system channel's id
Are server tags still undocumented?
yes
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
- Caches in discord.js are Collections which extend the native Map structure.
- learn more
I need to do like mobile icon on status. it's possible?
djs does not support setting mobile icon, bots are not supposed to do it.
I know gradient roles aren't supported in discord.js because they're not documented but I don't want to wait a long time to support them.
Does anyone know what routes to use and how to set gradient roles with the API?
I don't know for sure, but it is most likely just the role route and is an undocumented property
Probably yeah
How would you recommend I find that property?
oh hey someone already did it!
awesome tysm
Hello, i'm trying to do an autorole tag for my private server, anyone know why the guildmember event or userupdate is not triggered when tag is updated?
client.once(Events.ClientReady, async () => {
console.log(`Logged in as ${client.user.tag}`);
await client.guilds.cache.get(Config.GuildID).members.fetch();
});
client.on(Events.UserUpdate, async (oldUser, newUser) => {
console.log(`[UU] User Updated : ${newUser.tag}`);
});
client.on(Events.GuildMemberUpdate, async (oldUser, newUser) => {
console.log(`[GMU] User Update : ${newUser.user.tag}`);
});
client.on(Events.Raw, async (raw) => {
if (raw.t === "GUILD_MEMBER_UPDATE") console.log(raw);
});
Only the raw event seem to be working, but it can have some latency if it's a large server no? and also do i need to fetch all guild members before ?
Because tags aren't documented by discord, so the library doesn't support them until they are
yeah i know that, but for now i need to use the raw event?
Or a raw GET request, yes
Does anyone know why the /guilds/GUILD_ID/members request returns an array with only one user?
Nvm, I supposed to set a limit parameter
what version of djs added customization of how much stuff is cached?
iirc it was available in older major versions, but it's been available in all of the 14.x versions
do you mean v12 or v13 when you say older
no idea tbh but it's irrelevant as neither is supported
if you want to look through the repo, it should still be there, just look in the ClientOptions
how i can use addField on componentsv2
You don't
Containers are not embeds
how can i make a full width button wit the new containers with the action row
V20 Its woww
"full width button" isn't a thing
containers also dont' really have much to do here
ive seen people with a button that spans the full with of the container, and i dont think its whitespace
the components v2 you can put into a message can be put into a container, that's pretty much it
do you have any screenshots?
lemme see if i can find the image again
i cant find it, i closed the tab oh well
ty anyways
you can just look through your browser history then
i cant be bothered ive had so many tabs open lmao, ill use whitespace if you cant do it natively
hello, is there any way to fetch all the threads of a forum channel to check the title?
@loud quartz did it!
it's still undocumented so only with raw requests
not really, from what i can see. you can fetch archived ones, but that's paginated, especially as there is no limit on how many archived threads there can be in a channel
fetching the user directly via rest, as discord.js doesn't know about those properties
discord.js does not support features until they are officially documented.
While there might be a way for these features to work, it can change at any time without any notice
aww, is there any other way to find threads from name and delete older ones?
it sounds like you need some kind of db for storing the id
instead of fetch all and search by title
no, there isn't
how did you do this lol
yeah there's nothing in the api for that, that was definitely done manually and probably breaks in mobile
they say how just above
oh just whitespace, nvm lmao
that's what they already did, not what they saw
ah, thought they meant they found the example, my bad
yh same
yeah looks shit on mobile, even the left side and not the green button does, im just gonna make a button that reformats it for mobile without ANY styles
ooooor, don't do that at all
no
if you already know that some users will have it look like crap
mobile embeds look like shit anyways no matter what you do
and any attempts at styling stuff makes it worse
discord pls fix
nothing to fix
Embed backgrounds and buttons ect don't even look the same
because there's less screen space
and it's you who broke the captcha button here
not discord
anyway, this is getting offtopic
thats why i would have a fix for mobile button
which is a bad ux
because everyone sees it
and mobile users have to press it first to even get something usable, every time
but you do you
if you want control over display, make that dashboard into a website and send people the link
i already have that, but the whole focus on the bot is that no user has to leave discord
so thought it would be cool that even the setup was all done on an in app dashboard
back to the drawing board i guess
not if you're fighting the platform over it

typical discord
whats the function again isguildfetched or something likethat
wha
what are you trying to do?
just checking if its fetched from guild
"it" being?
whether an interaction comes from a cached guild?
yes
so there's nothing fetched
BaseInteraction#inCachedGuild() discord.js@14.19.3
Indicates whether this interaction is received from a cached guild.
yeah it's the way around, since it's cached, it's not being fetched
o yeah cached notfetched
Did they fuck something with the markdown again? Links showing as text.
Does that end with the correct ) and is a valid URL?
Yeah, I only snipped a bit since the url is loooooooooooooooooooooong
It was fine before for months. Now since 2 days it broke.
where is that?
My bot. inside a Discord embed it sends. I checked discord api gh since last time it was them doing an oopsie but I don't see anything now.
I mean, where exactly
in what part of the embed
any1 can help me? how to make that line not exist does the thumbnail in componentV2 count the line?
you mean you want something like this?
I want to delete the line from the name server to the server information. How do I close it even though I've used small separate?
yes like thats
Oh, haha. Inside fields in the embed.
It's fine on mobile but broken on desktops. Mac/PC
Put it in the section, not after
yeah that sounds like a discord bug then
We are not Discord, just some nerds who develop Discord bots!
- /report appeals and age updates
- /howtoreport reports (harassment/hacking/spam/abuse)
- /support anything Discord related
- /billing payment/nitro
- /feedback feedback/feature requests
oh ok il ltry
Odd. I can't find any other bots that have the same though. But it wouldn't be the first. This was the one 2 years ago.. https://github.com/discord/discord-api-docs/issues/6088 Silly Discord.
Hii, is it possible to “monitor” whether someone puts or removes the tag from the server? The idea would be to assign a role to the person wearing the server tag.
tags are undocumented by discord, any functionality with it is not supported by djs
you could get around via raw requests/listeners but you're on your own for that
discord.js does not support features until they are officially documented.
While there might be a way for these features to work, it can change at any time without any notice
hey guys !cmd @user why message.mentions.user.first wont work
do you have the MessageContent intent?
if yes, share your code
it only works when reply
Then you're indeed missing MessageContent intent
Why not use slashcommands instead?
oh right
i just prefer in that way (i have both)
and you are doing it with..?
indeed, profile is not accessibel to bots
but it's also not where the tag is
i didn't tell you to fetch user's profile, but the user
eh?
documentation suggestion for @lyric bobcat:
Users Resource - Get User
read more
then how to add bot or server logo next to name server or username?
``1
const botAvatarURL = client.user.displayAvatarURL({ dynamic: true, size: 64 });
const sectionHeader = new SectionBuilder()
.addImageDisplayComponents(img => img.setURL(botAvatarURL).setDescription('Bot Avatar').setWidth(64).setHeight(64))
.addTextDisplayComponents(text =>
text.setContent(**${guild.name}**\n__Server Information__)
);
i use this but not function
a section doesn't have "image display components"
it has a thumbnail accessory, and only one
SectionBuilder#setThumbnailAccessory() discord.js@14.19.3
Sets the accessory of this section to a thumbnail.
you can check the docs to see what methods each class has
so have to use thumbnail? then will it be in the left corner?
yes, like here
if you want to show it in an independent line you need to add it outside the section
given you're in a container:
ContainerBuilder#addMediaGalleryComponents() discord.js@14.19.3
Adds media gallery components to this container.
components v2 is not a 1:1 replacement of embeds. There is no author or footer icon
yo why theres no message content intent in v13 how do i use mention
Version 14 has released! Please update at your earliest convenience.
- Update:
npm rm discord.jsnpm i discord.js - Update guide (use
CTRL+Fto search for the old method or property)
im exploring v13
exploring?
just testing it
Then you're in the wrong place. v13 is unsupported
but what for
everything v13 can do you can do on v14
and then v14 has more things
ohhh is there no other way? is the only one making the thumbnail in the left corner?
i just prefer to code in v13 bro
Thumbnail always is on the right
Then you're on your own and in the wrong channel
what channel
alr
none
we dont' support v13
just help on the mentions i tried putting args it works but i want to know if theres other method
There is no reason at all to use v13. As tipaka said v14 can do all v13 could and more
I've only been trying componentv2 for about 5 hours and I don't understand the structure yet, it's complicated. 
what exactly are you trying to do?
What part confuses you?
even embed thumbnails have always been in the left corner
I don't think you're looking for a thumbnail?
*right
author icon is top left
footer icon is bottom left
right 
thumbnail is top right
image is entire bottom part
containers don't have any of those, for what it's worth.
there's a section component that can have a thumbnail, and you just so happen to be able to put a section into a container
same with image(s)
if you want to replicate author or footer icons, bots split an image into 4 emotes and use that
for an example
does it use emoji in the author?
you can click on it
or hover over it
how long do i have to reply to a deffered command? and is that time reset if the message is edited
I'd like to have some long running commands (like probably around an hour)
not sure if i can do that within the normal reply window or if i should just send a message and edit it or something
hwo to make it is there a tutorial?
uhh, do what
that emoji of mine is so small it's like following the text
all emojis are of the same size
you have 3 seconds to respond to any and all interactions.
if you need more than 3 seconds to produce an actual reply, you can respond with a defer, which will give you 15 minutes to update the response
you just need to split your image in 4 and make an emoji for each part
okay so ill probably need to just send a message and edit it after responding immediately
do you know if discord.js stops like whatever thread spawns to handle that command (or however it works im not too sure) after the 15 min time window too?
need more effort 
There's no threads being spawned, you decide how your code handles the emission of interactionCreate events
How do i know if there a new updates in the ComponentsV2?
what do you mean by "new updates"
can i add one role to multiple users with one api call?
Like new features
the entirety of componentsv2 are new features
but no, nothing has been added since it released
hmm, ok thank you
Hello y'all 👋
Do these codes do the same thing?
interaction.fields.fields.find(i => i.value === key)interaction.fields.getTextInputValue(key)
yes
thanks ^^
I have a bot that users can ask and answer questions anonymously (for a secret santa type thing)
User A asks a question; question goes into a db ->
Pings User B. User B uses a slash command to list their questions.
Questions are listed in an embed menu (next previous buttons to navigate through) ... when they have a question that needs an answer, an "Answer this" button shows.
Click button which starts the new interaction from the button ...
My question is, once that button interaction is made, how do I wait for the user to send the message (which is the answer)? or is that even possible?
why not use modals?
A modal is the way to go
wasnt even aware of that .... yeah thats exactly what I need
Im getting this
components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,) error when trying to add a mediagallerybuilder to my webhook
const webhookOptions: WebhookMessageCreateOptions = {
username: originalMessage.author.displayName || originalMessage.author.username,
avatarURL: originalMessage.author.displayAvatarURL(),
allowedMentions: {
parse: ['users', 'roles'],
repliedUser: false
},
components: [
new MediaGalleryBuilder()
.addItems(
new MediaGalleryItemBuilder()
.setURL(newContent)
)
]
};
needs the IsComponentsV2 flag set
ok, thx
also the parameter withComponents: true
can someone point me in the right direction in the docs for uploading emotes directly to the bots 2000 emote reserve?
ApplicationEmojiManager#create() discord.js@14.19.3
Creates a new custom emoji of the application.
// Create a new emoji from a URL
application.emojis.create({ attachment: 'https://i.imgur.com/w3duR07.png', name: 'rip' })
.then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
.catch(console.error);
thank you!!
Hey, I have a strange issue with the last version, all my interaction.options throw an TS error :
async execute(interaction: Djs.CommandInteraction, client: EClient) {
const options = interaction.options as Djs.CommandInteractionOptionResolver;
}
error TS2339: Property 'options' does not exist on type 'CommandInteraction<CacheType>'.
Did i miss something?
type as ChatInputCommandInteraction
Even for slashCommand ?
that is what a slash command is
oh. Thanks then
CommandInteraction includes context menu commands
Oh, that's why. Thanks ;)
how can i check how many people have my tag on discord using api
I doubt anyone knows since tags aren't documented by Discord thus far
-# Also, let's avoid ghost-pinging people just because they start typing in chat
is there a way to restart the command folder instead of a single command
just restart your bot
ig.. but why doesnt my slash command appear in /? literally no errors
Its not deployed or you need to refresh your Discord app
i restarted my discord many times but deploy?
You need to register your commands with discord. It won't magically appear
Creating Your Bot: Registering slash commands - Global commands
To deploy global commands, you can use the same script from the guild commands section and simply adjust the route in the script to .applicationCommands(clientId)
read more
ty
Hi,
Is followUp not usable after deferReply ?
it is
Why would I be getting InteractionNotReplied ?
Not awaiting?
note that it acts as an editReply if you have not used that before
why does it say client isnt defined in client.ws.ping?? im pretty confused with these kind of errors
I wish there was something that would automatically choose
tag suggestion for @ocean portal:
ReferenceError: "x" is not defined: learn moreTypeError: Cannot read properties of undefined/null (reading "x"): learn more
Is there a diagram of what can be used in which order ?
For interaction responses?
Yes
tysm
It's pretty straight forward really. You use deferReply so you need to follow to that, with editReply. And you cant use editReply/followUp without really acknowledging the interaction first either by reply or deferReply
Yes but then there's also what to use after reply and editReply and update, and also I sometimes noticed having to use the latter but without really knowing why.
It depends on what you want to do, if you want the edit the original message, you use editReply, or if you want create another response, you use followUp. And update is only for component interaction, which falls more or less in the same category on how to respond to it
I always want to edit the original message when there is one.
then update
or editReply if you replied already to that interaction (defer, update, reply)
actually after reading the document its still the same error... this is confusing
client is still isnt defined as always
client isn't defined, not undefined
this is basic javascript
you don't define any variable called "client"
the error is self descriptive
and you can access the client from message.client.ws.ping. no need to define it as a separate variable
alright it worked ty :)
please look at the docs on your spare time
will do
basically every djs object has a client property
Is this it ?
no, modals can also reply
and commands can show modals
and buttons can also reply
every interaction can reply basically lol (obviously excluding autocompletes)
not just commands
I'm not sure what's the issue tbh, it's pretty straightforward
you want to update? update or deferUpdate
you want to reply? reply or deferReply
want to edit your reply (or defer)? editReply
you want to show a modal? showModal, can't defer or reply in any other way
You cannot do this (image), as update() is a form of acknowledgement. Interaction acknowledgements can only happen once and must happen within 3 seconds of the interaction being created and received. You'd want to use editReply() in this case after using update(). reply(), deferReply(), deferUpdate(), update(), and showModal() are all forms of an acknowledgement. followUp() and editReply() can happen anytime up to 15 minutes after the initial acknowledgement and can be used multiple times
modals can also reply
buttons can also reply
Yeah but I always want to only have 1 message per command (create once, edit forever).
commands can show modals
Okay
is there a guide for cv2? i cant find that in docs
then I'd add somewhere that it's only for that case
just in case you don't check it for another unrelated project and think that is how the api behaves
Yeah, no worries, I won't forget how I'm trying to figure out how to accomodate the extravagant requests of this client
thanks and one more question
how do i make sub commands? Slash
it’s in the guide
feel free to use the search bar in there
do i have to make another file for using rest or put it on indexjs
what are you using rest for? your question is a bit vague
global slash command
Creating Your Bot: Registering slash commands
read more
please look at our guide
i did and i understand what should i do but
what file should i place this in
that section says exactly how to do this
it’s a file named “deploy-commands.js”
this is its own separate file
which is listed on that page
Create a
deploy-commands.jsfile in your project directory. This file will be used to register and update the slash commands for your bot application.
thank you.. one last question why doesnt the bot say in the console when its ready, errors, slash command register, and stuff?
its completely white on startup
you're supposed to run that file separately
it's not supposed to be ran when your bot starts
i have ready event though
where in the guide does it say to do that? we don't suggest this method at all as you can get rate limited by registering every single time your bot starts
rest?
no. did you read the guide fully? i think you're just guessing here
Once you fill in these values, run
node deploy-commands.jsin your project directory to register your commands to the guild specified. (or globally)
project directory? file manager right??
It's me again with the problem
Hi! I'm trying to create a dropdown menu (StringSelectMenu) in a regular message command (not a slash command) using discord.js v14.
I want to send a select menu in response to a classic prefix command like !help. The menu works, it sends correctly, but when I select an option, I keep getting "interaction failed" in Discord. Nothing happens.
I'm using the messageCreate event to handle the command. I also listen to interactionCreate, and I tried handling select menu interactions with interaction.isStringSelectMenu() but still no success.
Here's my structure:
- Commands are handled through prefix (!help)
- The dropdown appears in the message
- Selecting the option triggers an interaction error
How can I fix this and properly respond to dropdown interactions coming from prefix commands?
Thanks in advance!
do you know what your main project directory is? same place your index.js is located...
please show your code
specifically your interactionCreate event. you probably don't respond to the interaction
please delete that
you just spammed the chat
sorry..
you say send code
yeah, but not where it fills the entire chat window
^
normally if I looked and I even tested a lot of things
okay
it's a small code
please send your code again, from one of the links i sent
it was not small from what i saw, it took up the whole page
that's not your interactionCreate event.
i see a collector
what is your discord.js version?
test@1.0.0 C:\Users\krix\Desktop\test
└── discord.js@14.20.0
i mean, your code looks fine, but have you checked to see if the collector is being emitted?
Yeah I added a console.log inside the collector.on('collect') but it never shows up, so it seems like the collector isn't triggered at all.
place a console.log above the collector and see if that returns anything
okay wait
i dont really see why it wouldn't be firing
I added console.log("Collector created") and it shows, so the collector is created.
But when I click the select menu, I still get “interaction failed” and nothing happens — the collect event doesn’t trigger.
Do you know why this is happening?
me too
@bleak owlits my index.js : https://pastebin.com/SDhXptzm
why are you using every possible partial and intent
I used all intents and partials just to make sure nothing was missing during testing.
Once everything works, I’ll clean it up and only keep the ones I really need.
remove the Message partial
that's probably why its not working
enabling partials doesn't mean it will make your code work
Popular Topics: Partial Structures
read more
I removed all partials, but it didn't change anything. The interaction still fails.
i didn't say to remove all of them
ok remove the message part wait
i would suggest trying to handle this inside the interactionCreate event to see if this still happens while also attempting to use slash commands
im not sure what else to suggest
nothing
okay
this chat help ? @bleak owl @tribal kiln
what? this server is for the discord.js library.
please do not ping people without context
I have an error with my Discord bot code. Is anyone here who can help?
is your bot written with discord.js?
yes
then please look at #how-to-get-help instead of pinging people
to change the role style mode and change the gradient role color, is it supported in the latest version of DiscordJS? If it helps, I will provide the method, because I have not found it in the DJS documentation.
it's not
feel free to make a PR if there is not one open for this already on GitHub
Could you give me a prefix-based role menu example code? I'm struggling with it for some reason, and the issue is really annoying.
no
sorry
ok
why does this error staring at me when i use client.ws.ping?
you need to learn javascript
that is not how .then works
#1385094678151430185 message cc @bleak owl
e. but it is saying about client.ws.ping
and?
what about it?
i cant solve that thing
because it's not valid javascript
you've been told before about the code you have sent previously that it's not valid, which is why you need to take a step back and learn proper javascript fundamentals, which can be done by looking at #resources
and also falls under #rules 3
you can either look at the guide link i sent for checking a bot's ping, or look into learning a bit more js
i cannot help you anymore passed this point
neither can anyone else if you don't look at the resources we send
how to return option value? i cant find that on docs to
return option value?
like, the selected values from a string select menu?
string slash option
or the inputted autocomplete value?
from an autocomplete interaction? or from a chat input interaction
chat input, no autocomplete
Slash Commands: Parsing options
read more
ty
Hi all, I used the sample example code in the docs to start with and then switched to guild slash commands for quicker updates and now I can't get rid of the global commands. Any ideas?
If you have duplicate commands on your server, you registered both global and guild commands.
You can remove the duplicates by resetting either the global or guild commands
- Resetting global commands:
rest.put(Routes.applicationCommands(clientId), { body: [] }) - Resetting guild commands:
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
Thank you
guild commands aren't quicker to update though
you might need to restart your client
but it should be the same thing
the choice between global and guild should be a matter of where you want your commands to be executed, not how fast they refresh
applicationCommands can take up to an hour to update to the server where guild commands are relatively instant to an extent.
no, global commands are instant as well
^^
Hello anyone interested in gambling ?
Maybe once for fun. Can’t do it while in Hawaii tho
Prob bj or bingo. This isn’t rly a d.js question tho
I am selling my gambling wesbite
This channel is for questions about using the discord.js library, not website/company acquisition inquiries
how much embed description length limit ?
2000 iirc
So I have emoji attached to these dropdowns (application emoji) and some of them suddenly broke...anyone have this happen before? Using latest discord.js, and these aren't components v2
They were working earlier 
nevermind, turns out i'm just an idiot 
how do i check whether a specific member has permissions to use a slash command, including all command permission overrides and whatever?
im tryna limit buttons and stuff related to my command to only be able to be pressed by users who have access to the command itself, and id prefer for this to be able to take into account permission overrides for that command in a guild but idk how to do that
Easiest way is to just make them use the command and make the button show up in an ephemeral message tbh
this command opens up a menu that id prefer not be ephemeral, thats annoying
You would have to be in the guild to fetch the command permission and check the user/role permissions
but my bot is in the guild
like i know i can fetch all the permission overrides myself and probably put together some sort of check but that sounds slow and tedious and id hope that theres an easier option
Why does the bot shutdown when there's a single error? how do i make it stop this
I suggest you look into the well defined programming concept of "error handling"
In JavaScript, this is try/catch
I need to edit a specific embed field using message id
fetch the message, use <EmbedBuilder>.from() method to create an embed from your original embed and then use the <EmbedBuilder>.setFields() method to change the fields
EmbedBuilder#spliceFields() builders@1.11.2
Removes, replaces, or inserts fields for this embed.
// Remove the first field:
embed.spliceFields(0, 1);
Or that to edit a specific field
Is embed .setTimestamp function showing time relative to every user for their timezone?
yes
just curious, how it does?
discord doesn't gives timezone of any user?
do you know how timestamps work?
yes
then you should understand how it's possible for a local client to derive the time from that
your phone/pc/other device is aware of your timezone
the client locally calculates the time in your time zone based on the timestamp (amount of milliseconds since epoch)
but how is discord.js able to tell your local device to do that? it isnt discord?
it doesn't?
the viewing client (read: discord app) sees the amount of milliseconds in the embed structure and decides how to display it - based on your local timezone
discord.js doesn't do anything
hmmm, quite interesting
so you don't understand timestamps then. https://en.wikipedia.org/wiki/Unix_time
Hello. I just updated to 14.20.0 and I'm seeing that CommandInteraction no longer has a CommandInteractionOptionsResolver typed .options property. Can anyone help me understand the change?
Oh I see, nevermind.
im struggling to get an even listener for bans working....
const { Events, AuditLogEvent } = require('discord.js');
const sendWebhookLog = require('../utils/sendWebhookLog');
module.exports = {
name: Events.GuildBanAdd,
async execute(ban) {
const { guild, user } = ban;
const client = guild.client;
const config = client.config.guilds.find(g => g.id === guild.id);
if (!config?.modules?.logger) return;
const logFeature = config.features?.logger;
if (!logFeature?.events?.member_ban || !logFeature.channel) return;
try {
const audit = await guild.fetchAuditLogs({ type: AuditLogEvent.MemberBanAdd, limit: 5 });
const entry = audit.entries.find(e =>
e.target?.id === user.id &&
Date.now() - e.createdTimestamp < 5000
);
const mod = entry?.executor;
const reason = entry?.reason || 'No reason provided';
const logLine = `🚫 **${user.tag}** (\`${user.id}\`) was banned by <@${mod?.id}> (**${mod?.tag}**)\nReason: ${reason}`;
await sendWebhookLog(client, guild, logFeature.channel, logLine);
} catch (err) {
console.warn('[Logger] Failed to fetch ban audit log:', err.message);
}
}
};```
The ban event isnt even caught or logged at all, any advice? (I can sharer the event handler that triggers this, but literally every other discord intent works in this format except bans, unbans, and kicks 😭
is there a way to listen to guild tag changes? I want to check automatically if one of my guild members changed their tag so I can remove them a role, and vice versa
No
do you know if this is a planned feature or something?
does anyone know why the GuildBanAdd is not emitting and getting caught here?
does your event handler work?
yes, i have a ton of other event listeners registered through it (examples: detect nickname change, member update (roles), VC state update, etc). They all work except this one
maybe an intent
init:
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildBans,//Listed here tho i know its deprecated and now GuildModeration
GatewayIntentBits.MessageContent
],
partials: [
Partials.Message,
Partials.Channel,
Partials.GuildMember,
Partials.Reaction
]
});```
handler:
```JS
const fs = require('fs');
const path = require('path');
const logger = require('../utils/logger');
async function loadEvents(client) {
const eventsPath = path.join(__dirname, '..', 'events');
if (!fs.existsSync(eventsPath)) {
logger.warn(`No events folder found at: ${eventsPath}`);
return;
}
const files = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
if (files.length === 0) {
logger.warn('No event files found in the events folder.');
return;
}
for (const file of files) {
const filePath = path.join(eventsPath, file);
try {
const event = require(filePath);
if (!event?.name || typeof event.execute !== 'function') {
logger.warn(`Skipped invalid event file "${file}" (missing name or execute)`);
continue;
}
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
logger.info(`Loaded event: ${event.name}`);
} catch (error) {
logger.error(`Failed to load event file "${file}":`, error);
}
}
}
module.exports = { loadEvents };
Is it maybe the way in which the event handler is registering the event? I cant imagine this intent is emitted differently than all the other ones that work already
When it's documented I assume it will emit the guildMemberUpdate event
But I don't know for sure
👍 so it's a discord thing to add
on your event file you only accept one argument but in the handler you also give the client to the execute maybe that's why but i am not sure
i saw that, added that too and it still didnt work... but for some reason putting it in its own listener file with the same name as the emit works???
not sure why or how that solved the issue, but putting GuildModeration events in their own file with the same js name as the emitter solves the problem
Sorry for interrupting, but I only got a small question
What's the correct type for "any top-level message component" ? I tried out so many types and it won't work...
looks like you're trying to construct a class, id start by making it a class with a constructor instead of a returned object, see if you get the same result
.addTextDisplayComponents(
new TextDisplayBuilder({
content: `-# **:logs: Displaying page ${page + 1} of ${totalPages} | Requested by ${interaction.user.username}**`
})
);```
also, your message will error because youre not calling components properly, you reply with
const message = await interaction.reply({
flags: MessageFlags.IsComponentsV2,
components: [container],
allowedMentions: {users: []}, // Prevents the ping
//fetchReply: true```
that's not what I asked...
and it's not what the issue is
mayhaps i misread the question, 1 sec
But I don't want to just send a container - which is possible
when you say top-level did you mean the ### header?
the problem is that TopLevelComponent consists of components, not builders
no. this.
top-level-components !== headings
And what should I use for that? 😅
Make my own type?
i think you can just toJSON the builders to get the components data
I could. But I don't want to unless there's no other option.
whats the class construction look like
I think TopLevelComponentData should work?
that's the JSON-ified version I think
yep
does it throw an error if you use it though
yes, if I don't toJSON() it.
tbh types have not been very unplesant to work with when it comes to djs-Builders since they released 😅
I've now made my own type but djs isn't allowing me to use that in the .reply() method (directly passing the builders)
I have to toJSON() the array of builders to make that work.
using JSONEncodable<APIMessageTopLevelComponent> should work as the type
oooooh yeah that works
if not I'm going home and continue hating ts
😂 yeah
when guide-update tho >.>
Does anyone know whether or not it is better to disable inline comments for eslint, (looking for opinions)
the reaosn i asked about doing a class constructor is for the purposes of overriding the class super instead of changing constants
If you set contexts you can control where the command will be available
SlashCommandBuilder#setContexts() discord.js@14.19.3
Sets the contexts of this command.
i personally prefer to register commands locally / per instance
when is this discord.js update for role style?
whenever discord documents it

its an undocumented features not rolled out everywhere
if it is published in the documentation, it would be great to change it from the role style
if (interaction.customId === "call_user") {
await interaction.message.delete();
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
note : message is ephemeral
How can I fix it
that error is not from that code
CommandInteraction#deleteReply() discord.js@14.19.3
Deletes a reply to this interaction.
// Delete the initial reply to this interaction
interaction.deleteReply()
.then(console.log)
.catch(console.error);
but for deleting ephemeral messages, use that method
After a deferUpdate() in case you want to delete the message the button is on
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
Seems like you didn't do what I said or didn't await it
i try to edit it
But also find the place in your code that error comes from (look at the stacktrace)
Considering you had that error before and it was unrelated to the code you sent
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
this error
That's not the full error. Where's the stacktrace? If you log errors make sure to log the full error, not just the error message or stringifying the error
now i try deferReply
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
at StringSelectMenuInteraction.editReply (C:\Users\pc alkazaz\OneDrive\Desktop\ALL\developer\system\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:247:48)
at Client.<anonymous> (C:\Users\pc alkazaz\OneDrive\Desktop\ALL\developer\system\bots\test1.js:376:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:402:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
code: 'InteractionNotReplied'
}
And what is test1.js line 376? Or rather what is before that line
You call editReply on a SelectMenuInteraction without any reply before
this deferReply
But those are two completely disjoint if conditions. That first editReply will never be called on the same interaction that the deferReply there is called on
i start with this code
owners told me to use deferReply
What owners? And that code is still not the one causing that error
now i want to edit or delete the message
deferReplynot workinteraction.message.editnot work
edit and delete are different operations, which one do you want?
for editing it depends on whether you replied to it already
for delete it's deleteReply, but you need to have replied already
defers are completely unrelated to editing and deleting
tags are undocumented, hence not supported by djs
discord.js does not support features until they are officially documented.
While there might be a way for these features to work, it can change at any time without any notice
i want edit
^^
update if you haven't, editReply if you have
await interaction.followUp({
content: `\`\`\`${meta.status} ${meta.msg}\n${errors.title}: ${errors.detail}\`\`\``,
components: [row],
ephemeral: true
});```
This returns a normal message, rather than emphemeral, am I smissing something?
is it an actual follow up or the first "reply" after deferring
it's the first reply after deferring
Then yes, this is intended behaviour.
using followUp() after deferring results in the deferred reply being edited.
In that case the ephemeral state of the deferReply() will be used.
I see, is there a way to change it depending on if conditions are met, I will I have to handle that in different replies?
You need to check it before deferring then.
alright, thank you 
fetch them via the API and not djs
hello i need some help my bot are being rate limited for a sudden. how can i fix this? like cooldown or something.
https://i.imgur.com/MRHupZn.png
you can just use client.rest
Client#rest discord.js@14.19.3
The REST manager of the client
that isn't a ratelimit, either your machine where the bot is has high ping or you aren't deferring before doing an expensive operation
REST#get() discord.js@14.19.3
Runs a get request from the api
pass the route and it'll manage the authentication for you
im using discloud to host this bot. and its kinda wierd that is pinging me that is rate limited.
"❌ @Maxwell APP 1748357354847 shutdown due to Discord API abuse."
Users Resource - Get User
read more
ask them then, but that isn't a discord ratelimit, your bot simply didn't respond, which can be for the reasons I listed
interactions have their own ratelimits
you can't be ratelimited from an interaction you didn't respond
documentation suggestion for @civic bay:
Routes discord.js@14.19.3
@civic bay but if you aren't comfortable using raw requests I'd advise against trying to support undocumented features
i want to edit reply
look here
@rain forum
how can i add cooldown on slashcommand?
i have last update
you'll need some kind of storage for that, there isn't something built-in
I'm sorry, I meant the update() method
ButtonInteraction#update() discord.js@14.19.3
Updates the original message of the component on which the interaction was received on.
// Remove the components from the message
interaction.update({
content: "A component interaction was received",
components: []
})
.then(console.log)
.catch(console.error);
for example
oh
so i should do deferReply and after that update right ?
const targetUser = await args.pick('user').catch(() => message.author);
await targetUser.fetch();
I do this to make sure user's banner is fetched and it works, but should I fetch user in avatar command too or it's not needed
finely update work tysm @rose tangle
no, you can't defer after a reply, I'd advise you check what defers are, it looks like you're guessing
Slash Commands: Command response methods - Deferred responses
read more
you should fetch to make sure it's the latest banner
I think the api doesn't include them in update events
yeah as i said it works in banner command with the current code, but should i fetch in avatar command too
pretty sure the avatar is always sent
alright
Hello, I’m having an issue with select menus in my prefix command help. The menu appears correctly, but when I select an option, it says "interaction failed" every time.
Here's what I’ve already tested:
The interactionCreate event is properly loaded.
The customId of the select menu matches correctly.
The bot has full permissions and intents are all enabled.
I'm using interaction.reply() within 3 seconds.
I’ve confirmed the interaction type with isStringSelectMenu().
Logging inside the interaction event shows that the code does not run at all when I interact with the menu.
However, in another bot using the same menu logic (Snoway), it works perfectly. So I think it might be an issue with how my interactionCreate is handled or registered.
Can you help me figure out why interactions from the select menu are failing?
so i have a command where it checks for permissions then show a modal, but permissions dont take less than 3 seconds to check any solutions?
documentation suggestion for @novel pendant:
ChatInputCommandInteraction#deferReply() discord.js@14.19.3
Defers the reply to this interaction.
// Defer the reply to this interaction
interaction.deferReply()
.then(console.log)
.catch(console.error)
modals dont show up after defer reply..
Oh .. Yes you did say modal
I need to do like who added the bot to guild. Send a message to added user..
How could I make my bot use sub commands (on slash)?
documentation suggestion for @short mulch:
SlashCommandBuilder#addSubcommand() discord.js@14.19.3
Adds a new subcommand to this command.
you can use mine also for reference.
and when getting the subcommand you need interaction.options.getSubcommand()
What kind of permission check are you doing? It should be pretty quick for a any cached member
Hi,
How to check whether the message linked to an interaction has been deleted ?
Thanks
Fastest and safe way to extract audit logs information? sleep 1000?
Developing an anti nuke system and I need to extract information fast to preserve most.
If you have MANAGE_GUILD permissions you can call <Guild>.fetchIntegrations() to get a list of installed apps. The integration's .user is who added it. Other options are fetch audit logs, or default to the owner
If you need speed, I wouldn't use the auditLogEvent rather create listeners for the specific actions you're protecting against like "messageCreate" or "guildMemberAdd" as audit logs aren't realtime
Just try to do whatever with it and handle the error. If it's not ephemeral you can fetch the message to check, but you'd still need to catch the error if it doesn't exist
It would have multiple listeners, is there a possibility to run in ratelimitation for this?
Events don't have a ratelimit as it's data discord is sending TO you, not being requested
It just slows down your bot having many listeners open
I was thinking abou thaving a priprity but it would prompt out all information upon severe bot instances
Possibly resolved with thread on a priority
Thank you for your time!
In interactionCreate if I use: if (!interaction.isButton()) return; and I want to say add an emote or respond to a button, it keeps stating TypeError: interaction.isButton is not a function. I can do slash commands just fine, but if theres a reaction or button press, it freaks out. I am not sure whats going on. I've checked im on djs (latest) already.
Current interactionCreate.js
const {
Events,
EmbedBuilder,
PermissionFlagsBits,
ChannelType,
} = require('discord.js');
module.exports = {
name: 'interactionCreate', // Use string here
async execute(interaction) {
if (!interaction.isButton()) return;
if (interaction.customId === "ban_user") {
handleBanUserButton(interaction);
}
},
};
I suspect interaction there is not an interaction. Log it and see. Depends on how you are passing parameter to execute callback in your handler
The order of function parameters must match between definition and function call.
function execute(client, interaction) { ... };
execute(interaction, client);
- mismatch! you pass an interaction where the client is expected
- mismatch! you pass the client where an interaction is expected
I added client to both my index.js and inside the module itself, and did a console.log(interaction), what do I look for in that exactly?
Show what the it logged
its like 300+ lines though
Heres a pastebin: https://pastebin.com/KPMnmud7
Yup, that's a Client, not an interaction
but why is it passing the client and not the interaction when im passing the interaction?
const {
Events,
EmbedBuilder,
PermissionFlagsBits,
ChannelType,
} = require('discord.js');
module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
console.log(interaction);
if (!interaction.isButton()) return;
if (interaction.customId === "open_ticket") {
handleSupportTicketButton(interaction);
}
},
};
this is all that was re-done to the module, besides passing client in the index.js
You don't need to pass client at all since you can get it from the interaction... But could you show where you call execute in your handler?
Oh, the index.js execute:
client.on('interactionCreate', async interaction => {
if (!interaction.isChatInputCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (error) {
console.error('Command execution error:', error);
await interaction.reply({
content: `There was an error while executing this command! ${error}`
});
}
});
That looks like you have two interactionCreate event handlers... why?
And implemented in two completely different ways
I assume your event loader passes client as first parameter to the event's execute()
do builders mutate
like
const bruh = new TextDisplayComponent();
bruh.setContent("hello")
// do something with `bruh`
``` will this actually set the content of `bruh` or no
hello guys, is this the best way to get a channel and message or there is some better ways? (im getting many times error on getting)
let channel = await client.channels.cache.get('123');
let message = await channel_interaction.messages.fetch('456');
also there is any rate limit?
cache.get is not async, and it does not have a rate limit since it is accessing your local cache, not the discord api
ok nice, and about the fetchingfor the message?
channels are most of the time cached so accessing the cache generally works (i forget if there are any normal circumstances in which a channel wouldnt be cached by default), but with messages you do have to actually fetch them, idk the rate limit
ok thx for help
It does, otherwise it doesn't makes sense of having such methods
well i wasnt sure because .setContent() would return a modified instance of bruh, so it could be possible to just return a copy and not modify the original
Well no. It doesn't return new modified instance but modifies the current one and returns it
ok cool
Will djs support this?
Seems like it only shows install count
hello, is there a way to customize this msg circled in red? the use case is for commands that have an option string, I would like this message to include what the user's input was, instead of just repeating it back in the response.
No, you cannot customise that. you can click the "leave" thing and it will show the input
If you cik on leave it shows the options that the user provided if the command has them
gotcha, thank you!
i have seen now new SlashCommandBuilder().setDMPermission(false), is deprecated, with what i can replace it?
documentation suggestion for @toxic moat:
SlashCommandBuilder#setContexts() discord.js@14.19.3
Sets the contexts of this command.
Yes it will. There is a pr for it you can follow if you wish
#10933 in discordjs/discord.js by almeidx opened <t:1749912430:R> (review required)
feat(ClientApplication): add approximateUserAuthorizationCount
ty
so need to do new SlashCommandBuilder().setContexts(0) ?
Ideally you'd use the InteractionContextType enum and not just 0 to make it more readable, but otherwise, yes
ok ty
Hey yall, quick question:
Will using guild.members.fetch() cache the members returned by the function? Passing {cache: false} throws type error as shown on the picture bellow
cache:false is just available on the overload with user resolvable(s)
if you use it without, it sends a gateway command and will accumulate received GUILD_MEMBERS_CHUNK events the gateway sends
it cannot not cache those
thank you, just looked at the code myself and found that out, thank you for your time
i sometimes think we shouldn't even let you do that as an overload and fully require it to be its own thing with a big warning
it's okay on small server, but it really scales horribly on very large ones
alright sorry, thought this was more a code issue than a database issue but apparantly not haha
Moved it to there now
const {
SlashCommandBuilder,
EmbedBuilder,
TextDisplayBuilder,
MessageFlags,
SeparatorBuilder,
SeparatorSpacingSize,
SectionBuilder,
ThumbnailBuilder,
ButtonBuilder,
ButtonStyle,
MediaGalleryBuilder,
ContainerBuilder,
AttachmentBuilder,
FileBuilder
} = require('discord.js');```
Hi, Can you send me all the functions of this ComponentsV2?
https://discord.js.org/docs has them all
thank you
How can you use .update() from components v2 to content?
Here's my code.
From components v2:
if (interaction.values) {
await interaction.followUp({
components: [container],
flags: MessageFlags.IsComponentsV2
})
} else {
console.log('LOC185:', fromOrder)
await interaction.update({
content: null,
components: [container],
flags: MessageFlags.IsComponentsV2
})
}```
To content:
```js
await interaction.update({
content: `✅ Picked <@${creatorId}>!\n\nYou can pick more or wait for Creators to claim your order.`,
components: [],
flags: MessageFlags.Ephemeral
})```
I'd use this to update a message with components v2 to make it without components v2 and only text (`content`)
I don't know if this is discord.js-related tho
cant
Interesting, it worked the other way around
Yep
the MessageFlags.IsComponentsV2 flag is irreversible, similar to ``MessageFlags.Ephemeral`...once it's assigned, you can't remove it
So the content and embeds fields are remove permanently for that message
why does the components v2 setAccentColor(color?: RGBTuple | number): this; not use ColorResolvable for typescript?
Because that would include more types than it supports?
isn't colorresolvable a class to resolve a bunch of formats to what discord supports?
no
ah that makes more sense then, cheers
You can however just put a text display without being in a container
hey does anyone know how to get a database going?