#djs-help-v14
78874 messages · Page 6 of 79
If I send the URL in the message content
If you only send the URL it should do that, yes
There's other content in the message
Then what you ask for needs (an actual embed or) components v2 with a media gallery having one single item
//admins
let serversAdmin = servers[0].filter(guild => (guild.permissions & 0x8) === 0x8);
for 'manage server'
(guild.permissions & 0x20) === 0x20
20 or 32?
just use the enum
v10: PermissionFlagsBits
read more
Got a TS question, Property 'cache' does not exist on type 'GuildMemberRoleManager | string[]'. Property 'cache' does not exist on type 'string[]'.
This is what I am trying to do,
interaction.member.roles.cache.some((role: any) =>
[interviewData.createRole].includes(role.id)```
Use interaction.inCachedGuild() typeguard before trying that
And definitely remove that any there
Got it
Why does client.application.commands doesn't include any commands? I know for certain that I have application commands
Because you didn’t fetch them. Cache only has what the API sent at least once
So await client.application.commands.fetch()?
Doing that once would cause your cache to have all commands for the lifetime of the process, yes
Still doesn't fetch anything. how would I go around fetching all application commands for a command info command? (like an help command)
Then you don’t have any global commands deployed (at that time)
That's the weird part, I certaintly do. Checked acroos a few servers
Show your code
The part where you fetch and the part that makes you say it didn’t fetch anything
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[50035]: Invalid Form Body
options[0].required[APPLICATION_COMMAND_REQUIRED_INVALID]: Required cannot be configured for this type of option
name: "art",
description: "يُمكنك كتابة اسم بطاقة معينة للحصول على صورتها فقط.",
options: [
{
name: "name",
description: "name of the card",
type: 2,
required: true
}
]
is there any problem with this ?
i wanna the option be required, must i remove the type or i can use another type ?
That’s a subcommand. Subcommands are always required
so i don't need to use type ?
You probably meant another type. Which is why using the ApplicationCommandOptionType enum would be better
You do. Because I doubt you want name to be a subcommand
no, i wanna it required,
this will do great?
type: ApplicationCommandOptionType.String,
required: true
Yes, now the type is correct
well as i create a command, i can't see it in the App
Then you didn’t deploy it yet
Reload your discord if you did deploy
thanks, It shows now
uh...?
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
i literally took this from djs tutorial...
The tutorial isnt written in TypeScript though
true
but wouldnt Client still be the same type of object?
Yes. But JavaScript won‘t complain about it
thats crazy 💀
okay
thanks
Well... yeah. Its an object with no commands property
So in a loosely typed language (JS) you can just add it by pretending it exists
In TypeScript you cant
You are also directly mutating a client property that should be immutable. I would recommend you don’t do this.
art command used by Astax
TypeError: Cannot read properties of undefined (reading 'description')
```?
show the full error
Whatever you're trying to call .description on is undefined
typescript ?
Huh? No they don’t
Yeah if you check the screenshot that are creating client and then directly mutating the property commands which is an anti pattern in typescript.
there is no commands property on a client. Its added by the user
and recommended by the guide to do so
in typescript it requires casting or augumenting
How can i turn <Message>.components into their respective builders i thought i could do the following but this expect a API type instead of TopLevelComponent
const components = i.message.components.map(c => new ContainerBuilder(c));
c.toJSON() to get that API type
I tried but it still complains
https://i.jarco.dev/7MuhOEdz.png
Well, you‘d need to cast or better type check that it‘s a container before
You indeed can’t make a ContainerBuilder from non-container data
isn't every component in message.components a container?
I thought it was looking at the docs but idk still very new to how it works now i haven't touched discord.js in a little while
No. A container is the embed-like border. You don’t have to put stuff in a container
Oh wait yea i see it now my bad
I just have to make a parser for the builders with in TopLevelComponent idk why i thought what i did 🤣
createComponentBuilder discord.js@14.19.1
Factory for creating components from API data.
Just use that
Mention in case you already started working on it and didn’t check here anymore
Yea i saw it but trying to make sense of it my brain isn't braining
.map(createComponentBuilder) should do the trick
is there a way to make commands dev only? or do i just individually filter out any command via user id or create a wrapper class for it?
when are docs being updated for containers
They already are?
maybe you've got the wrong version selected but they are uptodate for me
like how embeds are on the docs?
Deploy them as guild commands to your dev guild only
Ah yea that did the trick thanks
Are you talking about the docs? Or do you mean the guide?
guide
How would i go from this back to something i can sent using <Interaction>.reply? 🤔
was stuck on it for 5min and ofc i figured it out as i sent that i forgot to remove the [] i had around it before cuz i used to just pick and update 1 component instead of parse all of them 
updatedComponents.map(c => c.toJSON())
how to get such command list in bio?
added automatically by discord when your bot is verified
thanks ✅
You can pass builders to send directly
I tried but it wouldn't accept the output of createComponentBuilder as input for components on a message
It doesn’t? 
Can you show the error?
const updatedComponents = i.message.components.map(createComponentBuilder);
i.reply({ embeds: [updatedEmbed], components: updatedComponents });
Text Inputs are not allowed in messages, that's why
ah yea that explains it cuz it just assumes all components
how can i fetch user by username?
import { REST } from "discord.js";
import { API } from "@discordjs/core";
const rest = new REST({ version: "10" }).setToken(token);
const api = new API(rest);
Property '#private' in type 'REST' refers to a different member that cannot be accessed from within type 'REST'.
only happens after updating to the new djs
why do you have djs and /core?
not possible, at most you can search a member in a guild by its username
GuildMemberManager#search() discord.js@14.19.1
Searches for members in the guild based on a query.
Can I have a ChannelSelection dropdown in a modal yet?
no
Okay thank you
is there documentation for in what cases guild.channels.fetch() errors?
to make api requests without logging into the gateway
but you only need /rest for that
and that's inside djs
how can i do it with djs? API isnt exported from djs
Creating Your Bot: Registering slash commands - Resulting code
read more
you don't need API
huh? im not registering slash cmds
there's an example there on how to use rest
the example happens to be for registering commands
but it applies to any endpoint
I mean if you want to use API that's perfectly fine, particularly if you're in some environment where you need to use @discordjs/core/http-only
however in that case, you should just import REST from @discordjs/rest (which /core depends on)
there wouldn't be a need to install discord.js at all in that case
const botUser = await rest.get("/users/@me").catch(() => null);
the type for botUser is unknown when i use the djs module
i use djs too
i just want to make single api requests to other bots
you can type it with dtypes
how
const foo: T
then the question is, why do you need to make these requests without logging into the gateway if you're logged into the gateway?
custom bot service. i need to validate their tokens
Type 'unknown' is not assignable to type 'PartialUser | null'.
type assert then
got it ty. users/@me is PartialUser right?
I think it should be APIUser
ahh ok
btw if other people are giving you their tokens, that's against the tos
ehh i mean botghost and stuff does it
doesn't make it less against the tos
i understand, ty
what is the maximum value that .setMaxValue() can be passed? (for a SlashCommandBuilder definition of a .addIntegerOption())
Learn more about slash command limits at the Discord Developer Documentation
Hi, Is there a way to get the moderator who moved a member from Channel A to Channel B in a voice? I can detect when a user moves themselves to another channel, but when someone else does it, I can't fetch that information
No
Do we use .publish() to publish message?
Message#crosspost() discord.js@14.19.1
Publishes a message in an announcement channel to all channels following it.
// Crosspost a message
if (message.channel.type === ChannelType.GuildAnnouncement) {
message.crosspost()
.then(() => console.log('Crossposted message'))
.catch(console.error);
}
okay
Can we set max character for slash option?
okay we can
Does anyone know of a way to properly schedule repeating tasks?
Should I just use a setInterval after the bot is ready and logged in?
depends on your task
djs doesn't have anything for that though
Okay wasn't sure if there was a task manager of sorts or not.
is there a type for Guild.toJSON() and GuildMember.toJSON()? I tried using APIGuild and APIGuildMember but then <member>.permissions isn't a thing with that typing
(im using broadcast eval so they're serialised)
That would be correct
what would?
Member.permissions doesn’t exist on the json-serialized object
but its a GuildMember serialised, does it not return even the bitfield? only because member.roles are an array of roleIds
D.js calculates it for you based on the roles
It represents what Discord would’ve provided
i had the assumption that djs would turn permissions into just the bitfield number as it cant parse the permissionbitfield class
so is there a difference between APIGuildMember and <GuildMember>.toJSON()
in terms of properties
because obviously <GuildMember>.toJSON() has the ability to parse the calculated permissions
Yes
yes? to what?
how to run a bot with a prefix?
👆 there is a difference
i don't want a / cmd bot.
Best case: don’t
Less good case: parse the string that is message.content any way you like
so for my original question, is there a unique type for <GuildMember>.toJSON() because APIGuildMember isn't accurate?
why wouldn't I?
I don’t think there’s a type for it
In the types, it’s unknown
Because it’s not worth the effort, won’t get approval by discord to work in more than 100 guilds, is way harder to implement and use, …
What’s the use case?
in my opinion its better.
using broadcast eval to retrieve a member from a guild and check if they have permissions
const member = await sharder.fetchGuildMember(guild.id, userId);
if (!member?.permissions.has(PermissionFlagsBits.ManageGuild)) return res.status(403).json({ message: 'Missing Permissions' });
public async fetchGuildMember(guildId: string, userId: string): Promise<APIGuildMember | null> {
const member = await this.manager.broadcastEval(async (shard, { guildId, userId }) => {
try {
return await shard.guilds.cache.get(guildId)?.members.fetch(userId);
} catch {
// todo
}
}, { context: { guildId, userId } }) as APIGuildMember[];
return member.find(Boolean) ?? null;
}
in the process of sharding my bot, currently using the type APIGuildMember until i remembered that serialised GuildMember !== APIGuildMember so when checking member's permissions, I won't have to calculate their permission bitfield from roles
Would probably be better to do the check in the eval and only return the boolean
that is probably true but I would reuse this function in other places where I need the member properties
Sending full structures over IPC is big overhead
i need to do .toJSON() still
No
?
If you do the check in the eval you can use djs methods on the instance
.permissions.has(…)
i understand that but i could just do
new PermissionsBitField(member.permissions).has(...)
assuming member.permissions exists on GuildMember.toJSON()
It does. But that adds even more overhead now
broadcastEval should transfer as little data as possible between shards for scalability
so you recommend having another helper function to check permissions specifically? what about in cases where i need the member object and to check their permissions?
i could also edit this broadcast eval function to only occur on the cluster containing this guild by parsing a cluster id
What cases are there where you need the full member „object“ (aka the json structure you get out of it) on a shard that member isn’t on?
Yes. That should be done too, independently of this
it's for my website, to check if the user has permissions to do X action, and i need their member object for database, logging purposes etc and for my anti-spam system which uses their member data for a scoring system
Thats your opinion. Just know you wont get approved for the intent
is there any way i can return the person who executed that command when i click the button?
if the interaction is cached, interaction.message.interaction.user I believe
Message#interaction discord.js@14.19.1
[DEPRECATED] Use interactionMetadata instead.
ah, use that instead I guess 
okay thanks
Hello!!!
Uhhhh for PM2, it says this, pm2 start your-app-name.js, and i was wondering how thats gonna work?
Is it like, the app name on discord, or the folder?
How is that djs related? Look at pm2 docs for that
I dont know- it was in djs docs.
pm2 is a process manager
it's not related to djs itself
it manages any node process, a bot happens to be one
Okay. Sorry.
as for your question, it't most likely index.js
it's whatever your start script is
Okay. Thank You!!
Are you responding to the interaction? Show your interactionCreate event handler
Is there a guide page for d.js components v2?
Wrap it in a try-catch to find the error.
Not yet
I don't think so, but there is a PR up on the github repo for it. I think
Is there an ETA?
When it's ready
Makes sense, but ETA = estimated time
ooof here we go xD
You can also download the data used to make the v14.19 announcement
Aighty
It is not related to your error but in the replies you should use flags: MessageFlags.Ephemeral instead of ephemeral: true as the ephemeral option is deprecated
where can i view all the functionality of components v2?
By reading the docs, but most use https://discord.builders to have a visual representation
how do i deal with a ```typescript
class APIInteractionDataResolvedChannelBase
when i receive it from Interaction.options.getChannel(); ?
it doesnt have most channel attrs
hey quick question how do i get defaultMemberPermissions to work on sub commands?
subcommands and subcommand groups are part of the larger application command. it can only be set at the top level
ok cool so if i make a command called x then all of x's sub commands are going to follow the same perms?
yes
can i do that with roles also?
Not in the bot. An admin could do in the permission override for the command
ah okay i was speaking more of the UI side i dont really want to show commands that user's can't use
That is what I mean if a user is not permitted to use the command by default permission or override it will not be displayed to them
ah okay so i have to write a check anyway for perms 
I dont. If the user can use the commanded then they can use it. set the default permission for what is needed to manually preform the action. then if the server owner want a role without the perms to use it they set that in the override
i see yeah but for me it's kinda weird because i have setup commands that only admins can use and also commands that are user based within like same module ig
It should return d.js structure like TextChannel, CategoryChannel, etc if it is in cached guild otherwise you can only get that information as you can't fetch channels your bot is not in
best way to handle it is to split them. else you will have to do the perm check
so that means that object is a channel my bot cant access?
i see I just thought of a way I can work around this thank you again love u
np, best of luck
It doesn't necessarily mean that. It maybe that typescript is inferring that interaction can be in uncached guild so it is showing you that type. So you should have typeguards for that, like interaction.inCachedGuild(). But if the interaction is recieved from unchached guild, then yes you'll only get that information. Be that due to your bot not being in that guild, or not having bot scope or missing guilds intent (in this case though, you maybe able to fetch the channel if the bot is in the guild)
how does someone invoke an interaction from my bot in a server it is not in?
User app
mines not a
Then you should use the typeguard I said to narrow the type
BaseInteraction#inCachedGuild() discord.js@14.19.1
Indicates whether this interaction is received from a cached guild.
ok thanks
index.d.ts(631, 53): 'fetchReply' is declared here.```
Why do I get this errors on a message reply?
Show the full error, that is usually a suggestion not an error (also the code)
can you show the full error, this says almost nothing
ooo i had issues with this too
did you fix it?
i ended up not using that method at all
can we get the call that this appeared on too?
And the code?
const msg = await interaction.reply({ content: ``, embeds: [embed], flags: [MessageFlags.Ephemeral] });```
Hey y'all. I may be blind but I don't see this in the docs anywhere, but is it not possible to do message.reactions.removeAll() in a DM channel? I keep getting an error for that, so I assume the answer is yes, I just don't see it documented.
Whats the error?
Pretty much what I said, it's a DiscordAPIError[50003]: Cannot execute action on a DM channel error.
I just find it extremely odd that I can't remove a bot's own reactions in a DM channel.
Well it can remove its own reactions, maybe you are trying to remove the other user reactions as well
it's the same as with bulkDelete
even if you would pass only your bot's messages to it, it's not a valid method on a DM channel
remove your bot's user from the reaction, one by one
or consider using buttons instead
the reactions are just a simple validation check, so the user sends something to the bot and the bot adds a check or cross reaction just to confirm validation. there is one instance where the bot will do something like "Did you mean....?" and if you click yes, then it should switch the reaction over.
but also noted
Instead of reaction just make two buttons with the emojis only. this will allow you to manage it way better in dms. *You can also play with the colors 😉 *
can disable the buttons too
but at this point it's mostly stylistic decisions and opinions
the reactions are functionless. they just exist as a validation to let the user know whether or not their input passed through. here's an example:
disabled buttons are also functionless
OH i see what y'all mean now
for an example of a DM from a bot
it's a disabled button
honestly, good idea, i'll use that. thank you
What is interaction typed as? Because the error suggest it can be both a message and an interaction in which case the error makes sense
Yeah basically... my old npm package I am rewriting was accepting both interactions and messages for the same things and it was compatible with both types. So interaction has both types. I am thinking of seperating each type in its own file
Yeah, so message reply cant be ephemeral, hence the error. You need to narrow the type to an interaction
so basically if I rewrite it to work with this types:
interface BaseTypes2048 {
client: Client;
embed: Embeds;
emojis?: {
up: string;
down: string;
left: string;
right: string;
};
othersMessage?: string;
notifyUpdate?: boolean;
time?: number;
}
export type Types2048 = (
{ message: Message; interaction?: never } |
{ interaction: ChatInputCommandInteraction; message?: never }
) & BaseTypes2048;
it should remove the error
can messages reply be ephemerals?
No, I believe only interaction replies
okay thanks
hey i need help.
what's wrong here ? :
message.mentions.id.first();
in future, please elaborate on what makes you think something is wrong (e.g. any errors you may be receiving)
however in this case, <MessageMentions>.id doesn't exist
were you looking for <MessageMentions>.users.firstKey() (since it's keyed by user id)?
im not in interaction im on message cmd.
I don't see how that's relevant to what I said
just saying.
that's great
there aren't any mentions in interactions
`module.exports = {
name: "deban",
description: "déban un membre du serveur.",
async execute(message, args) {
if (!message.member.permissions.has("BanMembers")) {
return message.channel.send(
"Tu n’as pas la permission de débannir des membres."
);
}
const user = message.mentions.users.firstKey();
if (!user) {
return message.channel.send("Tu dois donner l'id de l'utilisateur à débannir.");
}
// 🔒 Empêcher de se bannir soi-même
if (user.id === message.author.id) {
return message.channel.send("Tu ne peux pas te débannir toi-même.");
}
// 🔒 Empêcher de bannir le bot
if (user.id === message.client.user.id) {
return message.channel.send("Tu ne peux pas me débannir.");
}
// 🔒 Vérifie la hiérarchie des rôles
if (user.roles.highest.position >= message.member.roles.highest.position) {
return message.channel.send(
"Tu ne peux pas débannir quelqu’un avec un rôle égal ou supérieur au tien."
);
}
// 🔒 Vérifie si le bot a le droit de bannir cette personne
if (!user.unbannable) {
return message.channel.send(
"Je ne peux pas débannir cet utilisateur. Il a peut-être un rôle plus haut que moi."
);
}
const reason = args.slice(1).join(" ") || "pas de raison";
try {
await user.ban({ reason });
message.channel.send(
`${user.user.username} a été déban pour ${reason}`
);
} catch (err) {
console.error(err);
message.channel.send("Une erreur est survenue lors du débannissement.");
}
},
};`
@halcyon bison
I don't know what you want me to do with this
it doesnt work so do you know what's wrong?
in future, please elaborate on what makes you think something is wrong (e.g. any errors you may be receiving)
the commands doesnt work that's why.
it says "give the id"
ok I can't read french, but I'm going to assume that's the second if statement
it is.
I had assumed that when you did message.mentions.id.first();, you were looking for the id
currently, user is the id
therefore user.id is undefined since <string>.id doesn't exist
if you want the User object, you should just use <MessageMentions>.users.first()
however I notice you're also attempting to treat this user as a GuildMember, so I imagine you'll probably want <MessageMentions>.members.first() instead
its for unban someone if it helps.
that doesn't change what I said, no
i need help
see why we recommend slash commands? you wont ever run into these issues
npm i dotenv?
everything works except this.
its nodemon. not djs related
real
is that ai code
because you cannot ban a user like that
the ban works perfectly bro, its unban.
user.unbannable
so why are you banning them then
yea?
where did you get that property from
did you write that code
i dont think so
wrote it myself.
but like, this isn't a shooting range. writing random stuff won't really result in working code
did you see this property somewhere?
yea like there is user.bannable.
no there isnt
a user isnt a GuildMember
there is.
which is also one of your issues
Show me
i did it and it worked.
because your user was a GuildMember
not a user
and what is user defined as here
please do console.log(user.constructor.name)
then what should i do?
and show the result
you call it on the GuildMember first of all
where?
in that code
just to see the result of it
and you should know what code you write if it isnt ai code
your ''unban'' command just bans
yea but at what line?
(I've already mentioned what you should do to get a GuildMember for your unban code)
any
as long as it's after you define the user
doesnt show anything.
though actually now that I think about it, a banned user will never be a GuildMember, so coming back to what luna said
you can't handle it that way in the first place
you will need the User or their id, and instead use <Guild>.bans.remove()
then you didn't put what i said in a line that runs
const user = MessageMentions.users.first();
if (!user) {
return message.channel.send("Tu dois mentionner un utilisateur à bannir.");
}
console.log(user.constructor.name)
// 🔒 Empêcher de se bannir soi-même
if (user.id === message.author.id) {
return message.channel.send("Tu ne peux pas te bannir toi-même.");
}
...
sigh
Explaining <Class> and Class#method notation: learn more
you seem to be lacking basic understanding of js
im starting yea..
not to mention you refuse to use slash commands, which would have tackled this issue in seconds
#resources then, learn it first
you're just wasting our time by making it yourself very hard by refusing to use slash commands and not understanding what you are being told
what's the new "ephemeral" for interaction.reply?
The ephemeral option when replying to an interaction will be removed in v15
- {..., ephemeral: true}
+ {..., flags: MessageFlags.Ephemeral}
``` Read [here](<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR>) on how to specify multiple flags
thanks
i asked chatgpt but im not proud i wanna understand it.
chatgpt doesnt help at all
i dont know what to search..
the basics of javascript
i can use it like
await interaction.reply({
components: [containerRules], flags: ´[MessageFlags.IsComponentsV2, MessageFlags.Ephemeral]
});
}
yes
I'm also not sure where in #resources you see a search bar
I do however see a section titled Learning JavaScript and node.js
alr sry.
I swear you can also do .IsComponentsV2 | .Ephemeral ? Like use | ?
yes
where?
...nowhere
talkin bout this sry.
i have to read all of it?
yes
alr.
Hey!
I'm looking for ways to improve how I handle component creation and interactions. I was wondering, how do you guys manage it? Is interaction.customId the only way you use to identify which component was triggered? And if so, how do you usually generate a unique customId?
this isn't really the place to ask about general conventions/standards
ultimately how you generate your custom ids is entirely up to you
but yes the customId is what you would use to identify the interacted component
and I do often recommend using a previous interaction's id as a nonce in the custom id assuming this component is being sent in response to an application command or something
hello i'd like to ask if it's possible to filter out users in UserSelectMenu to show only those available to select?
-# i mean, i have warnlist command and I want specific users to be shown here, so like if I have user X displayed in embed, I'd like to be able to select it from user select menu to view more details about their warn cases etc.
no you cannot
that's sad :/
I think you can achieve something like that with command option + a autocomplete interaction
that's what I'm actually trying to accomplish
The fetchReply option when replying to an interaction will be removed in v15.
- {..., fetchReply: true}
+ {..., withResponse: true}
```This returns an [InteractionCallbackResponse](https://discord.js.org/docs/packages/discord.js/14.17.3/InteractionCallbackResponse:Class)
Use `<InteractionCallbackResponse>.resource.message` to get the message
@fair prairie please use #app-commands for personal use of the bot
sorry but i was just checking something that happened to me lately and i'm still figuring out where is the issue exactly. I didn't notice the room i was typing on
no worries, just for future
appreciate it ♥
For the devs passing by this message.
please i want to ask you about the interaction editReply and the the followUp.
my code is working perfectly and was responding normally to the interactions, but lately i noticed that he wasn't able to respond to the interaction.deferReply({withResponse: true}) no more.
i tried to debug the code and console.log every step the bot is passing by, and everything seems normal, until he reach the interaction.followUp/editReply he can't send it. even if the console mention that it does so.
btw the interaction.channel.message.send works and the interaction.reply works too.
so my question is: is that issue caused by some discord limitations or something else?
Additional: The bot is verified and it's on more than 30K servers and all the intents are enabled
In what way cant it be sent? Is it erroring?
not at all, no errors, even the debug shows no kind of issues
It seems odd that interaction.reply works - it shouldnt work if you deferred
Are you awaiting the calls?
yes i do
as you can see from this simple of the console.log
it does perfectly send the response
but doesn't appear to do on discord
Uhh, all that shows me is it being deferred
But are you saying it doesnt appear deferred on discord?
it's confusing i know, the interaction is perfectly deferred but the followUp/Edit doesn't happen
Can you show your code please
sure and i'm sorry if it's breaking Discord TOS in some Kind of ways 🙏🏻
i added some tests followUps to check
(it is breaking tos, and we don't provide support for tos violations)
It doesn't appear to be breaking any ToS if it's on 30k servers xD
I'm not sure how its server count affects whether it breaks tos or not
but if you have questions about why they've allowed something their tos explicitly disallows, feel free to ask discord
yes my bad. Btw i found the issue
basically the bot every time it does restart or connect take a while to connect to the discord end point i think what cause the interaction to not being working perfectly for a brief moment, but does after 2mins or so. i had to console log the time that the interaction take to fully load and everything to notice that out
i will be deleting the code from the room for TOS breaking
Curious, how was it breaking ToS?
I was thinking if you're at 30k servers, don't you HAVE to get verified past 100?
breaks both youtube's and potentially spotify's tos as
- youtube doesn't allow restreaming due to dodging ads
- spotify doesn't have a public streaming api, so either the lib they're using breaks spotify's tos, or usually they just search for the song on youtube
and this breaks discord's developer tos as they disallow misuse of third party apis for discord apps
discord can and has banned bots for this (you may remember this is why rhythm disappeared in the first place)
yes you have to be verified to go past 100
there's several possibilities for their situation including - these features were added after being verified
- discord overlooked it for some unknown reason
but again, if you have questions about why discord has overlooked it, you should ask them
Oh that makes sense, learn something new every day
If I'm not mistaken, containers have a limit of 10 components each. When I do something like a section which has text and a button, would the text and button each count as one component, or would only the section as a whole count?
No, 5 X 5. You can have 5 Action Rows each containing 5 components. So 25 total. Someone correct me if I'm wrong but I feel like I read that in the discordjs.guide
not anymore - just got raised to 40. Builders will be updated soon
5x5 buttons refers to the original components, not v2
🙏 oh thank the lord. i was going insane trying to make things work with the 10 limit because i have some very fun ideas with containers i'm trying to work out
that's for v1 components
oops didn't see monb already mentioned it
my bad
has djs added accent_color for containers?
Confused as to why you think we would have excluded one specific property while supporting all the others?
why the ephemeral option will be removed in v15?
to favor how it actually works, with the flag
how do i add it
so it becomes less confusing when mixing flags, and to have a closer behavior to the api
ContainerBuilder#setAccentColor() discord.js@14.19.1
Sets the accent color of this container.
Is there a way to see if a channel has an event going on in it other than grabbing all events and filtering for active ones in said channel?
doesn't look like there's a way to do the former
is there any option to not have a color on an embed at all
yeah dont set one
default is still a color tho
there isn't a way
only in containers
hm
i mean you can set it to the same colour as the background
But that will only work for matching themes
diff appearences on discord tho so it wont be great better than nothing
or move to cv2
slowly doing that i jsut find embeds easier to use and build as the container builder is kinda complicated
was not paying attention to the conversation above
how will we make ephemeral messages then?
The ephemeral option when replying to an interaction will be removed in v15
- {..., ephemeral: true}
+ {..., flags: MessageFlags.Ephemeral}
``` Read [here](<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR>) on how to specify multiple flags
oh i thought the message flag was gonna be removed
well thanks anyways
Why would it be? That's the API behavior
Could someone help me with a problem?
I can interact with slash commands in the bot chat, but if a user adds the app to his profile, he can't use it in his friend's DMS.
Is there a Gateway im Not aware of?
do gallery items from the new components v2 api work with attachment:// urls?
the command doesn't have the user install integration type or the private channel interaction context type
also you should probably look into what the gateway actually is
How would i Set that
should work, yeah
Where tho
are you using the builders or raw data
Builders
ddocs, I'm only saying that because you used that term completely incorrectly
it's unrelated to the issue
documentation suggestion for @errant void:
SlashCommandBuilder#setIntegrationTypes() discord.js@14.19.1
Sets the integration types of this command.
SlashCommandBuilder#setContexts() discord.js@14.19.1
Sets the contexts of this command.
there, those two
idk where to ask this, but uhh, anyone got any opinions?
you think i should leave it like this, or, add a seperator between text & button?
Fixed it
Thanks
Components v2 can only work in the slash command?
no, you can also send them directly
In msg command?
if you run interaction.deferReply() on an interaction, and then later attempt to interaction.reply() instead of interaction.editReply(), will it error with Unknown Interaction?
it should error with alreadyreplied
huh, I selected the InteractionAlreadyReplied value
weird
well, that
are you replying to me or to CodeMyGame?
You
you can send them anywhere you make a message
Fixed
in an interaction, in a "message command", etc
Can I make the collector same as normal ActionRowBuilder components?
yeah
you don't make the collector in the row, you make it in the message
or the channel
Ok ty 😊
i'm getting this error:
DiscordAPIError[50035]: Invalid Form Body
data.components[0].components[0].style[BASE_TYPE_REQUIRED]: This field is required
code:
if (!modal) {
if (isNumber) {
const numModal = new ModalBuilder()
.setCustomId(`configmodal~${settingID}~${int.user.id}`)
.setTitle("Cambiar configuración");
const numOption = new TextInputBuilder()
.setLabel("Nuevo valor")
.setStyle(1)
.setCustomId("configmodal_value")
.setMaxLength(200)
.setRequired(true);
const numRow = new ActionRowBuilder().addComponents(numOption);
numModal.addComponents(numRow);
console.log("Modal Structure:", JSON.stringify(numModal.toJSON(), null, 2));
return int.showModal(numModal);
}
}
i got the latest discord.js ver
can you share the whole error
it looks like there's more below
and this, also applies to errors
oh sorry
https://srcb.in/zuHTx3AFY7 there is the full error
This error occurs and the application does not respond when I execute a specific slash command.
the error comes from a .reply(), not a .showModal()
you are prolly replying the interaction with a button component without Style attribute, which is required
Hey, does d.js support Discord's Poll feature? And if it does, how can I acess it?
yeah
How can I access it? I've been scrolling around with the Guides and Docs for like an hour
polls are part of messages, so that's a hint where to look
Appreciate the help
MessageCreateOptions#poll discord.js@14.19.1
The poll to send with the message
for instance
InteractionReplyOptions#poll discord.js@14.19.1
The poll to send with the message
or for interactions ^^
though both are the same thing in reality since they're inherited from the same base message options
then you can listen to poll votes
(event) Client#messagePollVoteAdd discord.js@14.19.1
Emitted whenever a user votes in a poll.
or -Remove
what's the activitytype custom?
A custom status
example
Your It will take a while To... on your profile
ooh thx!
like about time,
is it permanent? or timed?
Same behavior as setting other statuses on your app
#1142187561729658942 may also be relevant
type: ActivityType.Custom,
name: "custom", // name is exposed through the API but not shown in the client for ActivityType.Custom
state: "🍋"
})
so state is like a emoji in front?
Not necessarily, as the first ℹ️ point in the thread mentions
Ooo
thx for info
does member.voice.channel use cached data? if so, when im fetching the member every time it says member.voice is undefined, how do i get around this?
Show how you fetch it
And do you have the GuildVoiceStates intent
container.addSectionComponents(
new SectionBuilder()
.setThumbnailAccessory(
new ThumbnailBuilder()
.setURL(
'https://cdn.discordapp.com/icons/1243137862757650464/819f2e5d8f55faf24854fecdfdb564fa.png'
)
.setId(123)
.setDescription('test')
)
.setId(123)
)
return error:
error: Invalid Array length
constraint: "s.array(T).lengthGreaterThanOrEqual()",
given: [],
expected: "expected.length >= 1",
setId? where did you get this code from?
why not
that’s weird, thumbnails don't have ids, neither do sections
hmmm
could you show where are you using that? (the function)
where's the ) btw?
Yes, they do, all components have an id, it's a getter that's why you don't see it when logging
ThumbnailComponent#id discord.js@14.19.1
The id of this component
You don't need to use it, it's automatically generated
yeah i checked the docs, but how would you even use that on an action row for example? we don't have like Message.components.get(ComponentId), do we?
I have a question, when we submit a modal, is there also a 3 seconds response time before the interaction expires?
yes
and we can defer the reply of the modal ?
in my memory idk why but we can't
you can defer replying to it yes. You cannot defer showing it
ok thanks !
bro, focus on problem, the shown problem does not on it, it just a typescript type defination
i just don't know when i send this components, it returns
756 | var BaseError = _BaseError;
757 |
758 | // src/lib/errors/BaseConstraintError.ts
759 | var _BaseConstraintError = class _BaseConstraintError extends BaseError {
760 | constructor(constraint, message, given) {
761 | super(message);
^
error: Invalid Array length
constraint: "s.array(T).lengthGreaterThanOrEqual()",
given: [],
expected: "expected.length >= 1",
at new BaseError (1:23)
i mean, if you had a function where the argument parenthesis wasn't closed, that would cause the function to not run since there'd be a syntax error 
where are you using the createErrorMessage
whats the full error
756 | var BaseError = _BaseError;
757 |
758 | // src/lib/errors/BaseConstraintError.ts
759 | var _BaseConstraintError = class _BaseConstraintError extends BaseError {
760 | constructor(constraint, message, given) {
761 | super(message);
^
error: Invalid Array length
constraint: "s.array(T).lengthGreaterThanOrEqual()",
given: [],
expected: "expected.length >= 1",
at new BaseError (1:23)
at new BaseConstraintError (...\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:761:5)
at new ExpectedConstraintError (...\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:780:5)
at run (...\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1045:79)
at <anonymous> (...\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:67)
at reduce (1:11)
at validateComponentArray (...\node_modules\@discordjs\builders\dist\index.js:1532:191)
at toJSON (...\node_modules\@discordjs\builders\dist\index.js:2166:5)
at map (1:11)
at toJSON (...\adruinmenon\node_modules\@discordjs\builders\dist\index.js:1871:35)
i'm sure that 100% problem from these lines because when i deleted it, it worked properly
Your are missing text display components in section
is this correct ```js
perms?.has([PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.ViewChannel], true)
Section needs to have both accessory and text components
Yes
ahhh, fixed, tysm
Got a question with replies to interaction. If I have an embed with a button, on click, I do interaction.deferReply() and edit the content further more with interaction.editReply()
How can I edit the initial embed that has the button?
You can't, unless you use update() first on the original response and then use followUp() for the reply
And if I want to edit the original response, I do .editReply()
Yes
And if you want to edit the followUp reply, you can pass the id of the message to the editReply call
message: 'id' right
Yeah
is it not possible to try interaction.message.edit()
You could yeah, but if it is an ephemeral response or your bot doesn't have access to the message, then you can only do it through interaction webhook
Okay got it, ty for the help
is there a way to get channel id given message id?
Not reliably, no
would there ever be a scenario where a slash command CommandInteraction interaction.channel is ever null or undefined?
context:
async execute(interaction: CommandInteraction) {
interaction.channel // some other method call
}
whats the most effective way to fetch a user? im using broadcast eval currently but that will fetch on each shard, whereas I want it to only do it until it's fetched it atleast once (no more), but i don't want to specifiy a shard unless that shard isn't online
client.users.fetch(user.id)
re-read my question
in this instance, i dont have a client only shardmanager
yes
When the channel is not cached. For user apps or without bot scope (interaction-only bots) for example
Depends on what you want to fetch them for.
i know the library say it may be null i just wanted to know in what case scenario (like qjuh said)
thanks though
i need to get the users data on my api which is running on my shard manager and not a client process
i could make a raw api request though using rest however using .fetch would allow cache
That’s still not saying what for, just stating that you do
i just need to access the properties from the user, i dont need any methods or anything. its for logs to help prevent people abusing my website
not sure how the use case of public user data is relevant
is this correct:
channel.permissionsFor(guild.members.me).has(PermissionsBitField.Flags.ViewChannel)
have you tried it?
Because it’s relevant what information you already have available about the user in question. Just the id or maybe the full data from oauth2 or a guild they are in or…
i only have their ID
when it‘s related to your website I‘d have expected oauth2 to be a part of it
well i could use oauth data but its not exactly kept up to date
Huh? Oauth2 data is always up-to-date if you request it from the endpoint with access_token. Which would be the preferred way for getting information about the logged in user on your website
it's only requested on sign in or when the user clicks the refresh button
and then stored in a database
is there documentation on discordjs.guide on components v2?
there isn't
When will there be?
how to do something like that?
Using Components V2.
For real.
is there any guide on youtube?
not any official one
^
it's the real answer if you're asking
Yeah I know I just said for real.
okay, but why fetch that information from your own API, trying to fetch it from one shard, etc. instead of directly getting it from the source via access token? that would be the most efficient way to do what you ask about
Hi, I'd just like a little technical confirmation. It's impossible to join a voice channel following a user interaction if the user isn't in a voice channel?
sure you can
no, why would it?
we agree, although it might sound differently
it's just that most bots won't do that because they don't know where to join
since normally voice related bots are meant to follow the user
We have a bot that lets you create voice channel, but we have a lot of them, so we'd like to use a button to create a voice channel instead. The aim would be to move the player into a new voice chat room, not the bot.
I forgot to specify that...
sure that's possible
without the user being in a channel first? He will therefore join one of them from the interaction
oh, no that's not possible
ah yeah thanks =)
Reply with an ephemeral message containing the channel mention instead
Interesting 👀
it wouldnt be from the source, it would still have to be on the api route because it website is serverless and i dont want to make multiple db connections but i suppose i could fetch it from access_token however i do have a similar scenario as this one where i need to run <Client>.fetchInvite which i would only want to run on a single shard from broadcast eval
You can fetch from discord api with serverless, what‘s the issue?
the access token is stored on the database
„From the source“ here means „from discord API“
ah - thought you meant from my website and avoid making a request to my api to handle this
Well, where do you get the user id from?
basic data such as name, avatar and id is stored in the cookie
Yes, avoid a request to your API, instead make a request to discord‘s
well i also need to figure out the most effective way to fetch an invite also
probably just an api req to discord without using djs methods?
fetch an invite from what information?
the invite code
Then yes, discord API
would it be bad practice to fetch the invite using a new REST instance just so the handling of the request is processed using discord.js ratelimit handler and the data is turned into camelCase
Invite Resource - Get Invite
read more
If you use a new rest instance then there won’t be any prior ratelimit headers to handle. Just do a fetch()
unless the new rest instance is defined top level
top level of what? Didn’t you say you‘re running serverless?
the API isn't serverless, the website is
Why is the API suddenly getting involved again? I thought you‘d request directly from website to discord API now
all requests need to be processed through the API from the website because the api has the bot and the database connections
in your original message, i thought you were calling my website the source, not the discord api
is it possible to send colored text with discord bot without using the 3 backtick ansi method? i cant seem to find one online
there isn't
hey i wanted to know if guild.name works?
and if not how bcz i tried and i have no issues.
if you tried and it works then why are you asking if there's issues? 
sounds like an xy question
well if you have a Message called message yeah
but Guild#name is always a thing
Is there no guild tag for this server? :c
this is support for the d.js library, other discussions/questions go to #archive-offtopic or #1081585952654360687 as appropriate
Can we use the new component, or not yes? I tried using it since 2h but not working... 😅
you can
show your code
Actually it's awfull, sorry :
const { ComponentBuilder, MediaGalleryBuilder, MediaGalleryItemBuilder, TextDisplayBuilder } = require('discord.js');
[...]
const components = new ComponentBuilder()
.setComponents([
new MediaGalleryBuilder({
items: [
{
description: "Some text here",
media: {
url: 'https://media.discordapp.net/attachments/1184590231194837013/1367848342444572712/rect4.png?ex=6816138a&is=6814c20a&hm=423e474c6bd5d9769d07aed41910f59957751169b8bd18bd6cb4f16b6c2221df&=&format=webp&quality=lossless&width=786&height=254',
},
},
],
})
]);
await interaction.reply({
content: 'Testing new component :',
components: components.toJSON()
});
ComponentBuilder is the base builder for other component builders
you aren't meant to use it
if you just want the media gallery only pass that to components
(in an array)
and you need to send the IsV2Components flag as well
So I have to use ContainerComponentBuilder instead, right?
ContainerBuilder if you want a container, yeah
it's not mandatory so you don't have to
Because I don't only want a gallery, I want to try other things in my container
well you can pass pretty much every component that can go inside a container, outside one
like I said, components is an array, you can pass more than one component
just making it clear that you don't need a container, it's a matter of looks
Ok! I'll try again! Thanks!
Can you have more than 1 image in message with components v2 ?
you could always have more than one image in a message
you just couldn't position it
specifically with V2 components though you can use a media gallery, similar to this
didn't understand if i want: { dynamic: false }, how to do it
forceStatic: true ?
yes
can i do deferreply and later update interaction?
or get the interaction message first, then do defer and then edit the interaction message? or i cant use defer in this case?
deferUpdate then
Error: Cannot find module 'dotenv'
does not seem like a d.js issue, please use #1081585952654360687 (also not necessary for a separate package with new versions of node, env support is native)
sorry
this may not be djs related unsure, but is it usual for your bot not to create a slash command / is there a delay before it registers
nope, deployment is instant. you may need to refresh your user client to see the new data
yeah i tried refreshing, the slash command doesn't show up + no errors are logged
Are you deploying global commands or guild commands
guild
Are you checking in the correct guild?
yeah
https://github.com/0x5b62656e5d/zephybot
/home/pepper/zephybot/node_modules/@discordjs/rest/dist/index.js:748
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/pepper/zephybot/node_modules/@discordjs/rest/dist/index.js:748:13)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async BurstHandler.runRequest (/home/pepper/zephybot/node_modules/@discordjs/rest/dist/index.js:852:23)
at async _REST.request (/home/pepper/zephybot/node_modules/@discordjs/rest/dist/index.js:1293:22)
at async ChatInputCommandInteraction.reply (/home/pepper/zephybot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:194:22) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: ':ping_pong: Pong! -1ms',
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 64,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
}
},
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1367881414262919269/aW50ZXJhY3Rpb246MTM2Nzg4MTQxNDI2MjkxOTI2OTo0bzlhc1JTazkxR1g0SWpkT0xyWDU2SGI0YkNPMVk1N2tMQWRySlVIbUVZTHhNd3BIR2t1a1ZHVDdSWHBrejIzZEtZWnRhZkdTVVF0UXNQQzJXSUFrT3ZMMks3RlliRG1USm9jTWJjOUR1N21rVjJFWmFvcVcyZ0F2WndqRWN2Yw/callback?with_response=false'
}
Node.js v22.15.0
when i run it on my macos, it works fine
but the moment i run it on my raspberry pi, it throws this error when i run a command
Did you stop the one running on your mac before running the one on your pi?
yes
ive ensured that the bot is offline before running on my raspi
ive also ensured all my application ids/tokens are correct
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
The token being wrong would absolutely not cause this error
Because your app wouldn't be able to log in to receive the interaction in the first place
im pretty lost rn man...
exact same code, nothing changed between the two systems
i just git cloned it, npm install, then npm start
and running /ping threw that error
Is your pi old or overloaded or something
its a raspberry pi 4b
ive ran a js version of this bot before and it ran just fine
Since you have 3 seconds to respond to interaction, if you take longer you will get that error too
Since that implies it's ts now, are you running transpiled code or using something like ts-node
yes
It was not a yes/no question
mb ts-node
Then don't
Transpile and run the resulting js
nvm that means i transpile it ig
I do rimraf dist/ && npx tsc && node dist/index.js
Then idk what to tell you
what the sigma 😭
it runs on a dockerfile now
wtf
its just awfully slow
FROM node:22.15.0
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]
How to add the --openssl-lagacy-provider flag to all shard processes when using the sharding manager?
ShardingManagerOptions#execArgv discord.js@14.19.1
Arguments to pass to the shard script executable when spawning
Default value: []
no wait, wrong one nvm, it is the correct one
ty ❤️
Hey, I got this file and I always used the interaction.options.getSubcommand() but it always gives me the error TypeError: interaction.options.getSubcommand() is not a function
This is the file:
//_SLASH_COMMAND
import { SlashCommandBuilder, Client, ChatInputCommandInteraction } from "discord.js";
import db from "../../handler/database";
import responseAnimations from "../../scripts/responseAnimations";
export default {
data: new SlashCommandBuilder()
.setName("server")
.setDescription("Toggle features")
.addSubcommandGroup( group => group
.setName("features")
.setDescription("Toggle features")
.addSubcommand( subcommand => subcommand
.setName("response-animation")
.setDescription("Enable or disable the response animation")
.addBooleanOption( option => option
.setName("state")
.setDescription("Enable or disable the response animation")
.setRequired(true)
)
)
),
async execute(client: Client, interaction: ChatInputCommandInteraction) {
const subcommand = interaction.options.getSubcommand();
// ! The line above causes the error.
if (subcommand === "response-animation") {
await responseAnimations.runScript(client, interaction);
return;
} else {
await interaction.reply({ content: "Unknown subcommand", ephemeral: true });
}
}
}
Anybody know why?
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
Thanks, that solved the issue haha
is there a way to troubleshoot why my slash commands aren't showing up
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
yeah i have a error logger, it isnt detecting any failures whilst registering
Have to tried restarting you client crtl + R
yeah, and manually closing and re-opening.
closing the window does not restart the client
yeah, i also restarted it with ctrl r.
this is not about logging errors
please do this to ensure the actual command deployment is executing when you run your deploy script and that the commands you're deploying look correct
yeah i know, i already have it so if they are registered correctly, it is supposed to say registered correctly,
but it isnt.
that doesn't sound like "it isnt detecting any failures whilst registering"
that sounds like it isn't registering
what does execute?
care to share your code?
require('dotenv').config();
const { REST, Routes } = require('discord.js');
const commands = [
{
name: 'testingcommand',
description: 'yeah i work',
},
{
name: 'help',
description: 'help embed soon',
},
];
const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);
(async () => {
try {
console.log('attempting to register slash commands');
await rest.put(
Routes.applicationGuildCommands(
process.env.CLIENT_ID,
process.env.GUILD_ID
),
{ body: commands }
);
console.log('registered correctly');
} catch (error) {
console.log(`error found: ${error}`);
}
})();
what does execute?
doesattempting to register slash commandslog?
nothing, the only thing that logs is that the bot is on
sounds like you aren't running this file at all
this script is intended to be run separately from your bot since you only need to deploy/redeploy commands when you change the command data (e.g. the name, options, etc)
yeah mb i forgot to run it seperately through a command
could you leave/tag the guide to the empheral messages (the ones only the command runner can see)
Slash Commands: Command response methods - Ephemeral responses
read more
you can also use the bot yourself
furthermore the guide has a search bar
I downloaded the source code from https://github.com/discordjs/discord.js/releases/tag/%40discordjs%2Fbuilders%401.11.1, I can't find any files relating to components v2, how do I find that?
Would be best to know where I can find documentation about components v2 ngl
Why are you trying to install the source code? You can just install the builders package npm install @discordjs/builders
For this reason
And if you're curious how this message was built, check out the source code!
And here's the documentation for that package
How do I find documentation for components v2 specifically?
I can't open that kind of file
Sounds like you're trying to open it as a video rather than as a text file
Your computer doesn't recognize it. Just open it as a text file in your text editor (like VSCode)
Got it, thank you for your help!
what are the limits with components?
it says there is no longer one?
I believe we're still waiting on an update for DJS for that. Right now you have to use raw API data to exceed 10
oh alright
There is a way to disable validators in builders until then
You can use disableValidators() (from /builder or d.js), but it will disable it for all builders
And what exactly would that disable?
validators
So the error?
Yes
You just run the risk of getting validation errors from Discord API
I have a question, how many buttons can be in one message at most? discord.js 14.19.2
Thanks
Or wait a second, it's only 1 per section bc it's an accessory
If you use 20 sections, you can get 20 buttons
I mean you still have action rows available, so with the new limit you can have 7 action rows containing 33 buttons
Yea, was gonna say that
Could someone give me an example of the container command with button and separator together?
a section also needs a textdisplay in it. so only 13. instead by using actionrows you can have 33 buttons
#announcements literally has sample code attached
the .mts file
Sorry I didn't see, thank you very much
can bots have buttons in there status?
No
Guys, I've got the error code 50024: Cannot execute action on this channel type.
However, I'm not quite sure which action caused this error. What do you think?
It must be either one of those two options:
await ctx.guild.channels.create(...)- Create a categoryawait category.children.create(...)- Create a forum channel
did you not get the request path alongside the error?
I have to see what sentry captured, one moment
- forgot to do this earlier
nope, I don't see the error.
Is there a limit to the number of sections or is it just the text limit of characters that discord has
After trying to send a message with components v2 to a user with
const container = new ContainerBuilder()
const text = new TextDisplayBuilder().setContent(`# New order available`)
const section = new SectionBuilder().addTextDisplayComponents(text)
container.addSectionComponents(section)
await user.send({
components: [container],
flags: MessageFlags.IsComponentsV2
})```
I get `CombinedError: Received one or more errors`. How to fix that?
sections need to have an accessory
and sharing the full error would be helpful
Thank you, trying now
Works, thank you!
const filter = (reaction, user) => { return reaction.emoji.name === '⏰'; }
message.awaitReactions({ filter, time: 15_000 , max:1, errors: ['time'] })
.then(collected => console.log("then"))
.catch(console.error);
Hii, I am attempting to use <Message>.awaitReactions promise, but the code errors this out:
if (collect && (await this.filter(...args, this.collected))) {
^
TypeError: Function.prototype.apply was called on #<Object>, which is an object and not a function
ive tried using example straight from the guide, but yet still the same
sounds like filter was not defined as arrow function like your code block suggests. can you double check the error refers to that code and that the file is saved?
yes the file is saved & i've restarted the bot
here is the full traceback: https://paste.taran.rocks/teghsomphe
(enable reply ping if anyone responds, ty)
How can I remove ban from guildmember?
GuildMemberManager#unban() discord.js@14.19.1
Unbans a user from the guild. Internally calls the remove method.
// Unban a user by id (or with a user/guild member object)
guild.members.unban('84484653687267328')
.then(user => console.log(`Unbanned ${user.username} from ${guild.name}`))
.catch(console.error);
Thanks haha
And just for clarification...you can remove the ban from a User...but you can't remove a ban from a GuildMember...as no such GuildMember can exist (because...ya know...they're banned)
...wait...did you just thank a bot?
Are there limits to how many characters one container can have?
LOL
I think they thanked themselves
bump^ in case it gets buried
Error: Cannot find module 'C:\Users\User\Desktop\EverythingDMA\src\register-command.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: []
}
you have an incorrect path, this is not related to d.js
Can we add images to components? If yes, how?
MediaGalleryItemBuilder#setURL() discord.js@14.19.1
Sets the media URL of this media gallery item.
ContainerBuilder#addMediaGalleryComponents() discord.js@14.19.1
Adds media gallery components to this container.
do you still use .addStringOption or no
hey im getting unhandled rejection issue its happening when my bot is in timeout but i have check to see if bot has send message perms
I'm trying to make a embed with comp v2 with just 1 single image there, here is my code:
async execute(interaction, client) {
if (interaction.user.id !== "530067274766483487") return;
// URL for the image
const imageUrl = 'https://cdn.discordapp.com/attachments/1011355084514394164/1181676507605774559/META_A_LUMBERJACK.png?ex=6815c3c1&is=68147241&hm=33b76dda150a9b98ad8f0cfa7fb86ff62644682162403a021d3a189fa3243b68&';
try {
const mediaItem = new MediaGalleryItemBuilder()
.setURL(imageUrl);
const container = new ContainerBuilder()
.addMediaGalleryComponents([mediaItem]);
await interaction.reply({
components: [container],
flags: MessageFlags.IsComponentsV2,
});
} catch (error) {
console.error("Error attaching image:", error); // Log any error
await interaction.editReply("Something went wrong while trying to display the image.");
}
},
but im getting a large error:
Error attaching image: ExpectedConstraintError > s.array(T).lengthGreaterThanOrEqual()
Invalid Array length
Expected: expected.length >= 1
Received:
| []
Show the full error
Error attaching image: ExpectedConstraintError > s.array(T).lengthGreaterThanOrEqual()
Invalid Array length
Expected: expected.length >= 1
Received:
| []
at Object.run (I:\Coding\Discord Bot\Meta\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1045:79)
at I:\Coding\Discord Bot\Meta\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:67
at Array.reduce (<anonymous>)
at _ArrayValidator.parse (I:\Coding\Discord Bot\Meta\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:29)
at validateComponentArray (I:\Coding\Discord Bot\Meta\node_modules\@discordjs\builders\dist\index.js:1532:191)
at MediaGalleryBuilder.toJSON (I:\Coding\Discord Bot\Meta\node_modules\@discordjs\builders\dist\index.js:2048:5)
at I:\Coding\Discord Bot\Meta\node_modules\@discordjs\builders\dist\index.js:1871:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (I:\Coding\Discord Bot\Meta\node_modules\@discordjs\builders\dist\index.js:1871:35)
at I:\Coding\Discord Bot\Meta\node_modules\discord.js\src\structures\MessagePayload.js:151:46
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
at ChatInputCommandInteraction.editReply (I:\Coding\Discord Bot\Meta\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:247:48)
at Object.execute (I:\Coding\Discord Bot\Meta\commands\developer\preview.js:30:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (I:\Coding\Discord Bot\Meta\events\interactionCreate.js:16:13) {
code: 'InteractionNotReplied'
}
don't think so
where can i read component v2 docs
Are there limits to how many characters one container can have?
Container as in components v2
it's not exactly hard to check yourself
Yeah that would help a lot too
dapi docs should have everything
?
im new i dont even know where to start
I searched dapi docs and it appears to be a bank thingy
Oh lol
that response wasn't directed at you
but the link to docs would be
ty
It appears as if there are no limits characters-wise
you can check it yourself then
string.repeat() might come handy
and like with embeds, i'd expect there to be an overall char limit over entire thing
what is the max length of text allowed on a Container text display component?
what do you mean with "doesn't work"
https://cdn.discordapp.com/avatars/347339119606890497/a14aa3d31ea951ef49e48a85a291c461.png?size=128 is your avatar restricted to 128x128. your avatar is larger than that.
https://cdn.discordapp.com/avatars/347339119606890497/a14aa3d31ea951ef49e48a85a291c461.png?size=256 is your avatar restricted to 256x256,
https://cdn.discordapp.com/avatars/347339119606890497/a14aa3d31ea951ef49e48a85a291c461.png?size=512 to 512x512
and https://cdn.discordapp.com/avatars/347339119606890497/a14aa3d31ea951ef49e48a85a291c461.png?size=4096 to 4096x4096.
the last 3 have no difference between them
are you sure the avatar link you have still points to an existing avatar?
which is built from cdn url and avatar hash, along with an extension (defaulting to one), and if you set it - size query param
where hash is taken from cache (and default extension deducted from it)
so it's not impossible for the avatar to change since you last fetched/received the member if you don't have a way to get the new avatar updated in your cache
it's also possible that the user changed their avatar since you got the link
can TextDisplayBuilder have color
no
Is there a way for me to globally view the date the user started boosting on Discord?
No, you can only do it on a per-guild basis via <GuildMember>.premiumSince
ok, but how they can do this?
🤷 Beyond my knowledge
...who is they?
i deleted the photo
k
I believe that would be wrong, right? Because discord does not allow storing this type of information for privacy reasons
storing is one thing
the much, much bigger problem is how they obtain it
but that's not a topic for this channel, really
collector.on("end", () => {
selectMenu.setDisabled(true);
});
why doesnt this disable it? it just makes the interaction not work. im still able to click the select menu.
oh im slow my bad lol.
yay i got it
is there a better & easier way to handle buttons than do the whole
if(button.customId === "xyz"){...} and doing that for every button? It feels very.. bare bones and tedious- any solutions?
I have a question, is it possible to send several surveys in one message or can you send a maximum of one survey in one message? (discord.js 14.19.2)
Do you mean a poll? And if so, you can have 1 poll per message
okay
nothing bundled in djs
but you're free to route your interactions however you want
it's pretty easy to make a variant of your interactionCreate.js event to handle button interactions.
personally this tutorial has something fairly close to what i use, but i have something a bit different, but it definitely helps declutter your code in the long run because you can just make individual files for buttons.
i have a very modified version that allows for keying buttons and also handles modals and every other interaction type as well. very handy!
-> https://youtube.com/watch?v=3AZ2ZA6_GJg&ab_channel=Lyxcode
worth noting i believe that this tutorial applies to d.js v13, so be wary of that. i don't think anything super substantial has changed but there will likely be some deprecated methods in that video
but you still get the gist of it
can we .setColor method on new component builder
.setAccentColor([R, G, B])
no embed color?
accentcolor does effectively the same thing, but i don't think you can do like .setColor("Blue") or something like that. example of one of my new bots below using accentcolor
thank u
I'll look into it, thanks a lot! You did mention however its for djs v13- are there any major changes (specific to this) that would throw everything off? I'm quite new to djs so I havent been around that long to see what has changed
i honestly cannot remember if i had to change anything in that handler when i ported over to v14, but i don't really think so.
if you do, the errors should help you figure out stuff, and you can always check here to see if your issue is one of the things that changed.
worst case scenario there are some other similar tutorials and scripts out there probably updated for v14, just search button handler and you should find some
what is the name of this element? because it is not embed, I mean specifically the name of what it is called
Thanks
I see, I appreciate it!
np y'all
or maybe someone knows how many such containers can be in one message at most?
there isn't a limit specifically for containers
there's a total component limit
40
https://www.answeroverflow.com/m/1183119785039511623
looks like someone had smt similar but no fix found
djs really isn't particularly optimized to run in systems with more limited resources
maybe you could try with @discordjs/core if you really want to host a bot there
it should be as lightweight as it can get in a js environment
i used to use commandkit for all my commands but im just using djs only now
would that change anything?
frameworks do add additional overhead, yeah
wdym overhead
that there's more resources, both in computational time and ram usage, with a framework than without one
since they just wrap around djs
adding more stuff to it
so aka less efficient?
it's not the same thing for you to directly listen to interactionCreate and reply than the framework adding its own command manager, doing the command location and routing up to your command object
yeah but usually it's neglectable
in these kind of cases though it could get problematic
😭
it used to run perfectly fine and smooth with commandkit
now it cant even respond in time without commandkit…
have you tested if it actually fully works without it?
can we add dropdrown menu inside components v2
exact same machine and os
ik you mentioned less sys resources may affect but the exact same code and node versions run perfectly fine on my mac, no errors
when i git cloned then npm install then start on my rpi, it lagged then threw a 404
if it's the exact same reply code then yeah sounds like the framework's overhead is causing an issue for you
no, both systems rn have the exact same code
https://github.com/0x5b62656e5d/zephybot
v2 components are an extension of v1, so yeah
djs only, no commandkit
ok
Is there a list of each Endpoint and how many times you can request it before you get ab 429?
is it possible to get the userid of the message that was replied to on a messagecreate event?
eg, if A replies to B, is there a way to get the userid of B from the message created by A?
no
Rate limits are dynamic. Implementing static timeouts based on observed values is a bad idea. They can change at any point without notice!
#1115977469497978931
you can fetch the replied message with <Message>.fetchReference()
then access <Message>.author.id on that fetched message
can i add fields like i did to my embed in a container?
no
You can just add text display components
alrighty thank you
do new containers support text inputs?
no, but you can use modals
by the models you mean what?
guide suggestion for @oak yoke:
Other Interactions: Modals
read more
oh modals
thanks!
yeah my bad I made an error
np, thanks anyway
Does the djs guide contain anything on the new components yet?
I dont think so, but you can ask here if you need help
check out the file attached in #announcements message
and read the discord api docs
can someone link me to the guide for this
guide suggestion for @hearty quest:
Other Interactions: Modals
read more
Random question, do collectors have a significant impact ram usage?
It is an event listener underhood, so it is same situation as that. Too many listeners will obviously consume more memory. Too much listener may cause memory leak. Although d.js increases maxListener amount for collectors so as to not get that warning, but you get the gist. Collectors are cleaned up when their use is done, but too many at once may slightly impact memory usage
so if i want the the buttons to be handled indefinately, i just handle them in the InteractionCreate event?
Yes
would that have any issues?
What issues? It is only one listener. Unless you are creating multiple interactionCreate listener for different types of interaction, which you should not do
nope, only one event
HI! i am working on automod feature for my bot using Discord's Automod API. Is it possible to toggle on/off the native Block Mention Spam using the bot and edit the mention limit?
if (mentionRule) {
await mentionRule.edit({
enabled: action === 'on',
triggerMetadata: {
mentionTotalLimit: mentionRule.triggerMetadata.mentionTotalLimit || defaultLimit,
mentionRaidProtectionEnabled: true,
},
});
} else if (action === 'on') {
mentionRule = await guild.autoModerationRules.create({
name: 'Block Mention Spam',
eventType: 1,
triggerType: 4,
triggerMetadata: {
mentionTotalLimit: defaultLimit,
mentionRaidProtectionEnabled: true,
},
actions: [{ type: 1 }],
enabled: true,
});
documentation suggestion for @cobalt tree:
AutoModerationRuleManager discord.js@14.19.3
Manages API methods for auto moderation rules and stores their cache.
documentation suggestion for @cobalt tree:
AutoModerationRuleTriggerType discord.js@14.19.3
yeah you can
AutoModerationRule#setEnabled() discord.js@14.19.3
Sets whether this auto moderation rule should be enabled.
i did it earlier by using the automod ID (test) but since servers automod has different automod ID and idk how to implement it to my bot
Fetch rules and .find it by type
how to edit a interaction message, how to let it and edit at last
documentation suggestion for @terse tiger:
Message#edit() discord.js@14.19.3
Edits the content of the message.
// Update the content of a message
message.edit('This is my new content!')
.then(msg => console.log(`Updated the content of a message to ${msg.content}`))
.catch(console.error);
Only works for non ephemeral messages
Ephemeral messages have to be edited through an interaction webhook using editReply
is per one type counted as 1 rule?
is it possible to get a CommandInteraction from a ButtonInteraction?
reason i need this is because i need to get the options that were passed when using a command
sorry what?
ButtonInteraction is completely seperate from the ChatInputCommandInteraction
ok
i'll just use awaitMessageComponent then
is per trigger type counted as 1 rule? for example my automod bot create a type 1 is it counted a 1 rule?
yeah ig?
@steel trail & @shadow pier Thank you! finally i can control it using my bot!
no worries
yeah i guess my raspberry pi really was the culprit @loud quartz
im running the bot on a rog laptop and it runs smooth like butter
what specifications is your rasbperry pi?
because I haven't faced any issues on mine

raspberry pi 4b
i was running this btw https://github.com/0x5b62656e5d/zephybot
rasberry pi os headless
ahh
im running ubuntu server, only has a cli
How can i make sure that i don't hit the Discord 3s timeout?
what timeout
That i don't get an error like "The reply to this interaction has not been sent or deferred"
defer the interaction
Let me try
documentation suggestion for @primal yoke:
CommandInteraction#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)
Im still getting same error.. Tried updated my InteractionCreate.js file and the command
show full error and code
similar, mine is headless lol
but for some reason it just wasnt fast enough to do anything??? idk why
it used to run fine
Defer as early as possible, before any async tasks that might take time
Thanks! It worked!
Is it possible to show 2 TextDisplays inline to each other in a container?
No
okay, thanks!
When i use editReply after deferReply, its not possible to remove the edited lable right?
No
Damn..
With Component v2 I was able to figure out some of basics with the new components but I am not sure if I can add fields to TextDisplayBuilder? I am using TextDisplayBuilder so I can split the sections.
TextDisplayBuilder
const PingInfo = new TextDisplayBuilder().setContent(
`**Message Latency**: \`${MessageLatency}ms\`\n` +
`**API Ping**: \`${ApiLatency}ms\`\n` +
`**MongoDB**: \`${MongoLatency}\`\n` +
`**Uptime**: \`${Uptime}\``
);
Building the Message
const Section = new SectionBuilder()
.addTextDisplayComponents(PingInfo)
.setButtonAccessory(RefreshButton);
const Container = new ContainerBuilder()
.setAccentColor(0x5865F2)
.addSectionComponents(Section);
You can't have fields in components v2
Unfortunate
Hey, don't know if I can do this, but I find a very usefull website to build containers : https://discord.builders/
Hope it can helps someone 🙃 !
User#bannerURL() discord.js@14.19.3
A link to the user's banner. See banner for more info
Is there a way to make a defer reply but then make it ephemeral if I want to? And even not ephemeral ?
I know when trying to do that with defer it will always will not be ephemeral unless I make it ephemeral in the defer itself but I mean is there a way to make it ephemeral or not ephemeral after?
are there any examples on how to use the new builders?
No
I see, okay thank you, have a nice day/night!
Not yet
const container = new ContainerBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder()
.setContent("hello!")
);
return interaction.reply({ components: [container] });
data.components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,)
am i missing smth?
Missing the IsComponentsV2 flag
is that the only way to do it or does djs export another function for componentsv2?
I'm using guild.channels.cache to count my server's channels, filtering by type (text, voice, etc.), but the total count is incorrect. It's showing more channels than I actually have. I'm excluding threads using c.isThread(), but the count is still inflated. How can I get an accurate count of real (non-thread) channels?
you always need to set the flag when using it
Categories are also counted as channels
Thanks!
stitch!! :3
why cant i use hex with setAccentColor for the new components?
I'm trying to get the total number of channels in a guild using guild.channels.cache.size, but the count is lower than expected. Some private channels (like staff-only) and the rules channel aren't included. The bot likely doesn't have View Channel permission for all of them. How can I get the total channel count including all types, even ones the bot can't see?
because thats how it is
you can still convert hex to rgb very easily
I have a question how the logic is implemented when creating channels (CategoryChannel), why they are created not on the position that is specified or conditionally not under the category that is specified
how should i format rgb
resolveColor discord.js@14.19.3
Resolves a ColorResolvable into a color number.
use that function
ty
Can someone help me?
that should include all channels. it might not include archived threads/posts though
what makes you say it isn't created in the position you specify? show code and expectation
logic of category and channel creation:
https://www.codebin.cc/code/cma853y040001jr09bucre5k5:DX53uV8k9umqi6jP2JYAAxj9j3RzE26XwHHqvA3n52BT
why are you using rawPosition instead of position there?
and there is no getChannel method on Client 
also there's no need to explicitly pass the generice to the create() method, that gets inferred from the passed properties
there is a similar situation with position as with rawPosition.
you didn't describe what situation that is. just that it apparently doesn't meet your expectations
fetch() already does that cache check internally, so that custom function is not needed and does double checks now
I have described, I will repeat again that there is a certain category under which my categories should be created, but they are created over a certain category, and it does not depend on whether I can take position or rawPosition.
Then why sometimes when a user is not in the cache I have to search for him/her with fetch()?
is there a bug? or whats caused this
fetch() checks the cache before querying the API. I didn't say you didn't need to fetch. just that you don't need to check the cache before
yes, but not djs related, only discord's desktop app
ah