#djs-help-v14
78874 messages · Page 17 of 79
What...? You aren't going to be making 300 separate requests, you make a single one
ah okay. that makes sense. no need to be rude- i didn't know 🙂
GuildMemberManager#fetch() discord.js@14.19.3
Fetches member(s) from a guild.
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
yeah just assumed that function made separate requests for each member
it can be used this way
but if you don't pass anything to it, it fetches all members via a different way
(await client.guilds.fetch(guilds.main)).members.fetch(); this fixed my problem, thank you
there's no need to fetch a guild
oh are they cached on ready?
you have the Guilds intent which means the guild is already in cache
thanks
is https://discord.js.org/docs down ?
im getting DNS_PROBE_FINISHED_NXDOMAIN when trying to access
it works for me
weird
Most likely a DNS issue on your side
btw can we add pages on models or no ?
No
Or only just 5 questions
Just 5 right ?
yes, you can put up to 5 action rows into a modal
each one containing single text input
What if I'm making app system like application and gotta add 10 qs so how can I manage that ?
whatever you're doing, the limit is the limit
Like adding one button per 5 q model , and make the sec button eligible when the user finishes the first ? , is it possible?
you cannot chain modals
but you absolutely can have more than one button on a message, each triggering a different modal
yes, but we can't detect it right if the user has clicked the first button after doing it will unlock sec one so it's not possible right
if you wouldn't be able to tell when the user pressed the first button... how would you ever show a modal from it
you can tell when someone presses the button - you show the modal
you can tell when someoen submits the modal
what you cannot tell is when someone cancels the modal, or clicks out without submitting
Oh I see so it's not possible,
gotta use timeout in dms
mmmm
what is not possible
@loud quartz That one
that question makes 0 sense
well anyways thanks
as i already said
yeah I got it what you are trying to say.
modal is not the same as button
const originalActionRow = interaction.message.components[0];
const originalSelectMenu = originalActionRow.components[0];
Property 'components' does not exist on type 'TopLevelComponent'.
Property 'components' does not exist on type 'FileComponent'.```
erm why is it using components v2 type or whatever
const originalActionRow = interaction.message
.components[0] as unknown as ActionRowBuilder<StringSelectMenuBuilder>;
const originalSelectMenu = originalActionRow.components[0];```ig this works but its still weird it type errors there
it's not weird
this is not a channel for sequelize support (message deleted)
try in #1081585952654360687 (message deleted)
why
because it's correct
worked fine before without needing as unknown as yada yada
because before there were no components v2
you're also casting as wrong type
you're casting as builders instead of received structures
oh yeah ur right
check the type of components[0]
toplevelcomponent[]
is it an action row, or is it <any other component v2>
the property
yaeh its an action row
then use that type check
instead of casting
const originalActionRow = interaction.message
.components[0] as unknown as ActionRow<StringSelectMenuComponent>;```
silly me
drop the unknown
maybe then you'll know if you're casting wrongly
oh that works
anyone experiencing TimeoutNegativeWarning?
full log :
(node:7384) TimeoutNegativeWarning: -17 is a negative number.
Timeout duration was set to 1.
at new Timeout (node:internal/timers:195:17)
at setTimeout (node:timers:163:19)
at prepareNextAudioFrame (D:\project-development\rikai-discordbot\node_modules\@discordjs\voice\dist\index.js:130:28)
at Immediate.<anonymous> (D:\project-development\rikai-discordbot\node_modules\@discordjs\voice\dist\index.js:135:22)
at process.processImmediate (node:internal/timers:508:21)```
happen on voice related activities
tried implementing padding frame and custom timeout but no luck
Might be better off having a look, and if not posting in #998942774994927646
where can I learn more about components v2 and its usage with discordjs specifically? resources/documentation would be helpful
Component Reference
read more
they will have respective builders on d.js's end
thank you, appreciate it
Same as deferReply and reply for command interactions, one gives you up to 15 minutes to respond, and one is a response
Except update edits the message the component interaction came from, not send a new message
can anyone help me? i been following the tutorial but it when came time for me to test the commands they arnt showing? the bot is online and working
No but you can use both deferUpdate and followUp
did you finish the entire tutorial, including the deploy script?
which is entirely independent from running the bot itself
The event handling?
no, the deploy script
which is entirely unrelated to events
Where would that be in the docs
you need to finish the commands part
Can this error be caused by just shards reconnecting too often? Or does this indicate a cluster (or like whole process I suppose) going down completely and needing to hard reconnect? I've been getting this error frequently as of recent on my relatively large bot (70k servers, 73 shards) and I'm not really sure how to resolve it. It's been causing me to need to regenerate the token often:
Error: Not enough sessions remaining to spawn 10 shards; only 4 remaining; resets at 2025-06-01T07:57:44.637Z
guide suggestion for @worldly whale:
Creating Your Bot: Registering slash commands
read more
Ah thanks
Wait no I did do it
then make sure you've read it, not just copied the code
otherwise you should've known what it is
and once you read it you'll know what it does and how to run it
Oop 😭 dang how ya know
You'd want to use editReply to edit the message after deferUpdate, but aside from that yes
I didnt do node fir the deployment
btw you can only acknowledge/reply to the interaction once, that means you can only deferUpdate, deferReply, reply OR update, then you can only editReply (whose behavior depends on which of the methods you use) and followUp which creates a new message
it edits the "target of" the acknowledgment you did
if you did update, then the "target" would be the message itself that was edited
if you reply()ed then it'll be that new message
basically the same respective thing for each defer
@halcyon bison any ideas? You usually have good answers haha :)
why do you want it?
you can't edit the message through its Message object since it's ephemeral, it's not an actual message
you need to use editReply
if you're using followUp, editReply can also take the target message to edit
InteractionEditReplyOptions#message discord.js@14.19.3
The response to edit
Default value: '@original'
Probably not the right place, but I was wondering if it's possible if a bot can fetch what on-going activities are being played in a Voice Channel?
It means that in total you had 1000 shards trying to identify (not just resume) in 24h. Which usually comes from shards being trapped in a reconnect loop because they error on ready or something. Check your error logs
is there something wrong with the api right now? completely unable to register command not even in test guild
what's the api response?
literally nothing but status.discord.com says its up
CNR
what do you mean "literally nothing"?
did you just spam deploy and now it's ratelimited?
could be late limit, I just deployed backup image that I know has worked in the past but now it doesn't - that might be it, thanks tho
I just wish I got my good old trusty erro 429 in return
how are you deploying?
tried passing the option so it rejects the promise on rate limit?
okay what the hell must've been one long rate limit, it does the job now
thanks for your time 👍
Did you look on the docs?
(static) StringSelectMenuBuilder#from() discord.js@14.19.3
Creates a new select menu builder from json data
looks like there is lol
There is, that's why I asked them
yh message was meant for rem
Is there a good way to add function to Interactions?
wdym by that
as in, custom implementations? No, it is not recommended to do so
You can have a helper function
documentation suggestion for @tough dew:
StringSelectMenuBuilder#setOptions() discord.js@14.19.3
Sets the options on this select menu
I think you are referring to this?
well you actually use that and use update({ components: [stringSelectWithSetOptions] }) where stringSelectWithSetOptions is the string select component where you use the setOptions() method to set the options you want
you need to map over the list of selected values <StringSelectMenuInteraction>.values and use that to put them as options
StringSelectMenuOptionBuilder#setDefault() builders@1.11.2
Sets whether this option is selected by default.
and then you can set those options to default
If you want them to be selected for everyone looking at that menu. If you just want them to stay as they were selected for that user simply don't update the menu at all
quicky: Is it possible to do live streaming with the library and if so could someone point me to the correct documentation page?
Just audio?
Oh thats a bummer, ty
is this valid? like i dont need to edit the message, just directly go for the collertor? im not sure what im doing. just asking for suggestion or recommendation by you guys.
Sounds like you should just use the interactionCreate event instead
how can i use this event on buttons?
Like on any other interaction
BaseInteraction#isButton() discord.js@14.19.3
Indicates whether this interaction is a ButtonInteraction.
ohh ok ok thank you @loud quartz
when im clicking the button for the first time its working, now when im clicking it again for some reason its not working.
nvm i fixed it, i just set the once to false.
Is there anyway to valid or know why api response when try to register slashComand . I am using SlashCommandBuilder from discord.js . I found that payload make error is below but don't know which party is wrong
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { '14': [Object] }
},
SlashCommandBuilder {
options: [
SlashCommandStringOption {
autocomplete: undefined,
type: 3,
choices: [Array],
name: 'action',
name_localizations: undefined,
description: 'Choose action (add/remove)',
description_localizations: undefined,
required: true,
max_length: undefined,
min_length: undefined
},
SlashCommandStringOption {
autocomplete: undefined,
type: 3,
choices: [Array],
name: 'type',
name_localizations: undefined,
description: 'Choose permission type (allow/deny)',
description_localizations: undefined,
required: true,
max_length: undefined,
min_length: undefined
},
SlashCommandStringOption {
autocomplete: undefined,
type: 3,
choices: [Array],
name: 'config_type',
name_localizations: undefined,
description: 'Choose configuration type (channels/roles/links)',
description_localizations: undefined,
required: true,
max_length: undefined,
min_length: undefined
},
SlashCommandBooleanOption {
name: 'bypass',
name_localizations: undefined,
description: 'Set bypass option for links (true/false)',
description_localizations: undefined,
required: false,
type: 5
},
SlashCommandStringOption {
autocomplete: undefined,
type: 3,
choices: undefined,
name: 'value',
name_localizations: undefined,
description: 'Channel, role, or link value',
description_localizations: undefined,
required: true,
max_length: undefined,
min_length: undefined
}
],
name: 'setlinkconfig',
name_localizations: undefined,
description: 'Configure server link and invite settings',
description_localizations: undefined,
contexts: undefined,
default_permission: undefined,
default_member_permissions: undefined,
dm_permission: undefined,
integration_types: undefined,
nsfw: undefined
}
Is there anyway to valid or know why api response
yeah. in theerrors
if you use node's util.inspect with a high depth setting, you can see the entire object
Thank you this tips really help
Can we do showModal() after interaction.deferReply() ?
no, you cannot suddenly appear a modal after up to 15 minutes
showing a modal has to be the first response to an interaction
tysm
im being extremely dumb or smthn but cant any commands to register, doesnt show in integrations or anything
module.exports = {
name: 'ping',
description: 'Pong! Returns ping.',
// devOnly: Boolean,
// testOnly: true,
// options: Object[],
// deleted: Boolean,
callback: async (client, interaction) => {
await interaction.deferReply();
const reply = await interaction.fetchReply();
const ping = reply.createdTimestamp - interaction.createdTimestamp;
interaction.editReply(
`Pong! | Client ${ping}ms | Websocket: ${client.ws.ping}ms`
);
console.log(`PING | Command ran by ${interaction.user.id}`)
},
};
this should work fine for the framework thing i use and it worked before on another bot
You have two possibility here either your registration script is not working or you just need to refresh your client
already tried refreshing like multiple times
Show us your deployment script. That's just a command file, that doesn't tell Discord your command exists
1 sec
oh woops i forgot it takes a while for global commands to register
It does not (anymore)
Just a client refresh
wait wha
either way im gonna wait a bit and ill come back here if its still not registered
did you restart discord
so just peaked on this bot im working on for a gaming studio server ive not seen this error pop before was a interaction deleted before the collector timed out? is that what this means?
Error handling interaction: Error [InteractionCollectorError]: Collector received no interactions before ending with reason: time
and are you sure you're running your deploy script
yes like 50 times
You have a component collector that did not receive any interactions in the specified timeframe
Or an awaitModalSubmit
Hi there, when my bot is playing a from spotify song, it ends at 30 seconds, and i heard that its due to spotify gives the excerpt of the song, how to fix this? (ive installed yt-dlp from python pip)
const { DisTube } = require("distube");
const { SpotifyPlugin } = require("@distube/spotify"); const { SoundCloudPlugin } = require("@distube/soundcloud"); const { DeezerPlugin } = require('@distube/deezer'); const { BandlabPlugin } = require('@distube/bandlab'); const { YouTubePlugin } = require('@distube/youtube');
const { YtDlpPlugin } = require('@distube/yt-dlp');
const distube = new DisTube(bot, {
emitNewSongOnly: true,
plugins: [
new SpotifyPlugin({
api: {
clientId: 'b39c35aeb118425ab2a50608d2b8f5f8',
clientSecret: g7SaQ541dOnD,
}
}),
new SoundCloudPlugin(),
new YouTubePlugin(),
new DeezerPlugin(),
new BandlabPlugin(),
new YtDlpPlugin()
],
});
distube.setMaxListeners(3);
distube
.on("playSong", (queue, song) => {
queue.voiceChannel.send(`▶️ Now playing: **${song.name}** \`[${song.formattedDuration}]\``)
})
.on("addSong", (queue, song) =>
queue.textChannel.send(`➕ Added **${song.name} by ${song}** to the queue`)
);
distube.on("error", (channel, error) => {
console.error(`DisTube Error: ${JSON.stringify(error)}`);
if (channel && typeof channel.send === "function") {
channel.send(`❌ An error occurred: ${error}`);
}
});
We do not support TOS violations
which distube is
Spotify does not allow playback. Distube uses youtube behind the hood
really?! oh gosh, but its useful ...
Its against TOS
alright its been an hour still not registered correctly
i know the commands are going to the discord api since if i mess smthn up about the command it returns an error
Show your deploy script
as in the index or the thing that registers the commands?
The thing thar registers commanda
deploying and registering are the same in this context
It should be a separate script
const { testServer } = require('../../../config.json');
const areCommandsDifferent = require('../../utils/areCommandsDifferent');
const getApplicationCommands = require('../../utils/getApplicationCommands');
const getLocalCommands = require('../../utils/getLocalCommands');
module.exports = async (client) => {
try {
const localCommands = getLocalCommands();
const applicationCommands = await getApplicationCommands(
client,
testServer
);
for (const localCommand of localCommands) {
const { name, description, options } = localCommand;
const existingCommand = await applicationCommands.cache.find(
(cmd) => cmd.name === name
);
if (existingCommand) {
if (localCommand.deleted) {
await applicationCommands.delete(existingCommand.id);
console.log(`REGISTER | Deleted command "${name}".`);
continue;
}
if (areCommandsDifferent(existingCommand, localCommand)) {
await applicationCommands.edit(existingCommand.id, {
description,
options,
});
console.log(`REGISTER | Edited command "${name}".`);
}
} else {
if (localCommand.deleted) {
console.log(
`REGISTER | Skipping registering command "${name}" as it's set to delete.`
);
continue;
}
await applicationCommands.create({
name,
description,
options,
});
console.log(`REGISTER | Registered command "${name}."`);
}
}
} catch (error) {
console.log(`mess up: ${error}`);
}
};
you don't need to deploy your commands one by one
Yeah no
just a single .set and you're done
There's indeed your issue
You're likely ratelimites
how come that worked before for another bot?
You do not need to deploy on every start
Creating Your Bot: Registering slash commands
read more
It should be a separate script that you run when you add or edit commands
Not every time your bot starts
alright
and this
send all your commands in the .set or .put if you use REST
this would work to make it a global command, right?
it works for both
if using the logged in client (not on a separate script but with a conditional so it only runs when you need it to):
- client.application.commands for global
- guild.commands for guilds
if using the REST class (separate script) - Routes.applicationCommands for global
- Routes.guildApplicationCommands for guilds, or something like that, it's in the guide
if you go for the first option I'd read from config or .env, some setting like "deployCommands" which you set to true when you need it and false afterwards
Hello, in the new update how to use the selectMenue classic because it mentions all the salons with it: js const channelSelectMenu = new ChannelSelectMenuBuilder() .setCustomId('select') .setPlaceholder('📁 Select Menue'); I've already tried it: StringSelectMenuBuilder but it doesn't work, why ? Error : js An error occurred in the command [TEST] DiscordAPIError[50035]: Invalid Form Body data.components[0].components[2].components[0].options[BASE_TYPE_BAD_LENGTH]: Must be between 1 and 25 in length. at handleErrors (C:\Users\Teck Génération\Desktop\Bad-Protect\node_modules\@discordjs\rest\dist\index.js:748:13) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async BurstHandler.runRequest (C:\Users\Teck Génération\Desktop\Bad-Protect\node_modules\@discordjs\rest\dist\index.js:852:23) at async _REST.request (C:\Users\Teck Génération\Desktop\Bad-Protect\node_modules\@discordjs\rest\dist\index.js:1293:22) at async ChatInputCommandInteraction.reply (C:\Users\Teck Génération\Desktop\Bad-Protect\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:194:22) at async Object.run (C:\Users\Teck Génération\Desktop\Bad-Protect\src\slashCommands\Security\settings.js:92:29) at async Object.run (C:\Users\Teck Génération\Desktop\Bad-Protect\src\events\Client\interactionCreate.js:60:9) { requestBody: { files: [], json: { type: 4, data: [Object] } }, rawError: { message: 'Invalid Form Body', code: 50035, errors: { data: [Object] } }, code: 50035, status: 400, method: 'POST', url: 'https://discord.com/api/v10/interactions/1378784688386343033/aW50ZXJhY3Rpb246MTM3ODc4NDY4ODM4NjM0MzAzMzpJZTNEVlc1MnV4UTRFdTl3VU5Ud2tyMDljVHZWdUZOWmJxWklkZmpMRXAxZkFJSDFsNXlpWUlGNUxGeU1JUWszS2M1eDkwRnZmVm5FWkljWkVlNDlPelpidEtBTFF4MXBpREt5MW1lRWtSYVRhaW9INWg1T2Z5WlpsS0FXTXI5Mw/callback?with_response=false' }
string select menus need from 1 to 25 options, inclusive
you're either not sending any option or sending more than 25
well... is there any other modules to do that?
I send 1 though ```js
const SelectMenu = new StringSelectMenuBuilder()
.setCustomId('settings')
.setPlaceholder('📘 Commencer la configuration.');
const SelectMenuRow = new ActionRowBuilder().addComponents(channelSelectMenu);```
it doesn't matter how you do it, any way to play yt or spotify music is forbidden
there isn't any option there
it's not about the amount of select menus in action row.
it's about amount of options the select has - which it has none.
okay.
[2025-6-1 13:13:31] Error: [ Discord API : 400] Invalid Form Body
at IncomingMessage.<anonymous> (C:\Users\nate\OneDrive\Desktop\Nate Assets\Discord Stuff\natebot1.0\Utils\RegisterCommands.js:86:19)
at IncomingMessage.emit (node:events:530:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
const { MessageFlags } = require('discord.js');
const { SlashCommandBuilder, TextDisplayBuilder, ContainerBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName("testing")
.setDescription("Testing component v2"),
async execute(interaction) {
const components = [
new TextDisplayBuilder().setContent("They said I couldn't teleport, so I went to a parallel universe and became a time traveler."),
new ContainerBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder().setContent("# testing"),
),
];
await interaction.reply({
flags: MessageFlags.IsComponentV2,
components: [ContainerBuilder.toJSON()],
});
},
Code : ```js
const mediaGalleryComponent = new MediaGalleryBuilder().addItems(
{
media: { url: 'My_url' }
},
);
const SelectMenu = new StringSelectMenuBuilder()
.setCustomId('settings')
.setPlaceholder('📘 Commencer la configuration.');
const SelectMenuRow = new ActionRowBuilder().addComponents(SelectMenu );
const Opencontainer = new ContainerBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder().setContent(Text))
.addMediaGalleryComponents(mediaGalleryComponent)
.addActionRowComponents(SelectMenuRow)
.setAccentColor(Colors.White)
.setId(1);
const msgwait = await interaction.reply({
components: [Opencontainer],
flags: [MessageFlags.IsComponentsV2]
})```
how to fix?
@nova pond
you're not sending your components, you're calling ComponentBuilder.toJSON() for some reason
oh i didnt even notice that
How do I add it?
StringSelectMenuBuilder#addOptions() discord.js@14.19.3
Adds options to this select menu
guide suggestion for @nova pond:
Message Components: Select menus - Building string select menus
read more
const { MessageFlags } = require('discord.js');
const { SlashCommandBuilder, TextDisplayBuilder, ContainerBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName("testing")
.setDescription("Testing component v2"),
async execute(interaction) {
const components = [
new TextDisplayBuilder().setContent("They said I couldn't teleport, so I went to a parallel universe and became a time traveler."),
new ContainerBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder().setContent("# testing"),
),
];
await interaction.reply({
flags: MessageFlags.IsComponentV2,
components: [components],
});
},
};```
that guide article should probably help as well
components is an array, you don't need to, and shouldn't, wrap it in another array
should i just remove components: [compnents]?
Your issue still is not related to that file
don't wrap it in an array
alr
well i dont know how to fix it
Then log the actual request you make.
Or use REST from discord.js to make the request to get more useful errors instead of your custom way
Whatever you're calling that on is undefined
Hi,
How to create at the highest possible position ?
Find the highest current position and +1
How to find the highest current position ?
Depends, what are we talking about? Roles, channels, ...?
Oh I'm sorry I meant to say "create a role", I don't know how I forgot to put those words 😅
RoleManager#highest discord.js@14.19.3
The role with the highest position in the cache
And so higher in the list is a higher number value (as in opposite to the notion of array indexes) ?
Few questions related to emojis:
- guild.emojis.fetch and client.emojis.fetch would resolve the same thing? As in, if an emoji is in a guild, then client.emojis.fetch would be fine?
- if 1 is true, the difference would also be that client.emojis.fetch would also fetch from the ApplicationEmojis? or do you have to use client.application.emojis as a seperate request
I fixed the invalid form body now I am trying to send but what should I do now? ```javascript
const { MessageFlags } = require('discord.js');
const { SlashCommandBuilder, TextDisplayBuilder, ContainerBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName("manage")
.setDescription("Testing component v2"),
async execute(interaction) {
const components = [
new TextDisplayBuilder().setContent("They said I couldn't teleport, so I went to a parallel universe and became a time traveler."),
new ContainerBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder().setContent("# testing"),
),
];
await interaction.reply({
components,
flags: MessageFlags.IsComponentV2,
});
},
};```
Arrays tend to be shown as horizontal from left to right. Discord roles go from bottom (everyone role) to top, yes
Does that not work? Do you get any issue?
what should I do now?
you tell us?
Command: manage
Error: Invalid Form Body
data.components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
data.components[1][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
];
await interaction.reply({
^^^
components,
flags: MessageFlags.IsComponentV2,
});
},```
Did you overwrite the reply method of interaction in any way? Can you console.log(interaction) before that line?
this is my code: ```javascript
const { MessageFlags } = require('discord.js');
const { SlashCommandBuilder, TextDisplayBuilder, ContainerBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName("manage")
.setDescription("Testing component v2"),
async execute(interaction) {
const components = [
new TextDisplayBuilder().setContent("They said I couldn't teleport, so I went to a parallel universe and became a time traveler."),
new ContainerBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder().setContent("# testing"),
),
];
await interaction.reply({
components,
flags: MessageFlags.IsComponentV2,
});
},
};```
Can you console.log(interaction) before that line?
You misspelled the flag
IsComponentsV2 "Components" is plural
Oh, good catch
what should i replace with that
I gave you the correct spelling
Oh alr
Can someone please link me the link to the duplicating commands page? ON how to solve it?
I cannot seem to find it
Well, arrays can also be as follows :
const array = [
highest,
high,
middle,
low,
lowest
]
```Where higher on appearance is lower on index.
Anyways, by "highest possible", I actually meant "possible" as in "won't throw `Missing Permissions`" ? How to take that into consideration ?
Thanks
const { MessageFlags } = require('discord.js');
const { SlashCommandBuilder, TextDisplayBuilder, ContainerBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName("manage")
.setDescription("Testing component v2"),
async execute(interaction) {
const components = [
new TextDisplayBuilder().setContent("They said I couldn't teleport, so I went to a parallel universe and became a time traveler."),
new ContainerBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder().setContent("# testing"),
),
];
console.log(interaction);
await interaction.reply({
components,
flags: MessageFlags.IsComponentsV2,
});
},
};```
Thanks.
what's the problem?
Error: Invalid Form Body
data.components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
data.components[1][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
Oh nvm. client.emojis.fetch doesn't exist, so you'd have to iterate over every guild to fetch an emoji?
did you save that code?
client.emojis is a pseudomanager that's only goal is to gather up emotes from all guilds and put them in a single collection
yes
app emotes are unrelated to guild emotes, therefore they don't exist under client.emojis
and if you have the Guilds intent, the client.emojis cache is already filled with all emojis, so you only need to .get ^^
what does the interaction log say
Issue is Value of field "type" must be one of (1,)
yes, that means you're not passing the IsComponentsV2 flag
which is why I asked if you're sure you saved the code
where should i put type at in my code?
ah, that was going to be my next question. I remember there was a guild emojis and stickers intent a while ago (might still exist), all emojis are sent over gateway then that intent keeps the cache up to date?
nowhere
did you save the file?
if yes, check again
yes
did you restart the bot?
yes
or reload the command
yes
cool thanks
emotes are sent along the guildCreate - that's why Guilds intent
and that's also a cache you can rely on unlike members for example?
but that intent is for emoteCreate, emoteDelete, etc. events
same as members, depends on whether you have the intent
ill have it so ig i can rely on it
wait, I might be dumb but I cannot find it...
cannot find what?
Like the part where it says duplicating commands
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: [] })
here
Ah thanks
which immediately tells you to delete one of them
which you were linked to on how to do that
I don't think that link actually exists
https://discord.js.org/docs/packages/discord.js/14.19.3/BaseGuildEmojiManager:Class#cache
guessing the cache is keyed by the emoji id, like name:**id**?
yes
thanks 😭
hm. it does seem to be somewhere else, https://discordjs.guide/slash-commands/deleting-commands.html#deleting-all-commands
yeah it's on the wrong page
cough
where did you find that link
maybe it was there before and it's a cache issue
I just copied it from that page
its long and i have to put it in a txt document
@rose tangle https://sourceb.in/XKPCapeRJe
can you npm ls discord.js and npm ls discord-api-types
in console
(and show the output)
alr
npm ls discord.js = discord.js@14.14.1
npm ls discord-api-types = ├── discord-api-types@0.38.9
├─┬ discord.js@14.14.1
│ ├─┬ @discordjs/builders@1.11.2
│ │ ├─┬ @discordjs/formatters@0.6.1
│ │ │ └── discord-api-types@0.38.9 deduped
│ │ └── discord-api-types@0.38.9 deduped
│ ├─┬ @discordjs/formatters@0.3.3
│ │ └── discord-api-types@0.37.61 deduped
│ ├─┬ @discordjs/rest@2.5.0
│ │ └── discord-api-types@0.38.9 deduped
│ ├─┬ @discordjs/ws@1.2.2
│ │ └── discord-api-types@0.38.9 deduped
│ └── discord-api-types@0.37.61
└─┬ v2componentsbuilder@1.0.25
└── discord-api-types@0.38.9 deduped
^
yeah no idea what "v2componentsbuilder" is
In that case you want the highest role of the bot and create the role below that
your discord.js version does not support v2 components
update to latest
i will do npm i discord.js@latest
and remove other packages
like v2componentsbuilder
and whatever other thing you may have
discord.js includes multiple sub-packages, installing these separately can mess with internal code:
[0;31mnpm [0;0muninstall discord-api-types @discordjs/rest @discordjs/builders
[0;34myarn [0;0mremove discord-api-types @discordjs/rest @discordjs/builders
[0;33mpnpm [0;0mremove discord-api-types @discordjs/rest @discordjs/builders
how do i do that
npm uninstall <package>
which ones should i keep?
the ones you're using
just uninstall that thing just mentioned, update d.js to latest and try again
for the discord part, you should only need discord.js and that's it
└─┬ discord.js@14.19.3
├─┬ @discordjs/builders@1.11.2
│ └── discord-api-types@0.38.9 deduped
├─┬ @discordjs/formatters@0.6.1
│ └── discord-api-types@0.38.9 deduped
├─┬ @discordjs/rest@2.5.0
│ └── discord-api-types@0.38.9 deduped
├─┬ @discordjs/ws@1.2.2
│ └── discord-api-types@0.38.9 deduped
└── discord-api-types@0.38.9
did you install builders separately?
because your builders version did not bump at all
and it's actually latest
I'll assume you did install it separately, because that old djs did not have that version
@torn orchid
thats what i did there not going away
alright, should be fine then
i have this
yes, those are appropiate versions for your djs version
alr
what is like the npm to see if you are at the latest version for discord,js
you used to have an old djs but newer subpackages, hence why you could build the components (/builders) but not send them (discord.js)
you can just open discord.js on npm and see
but you're on latest
there's also #announcements
technically speaking there's npm outdated, but it's not necessarily to be blindly trusted
And there is not fields in CV2 correct?
correct
there's no embeds
is there a identical way to have text go like this?
other than with spaces manually, which can break in mobile, no
oh alr
Only by having the interaction webhook of the first interaction still stored somewhere
And it being less than 15 minutes since
CommandInteraction#webhook discord.js@14.19.3
An associated interaction webhook, can be used to further interact with this interaction
can't you access the first interaction there?
have you tried collectors?
storing, retrieving and using the webhook directly isn't as straightforward as simply using the interaction object
soo, i've trying to edit the component instead of creating a new one
const message = await interaction.channel.messages.fetch(interaction.message.id);
const existingContainer = message.components[0];
const receivedContainer = new ContainerBuilder(existingContainer)
.setAccentColor(1691997);
const acceptedText = new TextDisplayBuilder()
.setContent(`✅ Accepted by: ${interaction.user} (\`${interaction.user.username}\`)`);
receivedContainer.addTextDisplayComponents(acceptedText);
but i'm getting this error
_ValidationError: Expected a string primitive
at _StringValidator.handle (C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@sapphire+shapeshift@4.0.0\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2615:70)
at _StringValidator.parse (C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@sapphire+shapeshift@4.0.0\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
at TextDisplayBuilder.toJSON (C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@discordjs+builders@1.11.2\node_modules\@discordjs\builders\dist\index.js:1708:33)
at C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@discordjs+builders@1.11.2\node_modules\@discordjs\builders\dist\index.js:2168:64
at Array.map (<anonymous>)
at SectionBuilder.toJSON (C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@discordjs+builders@1.11.2\node_modules\@discordjs\builders\dist\index.js:2168:35)
at C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@discordjs+builders@1.11.2\node_modules\@discordjs\builders\dist\index.js:1870:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@discordjs+builders@1.11.2\node_modules\@discordjs\builders\dist\index.js:1870:35)
at C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\discord.js@14.19.3\node_modules\discord.js\src\structures\MessagePayload.js:151:46 {validator: 's.string()', given: undefined, stack: 'Error: Expected a string primitive
at _St…js\\src\\structures\\MessagePayload.js:151:46', message: 'Expected a string primitive'}
so I'm building a ticket panel system using buttons and modals. After the user submits a modal (e.g. to add a question), I want delete the previous ephemeral message (the one with action buttons) to avoid clutter. However, since ModalSubmitInteraction doesn’t have .update() . How can I cleanly replace or remove the last ephemeral message after a modal submission?
do you have access to the ButtonInteraction that triggers the modal from where you handle the modal?
No
you're handling those modals separately, directly inside of the interactionCreate?
That's right
Need to .toJSON() the existingComponent when passing to ContainerBuilder()
omd, you're the king tysm <3
Can I see connections of user?
no
Is there any way
through oauth2
which djs does not support
So what do you think is there a way to do this? Because doing interaction.message./edit doesn’t rally seems to work with modals
use .update, assuming the modal is shown from a component interaction
I thought i couldn’t use .update let me re-try
you need to typeguard if using typescript
ModalSubmitInteraction#isFromMessage() discord.js@14.19.3
Whether this is from a MessageComponentInteraction.
Im trying to have a discord bot that scans a server and grabs all user ids (utilizing user apps) but i cant figure it out since i am used to only using guild commands, this is the code i am using now: ```const { SlashCommandBuilder, MessageFlags } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('list-visible-users')
.setDescription('Lists visible user IDs in this channel'),
async execute(interaction) {
const members = interaction.guild.members.fetch();
const ids = [...members.values()].map(m => m.user.id);
await interaction.reply({
content: `Visible User IDs:\n\`\`\`\n${ids.join('\n')}\n\`\`\``,
flags: MessageFlags.Ephemeral
});
}
};
(i know it sucks) it gives this err: at Object.execute (C:\Users\X\Downloads\TheChangeMakers\commands\Utility\pred.js:9:41)
at Object.execute (C:\Users\X\Downloads\TheChangeMakers\events\interactionCreate.js:46:25)
at Client.<anonymous> (C:\Users\X\Downloads\TheChangeMakers\index.js:19:50)
at Client.emit (node:events:518:28)
at InteractionCreateAction.handle (C:\Users\X\Downloads\TheChangeMakers\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\X\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\X\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31)
at WebSocketManager.<anonymous> (C:\Users\X\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\WebSocketManager.js:235:12)
at WebSocketManager.emit (C:\Users\X\Downloads\TheChangeMakers\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
at WebSocketShard.<anonymous> (C:\Users\X\Downloads\TheChangeMakers\node_modules@discordjs\ws\dist\index.js:1190:51)
that's not the full error
also this sounds really scummy
and i believe should be impossible for that exact reason
its so i dont have predators joining my server
at Object.execute (C:\Users\cgmcc\Downloads\TheChangeMakers\commands\Utility\pred.js:9:41)
at Object.execute (C:\Users\cgmcc\Downloads\TheChangeMakers\events\interactionCreate.js:46:25)
at Client.<anonymous> (C:\Users\cgmcc\Downloads\TheChangeMakers\index.js:19:50)
at Client.emit (node:events:518:28)
at InteractionCreateAction.handle (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31)
at WebSocketManager.<anonymous> (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\WebSocketManager.js:235:12)
at WebSocketManager.emit (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
at WebSocketShard.<anonymous> (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\@discordjs\ws\dist\index.js:1190:51)
and to do that you go to all servers and grab all users that happen to be in those servers? seems really unrelated.
i grab them put them in a database and then ban them from joining the server
i don't really understand how would you determine someone is a "predator" from their id
anyway
this is genuine invasion of privacy
and therefore is not possible
except its been done before (for different servers)
does not mean you should do it too
user apps dont have access to the members regardless
you cannot retrieve server members with a user app. if you need access to members, you have to install the app to the server in question
so whatever it is you are trying to filter for - you will need server staff to opt into it by installing your app (and giving it the required permissions)
Didn't that big one just get banned? Just because it's been done doesn't mean it's allowed
okay that worked thanks btw in a button interaction can i deferReply then update to edit the original message?
no
use deferUpdate and editReply
editReply in this case will update the original message that contains the button?
yes
how do you put a acccentcolor on a embed in discord.builders
we are not the creators of that website so we cannot help you
this server is only for the discord.js library
Are there any planned or anticipated breaking changes in v15? I was wanting to make a bot but I heard it was planned to be releasing soon and I didn't want to have to rewrite if that's the case
major version bumps are synonym of breaking changes
otherwise it wouldn't be a major version
there's no particular plans to release it soon
and no guide to update yet, since changes are still being done
you can see some here but it's incomplete and entirely bound to change https://github.com/discordjs/guide/pull/1595 and its preview on https://v15.discordjs.guide/additional-info/updating-from-v14.html
Yeah I know, it's just there's "ctrl+f replace all" breaking changes and then there's rewrite entire sections breaking changes, and I was wondering if there were any of the latter
I guess I heard wrong about v15 being impending, my apologies
there are behavior changes, yes
mostly with currently deprecated fields/methods being removed
my bot keeps telling me it's getting removed from the same server over and over but the number of servers it's in doesn't go down. all the info about the server is just "undefined" and the server ID is always the same. Any ideas?
do you have the Guilds intent?
yes
what code logs this
I do also get legitimate guildDelete events
but a bunch of these random "undefined" events firing for some reason
ah, yeah that's an unavailable guild
no properties are available on those
probably only the id is the only actually reliable one
filter out unavailable guilds in your log and you're good
or maybe only log the id if you want
what are these unavailable guilds? and why do so many fire at the same time
I think they happen due to outages, ddevs can probably give more info #useful-servers
and I also tend to see a bunch of them show up in the log any time I restart the bot
well the bot is still in that guild then
it's just unavailable
there must be a lot of outages..
well discord is quite a big platform
look how many fired all at once at this time.. I don't get it..
I'd recommend including the id, since you will get that at least
Then you can see if its the same, or one guild firing a lot
it's the same ID on all of them
Yeah, so that would explain it
One guild is flagging a lot
why does this happen?
I understand moving forward just filter them out but now I'm curious what causes this
^^
ddevs = discord developers (server)
thanks everyone. I guess this will have to do.
should add a ; so it doesn't execute the next line by mistake
👍
is there a way to make context menu commands show up in DMs like esmbot?
ContextMenuCommandBuilder#setContexts() discord.js@14.19.3
Sets the contexts of this command.
ContextMenuCommandBuilder#setIntegrationTypes() discord.js@14.19.3
Sets integration types of this command.
thanks!
like this?
it's still not showing
new ContextMenuCommandBuilder()
.setName("meow")
.setType(ApplicationCommandType.Message)
.setContexts(["Guild", "BotDM", "PrivateChannel"])
.setIntegrationTypes([0, 1]),
ah nevermind it just did
guess there was a delay
I did some more testing regarding this and there's 2 interesting finds, sorry for ping by the way.
if I deploy the exact same code and settings but change token to another bot it works flawlessly, so it shouldn't be the code. However if I with very minimal just set a single command this also work? so something tells me it's not ratelimit if some things work and some things won't
module.exports = {
roles: ["1375655275670798357", "1375658621458845797", "1375658664161181766", "1375661716976832532"],
name: "say",
aliases: ["repeat"],
description: "Sends a message",
usage: "say <message>",
async execute(message, client, args) {
if (!message.member.roles.cache.some(role => this.roles.includes(role.id))) return;
const sayMessage = args.join(" ");
message.channel.send(sayMessage);
await message.delete().catch((err) => {
});
}
}```
i want to have -say hello and -repeat to also say hello so another alias of say
did you make that code?
i thought discord bots could use emojis from other servers they're in in any guild?
You could make a Map that maps each alias to the corresponding command and check that in the message create event
They still can
with slash cmds too?
with help yes
Yea
how would i do that?
Given the bot or everyone role has the use external emojis perm
confused
let me make sure the external emoji perms is enabled 1 sec
Prob missing perm
Given the bot or everyone role has the use external emojis perm
i see; i thought external emojis was a default permission
It varies by server setup
yeah the bot and everyone has external emojis but its still like that, is it because its a user installed app rather than a guild command?
wait nvm its a guild command
Could also be an invalid emoji id
server with the emojis vs server without; both servers have external emoji permissions enabled for both the bot and everyone
the emojis are in the first server
And ur sure the perm enabled in the channel?
And you're sure it's not a user installed app?
i'll try removing it from my user install
it's the same, i think bots are unable to access emojis from other servers now? maybe due to them adding the app specific emojis? the external emojis permission is enabled and everything
that's definitely not the issue
but you should prefer app emojis if possible
💀
im trying to make a pokedex bot but i have more emojis than i can in the app emojis since i have 4 per pokemon 🥲
App emojis do bypass the permission
maybe i just need to rethink this
use a media gallery?
I mean, using emojis was the approach they did in the official stage
yeah thats what i was copying basically
it'd suck if you couldn't replicate yourself
i don't think theres any way to have both a button and image in a section?
correct, there isn't a way
like these are emojis on the left
yeah that's only possible with emojis, like they did in the stage
but limited to 500 pokemon (4 emojis per; 2000 max emoji in app)
how does that alignment work
Thats okay there are only 151 good ones 
its just ${emojis[0]}${emojis[1]} **${name}**\n${emojis[2]}${emojis[3]} ${genus} - ${types},
yeah imo it would've been better if they had chosen an example that wasn't limited by design
i mean i could have a single emoji per pokemon, but it wouldnt' display very well
yeah
like this is a bit ugly
I dunno, I like it.
i think it looks fine
even then can't have all pokemons 
should be able to
1025 pokemon (excluding other forms); 2000 max bot emojis?
ah, thought there was more
it does feel a lot more
OHHHH you were tiling 4 emoji. Yeah that threw me
yes !
I had no idea, well done
it was copied from the discord thingy they had for components v2 lol
what are prefered prefixes to use with custom bots?
Slash commands.
^
'jarvis' 
ik the consensus is usually to use slash commands, but alot of people liked using 'jarvis' on my server, so i used jarvis,
The / character
Since its built directly into Discord and offers significantly better functionality than literally any other prefix
Self-documenting, if you do it right.
Thats probably an exception if used in a roleplaying sense
get ready to write your own command parsing library, discord.js really leaves everything to you
Why not Friday? Or Edith?
i think nodejs has a built in thing for command line processing (parseArgs)
I don't think that works with arbitrary strings like a Discord message?
thats not exactly enough for discord commands tho,
yeh
yeah thats fair
module.exports = {
roles: ["1375655275670798357", "1375658621458845797", "1375658664161181766", "1375661716976832532"],
name: "say",
aliases: ["repeat"],
description: "Sends a message",
usage: "say <message>",
async execute(message, client, args) {
if (!message.member.roles.cache.some(role => this.roles.includes(role.id))) return;
const sayMessage = args.join(" ");
message.channel.send(sayMessage);
await message.delete().catch((err) => {
});
}
}```
how do i do that
do you know how to make a map?
nope
do you know javascript?
yes
how much
you could try use my command-loader lib i made for this purpose, but there's not much documentation as its literally just me using it, you'd have to clone the lib as its neither on npm (basically your on your own for the most part) -- its what im using with my discord bot atm
https://github.com/Syth-1/command-loader
its pretty stable tho, i have the same lib running in a game chat, where users are hitting about 30-40k messages with the bot a month
Map
The Map object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and primitive values) may be used as either a key or a value.
i started like 3 months ago - maps i never understand
orrr save yourself the trouble and just use slash command like normal people
we don't even recommend using prefixes as it results in really bad UX
i suggest you learn how they work
With the new components, is it possible to do something similar that EmbedBuilder.from() does and build a container from an existing message to modify things within it?
I'm assuming interaction.message.components[0] will always be a container (so it's a ContainerComponent when inspecting debug)
new XBuilder(component.toJSON())
Oh, so obvious...thanks!
is it possible to mimic the search function in discord using djs?
other than fetching every single message that has been sent and sorting through it?
No
Apps don't have access to the search endpoint
tags: { guildConnections: true }
What are considered as guildConnections ???
All I know is Linked Roles, is there anything else ???
Yes, it indicates whether the role is a guild's linked role
Anything else ?
No, only that
What about integrations ??? What do they represent
Check for integrationId
Like bot roles and what ???
If the role belongs to a bot, there will be botId
Role#tags discord.js@14.19.3
The tags this role has
documentation suggestion for @mellow tartan:
RoleTagData discord.js@14.19.3
All tags are here
Ik the tags but I don't know what all they represent
Like what comes under integrations in roles
Integrations can manage roles, like YouTube or Twitch. You get the role if you're subscribed. Integrations can be found in server settings > integrations tab
No to both
I mean neither is accepted
I believe you can use an empty string
There would be an API error
Just use an if statement
Well, ig that requires you to extract it as a local variable
Why don’t these methods accept undefined like required does?
required accepts undefined (or omitting the parameter) because setRequired() implies you want to set it to true already. It's not the same as unsetting
Right, default values
any particular reason why components v2 doesnt allow the content field anymore? unless its still wip for that part
Why would you need it when Text Displays exist?
mentioning users, mentions in containers dont ping
They do
you may be confusing that with embeds
Ddocs does say that components v2 will not work with content
nope im not, been fiddling with containers for a few days and mentions dont work at all hence why i asked, unless the highlight just doesnt show
To use components, messages must be sent with the
IS_COMPONENTS_V2flag (1<<15). Note that using this flag disables traditional content and embeds - all content must be sent as components instead.
It sounds like you're making use of allowed mentions and forgot?
got that too, and no not using allowed mentions
It doesn’t sound like enabling content will be a thing
Hello, probably might be a weird question, but I kinda want to know.
Supposed the bot doesn't have any permission flags (including view channel), and all of @everyone permission flags is also disabled. Then there's a private channel only for member/role with Administrator permission.
The bot doesn't show up on the member list, but when I'm using one of the slash command, they're still able to send non-ephemeral messages and image with non V2 Components even though it theory they should get permission denied / no access error. Is this intended or is there any reason behind it?
if its a reply perms dont matter
Is it possible to have a name:field below each other next to each other with text displays?
Price Style
20 Blue
No, but you can just like... do exactly what you just did
That would do weird line breaks I think If on a smaller device for example
anyone know about this error
Error [ShardingReadyTimeout]: Shard 43's Client took too long to become ready.
at Timeout.onTimeout (/home/container/node_modules/discord.js/src/sharding/Shard.js:190:16)
at listOnTimeout (node:internal/timers:581:17)
at process.processTimers (node:internal/timers:519:7) {
code: 'ShardingReadyTimeout'
}
can a thread not be renamed back after a rename? https://pastes.dev/kQjxRRMzcL getting stuck at renaming
how do i make the embed doesn't have a color like this?
Which is exactly the reason why it doesn't exist. Fields in embeds were never meant to be abused as tables, you can define the vertical layout of your components, discord takes care of horizontal based on device and screen size
Just dont set the accentColor for the container I think 😄
that will be gray
Isnt that an embed ?
A container is not an embed
This is a container
Is there documentation on vertical Layout ?
container and embed is different?
Yes, the documentation of components
Yes, read the announcement you screenshot there
and this one #discord-dev-news message
please help
Hi all, can anyone explain why code that worked before is stable and no errors. In the last 2 days there is just some horror going on. 2 gbps is happening at moments. And DiscordAPIError[10062]: Unknown interaction error like this. I understand that it is an error if the command is not answered in 3 seconds, but how can it be that the code worked all the time and now this happens? And it is the bot process that takes 2 gbps
Gentle reminder this is a volunteer service and people help as they are able and have time. There is no guarantee of a quick response (or one at all)
what is a partial
guide suggestion for @agile nest:
Popular Topics: Partial Structures
read more
if i use channel.permissionOverwrites.set(overwrites_role1_role2)
and there is already same overwrites for role1 and role2 does this request change it ? like remove it and readd it or it's just edit if the overwrites not the same ?
it will set it to whatever you provide even if its the same
so i should check if it's the same to skip useless request
is this possible???
(those small images inside cv2)
they aren't images, they are emoji's that have been joined together
so they are just text display?
correct
thats so sad ngl
you'll have to debug whether it's a network issue or your code now talking longer than expected
ask in ddevs
and yes
I'm sure it's a network issue because the bot functionality hasn't changed and has been tested on higher loads before
What are the ratelimits for messages?
- Knowing that the global is 50/s
- Do shards affect it in any way
- Is it per server or per channel or global
I know they aren't public, but someone might have figured them out
tag suggestion for @keen widget:
Ratelimits are dynamically assigned by the API based on current load and may change at any point.
- The scale from okay to API-spam is sliding and depends heavily on the action you are taking
- Rainbow roles, clock and counter channels, and DM'ing advertisements to all members are all examples of things that are not okay
I know but for example I figured out mostly the ratelimit behind changing nicknames. It is consistent making my bot work staying at their limits
So it's not as dynamic as you think it is
that info is all the help djs can give
not that it's a djs issue in the first place either way
oh I was about to go to the djs part
cuz djs has a built-in rate limit handler, doesn't it?
yes
so does it force every request to the same endpoint every time and looks up the retry-after or is it more customized towards the discord api rate limits in order not to hit 429(lmk if I gave the wrong status code)
or is it a queue and if one request got rate limited, the rest needs to wait
this, but for that endpoint obviously, not all the rest
though if it's the global ratelimit then yeah
it'd need to wait entirely
obviously lol...
mhm... so the best way is to just do the rate limiting myself to get control based on my guesses of the rate limits?
It knows the ratelimit buckets and abides by them, you'll see it in action if you intentionally hit them
Can i change the permission of a list of users of a channel at the same time?
to handle ratelimits or to avoid ratelimits? because if the latter you shouldn't need to unless it's a big bot, in which case you can request higher limits afaik
By "knows", Discord sends the ratelimit data in response headers, it's not safe to hard-code these values and most of the time you don't need to do your own ratelimiting.
but if an endpoint has multiple rate limit rules that aren't connected to each other then djs fails
avoid of course
Which is why you listen for the rateLimited event and handle it yourself if needed...I'm not sure which endpoints you're referring to, though. Most endpoints are pretty narrowly scoped, although yes multiple buckets can be part of a single request
I can just make an overlay on top off discordjs rate limit handling i guess
For example, /guild/id/member/id GET has both a ratelimit on the user and overall guild requests
But in reality, in normal operations you usually won't see it.
read the rest of my message then
a bot with 10k servers will hit the global rate limit in my case, but I don't want to hit the other ones
You can set overwrites: https://discordjs.guide/popular-topics/permissions.html#editing-overwrites
Rate Limits - Global Rate Limit
read more
If you are experiencing repeated Cloudflare bans from the Discord API within normal operations of your bot, you can reach out to support to see if you qualify for increased global rate limits. You can contact Discord support using https://dis.gd/contact.
I don't mind the global rate limit since in my case it's just a setInterval() setted up correctly
then it shouldn't be something you need to handle separately
if you're consistently hitting ratelimits and you want to handle it by yourself then either:
- you don't need djs but a thinner wrapper like /core
- you're doing what's considered to discord as api spam
- you could qualify to higher limits
or you need another approach entirely since there are endpoints with really high limits
anybody know why i am getting this error/what this error is
Code is: ```js
const Discord = require("discord.js");
// // Fetch a message
channel.messages.fetch('930492253439418460/1197905693676687410')
.then(message => console.log(message.content))
.catch(console.error);
> error is: `node:internal/modules/cjs/loader:1404
> throw err;
> ^
>
> Error: Cannot find module '/Users/redacted/discordbot2/collector.js'
> at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
> at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
> at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
> at Function._load (node:internal/modules/cjs/loader:1211:37)
> at TracingChannel.traceSync (node:diagnostics_channel:322:14)
> at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
> at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
> at node:internal/main/run_main_module:36:49 {
> code: 'MODULE_NOT_FOUND',
> requireStack: []
> }`
there isn't an easy way, I'd re-think the workflow either way since it doesn't look like good UX to have that many consequent messages
you require()d a module 'collector.js' and there isn't such a module
also that isn't a valid message id
i meant to do a fetch messages from channel
but you already have the channel object?
using channel.messages.fetch will only fetch messages from that channel
wouldn't make much sense for it to also get from other channels
not that it can either way
would i add the module in the code to make it work
wdym?
like a module export or import
I don't really understand
the error says youre requiring 'module.js'
and there isn't such a module
in case you wanted to require a local file you probably meant './module.js'
but that isn't djs related at all either way
i guess where im struggling at is how i know this is the code i need or if their is more code to be added
because what i have in my current file is just
you're supossed to know what your code does
i do
just not know where to end or if its if enough
then how do you not know whether you need more code 
if you know what it does, you'll know if it's lacking something
idk what im lacking is where i am having trouble is what i meant to say
and what are you having trouble with in the first place
Is this error here your issue? Or is it something else? If it's that error then show what you ran in your console that caused that
i just ran node filetitle.js
Hey, user.banner returns undefined even tho the user has a banner, v14.19.3
And what's filetitle.js? Rather weird name for your main file to run
User#banner discord.js@14.19.3
The user banner's hash The user must be force fetched for this property to be present or be updated
@hot marten ^^
._.
thanks guys :D
i was trying to hide the file name if that makes sense
It definitely does not. Because you're making it impossible to help you when you do that. So good luck on your own
it's not sensible data in case you were concerned about that
and it should be main.js or index.js either way
im just gonna try to figure it out on my own. sorry for bugging, just kinda feeling lost.
need to learn more
i would recommend #resources for general js guides, #1081585952654360687 and general servers like tcd or tph in #useful-servers for help with js/node
it actually just looks like you were running node collector.js while having no file called "collector.js"
so yeah you need to brush up on your js/node essentials ^^
Would a function like <Guild>.members.fetch() work?
No
That fetches members
with the user id
<User>.fetch() would
Still fetches a member
Despite sounding similar there is a distinct difference between users and members in Discord:
- User: global Discord user data (global avatar, username, tag, id)
- GuildMember: user data associated to a guild (guild, nickname, roles, voice, guild avatar, etc.)
- Conversion: User ➞ GuildMember | GuildMember ➞ User
* Note: Events received in cached guilds will often have both the member and user available, eg.interaction.userandinteraction.member
Never heard of this function, thanks again
You have the user already. Call .fetch() with no parameters on it
When using interaction.followup() is it possible to prevent it from being a reply? My issue is that I send an ephemal saying operation complete, and then folowup with a public message of the result, but that public message being a reply to the ephermal shows the operation complete text
to other users it won't show the text since they can't see the message
Oh, ok, perfect!
foo
it'll show like this
I'd show the confirmation in the same message as the question being edited
How to add buttons to activities? As the new Discord Social SDK has it but couldn’t find any example of it in the guide
You can’t reply to a modal with a modal. You can reply with a button or something asking the user to answer another modal
djs is not the social sdk
its a different sdk
which djs does not support
*+9+
where is the guide for component v2 on djs ?
i mean documentation
Use the search bar in the docs. Kinda depends on what you’re wanting documentation on. The guide, https://discord.com/channels/222078108977594368/1365720579977511083
.use discord builders fir component v2
For UserSelectMenuBuilder, is there a way I can limit the users that can be selected? I'd like for the user to pick only the users in a room, for example
no
what the tag crwl mean?
i need to know, everybody is asking me this
its me
#archive-offtopic for non djs questions
are builders or functions preferred? or just preference? ie:
const container = new ContainerBuilder().addSectionComponents((sb) =>
sb
.setThumbnailAccessory((thumbnail) =>
thumbnail.setURL(
pokemon.value.sprites.other["official-artwork"].front_default,
),
)
.addTextDisplayComponents((t) =>
t.setContent(`**${name}**\n${description}`),
),
);
vs ```ts
const container = new ContainerBuilder().addSectionComponents(
new SectionBuilder()
.setThumbnailAccessory(
new ThumbnailBuilder({
media: {
url: pokemon.value.sprites.other["official-artwork"].front_default,
},
}),
)
.addTextDisplayComponents(
new TextDisplayBuilder({
content: ## ${name}\n${description},
}),
),
);
preference
hm alright
pretty much the only actual difference is that the former lets you pass current data directly
but there's no difference if you're not doing that
is there any way to just pass the objects directly? without using a builder or something since its kinda verbose
(although i guess you'd need to pass the other stuff the api needs?)
d.js accepts objects w/ camelcase keys
hm; this like isn’t a big deal at all i was just curious on if i could clean my code up a bit lol
and Chewinky said you can
ty :D
How do perms for userinstalled bots work like are they based of the person who runs the command perms or do they have a strict set of perms?
There's an enum somewhere with the error codes from discord, anyone know what that is and what the error code is for max amount of emojis in a server?
documentation suggestion for @red coral:
v10: RESTJSONErrorCodes - MaximumNumberOfEmojisReached
read more
Ah, that one, thanks
<Guild>.emojis.create returns a GuildEmoji, it also seems as if most of the properties can be null, why would it be the case if .name or .animated are null?
Only nullable because of the message reaction events
ah gotcha, so if they were created using .create then you can assume they'll be there
#10913 in discordjs/discord.js by Amgelo563 merged <t:1748631966:R>
fix(Emoji): remove incorrect nullables, add ApplicationEmoji#available
@red coral ^^
oh sick thanks a lot
though it needs to be implemented for v14
Yea
How do perms for userinstalled bots work like are they based of the person who runs the command perms or do they have a strict set of perms?
user installed apps do not come with a bot that could have any permissions in the server
they are however interactions, so fall under usual set of permissions regarding interaction responses, some taken from the @everyone role
and the apps being able to respond non-ephemerally is controlled by the "Use External Apps" permission
oh okay thanks
Does anyone have the part of the code that allows you to put files inside the Container?
documentation suggestion for @oblique talon:
ContainerBuilder#addFileComponents() discord.js@14.19.3
Adds file components to this container.
{
name: "hours",
description: "the amount of hours to be applied",
type: 4,
required: true,
maxLength: 3,
minLength: 1,
}
14.19.2 
minValue and maxValue, not maxLength and minLength
length is for strings
builders exist to avoid these specific things
or you can type the option
i dislike it tbh, manual is better
thank you
could check at the regexes escapeMarkdown uses, but it's not 100% reliable
escapeMarkdown discord.js@14.19.3
Escapes any Discord-flavored markdown in a string.
hi just a simple question is a tsx watch a ts-node thing or it can be use on something like
rimraf dist && npx tsc && tsx watch src/main.ts
tsx and ts-node are 2 separate things but both accomplish the same goal. To run TypeScript code in real time
So, that script has redundant actions in it. There's no reason to compile your TS to JS (with tsc) before running tsx
so whats better tsc tsx ts-node
or people preferred
Depends. All TS code needs to be turned into JS at some point to run, and many just like to use it all the time...but if you want to use them:
tsc for production
tsx or ts-node for development...I think tsx is supposed to be better but it shouldn't make a huge difference
so tsx on making the bot then tsc when is it done or ready to be published
I just use tsc --watch and the run the JS
im really confused in typescript i only know the interfaces
its like coding in java
A little, yeah
can u help me with my confusion cuz samtino said tsc for production but tsx works too
you can use as much or as little of typescript as you want. at the end of the day, it's just type control for JS...it has a lot of power when it's fully utilized but you don't need to do any more than just controlling types
tsx works too in production
you shouldn't run tsx for production because it's converting the ts to js in real time which will use significantly more memory and processing time
oh just a memory
Hello, are message edits rate limited by any chance?
yes
pretty much everything is rate limited...but to what extent, depends on the action
10 per hour i think
3*
yea makes sense
thank you !
hey so tsx just use a lot of memory it doesnt make any difference on running it
why interaction.client.commands does not exist in ts
interaction.client.application.commands
commands are stored in the application not the client
so
interaction.client.application.commands = new Collection()
Because it doesn't. You'd be creating it yourself, d.js doesn't include it by default
no...you should not override the existing application.commands
It's a property you're adding onto the d.js Client
i am making command handler
it doesnt work when i created one
We highly recommend you extend the Client structure properly instead of just attaching custom properties like .commands to the regular discord.js Client instance.
- Using typescript, you might want to consider casting or augmenting the module type
so i am not using the discordjs one im making my own collection thingy
You always were
There is no discord.js one
but its in discord js docs
Creating Your Bot: Command handling
read more
client.commands
Yes, making your own is in the guide
thats exactly im doing its give me an error
Because youre using TS
And the property doesn't exist
so how
Which is not an issue in JS, but is an issue in a strict-typed language like TS
^
Or just dont attach it. Very little benefit honestly
The guide is kinda old and isn't written for TS projects
ima use array instead
lol
yeah thats the problem 
I dont mean to be rude but why are you using TS?
or just variable = new Collection() then export it
Yeah that's what I'd do, but not from index
using an array instead of a collection will make no difference. a collection is objectively better since it's a map
From a command loader file utility or something
i just want to learn new things
Fair enough
i only understand typescript in a react app
const commands: command[] = []
commands.push(command)
lol
no
thats a good reason. typescript is designed to prevent you performing actions on a type that it doesnt recognize. the built in Client doesn't have a commands property, so you can either override the Client class to add a commands type, or you can store your commands somewhere else
Have you built a bot in JS before?
no...do not store them in an array...just use a collection. a collection is a Map so it has helper functions that are extremely benefitial such as find and filter
ye im just messing
(I mean those are array functions too)
(The helpful Map ones are get)
what do you use new Map or new Collection
Collection (or map)
is it samething
no
Additional Information: Collections
read more
this typescript thing keep me stressing
I dont see difference in Map and Collection i build same one before
I mean we're literally telling you that there are differences
Collection extends Map with additional functionality
you dont have to use it...but it's objectively better for something like commands
thanks got a new knowledge bout that
how do u register a command in ts bro
same way as in js
Using the deploy script
Creating Your Bot: Registering slash commands
read more
ok but i got one more question when exporting a command should i use module.exprots or export default or interfaces
i tried it but so many config to make it make error on interaction: CommandInteraction, client: Client
depends in your esm/cjs settings, and interfaces are entirely unrelated
well what's the error
well first i make a js file not ts file inside a src folder now in the register command code i switch the file ends with js to .ts now i runned the code it give me a error that says : expression thing error so i remove the : in the async execute function so its likr async execute(interaction, client) and i runned again it give me a error of data not found but it was there
Probably because you export default but didnt adapt your imports
do i need to use a shard manager? previously i just used the client options but apparently v14 has changed stuff 🤔
If you set shards to auto djs should handle it for you
it doesn't return a shard count, it has 20k+ servers
from what i recall it's 2,500 per shard
client.shard -> null
client.ws.options.shardCount
That’s only available when using the ShardingManager
TypeError: Cannot read properties of undefined (reading 'shardCount')
Are you sure ur using v14?
yes
lemme get you the exact version
14.19.2
Mb, had the main docs
client.ws.shards.size
alright nice! it works thank you
does channel.messages.fetch get all, or does it have a limit and you have to offset?
i imagine there is of course, but is there no way to filter it for say a given day
by default the limit is 50, you can change that to 100
You can, of course, work with filters as well, like before, after, around
is there an offset?
What exactly do you mean with offset
You can provide message ids to before/after/around, if thats what you mean
interesting
i guess i can use that as a stepping offset, like get 100, then get the last id of the 100 and get before of that and so on
You may want to check out #1202608431685566464
yup thats what im looking for thanks thanks
np glad to help
in slash command options is there a way to like provide like suggestions?
guide suggestion for @abstract forge:
Slash Commands: Autocomplete
read more
cheers
What licenses does discordjs use? Is it possible to fork it create a own branch?
Legally speaking I mean the license regulates that
Apache License 2.0, means you can fork whatever you want, but you need to add a license and copyright notice and also list your changes.
Good because there is an important thing I want to change: Remove any kind of "Rainbow" in it
k
Do you literally just mean the logo in the readme? 
Do you hate the prismatic spectrum of light?
how do i send an attachment from a buffer?
The AttachmentBuilder supports buffers
thanks
AttachmentBuilder discord.js@14.19.3
Represents an attachment builder
[discord-types]
I can't find the type for https://discord.com/developers/docs/interactions/application-commands#making-a-global-command
is there one?
Hi,
How to allow selecting only specific users in a user select menu ?
Thanks
you can't
Any alternatives ?
you can list out the users and give a button for selecting each one
That would limit the list to 25
autocomplete
thats all your options
What's that ?
Slash Commands: Autocomplete
read more
documentation suggestion for @potent burrow:
v10: RESTPostAPIApplicationCommandsJSONBody
read more
thank you
Its a union of types but you can navigate from there
intellisense was not cooperating
are context menu commands not allowed to have components?
what
that question doesn't make sense
no command can have components
messages have components
and u can send messages as responses to commands
Responses to them can, yes
that's odd
is something wrong here then?
const {
ContainerBuilder,
SeparatorBuilder,
TextDisplayBuilder,
MessageFlags,
} = require("discord.js");
module.exports = {
info: {
name: "Meow",
perms: [],
dev: true,
},
run: async (client, i) => {
if (!i.inGuild()) {
const text = new TextDisplayBuilder().setContent("bwaaaaa :3");
const sep = new SeparatorBuilder();
const container = new ContainerBuilder()
.addTextDisplayComponents(text)
.addSeparatorComponents(sep)
.addTextDisplayComponents(text);
return i.reply({
flags: MessageFlags.IsComponentsV2,
components: [container],
});
}
},
};
oh wait it's probably the dev flag
i'll try turning it off real quick
Is there a message.awaitSomething function for that ?
Also, can the list show up before the user starts typing the first character, and is the list limited in number of values ?
yep that was the issue
my bad
wait, I think we misunderstood each other, autocomplete is just for slash commands
you cant do what you want in select menus
Yeah I understood that
I guess that would be commandInteraction.awaitSomething then
not sure what you want to await here
Just like there are awaitMessageComponent and awaitModalSubmit functions to avoid requiring globally listening to events, is there one for autocompletion ?
no because autocompletes dont happen after interactions
Then there's also no way to verify who is querying the autocompletion ?
And no way to respond if they don't have the rights to access the autocompletion data ?
Of course there is
Listen to the autocomplete interaction via an interactionCreate listener
Slash Commands: Autocomplete
read more
Okay
So, can the list show up before the user starts typing the first character, and is the list limited in number of values ?
Also, about responding to the user that they don't have the right to access the autocompletion data, I can only use the channel property for that, and therefore cannot use ephemeral ?
Yes (e.g, our /tag command, and yes)
No, it just fails
Theres no response until they execute a slash command
Why wouldnt they have rights to the data?
But still have rights to use the command?
No, they wouldn't have the right to use the command at all.
Then they wont be able to
You dont need to check yourself if you just use the permissions properly
Oh, you mean there's a role-based system to allow access to commands ?
That's interesting, although not applicable either in my case, because access control is not role-based
Ahh
Well yes there is, but I guess that doesnt help you then
I guess you could respond with a single choice that tells them access denied
Why not, lol
So what's the maximum number of items allowed ?
20 or 25, I dont recall
I think 25
Really anything more than 10 is bad autocompletion imo
Well, only one must be selected, but the option list might be bigger than 25
Thats why you filter based on what theyre typing
So they could only have a partial list before typing the first character
yes
Thats the whole point
Too many to choose from, so they type
Well, the thing is, the user doesn't necessarily know the content of the list
k i have no idea wft youre building lmao
An overly complex "security" bot
can i do something like this?
It's an array also, I guess you could do flags: [flag1, flag2]
why buttons not working i copy this component code from ddev
wtf are those flags lmao
This looks like really badly AI generated trash
u talk with me?
yes
Why not using the constants ?
what about it doesnt work?
"not working" tells us nothing
lol
first of all there is no event named componentsv2
emit
client.on("messageCreate", async(message) => client.emit("componentsv2", message))
why tho
still havent told us what isnt working
i want to make like this
this is my code's result
Discord caches the slash commands locally and if I deploy new commands to the bot... the only way for them to appear is, I need to refresh/restart my discord.
My question being, where exactly are these commands cached locally?
thats a section component with a text display component and a button component accessory
not a d.js question
Where exactly should my question be asked?
Is there a document?
Not specifically, no
There are builders
I think the only ones to answer that would be actual discord support, so https://dis.gd/contact
You still havent said whats not working
Oh crazy, thanks.
the formatting
but what they did wasn’t making use of a section, just text display with an action row
Finally. We got there from "why buttons not working"
It is clear from the beginning that the buttons do not work.
they work, you can click on them lol
I see two buttons right here
They work
Use your words, we cant help you if you dont explain what it is you need help with
