#djs-help-v14
78874 messages · Page 12 of 79
is it possible to add an attachment to a filebuilder?
Yes
Same way as you would with embed
Files in embeds should be attached via the message option object and referenced in the embed:
const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);
channel.send({
embeds: [embed],
files: [attachment]
});
Here's an example for ya.
const json = JSON.stringify(data);
const date = new Date().toISOString().split('T')[0]; // Get just the YYYY-MM-DD part
const buffer = Buffer.from(json, 'utf8');
const file = new AttachmentBuilder(buffer, { name: `infinitea-export-${date}.json` });
console.log(file);
await interaction.reply({
embeds: [
new EmbedBuilder()
.setColor('#2ecc71')
.setTitle('Thank you for using InfiniTea!')
.setDescription('We appreciate the time you spent with us. We hope you find a bot that perfectly suits your community\'s needs. Your data export is attached.')
]
});
await interaction.followUp({
files: [file]
});
appreciate it, but im talking about ther FileBuilder for the new components system, as from what ive seen you cant add attachments to it, they need to be filebuilders
It’s the same thing
You add file to the message and refer to it using the attachment url scheme
i didnt quite get this
Files in embeds should be attached via the message option object and referenced in the embed:
const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);
channel.send({
embeds: [embed],
files: [attachment]
});
ohhhhhhh
thx m8
attachment contains the file. EmbedBuilder refers to attachment in setImage, both embed and attachment are sent in channel.send
does guild.channels.cache (assuming guild.channels.fetch() is run beforehand) return a collection of all channels in the guild, or only all the channels the bot has view permissions for?
all channels in the guild, not including threads which need to be fetched
How do you specify only a given set of users for the UserSelectMenuBuilder? I've tried both addDefault and setDefault. It appears that it always shows all members, but I'm keenly interested only in the specific users that are online and available in the voice channel.
const selectMenu = new UserSelectMenuBuilder()
.setCustomId(`kick_${channel.id}`)
.setPlaceholder('Select a member to kick')
.setMinValues(1)
.setMaxValues(1)
.setDefaultUsers(channel.members.map(member => member.id))
don't need the fetch if you have the Guilds intent btw
not possible unfortunately
you can however make a string select with only those users
Oof custom impl then I suppose.
so all channels existing in the guild will be cached on startup?
yes, if you have the Guilds intent
(not including thread channels)
and those channels would be cached in client.channels too, not including DM channels (or threads)
Oof so if I use a StringSelectMenuBuilder I can't make it "Searchable" if the list exceeds 25... :S
correct
I'm going to have to get creative asf
Does the messageCreate event contain the components v2 data yet?
const admin = interaction.member.permissions.has(
[PermissionFlagsBits.Administrator, PermissionFlagsBits.ManageGuild],
false // <-- checks if the member has ANY of the listed permissions
);
This is returning false even tho I have only mange server perm?
components v2 has been fully supported (both sending and receiving) for a little over 3 weeks now
you're looking for <PermissionsBitField>.any()
that comment of yours is incorrect
documentation suggestion for @frosty epoch:
PermissionsBitField#has() discord.js@14.19.3
Checks whether the bitfield has a permission, or multiple permissions.
documentation suggestion for @frosty epoch:
PermissionsBitField#any() discord.js@14.19.3
Checks whether the bitfield has a permission, or any of multiple permissions.
You're right. For some reason, the message isn't populated with any embeds or components when my app tries to read its own messages. I typically have that manually excluded but turned it off to play around. Receiving message components from any other app/webhook seems to work fine.
how do i add emojis to my bot through code?
<Client>.application.emojis.create()
documentation suggestion for @prisma ruin:
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);
is there a way to pass in a file on attachment?
It takes a file path, yes
Why in the mention at phone it appears invalid-user and in the browser the mention is correct
Caching pretty sure, the app on the phone doesn't have that user cached, not discord.js-related
Is there a way I can create a BotDM context command to clear the chat? it drives me mad having all of these DM's that I really want to clear, and you can't send an ephemeral to the dms.
/Programmer
bulkDelete doesn't exist in DMs, fwiw
Also you can send ephemeral replies in DMs
What you can't do is respond in a different channel than the one the interaction came from
Correct, all of the DM's are coming from server.
So I can't send those ephemerally, but giving people the option to cleanup messages would be great.
There's not much reason to though
There's nothing else ever happening in those dms
People can also just close them anyway
why wont guildcreate and guilddelete work when the others do? no errors in logs.
The toggles on dev panel merely allow your app to request them, so showing them being on is not needed (you will get an error if you request disallowed intent). Guilds intent also isn't privileged so that makes the toggles even less relevant.
Are you adding the bot to a guild?
Or just the app
i have them all on just to be safe, thx for the insight. im adding and removing the bot from a test server via the discord provided link - nothing logs in there
Okay, but is it the app with the bot, or just the app itself
What are the scopes
admittedly, the terms app and bot are confusing to me, these are the scopes - ill look up what those mean
You could think of the bot as a discord account for your app
Application commands are called application commands because they work via and belong to the app
The bot account your app has is just a way for your app to interact with users and members in servers (and send/receive DMs)
ohh right, yeah, this is an old fashioned bot
Since it's the bot that will become a guild member that can then get permissions to do actions in the server
Hm
doesnt even use slash commands, just uses prefixes, hence i think of the bot account and the app as one
Which requires a bot to be able to view channels, yeah
Anyway, not sure why that doesn't work
You could try updating anyway, but doubt that would fix it
hm, i just ran npm i, ill look what the latest is
There's #announcements
14.19
.3
ye :p
oh wait fuck i was kicking the prod version when i was testing dev, sorry for wasting ur time
that makes a lot of sense
someone knows how to make a boost user count?
what would be the point of that?
i’m not sure how this is discord.js related
I'm struggling a lot with making the message/component attached.
I've tried various videos, github explainations, and I still have no luck. Maybe I'm not using it right but I need some help.
help about what specifically
Creating the container i think
And then the objects within the container, if that is what it's called
have you check the source code provided ? theres literally one in that screenshot
What source-code?
I tried opening that and It didn't work
you can open it with any text editor honestly
Alright thanks, whole time it was opening with my media apps
Okay guys, I have a challenging one for ya's. So I have this "Private" mode toggle that I'm triggering when a user joins a channel and sets it to private. This portion works just fine, however when a user is dragged into the channel, they cannot speak which is intentional, because they do not have the "Speak" permission. The problem comes whenever I set the channel back to "Public" so to speak, the user who was previously suppressed, stays suppressed.
// Update channel permissions
await channel.permissionOverwrites.edit(guild.roles.everyone, {
Connect: isPrivate ? false : true,
ViewChannel: isPrivate ? false : true,
Speak: isPrivate ? false : true,
});
// Get all members in the channel.
const members = channel.members.values();
for (const member of members) {
if (isPrivate) {
channel.permissionOverwrites.create(member, {
Connect: true,
ViewChannel: true,
Speak: true,
});
} else {
channel.permissionOverwrites.delete(member);
}
}
I attempted to directly unmute the individual, however that failed to actually unmute the user. Instead they had to disconnect and reconnect in order to speak again.
Nevermind.
Yeh it's the darnedest thing.
I suppose I could just remove the "Speak" given that the outside users can't actually see the channel anyway.
have you try with edit instead of create ?
Create , is creating permission for a user , Replace if one present
Edit , is editing permissions for a user or creates if none present
This is interesting behaviour though, because if edit works instead of create, that would imply that the "create" method is being invalidated by some discord system for assigning permissions
So "everyone"-level permission overwrites seems to take precedence over member-level permission overwrites.... but that makes no sense 
I tried incorporating given resources into my existing commands and I'm receiving this error:
[ERROR] Uncaught Exception: CombinedError (2)
Received one or more errors
1 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ButtonBuilder]
|
| Received:
| | undefined
2 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ThumbnailBuilder]
|
| Received:
| | undefined
show your code!
if (interaction.commandName === "lock") {
const rolesToLock = [
"1360382321211080805", // member
"1360382319285764227", // goat
"1360383170184478720", // bot
"1366071144049803365", // partner
"1360382317419433994", // staff member
"1366081883519058020", // partner manager
"1360383220188975114" // management
];
const channel = interaction.channel;
await Promise.all(
rolesToLock.map(roleId =>
channel.permissionOverwrites.edit(roleId, {
SendMessages: false
})
)
);
const container = new ContainerBuilder();
const text1 = new TextDisplayBuilder().setContent('## Channel Locked');
container.addTextDisplayComponents(text1);
const text2 = new TextDisplayBuilder().setContent([
`- Channel\n - <#${channel.id}>`,
`- Locked By\n - <@${interaction.user.id}>`
].join('\n'));
const section2 = new SectionBuilder()
.addTextDisplayComponents(text2);
container.addSectionComponents(section2);
await interaction.reply({
flags: MessageFlags.IsComponentsV2,
components: [container]
});
}
Sections need to have a thumbnail or a button. You can't omit one
Alright, thanks
If you don't want to add a button or section. Just add the text directly to the container
Alright
Thanks for the help
I just noticed a peculiar feature in your code: that you manually overwrite all possible roles with the anti-send messages permission.
I believe a better way to do this is to just overwrite guild.roles.everyone with this anti-send messages permission, and then for various management/staff roles you can override this permission as needed
An partial message only has channel, message and author id right?
In d.js land, a partial message is only guaranteed to have the message ID itself. Everything else is up in the air. An example of this is an event from the messageDelete event on an uncached message, where event from the API only provides the ID of the message and nothing else
Sorry, just checked. The channel ID is also provided, so the channel & message ID are the bare minimum you'll have
Yeah, for a while that was there for a few tests but I didn't know exactly what to do with it. Thanks for this!
Code: https://pastes.dev/WjOfbkKtYI
Error: https://pastes.dev/n9Rp9YGSP2
The error stack is not helping here at all, only going back to node_modules
In the code, the first console.log works fine and logs the container. From that, I assume containers[currentContainers] is not the issue, so whatever is adding onto it is the issue.
But the error happens after console.log(1) runs, and never gets to console.log(2).
The error is that content of some text display is undefined, but I don't really add anything that is undefined.
the error means that there's a text display without content
I do see you setting the content of the one text display in this code, so I have to assume the issue is either in containers[currentContainers] or there's something more to your code that you haven't shown in this bin (or your code isn't saved)
containers[currentContainer].toJSON() is working fine without any errors though
I also tried to do this:
console.log(
components[0].components.find(
(comp) =>
(comp.data.type === ComponentType.Section &&
comp.data.components?.find((x) => !x.content)) ||
(comp.data.type === ComponentType.TextDisplay && !comp.data.content)
)
);
it logs this:
TextDisplayBuilder {
data: { type: 10, data: { type: 10, content: '-# Page 1/2' } }
}
which is interesting because typescript should have caught it, right? if it was there at all
- I mentioned a couple other possibilities
- I'm just telling you the conclusions I've drawn with the info you've given
to me,containers[currentContainer]is a complete unknown since you haven't shown how it's defined
I don't even know whether it's a builder or whether it even contains any text displays
all I do know is that I see one text display that looks fine - caught what?
you've shown so little of your code, I don't even know how this new code block relates to your other code
isn't the content supposed to be in TextDisplayBuilder.data?
something like
TextDisplayBuilder {
data: { type: 10, content: "-# Page 1/2" }
}
https://pastes.dev/3ZS4M8DqqY this is how I define containers, and here is what containers[currentContainer].toJSON() logs: https://pastes.dev/g1SyYh4j6b
I still couldn't find any empty contents
What is the limit on adding custom perms for users in a channel? as in how many users can I add manually
yes you're correct that it should look like that
and that is likely the issue
that being said, it's not really a complex method, so especially since I still have yet to see the whole code as is, I have to fall back to what I said earlier
or there's something more to your code that you haven't shown in this bin (or your code isn't saved)
if you have to ask, I feel like a role might be better for your use case
I am trying to override a role permission without removing the role
sorry to clarify, you mean you're denying a role from viewing a channel, but allowing a subsection of that role's members?
https://pastes.dev/VmIZZRxBhL I switched up the code a little bit, and this is the entire code for pagination, nothing removed.
And as for the command itself: https://pastes.dev/3qUkEAoS1L this is the code from the building of the containers to calling the pagination function, nothing removed in between
I don't think I have removed any code in between in the code I sent before, only the code after (which shouldn't matter), and the code before (which is a check with early return)
And I also don't think the code isn't being saved since the new logs I added worked
and yes, same error
Can you console.dir(containers[currentContainer], {depth: null}) please?
before I modify them in pagination, or after?
After, before passing to editReply
I am trying to limit posts of a user to 3 in a forum channel. What I have in mind is to use threadCreate event for this and log the count of posts when they create. If it exceeds 3, I want to either update perms to not allow them create posts or to possibly just delete the post
https://pastes.dev/Q2SCbeSPKw
The TextDisplayBuilder causing the issue is still there:
TextDisplayBuilder {
data: { type: 10, data: { type: 10, content: '-# Page 1/2' } }
}
Then make another role allowing them to make posts and revoke that when they have 3
also real quick could you do npm ls @disccordjs/builders
PS D:\Projects\VerveVote> npm ls @discordjs/builders
sapphire-template@1.0.0 D:\Projects\VerveVote
├─┬ @sapphire/framework@5.3.4
│ └── @discordjs/builders@1.11.2
└─┬ discord.js@14.19.3
└── @discordjs/builders@1.11.2 deduped
Okay that sounds more reasonable
And before the forEach?
I only just noticed you're importing ButtonBuilder and TextDisplayBuilder from @discordjs/builders directly
I can reproduce this when doing so, but frankly I didn't think discord.js was changing the builders in any way such that that should even happen
but tldr I believe ContainerBuilder doesn't recognize those as instances of the same class, so it's passing the object to the TextDisplayBuilder Constructor
Why do you import TextDisplayBuilder from /builders there instead of discord.js? 🐌
interesting, I was importing by using autocompletions in vscode, never noticed that
looks like it works fine now
Yup, that’s indeed it
Can we get the details of the receiving event by applying to the server via the bot?
i need these question answers
no, that has yet to be documented in the api
damn that would be awesome with some ai
In discord.js v14, I want to reliably get the members who have access to a specific channel.
To do that, I believe I need to write something like this:
const members = await Guild.members.fetch();
const channelMembers = members.filter(member =>
Channel.permissionsFor(member).has('ViewChannel')
);
However, this approach likely comes with rate limits and may take some time to process.
Is there any other way to reliably get the members who have access to a channel?
you can shortcut to TextChannel#members, but under the hood that does the same thing.
there is no endpoint to just list the members that can see a specific channel
it won't incur rate limits. GuildMemberManager#fetch sends a gateway command which then sends the guild members via the websocket connection
however, that comes with its own caveats, yes
- waiting for chunks may take some time
- in very large servers it may back up the event queue to the point where receiving interaction creates may take longer than you have time for the initial reply (think of it like: the command execution is sitting in a traffic jam, but needs to be responded to within 3 seconds) - we are however talking hundreds of thousands if not millions of members until it gets that bad
as a small additional sidenote: per convention class names are capitalized in js. while the code may work, naming your guild instances Guild will likely lead to confusion both by helpers as well as potentially yourself (syntax highlighting, conflicts when actually trying to construct instances from classes, etc.)
to illustrate that: const Guild = new Guild(). instead it's recommended to go with lowercase for instances const guild = new Guild()
-# ofc i'd not recommend constructing guilds manually at all, this is just an example to illustrate the issue/point of confusion
I capitalized it on purpose, thanks!
At first, I was using channel.members, but I stopped when I realized it doesn't include members who aren't cached.
Popular ticket bots often have features that let you view logs on a website, right?
I wonder how those bots get which members have access to the ticket channel.
Hello guys, question about discord auth API. Is it against the TOS to share user data taken from the oauth2 (like servers the user is in) with admins for moderation purposes?
#useful-servers ddevs is better for that
Ah, sorry. Thank you!
By fetching all members of the guild once on ready. From there on out cache will be and stay accurate through the run of your bot
👍
is there anyway how can i use everyone or here with components v2
when can these properties be null?
Could you share the whole thing? It’s hard to know having access only to part of the line
my bad
Specifically its <InteractionCallbackResponse>.resource.message
hey folks I am having this error can someone please help me i am using discord.js after a long time
components v2 allows mentions (in contrast to embeds) and respects allowed mentions
sounds like interaction isnt an Interaction
Guys
Utkarsh Mitr
I am using slash command btw. And passing through function
yes?
Kya haal he

I am doing great and how are you doing?. Please refrain from chatting here and please go ahead in #archive-offtopic
Chill ok
is there any thing called permssionflagbits in V14 or it got depreciated ?
documentation suggestion for @native marten:
PermissionFlagsBits discord.js@14.19.3
yes, but you're not passimg the correct thing
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
yeah i tried it
thank you
is the character limit in text display 4000 characters same as text input?
No idea
Discord didn't document any such limits for cv2
You could try asking in ddevs, maybe someone there might know
yeah I don't see a limit in the documentation, guess there's only one way to find out then
oh, that makes more sense than limit testing myself lol
Tbh they would have to test themselves too lol
so someone in ddevs does the limit testing for you 
Maybe if enough people ask there someone notices them not existing and documents them in any capacity 
cv2 is absolute cinema
Because InteractionCallbackResponse is the same result interface for all the different ways you can respond to an interaction. And a modal or a deferral has no resource associated with it
Was supposed to be a reply 👆
Same way starting an activity as response to an interaction has a resource, but no message
ahh
Technically that interface could be typed with a generic to not be nullable depending on interacting response type, but that‘s ts shenanigans
how to enable commands in userDM?
documentation suggestion for @ember crest:
SlashCommandBuilder#setContexts() discord.js@14.19.3
Sets the contexts of this command.
science has been done @crimson gale
is that the API or our builders assuming
Good question
at Object.run (C:\Users\user\WebstormProjects\discord-bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2422:79)
at C:\Users\user\WebstormProjects\discord-bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:67
at Array.reduce (<anonymous>)
at _StringValidator.parse (C:\Users\user\WebstormProjects\discord-bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:29)
at TextDisplayBuilder.toJSON (C:\Users\user\WebstormProjects\discord-bot\node_modules\@discordjs\builders\dist\index.js:1708:33)
at C:\Users\user\WebstormProjects\discord-bot\node_modules\@discordjs\builders\dist\index.js:1870:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (C:\Users\user\WebstormProjects\discord-bot\node_modules\@discordjs\builders\dist\index.js:1870:35)
at C:\Users\user\WebstormProjects\discord-bot\node_modules\discord.js\src\structures\MessagePayload.js:151:46
at Array.map (<anonymous>)
is all I got
alr setContext - PrivateChannel, but comands still not show in userDM
have this error in terminal (at the bottom)
its a single parameter. Not 2
GuildChannelManager#create() discord.js@14.19.3
Creates a new channel in the guild.
// Create a new text channel
guild.channels.create({ name: 'new-general', reason: 'Needed a cool new channel' })
.then(console.log)
.catch(console.error);
i'd recommend reading responses you get, if you want to solve your errors
components[COMPONENT_DISPLAYABLE_TEXT_SIZE_EXCEEDED]: Components displayable text size exceeds maximum size of 4000```
I assume this is a discord and not d.js
albeit that's the whole component, not just textDisplay
there you go

not surprising, but nice to know
what do you mean?
time for a dumb question, but why didnt grids get included with v2?
i had a moment and was pondering going though my channel update logger and was like "How could i add a table into the component without it being jank" then it hit me, a reasonable feature that could of been added wasnt added cuz discord is still in the ice-age with v2 so heres to hoping it may be possible to have a native table grid
but is there anything with the components that are planned to work like tables?
How can you register all slash commands as user installable 
that would be a question for #useful-servers ddevs rather than us, but afaik there are no such components planned, especially since they would be unable to display on mobile
figures it would come down to a mobile thing
why commands not show in userDM? commands already deploy by clientID.
Did you deploy them globally?
Did you set the commands to have proper contexts?
If you mean all DMs, did you set proper integration types for the commands?
And did you install the app to your user account?
Heya, is there a guide to the new components v2? Can’t find it
nvm figured it out
Did you deploy them globally?
yes. Routes.applicationCommands(clientId)
Did you set the commands to have proper contexts?
yes. .setContexts([InteractionContextType.PrivateChannel]) only
If you mean all DMs, did you set proper integration types for the commands?
yes
Did you install the app to your user account?
yes.
if im missing something, let me know.
where exactly are you trying to use the command?
in someone elses dm or the bots dm
users dm only
is max limit of role select menu 25?
role select menus are auto populated?
anyone who what's wrong?
create takes one parameter
and that means?
That means one, not two like you provide
GuildChannelManager#create() discord.js@14.19.3
Creates a new channel in the guild.
// Create a new text channel
guild.channels.create({ name: 'new-general', reason: 'Needed a cool new channel' })
.then(console.log)
.catch(console.error);
I meant the max select option
Your syntax is outdated by multiple versions, so either you are updating an old project or following a very outdated guide
Or using AI
25, yes
you means i should write it like this instead
above
That's the correct syntax, yes
still get this but on guild
get what? you cut all of your error
in components v2, how do i make it so the text components are inline?
you don't
so it can only look like this?
yep
greatt
well, you can make longer lines any way you want
but they might wrap on mobile and look worse than you intended
yeaa
waiting for that feature, it works now but it will be nice to have it, if it is a feature they want
it's a feature that's very likely not happening
the devs making components v2 have stated multiple times that not having horizontally aligning components is a deliberate choice
well whould be good is either multiple per section, that they go next to eachother if they have space, or you can specify that. But it would b a good feature to have.
i personally agree with the devs that it would not
see embeds; they optionally respect the inline specification, and people abuse it to display table-like data and completely ruin it for mobile users
I mean yea, it shouldn't be used for that but with right now it may use a lot of vertical space while the horizontal is so less. So that could ruin it.
only because you choose to write only two words per line
Can i select some default roles in the role select menu?
default it will be populated by how many roles?
What exactly are you asking about here?
role select menu
Okay but what about it?
Given how you yourself have to explicitly set the defaults, not entirely sure what you're asking about
I think i got it nevermind
it's being worked on!
hey, how to make multiple buttons in one section? like this
put them in the same action row
i use v2 components, does action row work on this?
Is it possibale to use js to connect to http things.
Like lets say theres an game i want my bot to connect to, to do stuff like ''!playercount'' ''!load all players'' etc
documentation suggestion for @pearl dome:
ContainerBuilder#addActionRowComponents() discord.js@14.19.3
Adds action row components to this container.
Yep it's called an api but that's not djs related
Ofc i know its called an api but like is it possibale with js
An api is possible with pretty much any language
Sure buddy
ty
Why is Events.MessageCreate not firing for messages sent in DMs until the bot itself sends a message to that user?
To receive direct message events on "messageCreate" with your bot, you will need:
- The
DirectMessagesgateway intent - The
Channelpartial setting
Probably the partial
tysm!! yes that was the fix
i have uploaded emojis to the bot
how can i get all of them in a array for later use?
you'd need to fetch them with <Client>.application.emojis.fetch()
this resolves with a Collection (or you could also then access <Client>.application.emojis.cache)
Converting a Collection to an array
You only need to convert it to an array if you need the index of an entry:
- Iteration (looping) is possible with
for...ofoverCollection#valuesorforEach - You can transform a Collection to an array with
Collection#map - If you need indices, you can get the array using
[...collection.values()]
.setColor(resolveColor(rr.color ?? "#FAFA00"))
Argument of type 'string' is not assignable to parameter of type 'ColorResolvable'.ts(2345)
What do I do with this?
why when editing an embed it then says "this interaction has failed"?
but then edits anyway?
On discord? You don't acknowledge the interaction
You may use .edit not .update for example
type assert
Like do as ColourResolveable?
yes
message.edit({ embeds: [resend], components: [new ActionRowBuilder().addComponents(button1, button2)]});```
this is the code im using
thanks
you aren't responding to the interaction, you would use interaction.update() and not message.edit() in this case
is there a way to add emojies to the bot using djs@14?
documentation suggestion for @wooden jetty:
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);
imagine that
TypeError: interaction.update is not a function
We need more context, can u show more of what you're doing?
so im editing an embed and after the edit 2 buttons appear, after updating it is saying interaction failed whilst button1 appears to be loading.
I'm talking code
interaction.update({ embeds: [resend], components: [new ActionRowBuilder().addComponents(button1, button2)]});```
edit: my apologies
"interaction" is apparently not an interaction
context, we need more then just what causes the error
could log it to see what it actually is
ill log the interaction
ChatInputCommandInteraction
.update doesnt exist on that, again can you show more code for context
const message = await interaction.reply({ embeds: [embed], components: [row] });
const selected = await message.awaitMessageComponent();
const brand = selected.values[0];
if (selected) {
const resend = new EmbedBuilder()
.setDescription(`# ${brand}\n\n` +
`email: \`${interaction.options.getString("email")}\`\n` +
`product name: \`N/A\`\n` +
`price: \`N/A\`\n` +
`shipping: \`N/A\`\n` +
`image: \`N/A\``)
.setColor(process.env.default)
.setFooter({text: "only press 'send' button when the details above are correct"});
const button1 = new ButtonBuilder()
.setCustomId("step1")
.setLabel("step 1")
.setStyle("Primary");
const button2 = new ButtonBuilder()
.setCustomId("step2")
.setLabel("step 2")
.setStyle("Primary");
interaction.update({ embeds: [resend], components: [new ActionRowBuilder().addComponents(button1, button2)]});```
selected.update then, since awaitMessageComponent returns a MessageComponentInteraction
thankyou so much
how does one make an interaction handler file?
so for instance a button has a custom id, upon the user pressing that button it gives them a modal etc.
and then in the same file have the same setup for another button with another id?
check if interaction is from a button then switch statement on the custom id?
whats the method to check if its a button?
BaseInteraction#isButton() discord.js@14.19.3
Indicates whether this interaction is a ButtonInteraction.
there's .isX() methods for every X interaction type
oh right thankyou
so after this how would i switch statement the custom id of a button?
something like interaction.customId?
yes
ButtonInteraction#customId discord.js@14.19.3
The custom id of the component which was interacted with
quite literally that
you can also see the docs for each class in the docs website
thankyou for the help
either im going insane or something else but why do select menus want a different format when passing unicode emojis
buttons accept this
{ id: null, name: '😭', animated: false }
and select menu options just want the '😭' passed directly
are you importing both from djs?
yop
the builders right?
for select menus the builders and for buttons the json thingy
dont know if that makes a difference
then yeah that makes sense
the api only supports the full object
ahhh
builders accept that "partial" string and then makes the full object itself
because they're meant to be utilities
yeah thanks for clearing my doubts about this
i thought i was going insane
the builder should actually also accept the object
if I had to guess, you're receiving a type error?
if so, it's because id is expected to be string | undefined
yeah
interactionHandler.js:
module.exports = {
name: 'interactionCreate',
async execute(interaction, bot) {
if (interaction.isButton()) {
switch (ButtonInteraction.customId) {
case "step1":
interaction.showModal(apple1());
}
}
}
}```
anotherFile.js:
```js
if (selected) {
const resend = new EmbedBuilder()
.setDescription(`# ${brand}\n\n` +
`email: \`${interaction.options.getString("email")}\`\n` +
`product name: \`N/A\`\n` +
`price: \`N/A\`\n` +
`shipping: \`N/A\`\n` +
`image: \`N/A\``)
.setColor(process.env.default)
.setFooter({text: "only press 'send' button when the details above are correct"});
const button1 = new ButtonBuilder()
.setCustomId("step1")
.setLabel("step 1")
.setStyle("Primary");
const button2 = new ButtonBuilder()
.setCustomId("step2")
.setLabel("step 2")
.setStyle("Primary");
selected.update({ embeds: [resend], components: [new ActionRowBuilder().addComponents(button1, button2)] });
}```
why is the modal not showing up when i click the step1 button on the edited embed?
edit: no error in terminal
ButtonInteraction.customId isn't a thing
so that's basically switch (undefined) {
o
this means "the customId property in an instance of ButtonInteraction"
not "the (static) customId property in the ButtonInteraction class"
o
the latter wouldn't make sense, it'd need to update the property whenever a button is received, it'd be a pain for concurrency
so what ur saying is what im trying to do is impossible?
oh wait, the way ive gone about it is just wrong
of course not, buttons you wouldn't be able to discern them from each other if it were impossible
notice how you did interaction.isButton() and not BaseInteraction.isButton()
it's the same thing
yeah i get it now haha
Explaining <Class> and Class#method notation: learn more
so like, how would i tell the customId of a button used in the interaction?
^^
im slightly baffled... what would i put in the switch statement?
sorry for all of the questions
you need to access the customId property of that "interaction" variable, that is a ButtonInteraction
that's what ButtonInteraction#customId means
the same way you accessed and called the isButton method of that "interaction" variable
so interaction.id ?
i suggest looking at the docs instead of wondering what methods or properties to use
id is a different property ^^
how does one go about doing this then brother
can i put booth overwrite in the same i send in last image
I'm unsure what's the issue, you've quite literally done the same thing for the isButton method
i need to know the customId of the button pressed in the interaction
yeah, so access the customId property
it's the customId of the button pressed
yeah the button pressed was made in another file, im trying to make a file solely for interaction handling
the interaction holds the customId property of the button that was pressed
that's why it says Button__Interaction__#customId
instead of, say, ButtonBuilder#customId, if that were a thing
how do i access the property of that from the interaction variable then
you can only add once at a time, create() accepts many because you're creating the channel
if you don't know how to access properties of an object then you need to brush up js essentials, there are resources in #resources
but then again, I'm not sure how you managed to write the isButton check at all, that's how you access a property and then call it
but will that channel have same as the category? (the channel create in a channel)
im trying to console.log the interaction and its not giving me anything
if you use guild.channels.create that'll create the channel outside any category, unless you pass a parent
maybe that code doesn't run at all then
this is the old code
yeah just pass the name as well inside of the object and it'll work
it wasnt running. fixed it
like this?
there's no GuildChannel channel type
in runtime it'll read like type: undefined, and then it'll fallback to the default GuildText channel type
there's also no Permission class, and it wouldn't make sense for it to have a "gateway intents" property
and a "gateway intents" object surely wouldn't hold permissions like ViewChannel
that whole line doesn't make much sense
Out of the blue I'm having shards dying left right and centter. Did any breaking changes occur on Discord's side?
who should i write it then?
well, what type do you want
create a channel when someone react on another message. Its a ticket bot
yeah, but there's many channel types
though from your use case it sounds like you want a regular text channel
so GuildText
or just don't specify a type
since GuildText is the default
Question — I've seen music bots be able to give you like an infinite amount of options in command options, i.e. doing /play {song name} and it comes up with autocomplete options as you type.
Can something similar be done with string select menus and autocomplete? Or are string select menus strictly limited to 25 options?
No, select menus can’t be dynamic/autocomplete
👍 roger, ty.
hi
what's the color for invisible embed?
Do i need to imort something so its work?
sounds like you're accidentally calling it somewhere below
using ;s would fix that
Whatever the color of the client bg is, but given there are multiple, there's really no such thing
ok ty
still same issue
if it's the same error, the answer is the same
just in case can you console.log(guild)
in the guild.channel?
wdym?
in this?
no, you can't log inside .create()
or well, I guess you can but that'd be weird
log before that call
what should i look for? get this and alot more stuff
the first line says it's a client, not a guild
and exactly what that means?
that your "guild" variable isn't a Guild, it's a Client
client.channels.create() isn't a thing
so i should change to Client.channel and not guild.channel
no
you should get an actual Guild, not just call your variable guild
(naming it "guild" doesn't automatically make it a Guild instance)
Like GuildMessages etc?
I'm not sure what you're talking about
did follow this example
but in that example, "guild" is a Guild
your "guild" is a Client
so not the same thing
^^
the variable name is independent from what it actually is
you can't call a variable mee6BotToken and then expect it holds the mee6's bot token, for instance
Whatever you defined your guild variable as is incorrect, and is what you need to fix. If guild is a parameter of a function, then your parameter ordering is likely incorrect and is something you need to fix
Can someone fix this code for if u have a certain role (role id) in a discord server u be able to run the commands /db-add and db-remove ??
How do I do If I don't want to send a reply after a button is pressed? <Interaction>.deferReply() send the message "... the bot is thinking"
we can tell you what's wrong or how to do something, we won't write or give you the fixed code
since that's spoon-feeding and not learning
So my code u can't run /db-add and /db-remove if u don't got perms to ban in a server but it works if u got perms to ban in a server I'm trying to make it for it only works when u have a certain role in a server
you can deferUpdate and then it'll show an error after like 15 mins, at which time it's unlikely the user is still viewing the channel
ideally you should always let the user know their button press did something
not replying is not good UX
I'm making a menu
So when the user press the button, the message get edited simulating a changing of page
then reply with an update
(interaction.update)
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);
do i need to make like
let supportChannel = guild.channel.create?
Oh so instead of <interaction>.message.edit i do <interaction>.update
yes
Thanks
also message.edit won't work if it's an ephemeral message
check member.roles
Huh?
GuildMember#roles discord.js@14.19.3
A manager for the roles belonging to this member
GuildMemberRoleManager#cache discord.js@14.19.3
The cache of items for this manager.
and then .has(id) on that
I'm not sure how that replies to my message
I'm confused
look at the docs I shared
you need your "guild" variable to be an actual Guild
If I want to update a button, is better to create a new button and substitute the old one or edit the one that is already attached to the message?
you shouldn't edit the message if that's what you mean
like message.components[0].components[0] = newButton
Yeah I'm making a new button it's way easier
is there a specific stage when i need caching ?
caching is already built-in?
oh mb like custom cache sweeping
depends on your bot then
it's entirely up to you tbh
hmm i got like 700+ but my slow gets slow af after like a day uptime
First step would be checking you only use the intents you need
Next step checking what your bot actually does and if/what cache it relies on
Not having cache/sweeping it won’t make your bot faster. It might even make it slower because you need to fetch more
oh
alright thanks ill check it
Is there any way to detect what device a user is on? I have a 20-char ID, but found out it can't be copied on mobile, so I want to DM it to them only if they're on mobile...
If it's not possible I'll figure something else out, just wanna know if it's possible
this can be perfectly copied on mobile maybe try a codeblock?
if i pass an emoji object to a string does it automatically dfisplay an emoji when discord sends the message?
If it‘s an actual instance of the class, yes. If it‘s just a plain json object, no
accessing it inside my customEmojis collection
Those are instances of the ApplicationEmoji class, so yes
appreciate it, also would you sugger any changes to that code?
my friend told me i could just get emojis from this.application.emojis
Yes, that customEmojis collection is redundant
if i remove that would i need to fetch from app.emojis or u think id be good to just go with cache?
If you only remove the collection but kept the create calls like they currently are (which already check cache before doing so in your code) your cache would be accurate
appreciate it
is the AutoModerationActionExecution#channel the channel the action logs to, or the channel the matched execution was sent in? for example, if i log to #mod-only or something, and someone says something to trigger automod in #gen, does AutoModerationActionExecution#channel.id resolve to gen or to mod-only?
documentation suggestion for @ruby bane:
AutoModerationActionExecution#channel discord.js@14.19.3
The channel where this action was triggered from.
(So #gen)
yeah but that didn't seem to do what i needed either way
still weird, are you unable to read msg content from automod? its resolving, just not there:
override async run(message: Message) {
if (message.type == MessageType.AutoModerationAction) {
console.log("Automod msg");
console.log(message.content);```
logs:
Automod msg
""
well if you're receiving a Message, it doesn't sound like you're working with an AutoModerationActionExecution object
but you do need the MessageContent intent to receive the content for both the autoModerationActionExecution and messageCreate events
Okay, so originally i was using the Message check i just showed you, which didn't work, so then i tried AutoModerationActionExecution, which also just logged nothing, its like the bot wasn't noticing there was anything from automod (yes they can see the same channels, it has permissions, etc), so i moved backed to msgs
I have the intent, and everything about the code works when moved out of the message type condition, just when added to it, does not work (this code is to resolve discord servers via url).
could you show that you have the intent?
could you show your Client constructor?
i have about 4-5 other commands that rely on the intent.
you will also need the GuildModeration intent to listen to the autoModerationActionExecution event
as for the content, I imagine the AutoModerationAction message's content isn't necessarily the automodded message's content
Does ComponentType work for components v2 too?
yes
alr ty
found the issue, its not considered message content, but rather an embed description
You can control which entities receive notifications via the allowedMentions option. You can:
- Set a default on the client
- Set for a specific message
- Use the
repliedUserkey to disable in-line reply mentions
{ ..., allowedMentions: { parse: ["users", "roles"] } }
please try not to delete your messages, it disrupts support flow
Hello, please tell me how to make a button in embed not on the right opposite the text but at the bottom and several buttons?
you can't put buttons into an embed, at all
you can put an action row with buttons into a container
which is a components v2 thing
I know that, but I don't understand how to make not one button but several
just set more buttons in the action row
that's why the action row exists, to wrap many buttons (or one select menu) otherwise you'd just send the buttons directly
Make one button
Make another button
Two buttons

i said specifically "put an action row"
nothing new about that for past several years
the only new part is the one you're focusing on - single button as part of a section
that's brand new, and not what you seem to want
can you give an example or give a method with djs docs
Message Components: Buttons
read more
this is not it i need component version 2
you still wrap buttons in an action row in components v2
the only exception is inside an accessory, which is not your case
ContainerBuilder#addActionRowComponents() discord.js@14.19.3
Adds action row components to this container.
(in case it helps)
aaaah I get it, it turns out it's so easy
Where do I report bugs? I guess the issues tab right?
thanks
yes
happy to chat here first to make sure its actually a bug
it's kind of a bug, on the website, so a broken link is a better way to describe it lol
can you show what link you are referring to that is broken?
how come you're not using discord.js.org
1.11.1 
Its messing up the version number
Where were you linked from?
Builders?
Yes
Then I clicked permissions
We might have already known about this one, one sec
Actually yeah it works fine on the normal site
nvm no it doesnt
idk how it directed me to version 1.11.1
uhh yeah so
It works in 1.11.2
So Im saying fixed
thats fine, thanks o7
what's the difference between main and 14.19.3? prolly a stupid question lol
👍
main is anything thats been merged on GitHub
14.19.3 is the stable release
and main will eventually be released as v15
Or 14.19.4... or 14.20.0
wouldn't that be the v14 branch
Its all a mess now tbh
any previsions of what could be coming in v15
discord-wise? nothing, really. v14 supports everything already as of right now.
discord.js-wise is a bit harder to say, for what it's worth
Who says v15 is even coming at all
Is there a way for a message.reply() to not even ping the user (similar to how you can turn off a ping when replying while using a normal Discord user account), or can you only suppress the notification (via flags: MessageFlags.SuppressNotifications)
use allowed mentions
there's a field dedicated to exactly that in there
if i set allowedMentions in ClientOptions when creating the Client, do I have to set them again when replying to an interaction or message? and if I do, do they override the ones set in ClientOptions?
i’m fairly sure they’re overridden when passing in the message directly
can i keep selection menu in compnent v2?
yes
how?
Im not sure I understand the question
const section2 = new SectionBuilder().StringSelectMenuBuilder(...)
No, not in a section
They go in ActionRows as usual
And action rows can be added to containers
const section2 = new SectionBuilder().addOptions(
new SectionOptionBuilder()
.setLabel('Select a country')
.setValue('selectCountry')
.addComponents(selectCountry)
);
Where are you getting this code? SectionBuilder().addOptions() doesn't exist
copilot :/
i have const selectCountry = new StringSelectMenuBuilder(), how to keep it in section?
Ok. So don't listen to an AI on a brand new feature
You don't. A Section can't have a SelectMenu
Create an ActionRow, add the SelectMenu to the ActionRow...add the ActionRow to the Container
A ComponentsV2 Section is a very specific thing. It's text with an inline Button or Thumbnail...it's not just la sub-container to hold any component
thank you Samtino, have a good day! You explained so clearly
does discord.js automatically retry requests on network errors (like EAI_AGAIN) or do i need to handle that myself
on ws or rest?
though I think the answer is no for both, but I'm unsure how you'd recover from EAI_AGAIN
on REST
that'd mean that something is wrong with the network itself, far outside the control of the bot
yeah i dunno, i'm seeing it happen randomly
you probably should ask your host instead
also try to start with the issue itself (getting EAI_AGAIN randomly), not what you're trying to do (retry network errors)
it'll avoid https://sketchplanations.com/the-xy-problem
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildModeration,
],
})```
```js
const GuildMemberUpdate = {
name: Events.GuildMemberUpdate,
once: false,
/**
* Emitted whenever a guild member is updated.
*
*/
async execute(
client: Client,
oldMember: GuildMember | PartialGuildMember,
newMember: GuildMember
) {
console.log("update")```
The `GuildMemberUpdate` event is not emitted until the `second time` the event is emitted for a specific GuildMember. Is this a caching issue? I have the GuildMembers prescence enabled, so I don't understand the issue.
It is indeed a caching issue. If you specify the GuildMember partial, the event should then emit all the time
Popular Topics: Partial Structures
read more
if anyone is searching around this server because youre intermittently seeing EAI_AGAIN or similar in your bot, if your server uses systemd-resolved try using external resolvers like 1.1.1.1/8.8.8.8 directly instead
Hello!!!!
Thru the discord api, is it possible to get the connections of the user and a link to them?
Just from the user id, without the user connecting to the bot via oauth
Nope, oauth needed
Ah crap
Okay, thank you!!!
if you need it for roles there is an option in discord
No, for connections thru github
Yes, but what do you want to do with those connections if you were able to get them through API?
check how many commits a specific user has commited to a specific repo, and just mainly identify them by their github profile
would be easier than oauth, but like i could add a /connect command
I mean if it's a public repo, why not just get it through their public connection?
huh? wdym
is there a reason why the user needs to be authenticated?
yes, i just have to verify they are the owner of that github
you can link github to profiles
yes, but i dont want to manually verify them
so il use a connection with a connect command
alright
when building select menus, is .setDescription("") required?
If I remember correctly no
Just the label
is there a way to know if a guild's server insights are enabled? Doesn't seem to be in guild.features
Gm all. Is there a good resources on using components v2? I don’t see anything on discordjs.guide yet, maybe I’m missing it.
It's being worked on, there should be a pr
so ive noticed member tags are sniped in automod, but from what i gathered it prevent messaging? i mean in the server i saw the popup its reason was "tag" is there a way to know through the api if any messages get blocked or sent? Unless its just a member update trigger and not messaging?
Does anyone know if Components V2 has docs?
if anything from the member profile gets blocked, the user is quarantined - they cant interact with the server at all.
oh
of course it has docs
ContainerBuilder discord.js@14.19.3
A builder that creates API-compatible JSON data for a container.
can bots send interaction components on DMs as well, or only in slash command interactions?
components can be part of the message payload on regular sends, not just command responses
you need to make sure to set the appropriate message flag / query parameter (latter if webhook)
-# text
thanks goat
is it possible to react to a forum post (the actual post and not the first message)
with discordjs ofc
That’s the same in terms of API
Since the first message in a post is the post‘s starterMessage. The one shown at the top, containing the title and the reactions of the post
so if I react to that it looks the same as the default emoji you can select in the UI?
Hey How Can I Disable Send Message Perm But, Still Make Everyone To Use Slash Commands In A Channel?
Yes
great! tysm!
You can’t
I Don't Want People To Send Messages In The channel.. just a channel reserved For Slash commands. How Can I Do It?
you dont
🥺
Have a bot delete all messages sent that aren’t interaction responses. Or disable message history if you simply don’t want users to use it to chat
@steel trail
can you help me
also if you're new to js and struggling, learn the basics first. #rules 3,
start in #resources
why is the one error i get not in the list of websites
and that error would be?
Error: Cannot find module './config.json'
Require stack:
yeah this is just basic js
either the file path is incorrect or the file doesn't exist, really basic js
.
i have the file though
its isnt a djs issue regardless
i think i need to continue learning js first
Greetings! Is there a documentation for the new DiscordComponentV2 system?
ContainerBuilder discord.js@14.19.3
A builder that creates API-compatible JSON data for a container.
Thanks!
Hey there! Where could i see how this message is build, i couldn't find it in the source code? #announcements message
in the file attached to it
thanks!
can bot forward voice messages or copy their link like a video?
they can do both
voice messages are effectively just messages with an attachment
when i run node deploy-commands nothing happens
Did you write the actual code file? Did you forget the .js at the end?
Can I send a file with MediaGalleryBuilder or does it have to be a URL?
u sure? my bot cant see or copy the attachment link of a voice messages like the new discord function and showing every dm message it doesn't even show it
yes I'm sure
not sure which 'new discord function' you're referring to regarding voice messages, but feel free to share your code if you'd like help debugging
tag suggestion for @tepid maple:
Files in embeds should be attached via the message option object and referenced in the embed:
const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);
channel.send({
embeds: [embed],
files: [attachment]
});
^this can be applied to media gallery and file components as well
Ah great thank you!
ok so im talk about the voice message function where you click the microphone on mobile and then record an audio, even on normal client you cant copy attachment url
That's not really new, but yes that is what I was talking about
Bots can forward those, and they can still access the attachment's url
Is there a way to retrieve the thumbail of a members stream?
nope
thanks
no i wrote the code
- Do you have logging on your side to show if it actually worked or not?
- Have you restarted your client after deploying commands? (Ctrl+R) The commands cache on your client needs to be cleared for commands to show up
Also clarify on what that „nothing“ is that happens
Hi, who owns the DOC for the V2 components?
nobody "owns" it, what exactly is your question
Do you need a link to it?
is there a property in User for the new server tags
no
server tags are undocumented by discord, so we dont have it implemented.
you can however do a raw rest api call to get the user, which includes tag data
so the api also doesnt return them?
Nothing special, I just wanted to test these features
documentation suggestion for @strong garnet:
ContainerBuilder discord.js@14.19.3
A builder that creates API-compatible JSON data for a container.
thanks!
@snow onyx Thanks
I know this isn't like fully djs but is there anway I can stop people from using slash commands in DM's with my bot?
Or will i have to go into each command and do like (!interaction.guild)?
Set the contexts for the commands
SlashCommandBuilder#setContexts() discord.js@14.19.3
Sets the contexts of this command.
i got it to work
how to i prevent my bot from not working when my editor is closed
Did d.js recently update logic for command autocomplete? I had an autocomplete command that worked fine a few weeks ago, but I just realized it's been unable to process autocomplete options since I updated to the new version. I haven't changed any other code.
run it on a host
#resources has some
no
Can someone help me i am new on making bots can someone helo me from the start?
Home: What's new
read more
follow the guide
but make sure you know the basics of js first
Okay but i dont know do i need bot host or what
very odd then
most likely yes
Okay
I want to make utility bot so i hope it is not that hard😃
ty
wokring on a ticket bot and need to add this. What is the message reaction id and where should i put category id?
we arent 3rd party support
ask the creator
okay sorry
Hey there! I want to send a componentsv2 which is ephemeral, looked up the documentation and couldnt find how to use two flags, i am probably missing something. How can i use two flags for a interactions.followUp?
pass an array of them
right now i am using this, but the message is not ephemeral
static async onInteraction(interaction) {
let outputContainer = await CreateTicketComponent.create();
await interaction.deferReply();
await interaction.followUp({
components: [outputContainer],
flags: [MessageFlags.IsComponentsV2, MessageFlags.Ephemeral]
})
return;
}
I could be wrong, but I'm pretty sure you need to pass the ephemeral flag to your deferReply call.
Thanks, that worked!
what causes the data.embeds[0][LIST_ITEM_VALUE_REQUIRED]: List item values of ModelType are required error? Invalid embed array?
does discord.js support gradient roles?
i don't see it in the official docs
invalid embed, the full error and code would be useful for debugging
tag suggestion for @uncut mango:
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 see
is there any known knowledge about them?
you're pretty much on your own for finding undocumented features
and also on your own if you decide to support them and they break/get removed
well yeah
does Message.deletable represent whether the client user has the permissions / channel access necessary to delete the message, or does it represent something else
the former
Message#deletable discord.js@14.19.3
Whether the message is deletable by the client user
you can also check the code to see yourself what it actually checks if you want
mhmm. is there an easier way to find the function implementation? because command clicking on VSCode just takes me to the type definition, and then i have to ctrl+f for the function in the source js files
open the doc, click on the </> button
tysm!!
do SlashCommandBuilder BooleanOptions default to false if not passed?
they default to null
thx
Which channels don't have a .name property defined for them? Just DM channels right?
you could just check the docs
is there a way to figure out which functions throw what exceptions
yes, its a new feature they introduced called "Reading"
The error stack thrown and logged with the error tells you think
Hi guys.
How can i edit a container Component?
edit the message with the new components
I have problem only emoij reaction event
all events works fine, just the messageReactionAdd/Remove()
Message.edit?
yes
Didnt work. ( cant send error code im at work )
Or interaction.editReply
But yes, you just edit it normally
Hi,
I cannot fit all my data into a single InteractionCallbackResponse, so I would like to send multiple replies, except InteractionCallbackResponse doesn't contain a reply method.
So, how to reply to an interaction reply ?
Thanks
interaction.followUp()
ChatInputCommandInteraction#followUp() discord.js@14.19.3
Send a follow-up message to this interaction.
Amazing, thanks !
Does this method exist for normal messages too ?
Nevermind, I thought this method would always reply to the last reply rather than to the original command, I guess that's still fine.
However, is there a method that automatically choose between reply and followUp so I wouldn't have to make the ternary ?
Thanks
defer and then use followup
You can use followUp after a reply was created, or after the interaction was deferred.
Then the first followUp edits the reply and the second followUp sends a new message.
If i was making a multi-step command would interaction.followUp be the best to use to update question and possible answers?
Depends what "multi-step" here means
If you use buttons etc. you can just reply to the component interaction
is there a limit on the amount of buttons on one message
well, 5 per action row
and however many action rows you can slap into messages now
with legacy components its 5x5
Would you happen to have an example code please ?
Here's what I currently have :
const reply = (...args) => submission.replied ? submission.followUp(...args) : submission.reply(...args);
You should defer all interactions anyway
ButtonInteraction#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)
I'm sorry I don't understand, where should that be located, what should in practice be in then and what should in practice be in catch ?
Well, I'm afraid I also just don't know what the word "defer" mean 🤔
Slash Commands: Command response methods - Deferred responses
read more
Oh, so I should do deferReply then I can always use followUp ?
yes
Well, actually, that still throws InteractionNotReplied, so I'm still looking for a way to get rid of the ternary
show code
you dont need a ternary at all
const submission = await confirmation.awaitModalSubmit({
filter: _interaction => _interaction.user.id === interaction.user.id,
time: 5 * 60 * 1000
});
submission.deferReply().catch(console.error);
for(let i = 0; i < addedEmbeds.length; i++){
await reply({
content: i === 0 ? 'The following links were added:' : '',
embeds: [addedEmbeds[i]]
});
}
you arent awaiting the deferReply
Oh, so I can't parallelize telling it I'm thinking and doing the actual thinking
huh? you need to wait for discord to acknowledge the thinking state in the first place
Well, that means if my server thinks in less than 3 seconds, then the reply is actually delayed by having to tell Discord it's thinking
I suppose ideally I would fix this with something looking like this :
let isThinkingKnown;
submission.deferReply().then(() => isThinkingKnown = true).catch(console.error);
const
data = await think(),
reply = (...args) => isThinkingKnown ? submission.followUp(...args) : submission.reply(...args);
for(let i = 0; i < data.length; i++)
reply(data[i]);
```But we'd be back to more code.
You either do it with await defer or go back to your ternary, there isn’t really anything else
There's nothing wrong with "more code"
More code, assuming it's purposeful and written well, means more functional
If you want to parallelize it, you can technically store a Promise and await it later
const deferral = interaction.deferReply(); // dont await
const thinking = thinking(); // dont await
await Promise.all(deferral, thinking); // now wait for both to complete
await interaction.editReply({ whatever it thought about })```
or whatever order you want
Nice one !
Hi, I'm not too familiar with the new way of flags and I keep bumping into this weird type bug ? Is this an actual thing I can't do alongside ephemeral?
provide that flag in your editReply/followUp
It now doesnt let me use ephemeral
you dont need to provide ephemeral again
or rather cant, putting it in deferReply is enough
ohh okay ty
How to do confirmation.showModal after confirmation.deferReply() ?
You can't.
So deferring wouldn't be a good practice in this case ?
The modal needs to be shown immediately.
Well, I have a setValue in a modal input, and that data is from the DB
The modal needs to be shown in less than 3 seconds, so if that DB call is fast enough that may work, but its not guaranteed.
It does work, it's just since we talked about deferring being a good practice earlier, I thought I'd add it there too
to be sure you could have an additional interaction in between
Yeah, that may have been miscommunicated. Only if you plan on replying with a message. If you want to show a modal, you can't defer.
so your first, deferred interaction will retrieve data from your db, second interaction will show the modal
hello guys
let text1 = new TextDisplayBuilder()
.setContent('## :loading: Checking input data...');
container.addTextDisplayComponents(text1);
await interaction.reply({
flags: MessageFlags.IsComponentsV2,
components: [container]
});
const message = await interaction.fetchReply();```
how can i do for change what is writed inside text1 after i have sended a message?
text1.setContent()
and if i have just
const containerEdit = m.components[0];
and i want to edit the text1 what should i do?
Depends on what m is, if its a message you wont be able to run the method and change it, if its an actionrow or container or something then you can still do .setContent()
m = message fetched in the cache by id
Then youd have to turn the object assuming its a textdisplay component, into a textdisplaycomponent builder and then do .setContent()
oh shit, seems difficult
Or you can do containerEdit.content = "..."
oh ok
But I just find it easier to work with the class
not the classroom btw, the discordjs textdisplaycomponent class
ahahha
Youd have to provide code but possible reasons could be:
Multiple listeners, multiple instances
I’ve been reading the v2 docs but can’t find a way to make them inline….. any idea?
put them in the same action row
please take screenshots and not pictures with a camera xD
And that doesn't change my answer. When you add the button to the component, put it in the same action row as the other button.
Ohhhhh i read wrong
In v2 can we stack multiple accessory per section?
I can't answer that, haven't worked with v2 yet
I don’t think so
Mabe Im wrong but it doesn’t look like it’s possible to make them horizontally inline.
I would do…
container.addActionRow(
new ActionRowBuilder().addComponents(…)
)
I’ll try
So put the buttons in the action row first, then add the action row to the container
It doesn’t look like we can nest a v1 action row down inside a v2 container…
Mabe Im wrong……….
the "v1 action row" is the same as the "v2 action row"
You can.. this is my working code…
let buttonRow = new ActionRowBuilder().addComponents(
gameButtons.join,
gameButtons.status,
gameButtons.leave
);
test.addSeparatorComponents(separator);
test.addActionRowComponents(buttonRow);
And that puts them inline
Ooo alright lemme try
It has been working fine for me past few weeks, only issue I’ve found is that people with outdated app versions can’t see v2 components
It’s not working 😭
show the code and errors/wrong output
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const fs = require('fs');
const path = require('path');
// const { features } = require('process');
require('dotenv').config();
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildExpressions,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageTyping,
GatewayIntentBits.AutoModerationConfiguration,
GatewayIntentBits.GuildMessagePolls,
GatewayIntentBits.DirectMessagePolls,
]
});
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.login(process.env.token);
Heres the code
node index.js
/home/runner/workspace/node_modules/@discordjs/ws/dist/index.js:1151
error: new Error("Used disallowed intents")
^
Error: Used disallowed intents
Why am I getting this error?
Alright I got it!
Because you are using intents that your bot isn't allowed to use. Check on your bot's page in the dev portal, there's 3 that are priviledged and need to be turned on there as well, you are using at least one in your list (i just scanned quickly).
(i had already typed most of my answer, was that it?)
Yeah I just Checked now thanks!
ok, figured i'd post the answer to confirm and help others that could see your question and have the same issue.
how to make button works in dm?
Add it to an action row, and send the components… client.users.send(id, { content:”your message”, components: [actionrow]})
You can then use collectors, etc to grab the interaction and respond
const { EmbedBuilder } = require("discord.js");
const Event = require("../../structure/Event");
const { featuredChannelId, showcasechannelID, customStarEmoji, embedColour } = require('../../config')
module.exports = new Event({
event: "messageReactionAdd",
once: false,
run: async (reaction, user) => {
if (user.bot) return;
try {
console.log(reaction)
} catch (err) {
console.error("Error in messageReactionAdd:", err);
}
}
}).toJSON();
How do I get information on the message the reaction was placed on?
The reaction gets detected, but it doesn't have any of the information I need
as I take it server member applications aren't yet part of discord.js rght?
re they on the API yet though? lke is it possible to have an event trigger and f.e. send a notfication when a new request comes in?
It has yet to be published in the Discord API documentation
why am i not seeing the option? Small large etc????? when i put const separator = new SeparatorBuilder()
.setSpacing(SeparatorSpacingSize.Small)
its saying undefined
anybody know if its possible to forward messages from one channel to another after requesting the command
ooooooof, not even there -_-
well, thank you kindly
Your require should just be from “discord.js” not “@discordjs/builders”
it’s not a builder so it can’t find it
Ohhhhhhhhhhh
documentation suggestion for @copper trail:
Message#forward() discord.js@14.19.3
Forwards this message
If reaction.message is a partial, you can .fetch() it to get the full Message
@snow onyxhow would i create it as a command
like input the channel i want to listen to and have it send the messages there
Please stop pinging me, just ask your questions and when someone knows the answer they will respond.
sorry
is there any guide for changing gradients for role?
afaik it's not documented
can u tell with some example?
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
Is it possible to check if a channel is an "Announcement" channel?
While there might be a way for these features to work
Do you mean this with discord api or discord.js ?
documentation suggestion for @hexed marsh:
NewsChannel#type discord.js@14.19.3
The type of the channel
check the channel type
That's it, couldn't find that darned thing
this is support for d.js. we don't offer support for raw api requests here, you can ask in ddevs in #useful-servers
i mean i was asking if u meant which one, assuming u mean discord api
This is not a feature thats documented by discord in the discord api, thus discord.js is not adding this as a feature until it is.
ok ty, any expected date?
ask discord
😭 ok
Do you know how I can check if its a partial or not?
Popular Topics: Partial Structures
read more
Thank you
I've got them in both my intents and my partials? Does that mean I can use the fetch method?
You can always use the fetch method regardless if you have partials or not
Right I see, so something like this?
const { EmbedBuilder } = require("discord.js");
const Event = require("../../structure/Event");
const { featuredChannelId, showcasechannelID, customStarEmoji, embedColour } = require('../../config');
module.exports = new Event({
event: "messageReactionAdd",
once: false,
run: async (reaction, user) => {
if (user.bot) return;
try {
if (reaction.partial) {
try {
reaction = await reaction.fetch();
} catch (err) {
console.error("Failed to fetch reaction:", err);
return;
}
}
if (reaction.message.partial) {
try {
reaction.message = await reaction.message.fetch();
} catch (err) {
console.error("Failed to fetch message:", err);
return;
}
}
console.log(reaction);
} catch (err) {
console.error("Error in messageReactionAdd:", err);
}
}
}).toJSON();
i cant seem to the message to work
gonna need to be more specific than that
sorry discord didnt load previous message so i thought i was still on my convo. anyways when i try do the message forward method it doesnt seem to work
is there documentation yet for the new role style colors?
no
again, you need to be more specific. "it doesn't seem to work" is not enough to give support. please read #how-to-get-help and follow its suggestions when asking for support
could you share the code you are running and elaborate more on what you mean by "it doesn't seem to work" like error that is printed to the counsel
Why Isn't Embed Showing Mentions Properly?
yes give me a moment
it is a cache issue. Your discord client does not have those users cached. cant do anything about it *opening the user's profile should cache them and it will appear as intended
Embeds don't contain user data in the message like normal mentions do.
However, if you use ComponentsV2, then user Mention data is included in the message so it will both ping and be able to click to see full profile of users
const { SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('messages') .setDescription('Forwards messages from one channel to another.') .addChannelOption(option => option.setName('source') .setDescription('The channel to forward messages from.') .setRequired(true)), async execute(interaction) { // interaction.guild is the object representing the Guild in which the command was run await interaction.reply("Here are the messages from the source channel" + MessageChannel("source")); // interaction.guild.channels.cache.get('source') is the channel object representing the source channel }, }; this is the code that i have for a slash command but when deploy and test it in my server it responds with an application error
Are you getting any errors in the console? If not, then your command handler is likely the issue
I'm Fetching The Member Before Mentioning It
your app client !== your user client
sorry not the bot cache but the Discord App its self
Embeds don't contain user data
Ohh
So, I Can't Do Anything About It? it's Specific To The User Who's Viewing This Embed
ya the the app displays the user id whan the user is not cached
nothing in the debug console
no you as a dev cant do any thing, yes it's Specific User Who's Viewing the mention
Ok. So your file is never being run. Can you show us your command handler?
wdym by command handler, im newer to java script so not familiar to all the terms.
https://discord.com/channels/222078108977594368/1370478227872551032
Like I said, you can use ComponentsV2 instead...it will fix your issue and look practically identical in this example since you're not using embed fields
guide suggestion for @copper trail:
Creating Your Bot: Event handling
read more
I'm Actually Using Embed Fields
you could use markdown in a textDisplay component. might be worth a shot to test
I have been using cv2 and so far real happy with the resalts
Oh. Well on mobile you can't really tell (I'm assuming you mean that you're using inline)...but still, I would recommend CV2 if you want to list users who might not be cached
bruh i did everything and it still didnt work. command handler is the same
output is nothing
tag suggestion for @copper trail:
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
your going to need to work though why you command is not being run by your handler
also in the Discord client I assume you are seeing "The application did not respond" message is that right?
yes
from what i have seen it works up until i enter the command
what do you mean by work? do you have other commands? or actions related to events
Go to your client.on("interactionCreate") and add console.log(interaction) or something similar to see if your command handler is even doing anything
Just because the code exists, doesn't mean it's running
this message is pin worthy
but anywas im gonna have lunch and try to figure out whats wrong. I have realized that i cant keep asking people for help and not learn it myself
hey quick question is there anyway for my bot to add another bot into a server?
no
does components v2 have any coloring options for sections like legacy embeds had that color bar?
documentation suggestion for @half night:
ContainerBuilder#setAccentColor() discord.js@14.19.3
Sets the accent color of this container.
yes
thank you 
can i do this too in components v2? container does not have .setAuthor so i am asking if there is something familiar now?
no
so i cant do this little image thingy up there? only in regular embeds?
correct, the author property does not exist on the container in cv2
ok thanks
Guys how do i check is a message has a mention?
message.mentions.has() always says false
What kind of mention
user mentions
I think that is right?
https://discord.js.org/docs/packages/discord.js/main/MessageMentions:Class
But if i mention someone its still false
Does your bot have MessageContent intent?
yes, also all the guild intents
Is there an easy way to see if an interaction has already expired?
Show your code checking the .has()
module.exports = {
name: Events.MessageCreate,
execute(message, client) {
if(!message.author.bot){
console.log(message.mentions.has());
}},
};```
Try to reply to it and catch the rejection. Or calculate the time since interaction.createdTimestamp, but that relies on your server clock being in sync with discord‘s. What’s the use case?
There’s nothing in your () so ofc it won’t check anything
.has() needs a UserResolvable | RoleResolvable | ChannelResolvable
Currently, I do .update on a button interaction, but then get a 404 back.
Great, then catch that and you know
Are you sure it expired though? What happens in discord itself?
I'm not sure it has expired, that was just a guess
Do you want your code to check for a specific mention or if there was any mention at all?
Just check for user mentions
message.mentions.users.size > 0
If you just want to check if any user was mentioned
And how could I check is my bot is mentioned?
Does anyone understand in Sql database and can help my question in #1374458927193788436 please 🙂
Pass the client.user.id into the .has(…) as parameter
Is it practical to go over all mentions, or just parse from the message content?
Don’t crosspost, even less if not djs related
I just tried to upload an emoji to the developer portal and changed the emoji ID in my bot code to the new ID that's in the portal (replacing an emoji ID that's in a private server) and didn't change any other code. it worked before changing and now it doesn't. I get error: "Emoji must be a string or GuildEmoji/ReactionEmoji"
My bad I didn't know
Show your changed code. ids are strings, the error suggests you didn’t pass a string
const { deleteEmojiId } = require("../../config.json");
declared then later called:
const reactionEmoji = await client.emojis.resolve(deleteEmojiId)
This code worked perfectly before. All I did is change the ID number stored in my config.json file
Does DiscordAPIError[10062]: Unknown interaction mean anything to you? Are there any explanations for the codes?
Because all I get is that and 404 - Not Found, which comes up in the REST.Response.
Is it a string in the config.json though?
Oh, wait, why do you use client.emojis.resolve?
client.emojis only contains GuildEmoji
documentation suggestion for @verbal plinth:
RESTJSONErrorCodes discord.js@14.19.3
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
It only says Unknown interaction which I already know
Common causes of DiscordAPIError[10062]: Unknown interaction:
- Initial response took more than 3 seconds ➞ defer the response *.
- Wrong interaction object inside a collector.
- Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance)
* Note: you cannot defer modal or autocomplete value responses
interesting. So what should it be to call the emojis uploaded to the developer portal site
Which is why I asked what happens in discord
In Discord it says that the interaction failed, nothing else happens.
yo bro
Then it‘s the first bullet point most likely
I think I found a bug in the discord.js module
Why do you want to resolve it in the first place? What are you doing with the result afterwards?
discord sends all mentions, so checking .mentions.users.size like you were told is absolutely more than enough
it would work just doing message.react(deleteEmojiId) right?
And what would that be?
sweet thanks
when I delete a channel but do not respond to the interaction, I get an unkown channel error, and I should probably get an interaction error
is the interaction deleting the channel it was used in?
yes
In that case the error is correct
You try to reply in that channel, but the channel does not exist anymore
no
I think we don't understand each other
Show your actual error with stacktrace and code then
unless it's my bot's fault, never mind
should i always defer command replys ?
another thing if my command fetches data from my database would you recomened defering the reply ?
You should defer before any async tasks, yes
Hello, I'm currently making a bot, and I want it to be able to play songs from Youtube. Is there any way to fix this? Because right now, what I have is this:::::: Sign in to confirm you're not a bot
no, that violates the youtube tos
thank you so thats every command as it all uses async just to make sure what you mean /