#djs-help-v14
78874 messages · Page 77 of 79
Isn't it an option in the send options
It is indeed
WebhookMessageCreateOptions#withComponents discord.js@14.25.1
Whether to allow sending non-interactive components in the message. For application-owned webhooks, this property is ignored
That is create option...
The webhook already exists.
that is actually "message create"
Oh wait. I read it wrong.
Yes that worked.
Can I preset select menus to one of its own options eg how that menu looks when users select an option
Yes, for options you want to pre-select, pass default as true for that option
If it is autopopulating menu, then you need to pass default_values
StringSelectMenuOptionBuilder#setDefault() builders@1.13.0
Sets whether this option is selected by default.
UserSelectMenuBuilder#addDefaultUsers() builders@1.13.0
Adds default users to this auto populated select menu.
How you would do with builders for example ^
How can I disable role cache in discordjs 👀 also is it fair to disable or should I keep it?
I think the question is rather why do you want to disable it?
To minimise memory usage
Depends if you need the roles cached ig, but bare in mind that a few of the helper functions rely on things that should be cached to be cached
You can also just see what’s using the most and disable/sweep those
Yes I have it, it's just random when it doesn't show up
how do you use v2 components in .send again?
Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.
On a Webhook, or just a regular guild or dm channel?
regular guild channel
Then just the flag is necessary
flags: MessageFlags.IsComponentsV2 and use components to add components
The guide above covers the different types of components and where it can be used
alright thanks
With cv2, can you not put a mention in a heading?
… @red coral
For me it doesn’t work and just shows the string version
Then that is not a valid mention. A mention has <@id> format
Ah Yh nvm
just says it has to be between 1 and 768 hours
sounds arbitrary then
just in a different range
maybe its so they don't have to update them on their end as frequently, i dunno
Hey their got a question regarding discord.js v14.25.1, just don't know where to ask because it might be a issue that i need to ask about privately
... what type of question needs to be asked privately about an api wrapper?
not that just getting something about packages discord.js uses
i'm trying to find 2 different things at once as well so....
i've had about 5 dependabot security alerts opened on github with one of the packages on discord.js
if you are talking about undici, you can ignore that
okay wasn't sure because i had 5 of those come through
thank you gort for telling me because i got confused about it
Is there a component for selecting a date ?
no
not gonna say "planned" but highly requested and the interest is known
Nice
would be nice if discord released more of the modal components they use internally
has anyone else experienced type error with using a discord.js but, but the imported type just has { with: { "resolution-mode": "import" } }, which results in a type error? importing SlashCommandBuilder directly from node_modules instead of discord.js fixes it ..
unsure if its specifically a discord.js issue or some pnpm quirk
https://npmx.dev/package-code/trivious/v/2.0.4/dist%2Fmodules.types-uNvWKT4j.d.ts
not sure whats going on as its just a normal import from discord.js
but as it uses normal dependency and not peerdep, its highly likely to have version shift and conflicts
I don't know what discord.js+builders@1.13.1 is. Do you have a normal installation of discord.js?
its how pnpm does isolated installs - it makes alot of symlinks to that .pnpm dir (which then is hardlink to global cache)
would you recommend doing it differently?
Getting error "Module '"discord.js"' declares 'GatewayIntentBits' locally, but it is not exported." I'm on Discrd.js 14.24.0 and typescript 5.9.3. Attempted to reint my project still getting it, I also attempted to use the discord bot templates (bun - typescript) and still getting the same error. Any idea anyone?
EDIT: My import is: import { Client, GatewayIntentBits } from 'discord.js';
But why is it called that and not discord.js
doesnt discord.js re-export the builders from @discordjs/builders?
This is usually a Webstorm error and nothing we can fix
Yes but I dont understand what that would have to do with an install path
I’m on VSC
Can you npm why discord-api-types please?
Is it possible to have a description at the top of a modal ? (under the title)
With the modal redesign, you can add a text display component to a modal. Note this counts against your total component count. Meaning you're limited to one text display and four interactive components etc
Okay ty !
Hey.. Is there any repository which has a discord.js bot template? I’ll be starting out with bot development and the template will help me out with the basic structure.
Also which language is the best in use with discord.js? Javascript or Typescript
if you follow the guide, you can get yourself a pretty good starting template
Check out sapphire if you want a ready to go template #useful-servers message otherwise as Jo suggested, following the discord.js guides you'll end up with a pretty good starting point
tbh, this is my first time ever i got no idea how to code and i want to learn it with the flow xD
you'll definitely want to learn how to code first before making a bot
yea then you should probably follow the guide
Will do tysm!
oh i see
and about the coding language? JS or TS?
thats ultimately up to you
typescript is a bit more advanced than JS imo
ooh, then that works ig
you can look at #resources for learning JS, but if you have any questions, don't hesitate to ask in #1081585952654360687
avoiding that error from happening isn't possible. you need to make sure you're responding to the interaction properly
could someone please link me components v2
fixed it this morning, dont know why but reinstalling either vsc or bun fixed it. thank you
guys in modal
select menu and file
should be required ?
can i make it not required
StringSelectMenuBuilder#setRequired() builders@1.13.0
Sets whether this select menu is required.
Yes. Just don't add setRequired on it
i didn't but it set required
how do i do an embed without a side color?
its not an embed but a container
guide suggestion for @keen coral:
Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.
what djs version are you on? be sure youre on latest
latest
what is menu defined as?
show your code

how can i send all this
bro i didn't use required in anywhere
well then show your code so we can see
I try to find where can i add setRequired
how about file ?
please show your code
your error stack will tell you where the problem lies
id did it
menu default as required
i should to add setRequired
bro it large function and menu build in deferent place of it
i fix it
ty @bleak owl @tardy sable
.setAccentColor(0x0099ff) so is this not required?
nope
Guys how many the maximum button can I add in component v2
there's no maximum for buttons... but there's a 40 total component limit for a Components V2 message
actions rows are still limited to 5
how
What do you mean "how"? That's the limit that not a technical limitation. It's an intentional one to discourage sending messages with large amounts of buttons.
If you need a user to have a lot of options to select, you should use a StringSelectMenu instead
i mean how can 40 components make only 5 row
Because there's more components you can use at the top level than just action rows, e.g. separators or text displays
The 5 limit only applies to how many components you can put inside of an action row, if you so choose to use an action row in the first place
If you want to add about 7 components, all for the Actions Row Builder, will they count as 7 only ?
action rows themselves are components
so they count
if you add an action row which has one button, that'd be two components
ohhhhh
row with 5 button it 6 ?
yes
so 7 with botton it 40
no, it depends on how many buttons each row has, it's different to have 7 rows with 1 button each, than having 2 rows one with 5 buttons and the other with 2
yes i mean if all have 5
then you'd have 7 buttons + 2 rows = 9 components
ty @rose tangle | @topaz bluff | @clear garnet
Hey guys,
I keep running into an error that I’ve sent below, and I’m not really sure what’s going on. Is this an internet connection thing (I’m hosting the bot on a Google Cloud VM), or some other issue? They always come together at the same time in this order
it is network issues
That’s interesting, cause I have several other bots on that same server, none of which are having an issue like this
try to host bot local and see if issue persists
I was able to fix this by changing the type of my interface to SharedSlashCommand from the union type, don't know why having it in a union caused the error but at least I got a workaround
How was it typed in your interface? Where was it imported from there?
in my framework package it was typed as SlashCommandBuilder | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandsOnlyBuilder and then in my bot the interface is imported from my package, both my package and bot use the same version of discord.js and I've had this setup for months and only now had this specific issue
originally iirc I only had SlashCommandBuilder | SlashCommandOptionsOnlyBuilder
Are both of them ESM or is one CJS?
both ESM
Guys
I gave a role the ban permission but users say that they can't ban anyone
even the users with roles way below theirs
am I missing something here?
Once a role has the ban permission and is above the others it should work
isn't that so?
The target user’s highest role must be strictly lower than the executor's highest role
Yes it is
Also can’t ban the guild owner
Yep
Not rly a discord.js issue tbh
Are you checking this code?
Where should I ask it?
Members can see that others haave the perms, but when checking yourself the perms don't appear
Overseer role has the ban and timeout perm
Could ask in discord devs ig
It rly can’t be anything else
Except refresh Discord app ig
Okay thank you, but could you tell me if you see the reason in those images before I ask there too?
Is this a new Discord app view?
Right-click on the user
and click on View in Mod view or something
'Open in Mod View'
I don’t use Discord on my computer enough ig

You have ban permissions on 1 acct that has overseer, but not the other?
could be something overriding the perms on per channel basis maybe
Ban perms on channel perms?
Doesn’t affect ban permission
When they check themselves this is what they see too
none of the Overseers can ban anyone btw
when you right click on the user the ban button doesn't appear
Does the guild require 2FA?
Oooh, is that a requirement for ban perm?
If configured, yes
Only if required by the guild
hmm thank you for pointing that out
lemme check
That’s my actual last reason I can think of
Ah yes, that was the reason
Thank you very much ❤️
Is there a limit to the length a customId for a button can have?
thanks!
How can I make such a selectmenu in a modal because I still have a problem with it
What problem are you having with it?
When I run the bot on the desktop, everything works as it should, but when I upload the bot to the hosting, the bot doesn't run.
Maybe you know something about this because I have no idea what to do anymore
Hi this doesn't sound like an issue with discord.js, it sounds like an issue with the host. This isn't the right channel to deal with these issues.
Okay, thanks, where can I write about these things to avoid problems? So, should I write to the hosting owners?
What hosting service are you using?
You should contact them
okay
Is there a message component that allows the user to enter custom text?
Im looking for something like a select menu, but one where the user can customize input completely
Cant use message collectors since i need to update an ephemeral message when the user inputs the text and I can't do that without storing the message ID somewhere which I wanna avoid
modal
No, but you can use modal with text input
thanks!
how many characters can we write in title?
45
I have a question, in discord.js docs it says CLIENT ID but when I put client ID in my code (in the second picture), I got the following error:
DiscordAPIError[10002]: Unknown Application
at handleErrors (C:\Users\techn\OneDrive\Desktop\things\node_modules\@discordjs\rest\dist\index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async SequentialHandler.runRequest (C:\Users\techn\OneDrive\Desktop\things\node_modules\@discordjs\rest\dist\index.js:1163:23)
at async SequentialHandler.queueRequest (C:\Users\techn\OneDrive\Desktop\things\node_modules\@discordjs\rest\dist\index.js:994:14)
at async _REST.request (C:\Users\techn\OneDrive\Desktop\things\node_modules\@discordjs\rest\dist\index.js:1307:22)
at async refreshCommands (file:///C:/Users/techn/OneDrive/Desktop/things/functions/refreshCommands.js:14:7)
at async file:///C:/Users/techn/OneDrive/Desktop/things/index.js:13:1 {
requestBody: { files: undefined, json: [ [SlashCommandBuilder] ] },
rawError: { message: 'Unknown Application', code: 10002 },
code: 10002,
status: 404,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1175040737784643637/commands'
}
It should be Application ID right? then shouldnt it be Application ID on docs?
it works with Application id
I believe the application ID and client ID are the same
hm
They are the same, unless your app is really ancient
Like 2017 or earlier ancient
which i highly doubt
-# stats from discord.watch
there is NO way thast true
i have 2 apps with different user ids
hmm oh yeah maybe its only about deliverables apps then
at very least with this user they gotta be using someone elses bot or alt acc
there are regular bots that are just old that have separate app id from bot id
nadeko for example
thats crazy!!
whats the max time limit i can set on a collector? is it same as interactions, 15 min?
is there a max time? buttons for example never expire on their own
an interaction ends after at most 15 minutes, but something like a message component collector collects new interactions which have no need to be constrained to the 15 minutes of the original interaction that may have sent those message components in the first place
personally i dont use collectors, i keep things stateless and run everything through my interactionCreate handler, so i dont actually know for sure if they do have some sort of limit, but i would assume no
i also prefer interactioncreate but sometimes a collector is better for certain functions
i guess theres no max time limit since its optional?
perhaps, either way i dont think there should be a max time limit, unless djs is adding arbitrary limits itself
i hope so otherwise im gonna move it to interactioncreate
if you have a permanent collector you could just have an interactionCreate listener
but yeah there's no limit if you don't set one
Anyone has an idea of why the GET request for /guilds/{guild.id}/scheduled-events/{guild_scheduled_event.id} is slow asf ? Sometimes, it's fast and when I redo it, it takes about 5 seconds to resolve
ok good thanks
is there a alternative i can do for this? when i turned on the bot to test the enabler to turn the setting to be true, as it was false the function just died now its ture (bot still on) it came to XX:55 to send the message and.... nothing was sent as the loop is no longer functional is there a way... i can have this so it doesnt just die bit still checks the source in the time allocated i did? cuz this is stressing me out, i dont want to have to keep rebooting the bot everytime a settign gets updated
async function runEventPing(client) {
const enabled = settingsDB.get("isAutoEventMessageEnabled") === "true";
if (!enabled) return;
for (const guild of client.guilds.cache.values()) {
startEventPingLoop(client, guild.id);
}
}
client.on("clientReady", () => {
runEventPing(client);
});
same here, fetching guild events is probably the longest fetch there is on discord
I've found why... The ratelimit is really strict 😔
there also isnt a cache for it so you have to make your own cache
Yepp
Schedule events have a cache Guild.scheduledEvents.cache
Guild#scheduledEvents discord.js@14.25.1
A manager of the scheduled events of this guild
Cc @subtle falcon
Thx
you should also have the intent for GuildScheduledEvents
Ye ik
hello
how can i do this in my bot?
commands section...
only available on verified bots, and automatically done by discord when it has enough data on command usage. not really d.js related
oh Thanks bro
i think also needs to be global with no permission restrictions (and yeah alota usage)
i have question please i have bot it's working in host but when i turn to another host it's online but not reply any message it this problem from my side or the host
there isnt much info we can help you with there. place console logs and see
there is nothing in the console in the console it's showing that the bot is online but the command is not working
tag suggestion for @jaunty urchin:
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
if the bot is online that means the host is fine.
but in the other host it's working and the command working but in this host it's online but the command not working
there isnt much i can help you there. just do some basic debugging to find out
It's in 550 servers
that means nothing here
you can't.
I want my bot commands to appear in profile 😒
So I will wait
you just need to wait. this is completely irrelevant to discord.js
Why did I sometimes just don't get the log```js
console.log([CLNT] Client is ready as ${client.user.tag}!);
Where is this log in your code?
Or rather, how are you registering the event?
Here it is
Oh and because of this, the setInterval inside my clientReady are somehow just don't work at all. I need to restart the bot so that the log appear, and the setInterval is actually working
That happened once few days ago
just to be absolutely sure there's no race condition or anything like that, could you also share where this function is being called?
I call the handler in my main file
on the assumption this is handler in your main file, looks like you aren't awaiting it resulting in a race condition between registering commands/events and logging in
we also recommend separating command registration (and not registering on startup) since it's unnecessary to do so unless you've changed the command data
it's unnecessary to re-register commands if you only changed the callback that handles the interaction
So it is better to use await for the handler and also just stop re-register all the commands when there's nothing I change?
for the modal components, is there a way to make it where you can only put a positive integer?
no
use a text input and validate for positive integer after submit
is there an event to see if a mod has timed out a user or just audit log
both. check the guildmemberupdate event for communication disable changes and get audit log for getting the executor who did it
how can i fetch previous messages from other users in a channel? like i want to fetch previous messages in a chat, how can this be done with interactionCreate
documentation suggestion for @proven thunder:
MessageManager#fetch() discord.js@14.25.1
Fetches message(s) from a channel. The returned Collection does not contain reaction users of the messages if they were not cached. Those need to be fetched separately in such a case.
// Fetch a message
channel.messages.fetch('99539446449315840')
.then(message => console.log(message.content))
.catch(console.error);
see the doc link for examples on fetching multiple messages ^^
alright thanks for your help
it returns empty stuff.
Code:
const channelMessages = await interaction.channel.messages.fetch({
limit: 10,
cache: false,
});
const formatted = channelMessages.map((msg) => ({
id: msg.id,
author: msg.author.username,
content: msg.content,
timestamp: msg.createdTimestamp,
isReply: msg.reference !== null,
attachments: msg.attachments.map((a) => a.url),
embeds: msg.embeds.map((e) => ({
title: e.title,
description: e.description,
url: e.url,
image: e.image?.url,
})),
hasAnyContent: msg.content.length > 0 || msg.attachments.size > 0 || msg.embeds.length > 0,
}));
Why is this
have you enabled the message content intent?

what is the maximum message fetch limit
100 per request iirc
ok
Can the role option in slash commands support more than one role selection
no, but you can use a role select menu(in a message or modal) to have a user select up to 25
Thank you very much :)
Oh one more thing can bots sync channels to categories
documentation suggestion for @orchid radish:
GuildChannel#lockPermissions() discord.js@14.25.1
Locks in the permission overwrites from the parent channel.
Awesome :)
how to get accurate guild member count without it going Request with opcode 8 was rate
fetch all guild members once and then rely on the cache
Guild#memberCount discord.js@14.25.1
The full amount of members in this guild
Can I put select menus in modals
yes
Modals
Modals are pop-up forms that allow you to prompt users for additional input. This form-like interaction response blocks the user from interacting with Discord until the modal is submitted or dismissed. In this section, we will cover how to create, show, and receive modals using discord.js! This page is a follow-up to the interactions (slash commands) page. Reading that page first will help you understand the concepts introduced in this page.
Just confirming <guild>.<members>.cache.get() will fetch if it does not exist correct?
no, because its get and not fetch
Other way around, fetch will get from cache first
I have DJS running on an API route that rapidly requests a bunch of user IDs, Im only grabbing ID, username, avatar and if they are in the guild, Im getting ratelimited if i hit it more than twice,
How can I tell DJS to populate the cache with every member?
it does that already
unless you tweak the cache manually
with sweepers or limits
otherwise, it's already stored in cache
guild.members.fetch() once
async getDiscordUserDataFromId(userId: string) {
const guild = await this.getNCFCGuild()
if (!guild) return null;
const user = await this.users.fetch(userId);
if (!user) return null;
const member = await guild.members.fetch(userId).catch(() => null)
return {
username: user.username,
avatar: user.avatarURL() || "",
isInServer: member !== null,
};
}```
This is my fetching function, I can safely just fallback to cache?
like monb said, fetch fallsback to cache already
You get the user by fetching the member anyway, so that can eliminate one call
or well, not fallback, it's what is checked first
You can also simply populate the entire cache with guild.members.fetch() and then get from there without fetching
But if the member is not in the server, the member call will fail no?
if you need to know that, yes
Im using the state of if they are in the community to unlock actions on the API
there isnt really any way to not be ratelimited with a lot of calls though, djs will queue them accordingly
Well you could go the other way, fetch the member first, then only fetch the user if it fails
That flow will still save calls
Such as ```ts
async getDiscordUserDataFromId(userId: string) {
const guild = await this.getNCFCGuild()
if (!guild) return null;
let user = this.users.cache.get(userId);
if (!user) {
user = await this.users.fetch(userId);
}
if (!user) return null;
let member = await guild.members.cache.get(userId);
if (!member) {
let members = await guild.members.fetch().catch(() => null);
if (members) {
member = members.get(userId);
}
}
return {
username: user.username,
avatar: user.avatarURL() || "",
isInServer: member !== null,
};
}```
no
no, like mentioned that's what fetch does
fetch works like return this.cache.get(id) ?? this.callAPI(id)
In fact this is the exact opposite of what I said
Sorry ;w;
I would suggest
- get the guild
- fetch the member, which will use the cache if its there
- if that throws, fetch the user, which will use the cache if its there
- return the object
I see
do modals support file uploads similar to the slash command option
documentation suggestion for @orchid radish:
LabelBuilder#setFileUploadComponent() discord.js@14.25.1
Sets a file upload component to this label.
No
Modals only support text input
I forgot lowkey forgot
You might want to take a look at the Discord developer docs changelog
Send link I needa take a look myself
their question was already answered above
Well, this for example
Thanks
If only dropdowns could surpass 25
that'd be a pain to navigate
It’s only scrolling down
I mean I have a vault feature for users to store items in but when a user places item to bet the dropdown is limited to 25 which means the inventory is limited to 25
Double dropdown would help but it would be a bit weird
when updated modals
when code is done, reviewed, merged and released
keep this channel for support please
hey.
Has the <TextChannel>.stopTyping(); method been removed?
If that was a function. Yes it was removed. When using <BaseGuildTextChannel>#sendTyping() It will resolve on sending a message. Per Discord
Post a typing indicator for the specified channel, which expires after 10 seconds...
Generally bots should **not ** use this route. However, if a bot is responding to a command and expects the computation to take a few seconds, this endpoint may be called to let the user know that the bot is processing their message.
D.js used to send typing in a loop until you sent a message or stoped typing
This was removed in v13 iirc
Hi, on my server, I wan't to detect when the member accept the Discord natives rules to accord him a role, actually I'm trying to make this using the GuildMember Flags specially "CompletedOnboarding", I don't have the onboarding active, only the rules, do you have a workaround ?
My actual logic is that :
const completedOnboarding =
!oldMember.flags.has(GuildMemberFlags.CompletedOnboarding) &&
newMember.flags.has(GuildMemberFlags.CompletedOnboarding);
if (completedOnboarding && config.noVerifiedRoleId) {
if (!newMember.roles.cache.has(config.noVerifiedRoleId)) {
await newMember.roles.add(config.noVerifiedRoleId);
}
}
GuildMember#pending discord.js@14.25.1
Whether this member has yet to pass the guild's membership gate
documentation suggestion for @lofty topaz:
GuildMemberManager#editMe() discord.js@14.25.1
Edits the current application's guild member in a guild.
Avatar, banner ?
yes click the edit options to see all
whats the difference member.timeout and disableCommunicationUntil?
Timeout is a function. The disable communication until is a value
no theyre both functions
GuildMember#disableCommunicationUntil() discord.js@14.25.1
Times this guild member out.
// Time a guild member out for 5 minutes
guildMember.disableCommunicationUntil(Date.now() + (5 * 60 * 1000), 'They deserved it')
.then(console.log)
.catch(console.error);
i guess only difference is that you can put date here?
Anyone knows why i got this error on
Error executing command info: TypeError: interaction.options.getSubcommand is not a function
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
module.exports = {
category: "general",
data: new SlashCommandBuilder()
.setName("info")
.setDescription("Show info")
.addSubcommand(subcommand =>
subcommand.setName("server")
.setDescription("Show server info"))
.addSubcommand(subcommand =>
subcommand.setName("gebruiker")
.setDescription("Show user innfo")),
async execute(client, interaction) {
const subCommand = interaction.options.getSubcommand();```
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
Likely the above
So it's must be
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
module.exports = {
category: "general",
data: new SlashCommandBuilder()
.setName("info")
.setDescription("Show info")
.addSubcommand(subcommand =>
subcommand.setName("server")
.setDescription("Show server info"))
.addSubcommand(subcommand =>
subcommand.setName("gebruiker")
.setDescription("Show user innfo")),
async execute(interaction, client) {
const subCommand = interaction.options.getSubcommand();
No idea, depends how you handle commands
yeh it must be async execute(interaction, client) and not async execute(client, interaction) so thx 🙂
Oh, I have no idea. Sounds like the timeout function did not get removed or something
SelectMenuModalData#roles discord.js@14.25.1
The resolved roles
can you log if a message was forwarded
like from the side of the message that was forwared?
ye like the messag that was forwarded
no, I dont belive so
y
you can tell if a message is a forwared message tho
what do you mean "y"
it's just not possible... when a message is forwarded is not emitted through the gateway as you don't control where the forwarded message went... the only way to tell is if a message is a forwarded message
yea a forward is sort of like a screenshot of a message, you cant actually tell if someone else screenshotted something unless they send the screenshot and you see it
plus, similar to screenshots, iirc they take a frozen copy of the content and dont follow any edits made to the original
Yo
Have anyone of you here build an instagram scraper?
Maybe, but that’s a question for #general or #1081585952654360687
Bet
why do you want that
hello. could member leave events ever be partial? and if yes, will Partials.GuildMember fix the issue of missing those events?
Frtch all your members when your bot starts then you will have more data
You will need the partial as well
yes, that part is true. but also, does the member leave event not get emitted at all if that partial isn't present?
IF the "member" in the object is partial, that is
Uhh not sure I think it may not sometimes
hmm. i'm also working with the same assumption currently. anyway, thanku
why i get twice the same event if a members get muted and shortly after a role added? it sends the role event twice then? even tho i have enforceNonce set to true
error when i click on my modules v2
You can not use content with components v2, you should use components
so i have to do await message.channel.send({ components: [container.toJSON()], flags: MessageFlags.IS_COMPONENTS_V2 });
yes
but then ill get Error executing command help: DiscordAPIError[50035]: Invalid Form Body 4|rewrite | components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
what is MessageFlags
The message flag is the wrong value. The enum doesn't have underscores
nor isn't written in screaming case
documentation suggestion for @next wraith:
MessageFlags discord.js@14.25.1
in general (not just for members), that is how partials work
if an event would emit a partial structure, and the associated partial isn't enabled, the event won't emit
as a general rule of thumb, delete/remove events tend to emit partial data unless the structure was previously cached
discord tends to only send the updated structure for update events, so the old structure would also be partial if not previously cached
} = require('discord.js');
so the answers you received are correct
it is not IS_COMPONENTS_V2
MessageFlags#IsComponentsV2 discord.js@14.25.1
Allows you to create fully component-driven messages
Oka. That makes sense. thanks
a mute and a role being added are separate changes that would each emit a guildMemberUpdate
they should emit as separate changes, but I suppose if they happened to be received at the same time, it's possible the oldMember could be cloned at the same time for both (showing neither change), then since the newMember is the actual cached object, it'd be patched with both changes
therefore your guildMemberUpdate handler would detect both changes both times
I can't imagine the window for this to happen is very big
even tho i have enforceNonce set to true
this is entirely unrelated unless your nonce is the same for both times you attempt to send the message
on the assumption this is some logging system and you're seeing both changes being logged twice, I suppose you could hash the changes and use that as a nonce or something
Good evening, I would like to know how to create buttons with different layouts. For example, buttons inside embeds, etc. I haven't found any documentation on this.
those arent embeds
I'd like to know how to make the buttons appear on the right side.
Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.
those are sections
thank you!
Hello
I have made a menu , when I chose any option the option still, i can’t chose same option
yes thats how discord intended it. you can edit the message to reset the menu selection
Like what?
thats looks like a container? edit the message then with the same contents
okay that makes sense thanks. will add some cooldown to it if same stuff
What about
await interaction.message.edit({ components: interaction.message.componets )};
what about it
I don’t know?
i think that works. not sure tho maybe you have to reformat message.components
so are you guessing or are you making it do what was suggested
U knows
Is there an option in the library that does this automatically?
no, we don't do empty edits
Guessing
all you need to do is just edit the message with the same components
then don't. if you think that line does what you were told to do, don't ask us if it does it, run it in your code and see
So that works?
you can check if it does
it will either do what you want, or error
we are not running your bot's code
Most likely, someone else was asked the same question, so what was your answer to him?
this
you asked how to reset selection, got the answer to edit the message to have the same components again
you came up with the code to do it (bearing one typo, but your IDE would hopefully catch it anyway)
try it out
Ok
Wait
Another question in the code I only edit components, will the embed change? Or delete?
honestly unsure, but it will not hurt to pass those too
i have foggy memories of content not changing when editing only embeds, but it was years ago and i might not remember it right
yh that still happens sometimes
@empty spear hey could you add me? have something i wanted to ask you
if you have a question for someone, dm them
if their DMs are closed or they are not responding, then don't use this server to bypass DM restrictions
Hello !
How's the deprecation of the "ready" event coming along ?
I've just today upgraded from v14.24.2 to v14.25.1 and I'm a bit confused since :
- I no longer get the deprecation message for using the
'ready'event listener on the client - the
'clientReady'event never fires (I've been exclusively using the event for the past few weeks without a problem until today)
Sounds like a totally unrelated issue, nothing has changed about its deprecation
If I had to guess based on what you've said, the event isnt being registered, since you would recieve the deprecation if you registered ready and clientReady should be firing
Few things :
- I haven't changed the way I register the event collector.
- I am now at the moment exclusively registering
'ready'and getting no deprecation warning, and it fires correctly
Timeline of what happened for me:
- upgrade to 14.25.1
'clientReady'stops firing- I add back the
client.on('ready', onReady)registering -> it fires, no deprecation warning - I comment-out the
client.on('clientReady', onReady)registering -> nothing changes
Huh... are you sure you're on the version you think you are?
npm ls discord.js?
that's a good question
Holy shit I'm stupid, the package-lock is somehow disregarded for an older version in the container it seems
All good, these things happen
I must've broken my Dockerfile months ago 😭
-# edit : it was even more stupid
Thanks a lot
Is it okay to put Japanese characters in setCustomId?
i am not aware of discord having a strict regex there
i don't see why not
hello how can I set VoiceChannel's Status in the bot?
Considering discord usernames are unique, can we find a user directly by username?
If you know what server you have in common with them: yes
GuildMemberManager#search() discord.js@14.25.1
Searches for members in the guild based on a query.
Filter members whose username or nickname start with this query
do be warned that it can return many results (inc from nicknames)
i have wondered that
i right now do the most sus thing ever with checking every so often and then having 2 clients and subscribing to both but dedupe events
yo whaddup , im a bit fresh on this , so sorry if its a silly question , but is it possible to make a standard game invite like such ?
im sorta looking for a way to make source game invites in an integrated fashion since the steam protocol isn't supported
This is unrelated to discord.js you will what to ask on DDevs(#useful-servers) for the Soical SDK
i see i see
Hey i am sometimes getting „.permissionsFor is not a function“, im using it on a fetched discord channel
I wonder if this is a known issue, shouldnt that function exist on all channels?
can you show your code?
const discordChannel = await guild.channels.fetch(channel.id)
.catch(async err => {
if(err?.code === RESTJSONErrorCodes.UnknownChannel) await this.removeChatChannel(server, channel);
return null;
});
if(!discordChannel) return null;
const canManageWebhooks = discordChannel.permissionsFor(guild.members.me).has(PermissionFlagsBits.ManageWebhooks);
if(!canManageWebhooks) {
await discordChannel.send({ embeds: [getEmbed(keys.api.plugin.errors.no_webhook_permission)] }).catch(() => {});
return null;
}
It doesn’t exist on all channels
It doesn't exist on dm channels
What exactly is channel here? Because I'm confused why you need to fetch the channel in the first place here
Im getting it from a config so it might not be cached also itll get it from the cache anyway if it is right?
I see no reason to use cache.get over fetch
Well there are no dm channels when im doing guild.channels arethere
And im very sure its not a dmchannel in any case
If you get the error, log the type or just the channel
Also, if channel doesn’t have an id, then that’ll return undefined which fetches all channels for that guild. Which ofc doesn’t have a permissionsFor method. Hence Qjuh asked what channel is
I don't think Qjuh meant that, it's just that at first glance channel looks like a Channel already, so fetching it would've been redundant, since you have it already
since it's not a Channel then it's fine
Oh well if not mb lol
I mean logging it is the best to figuring what it is tbh, my best guess is what you said, that channel.id is undefined
Okay i get it
Ah that might make sense
Can we make something like auto-resharding without a downtime in the built-in sharding in Discord.js?
How did they send the container without the background ?
thats just muliple media galleries with separators
By not sending a container at all
I'm looking to do some unit testing for my bot and part of that is testing the messageCreate event. My initial thought was to capture a message from the raw event and then just replay it with emit('raw', ...) but it just seems to go to the void. My guess is that DJS just throws out the events since it is not logged in but I obviously can't do that during tests lol
Is there some way to override this behavior or am I forced to instead emit a messageCreate with a full Message instance? I took a look in the github but couldn't find any logic to throw out these events so take it with some salt
i thought mediagallery only works with container, my bad
You can emit the raw event. But that will just emit that. Not messageCreate. So if you want to test that then you need to emit that
Just adding on to this, I see there an injectedUser, injectedGuild, and injectedChannel. Not sure what the purpose of them really is besides for testing, could that be what I'm looking for?
https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/client/actions/Action.js#L105
I would think raw would pass it around the client and do the initialization for me? Is that not the same pipeline?
generally you want to test your methods, not the event itself
you can mock a Message instance or something like that and then just call your handler manually in your test
or make the handler accept the minimum amount of properties you need and then just mock that
the difference between that and an .emit test would be that one tests the event emitter (which you don't really need), at most whether the listener is appended but that'd be hard to miss
I was worried that would be my only option, thanks lol
No. Events getting emitted are output of the client. You can't put anything into the client that way
👍
I mean pretty sure you can emit the event, it's just that it's not really needed
Yeah yeah I was just being lazy in the hopes that raw would somehow pass it around to messageCreate with the message instance lmao
it does that but then you'd need to mock a lot of data instead of just what your method accepts
so it'd be more work actually
Someone made the constructor private for some reason so TS complains that I can't create my own instance lmao```
TS2673: Constructor of class Message<InGuild> is private and only accessible within the class declaration.
oh, guess that makes sense, you're not really supposed to make a Message yourself
you can ts-ignore it ig if you really want a full Message
I'd just do this
can even Pick it
That's what I did, seems to work fine regardless
I'll put in a quick pr to fix that, it's just one word. I'm not really sure why it's disallowed for cases like this lol
I've seen users make their own Message and Channel thinking that's how it works so it's understandable imo
Do people really do that? 😭
Well shit guess the private is staying then lmao
yeah quite a bit of guardrails are in place so newbies don't shoot themselves on the foot
as much as we don't want it, truth is a lot of people who don't know basic js or programming try to start making a full bot
God do many kitchen sink bots lmao
Anyways, thanks for the quick response, I'm not going to continue derailing this channel with random chatter lol
❌ Panel Error: ValidationError > s.string()
Expected a string primitive
Received:
| undefined
at _StringValidator.handle (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2615:70)
at _StringValidator.parse (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
at TextDisplayBuilder.toJSON (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2074:33)
at C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2535:64
at Array.map (<anonymous>)
at SectionBuilder.toJSON (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2535:35)
at C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2237:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2237:35)
at C:\Users\Administrator\Desktop\Teams Bot\node_modules\discord.js\src\structures\MessagePayload.js:151:46
That's a cool error. Any more details?
❌ Panel Error: 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
at _UnionValidator.handle (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1965:23)
at _UnionValidator.parse (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
at SectionBuilder.toJSON (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2536:37)
at C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2237:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2237:35)
at C:\Users\Administrator\Desktop\Teams Bot\node_modules\discord.js\src\structures\MessagePayload.js:151:46
at Array.map (<anonymous>)
at MessagePayload.resolveBody (C:\Users\Administrator\Desktop\Teams Bot\node_modules\discord.js\src\structures\MessagePayload.js:150:49)
at TextChannel.send (C:\Users\Administrator\Desktop\Teams Bot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:191:61)
CODE :
Sections need an accessory
Either a button or a thumbnail
If you don't need that, don't use sections
how to stop false posotvites in the memberupdate event shows roles added even tho i update my global avatar or is that just part of discord automation
The event contains both the old and new member state (if the member was cached)
Compare the old roles to the new ones
tryed this cant lie mate
Do you have the GuildMember partial? Is the old member state cached beforehand (aka, are you fetching all members on startup)?
yes i have the partial
Then you'll need to check if the oldMember is a partial before comparing the roles as it could be null
wont this blow upo my bot fetching all members on startup
No. You do it once on startup and let the GuildMembers gateway event keep your cache updated
GuildMemberManager#fetch() discord.js@14.25.1
Fetches member(s) from a guild.
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
It's a single API request. It returns the entire members list of the guild. It just takes time so do it as early as possible
memory usage will be thru the roof
Then you can make it ignore all guildMemberUpdate events where oldMember.partial == true
does it not send a gateway request?
yes, but "gateway" and "http"/"rest" are still the overall discord's API
i see, thank you for elaborating the terminology
does it really get all? like as in for big servers does it do the pagination?
(i wonder for future me, idk what it does)
it doesn't hurt to open dapi docs
it's a single request, not pagination per se
according to my research, running it on a 2.5m server has fried the event loop
lol
that's because you received 2500 events
yeah the api i know doesn't yield all but wasnt sure how chaotic djs was haha
the api does yield all
just not at once
you don't get a gigabyte blob of 2.5m members
or if the guild is over 75k members, it will only send members who are in voice, plus the member for you (the connecting user).
When initially connecting
please read entire paraghraph first
ah, that blob of text is painful
last 2 sentences are of relevance here
yeah i read it again fully now and feel dumb
im glad to not need member info, as idk how these bots deal with that spam
they receive it
hahaha
imagine the cost of reconnecting to shard... well honestly that event is prob least of the conserns
the fact that one bot has "fried event loop", whatever that even means, does not mean that this request is a certified killer
literally 0
reconnection is not reidentification
like spawning new i meant, like when you need more as too many servers
there are ways to do it without downtime
at least discord allows you to have many ws connections at same time :)
it involves some math and careful restarting, plus a way to stop one instance from responding
but tl;dr you spawn 2 bots at once, one with more shards
and then you stop the old one
that's.. sharding
like many of same shard
it doesn't allow, it requires
who needs over 2.5k servers
going back to this, is there really any gain to use the normal http endpoint over just this (when already have connection)
seems like way better in scheme of ratelimiting haha
lack of gateway for starters
If you have a gateway connection using it for fetching all members is the best option.
the second part is lack of the intent to receive the chunks (though the same intent also gates the rest request, so a moot point)
time to make ws conn, just so i can request that
None of this is djs related at this point though, so as tipakA already said: #general
ye my bad
Hey how would i get the owner of a bot with or without discord.js is there anyway to see the bot owner without using discord.js?
Like is there an API to see information about a bot
no
There is a way to get the owner of the bot you're running. But not of other bots
damn.. that sucks, why doesnt discord have an api for that tho? or an feature for that
Because it's not public information I'd say
quick question: is there no way to get an interaction when a select menu is cleared (clicking the x on the right)? it seems to be just a client side change that unselects it but doesnt do anything. it's annoying me a little in a ui design sense that i have to also add explicit clear buttons when there's an x right there
Yeah the x doesnt send a new interaction, that selection is only in the client side cache
aw :(
thanks
I am having an issue with guildmember cache. I want to get all members of a role. It worked after the bot booted. but I think the members got sweeped. This is a single server bot. I want to double check my work here
I am going to add this to the client will it fix my problem
const client = new Client({
intents: [
Intents.Guilds,
Intents.GuildMembers,
],
sweepers: {
...Options.DefaultSweeperSettings,
guildMembers: {
interval: 86_400,
filter: () => (member) => member.guild.id !== process.env.GUILD_ID,
},
},
});
Why do you have a sweeper at all for a single serrver bot?
therres no default sweeping behaivour on guild members
when is guild messages search getting added
bro is just got documented
it’ll be available in a couple days
whenever it’s ready djs doesn’t give eta’s
someone will push it on gh
What’s actually wrong? Does it just give a wrong number
it is returning a list one member from role that has more, so I am trying to figure out what is clearing the cache
hmmm any ideas on what might be clearing the cache
Can you rephrase that? Idk what you mean
There's alread ya a PR for it
It will be added when the PR is reviewed, approved, merged, and released into the next stable version
Nope no idea sorry
I have a command that is to return a CSV of the members with a role
The command was not working returning a incomplete list
I added Fetch to the ready event, it worked.
but then stopped seeming that the cache was cleared
Ig that is strange. Like mon I have no idea. Maybe you’re deleting members from the cache manually somewhere?
Does it just return no members?
no it returned one or two
What happens if you refetch? I genuinely don’t know
I am not sure. I will try and let you know
brill news thanks
i uploaded an emoji to my bot and tried doing
client.emojis.cache.get(this.EMOJI_ID)?.toString()
``` but i am getting undefined, is that a partial or something i need? (and yes it is the right emoji ID)
client.application.emojis()
client.emojis is for guild emojis
thank you
what type of data did you want from it?
as if its just the mention you can use the for matter with that id https://discordjs.guide/legacy/popular-topics/formatters#mentions and not need to worry about cache :)
I was hoping there was a way to feed some function an emoji id and then it spit back the formatted emoji like <:emoji_name:emoji_id>
yeah that formatter i linked does it
Oh shoot my bad thank you!
Wait sorry I don’t see it in that guide, what function exactly? I only see something for channel role and user but nothing for emojis
formatEmoji discord.js@14.25.1
Formats an emoji id into a fully qualified emoji identifier.
oh damn the guide dont have it, but it should be formatEmoji
Oh okay thank you that worked
How large is the server?
Cause pretty sure during reconnects(?) or something like that we have to assume the cache is stale and redo it
I bumped into that myself a lot over the years, in a ~8k server iirc
You can probably find my and others' diggings if you search for memberCount from me in #internals
About 11K
On reconnect the member cache gets cleared. Should (re)fetch on shardReady instead of clientReady
Is that on client or shard manager?
(event) Client#shardReady discord.js@14.25.1
Emitted when a shard turns ready.
Thanks
Hi, webhook can send component v2 right? cause when i try to send it, it throw DiscordAPIError[50006]: Cannot send an empty message
You need to provide withComponents: true
thanks
and i need to incl. flags: MessageFlags.IsComponentsV2, right
Yes
thank you
you also can "upgrade" a message from normal to cv2 with those 2 options, but not other way around
Is it possible to read the 'about me' of some user through discordjs?
Not through the API period
How to get Upload File feature in Modals
guide suggestion for @copper breach:
File upload
File upload components allow you to prompt the user to upload a file from their system. Discord does not send the file data itself in the resulting interaction. You will have to download it from Discords CDN to process and validate it. Do not execute arbitrary code people upload via your app!
Ok
To clarify the linked guide section explains how to add the file upload component to a modal
shardReady fires no matter if you have sharding or not right?
i mean you always at least one shard :)
i can't see any reason it wouldnt
Is there a way to determine if a user icon is the default one?
Perhaps using a hash?
the user avatar hash would be null i think
User#avatar discord.js@14.25.1
The user avatar's hash
Even with icons like this?
How is it that there can be DMChannels in guild.channels.cache
are you sure? it doesnt make sense for dm channels to be in guild cache
yes. you can always try it out first
thank you!!!!
I know but i keep occasionally getting permissionsFor is not a function because theres dmchannel sometimes there
are you doing that command in dm?
they are like normal pfps, but they seem to use the same hash... so you gotta find them all and then make collection of hashs thata re default
i remember hearing there was 25 pfps made, but idk if all are usable
(all i know is in mobile app apparently on user creation it suggests some)
thank you!!!!!
here are a few hashes that some people use btw to get you started :) https://github.com/ImLunaHey/jive/blob/53e614eee74c3146573cf877b3d077ff8fd0fde9/src/features/safety/feature.ts#L54-L63
very very thank you!!!!
oh so it really is just those 8
good to know
👍
Are you by chance adding those channels there?
Yes
Im not adding any channels to the guildchannelmanager if thats what you mean didnt know that was even possible
that'd be a cache.set()
you aren't using that anywhere?
or an accidental = instead of == / ===
Is this the proper way to retrieve the values of a modal string select menu interaction.fields.fields.get('eat').values; 
No
interaction.fields.getStringSelectValues("customId")
Thank you so much!
am I able to change the bot's avatar and username only in one server?
documentation suggestion for @sand minnow:
GuildMemberManager#editMe() discord.js@14.25.1
Edits the current application's guild member in a guild.
thanks!
I'm curious why does setting like banner: null, and banner: "" not remove it?
trying to remove the banner and bio
As in to default discord style or the default bot?
default discord style
Ah i dont think thats possible without also resetting ur bots main
here is the Discord doc for the end point it is not imidately clear to me how to remove the banner
Yeah Its clear how to remove to fallback to bots, but not to completely disable
I guess I am just miss understanding what "default discord style" means
#11462 in discordjs/discord.js by Qjuh opened <t:1774037898:R> (review required)
feat: allow partial DMChannel without client user
@rugged dirge please use #app-commands for personal apps usage
nah no way
check tipaka's comment
no
i wouldnt do .channels.cache === 'to idk what this would be'
not that, assigning a channel instead of comparing
just double check all your comparisons are with == or ===
otherwise, show how you are fetching the dmchannel initially, not getting it from cache
they definitely are
im not really fetching dm cannels at all, i do have a place where im doing user.createDM
can you show that file?
when i refetch all channels theres no DMChannel but it stays in the cache
its on entitlement create im just doing
const user = await entitlement.fetchUser();
logger.info(`Entitlement created by user ${user.displayName} (${user.id})`);
const dm = await user.createDM();
await dm.send(getReplyOptions(keys.custom_bot.success.subscribed, await ph.commandName('customize', true)));
on another note im getting this error when simply doing guild.members.fetch sometimes
We know our code, we don't know yours
dude im just doing guild.members.fetch
Like for example that "fetchMembersIfCacheDiffers" cathes attention
well im not making guild.shard undefined
No dude, that's not the only line of code in your entire project
if(guild.memberCount !== guild.members.cache.size) await guild.members.fetch();
``` this is the entire fetchMembersIfCacheDiffers
you should fetch all members on clientReady for every guild
and just use cache
bruh goodbye memory
arent u killing memory this way same way
no its only limited guilds
If it's undefined it would most likely mean it's not a guild in the first place
so other guilds dont have members at all or?
Reconnects clear cache anyway so that fetch is still useful
well discordjs keeps track of members afaik by gateway events or fetches or whatever
so most guilds will have valid members
members wont be in cache if u dont fetch them
i only need to fetch members in specific cases
That's why they are fetching them
they will by events but not all of them
If they don't have them
And need them
it doesnt even matter, theres an error and its unrelated to what we are discussing
right, my bad
np
im fetching members so that i can check whether a member has specific roles
one question do u use typescript
apparently fetching a single member isnt enough for that (not sure but thats probably why i wrote the code like that)?
nop
are you sure that guild is always a guild
jsut look at the stack trace not sure it could be anything else
it could be undefined if you did
const guild = client.guilds.cache.get(...)
guild.members.fetch()
guild.shard is a getter
and that COULD give that error idk never seen it
What's guild.shardId on that guild
That's completely not what the error is
its 7
and guild.client.ws.shards?
Guild#shard discord.js@14.25.1
The Shard this Guild belongs to.
collection of one shard
With id of
0 actually but im evalling this from a different shard than the code is running it from
wait actually idk
well its 0
Are you fetching guilds
and the guild.shardId is 7 but doesnt that just mean what shard the guild is "assigned" to
yes?
don't
instead? and why?
You have fetched a guild on a shard it doesn't belong to
what thats a thing, that breaks stuff?
Instead of fetching the guild locally
so is this only for guilds or for other data too?
All
But some stuff breaks more than other
so basically never do fetch but always like shrad.getClientData or broadCastEval on that specific guild.shardId
You can broadcastEval too, but don't try to pull entire Guild if all you need is it's name
Or don't try to pull all thousand members from other shard just to count how many you got
The shard that already has that data is already capable of counting it and returning you the number
well i often need a guild object to do operations on it, i could just pass the id and then broadcastEval whenever i need to operate on it
Yeah
Do that. Tell relevant shard to do work on guild it has
this is new to me, didnt think that could make issues moderately annoying
Because a guild can only ever be on one shard
You fetch a guild that will then no longer anyhow update, and it might have less data than the guild received on login
so could this also be responsible for the permissionsFor issue ive had previously
Dunno
Sounds unrelated, but i guess you could revise your code now with this knowledge
okay time for refactoring, gtg good night thansk for helping
And maybe you'll find something similar
if i put id of a category id
const ignoredChannelIds = ['1461151996550582446'];
if (ignoredChannelIds.includes(message.channel.id))
would this work (its a category not a channel)
....day, uh... whatever it is until new modal components are integrated within d.js
no cuz a channel is not a category
message.channel can't be a category though? you can't send messages to a category
categories are channels, it's just not possible for message.channel to be one
so what do i do
category is message.channel.parent
do you want to check the channel's category or where is your category?
🤷♂️
I don't understand what you meant but if you're asking for an eta or release date, the team doesn't do that, it'll be released when the new version is ready
I meant to say "modal components", but my brain gets ahead of me
and no, sir; just... a "reminder", (I guess?)
nothing much I could say in here for the time being
using the indev wouldn't be a good idea for me
and from my experience of using hybrid raw API and d.js... they aren't well.
theres only the new radioboxes and checkboxes to be released, the other components are already out
yes, I'm looking for them two
it'll be announced in #announcements with an everyone ping so there shouldn't be a need to remind specifically someone
alright then, appreciated 
when i deploy my deploy-commands.js script
DiscordAPIError[50035]: Invalid Form Body
9.options[2][APPLICATION_COMMAND_OPTIONS_TYPE_INVALID]: Sub-command and sub-command group option types are mutually exclusive to all other types
you going to need to share the commands that you are trying to register.
specifically the 10th command you're deploying has both subcommands/groups and regular options
https://sourceb.in/kdbmIQ8XxS - thats the full error
we know what it means so it's not really helpful, you're going to need to log your commands before deploying
all of them?
I don't know if the order of your commands is constant and they're deployed in bulk so yeah ideally
you can also just log the names in the same order
in deploy-commands.js?
yeah
oh yeah, it does go in the same order
like after the last one it says
Started refreshing 27 application (/) commands.
then errors
"after the last one"?
can you show your code?
yup
okay and does it still specifically say 9.options[2]... ?
yes
9.options[2][APPLICATION_COMMAND_OPTIONS_TYPE_INVALID]: Sub-command and sub-command group option types are mutually exclusive to all other types
then the issue would be the 10th command you logged
^^
alright
Hi! Veteran here (im very lost with v14)
when I have
await interaction.reply({content: `${emoji} ${result.message}`, ephemeral: true})
it says its deprecated but
await interaction.reply({content: `${emoji} ${result.message}`, flags: MessageFlags.Ephemeral})
doesnt work either
would appreciate some help!
This is the error message
ReferenceError: MessageFlags is not defined
you need to actually import MessageFlags
that's just how js works, nothing is imported by default
Okay thanks! My bad, thought I was missing somethng else
it's fine to see 4 vulnerabilities (3 moderate, 1 high on discord.js 14.25.1?
Yes, they're related to undici and dont impact discord.js usage
in my code I'm able to do flags: ["Ephemeral"]
can threads be created with it being never archived or smth?
Error: Expected the value to be an object, but received string instead
when using an unicode emoji in a button inside a section
in a normal button it works, it errors only if the button is an accessory
Can you put emojis into a modal?
in a forum you can make one pinned and that never archives
otherwise you can make a bot that auto-unarchives them
How do you mean? I believe you could by adding a text display to the modal
could you show your code?
Hiii
HI this is a support channel if you nee help please ask( #how-to-get-help ) other wise uses #general
hey
same for you
do u know how they got the lines on this
guide suggestion for @ivory spruce:
Separator
A Separator is a layout component that adds vertical padding and optional visual division between components. You can select the amount of padding used for the Separator component (small or large) as well as whether a visual divider should be displayed (defaults to true). You can use the SeparatorBuilder class to easily create a Separator component. When a Separator component is used without any non-Separator components in the message payload, the message will not have any visible content.
and they added the button by components v2 right
if you are using ButtonBuilder from "@discordjs/builders", try to use it from "discord.js"
the screenshot you send is all via cv2 its mostlikely textcomponent, separator, section, separator, section, separator, actionrow component
the whole message is cv2
container
text display
separator
Section
text display
Thumbnail
separator
Section
text display
Thumbnail
separator
action row
button
Like it shows the emoji panel where you can select custom emojis
oh no, users can not submit custom emojis
but if they are smart, they can manually construct the <:name:id>
(ie if you're going to just directly use the content for a message)
im not using buttonbuilder
setButtonAccessory gives me a button builder as parameter
then you need to use ButtonBuilder
like setButtonAccessory(new ButtonBuilder().setEmoji(emoji))
im following the guide basically
const exampleSection = new SectionBuilder()
.addTextDisplayComponents(
(textDisplay) =>
textDisplay.setContent(
'test',
)
)
.setButtonAccessory((button) =>
button.setEmoji("👍").setCustomId('exampleButton')
.setLabel('Button inside a Section').setStyle(ButtonStyle.Primary),
);
interaction.reply({
components: [exampleSection],
flags:[
MessageFlags.IsComponentsV2
]
})
sure but the guide is quite misleading then
using a callback function is valid
where do you import SectionBuilder from?
discord.js
import {SectionBuilder} from "discord.js"
ok, just checking
one sec I am going to try and relipicat the issue
its kinda hard to replicate it
@copper breach please use #app-commands or the hide option
what do you mean?
im trying to copy its look
guide suggestion for @ivory spruce:
Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.
Your going to need the read the guide no one here is going to do it for you
ty
Ok
I think I know what is up. section builder call back is using the underlining builders class witch is expecting an APIMessageComponentEmoji
the button builder as exported by discord.js main is extended from this builder
so basically it's a bug and the workaround is to pass the correct builder?
it's not a bug, it's by design
the callback passes in a /builders class, not the discord.js class
so this is not going to be changed?
doubt because instead of using callback you can just make a new discord.js class and pass that
well yeah but i don't see the point of passing a builder to a callback if i still need to create my own instance
i wasn't part of the design
fair point
The function can take a buttonBuilder as a pram instead of the callback
can't tell you if it was more of a idealistic reason, or more of a technical because builders aren't actually part of d.js
making them return discord.js classes would mean you couldn't use them without discord.js, which ruins entire point of it being a separate package
Hey - is the auto role assignment in stable djs yet?
you can check #announcements
i see
I guess not as there hasn't been a release this year? Unless I'm blind
correct
Is there a list of what's needed until next version releases?
I've been facing this error and I know of no clear source/origin that's causing this.
DiscordAPIError[10062]:Unknown interaction
File "/opt/magpie-khxyro-yt/app/node_modules/@discordjs/rest/dist/index.js" , line 762 , col 17 , in handleErrors
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
File "/opt/magpie-khyro-yt/app/node_modules/@discordjs/rest/dist/index.js" , line 866 , col 29 , in runRequest
const handled = await handleErrors(this.manager, res, method, url, requestData, retries);
File "native" , line 7 , col 39 , in processTicksAndRejections
"needed"? not really. as always we have no ETAs and discord continuously changes things currently
tag suggestion for @winter mason:
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
Is there a way to debug this more effectively when I have 50+ commands, components and buttons?
Is there anyway to know more details on which command/command (custom-id), this is occuring with?
Does anyone have the link to docs/guide for when they added channel, roles and users select menu inside of modals
guide suggestion for @hoary rock:
Modals
Modals are pop-up forms that allow you to prompt users for additional input. This form-like interaction response blocks the user from interacting with Discord until the modal is submitted or dismissed. In this section, we will cover how to create, show, and receive modals using discord.js! This page is a follow-up to the interactions (slash commands) page. Reading that page first will help you understand the concepts introduced in this page.
Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.
client
.on("debug", console.log)
.on("warn", console.log)
- Note: if you initialize your Client as
botor other identifiers you need to use these instead ofclient - If the output is too long to post consider using a bin instead: gist | sourceb.in | hastebin
Can I use warn button?
.setStyle(ButtonStyle.Warn)
is it wrong?
that is not a button style from Discord
Sorry?
there are six button styles in Discord
Warn style doesn't exist. if it did it would be listed
My question is not about Buttons..?
I thought it was real
did you see the answer you got already?
😭
I am sorry I replied to the wrong post 😭
yeah, it's literally a feedback post (from 3 years ago)
Yes. Is there a more reliable way of debugging this instead of relying on complete code audit?
catch your promises
and....?
and see what throws?
you have an error of unknown source, that has only so many possible reasons
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
It is one of those three things
the Promise rejects with that error
you gotta find which one
to have a chance on figuring out why
can i .editReply interaction multiple times?
Yes, as long as it is within 15 min of interactions acknowledgement
alright
I was trying to install @discordjs/opus and this is what I get: https://srcb.in/hK7J5cAR2h
Why?
it says exactly why and what you need to do
Hey so curious question, with interactions v2, say if you wanted to edit a specific field to replace buttons with a select menu, as easy as embeds, would you have to replace the ENTIRE container, or can you js edit that one field of the container where the interactions are
yh you have to replace entire container. it doesnt have any set methods like embeds only add
that's so lame
you have only spliceComponents that might be useful for you
ContainerBuilder#spliceComponents() discord.js@14.25.1
Removes, replaces, or inserts components for this container.
you can recreate the builder from the message component data. then edit
Is there a way to set permissions for threads created in channels?
ThreadChannels don't have permissions on their own. They inherit them from the Parent channel
I understand, thank you.
What is the different between this two? Is it only for the developer or the user can see it too?
The latter is a group of the former
Sub commands have a limit, i think its not particularly generous.
Lets assume it would be only 10 sub commands you can have (which is probably wrong)
With sub command groups, you could have 10 groups instead of 10 subcommands.
Those 10 groups can then themselves result in a lot more sub commands than you would have otherwise.
But in short, the latter is a group for the former
I did not find groups particularly fun to use from a user perspective, and since I dont really need 100 sub commands, I tend to not use them
It's 25, so 625 sub commands
But grouping has more uses than just "I need more than 25 subcommands". /settings add user vs. /settings adduser makes more sense semantically
sadly they arent as much independent as people want. mainly as they still only have same perms as top level and in code the subcommands are just "options"
I updated to discord.js version 14.25.1 and it says there's a high vulnerability and a moderate vulnerability what do i do, how do i fix it
what package does it talk about
if its undici you can ignore it
Okay yeah it's undici
I need help disabling the discord server embed of the message, I've tried putting the discord gg link in < > but that didn't work
Is there a way to send a message with disabled embeds?
doesnt work with invites
set in a container or embed instead
Does my bot need the EmbedLinks permission to send embeds to a channel?
Reason I'm avoiding containers or embeds is because of this, I want the bot to send this message on invite to a channel he has access to sending messages to, and I want to avoid looking for a channel with embedlinks permission
honestly best use of cv2 even if you are just sending normal just what content can do
What? I don't understand
Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.
appreciated
i cant remember, but i dont think embeds from bots are subject to that and its only autogenerated ones... but i havent tested
the new components i dont think should count - esp how that annoying user setting 9to not show embeds) doesnt effect it which is a big W
Alright got it, many thanks
how come my command name change isnt deploying or changing via / my bot is sharded also any reason for this ?
- Are you registering your changed command names with Discord? Updating your code alone doesn't update the commands
- Have you restarted your Discord Client (the app itself, not your bot) with Ctrl+R?
ye refreshed my client wdym by num 1
using rest to register commands usualy it updates straight away now i changed a commands name due to inccorect spelling and its failing everytime i run the command
Define "it's failing"
Is there a way to convert a JSON modal like this (made with https://modal.builders/) to an actual modal with discord.js?
"title": "Modal",
"custom_id": "modal",
"components": [
{
"type": 18,
"label": "Text Input",
"component": {
"type": 4,
"custom_id": "46fa1bad6b864cfca3603b70794bcb0e",
"style": 1
}
}
]
}```
fixed it thanks
this is usable exactly as is
the builder isn't required, and you're free to pass that directly to <Interaction>.showModal()
Beautiful 🥹
Can I also directly use the JSON output from https://discord.builders/ in interaction.reply?
yeah
Wow this is truly a dream coming true 🥹🥹
it has an option to make it discord.js instead of json
Yeah I know, but I want to allow users to build custom modals my bot then uses.
Oh, thats actually a good idea never seen anyone do it
I thought I had to build a manual parser for my bot to understand this JSON modal, but discord.js is just perfect 
djs functions usually take either a valid json object, or any object with a toJSON() method that returns a valid json object
ModalBuilders have that toJSON() method so they work fine, you can add that method to any other object, or you can use json directly
JDA doesn't seem to have this 
It's just the raw JSON that discord's API accepts, nothing magical about it. Any library that can send a request to discord can also do this
javascript just happens to have very nice syntax for JSON, hence the "JS" part of JSON
There is a function for get the list of joins request
more context?
I have a server that is in ‘ask to join’ mode, and I would like to create a bot that gives me the list of people who have submitted a request with discord.js v14
I dont think thats available in the api yet
How does someone submit a join request?
should my bot fetch it's member self in a server before like checking for it's member permissions in a server? Or are those always in cache by default on guild join or boot up? I have the Guilds & GuildsMembers intents.
some servers can now set join requests, wheres users upon joining must submit an application first
no members arent cached by default on startup. you gotta fetch them to have them cached
Even the bot? I don't care about other members just the bot
i dont think you have to fetch the bot as a member
although docs say guild.members.me could be null so im not sure
prob because its not guaranteed to be cached
like you can customise how cache works
like making agressive sweepers or just disabling it
aside from that however, it should be cached on ready with the Guilds intent
alright thanks all
ah yeah i forgot about when you try to access before Ready event too
Is fetching the audit logs the only way to figure out who deleted a message? I have a problem where sometimes the message deletion doesnt get logged in audit logs and thus i cannot find who deleted it
user self deletes & bot deletes (not bulk) dont get saved to audit log
ah
RangeError: Value is too large to be represented as a JavaScript number: 1424408311582953628
at Object.find (file:///C:/Projects/Shockwave/db/db_handler.js:44:30)
at log (file:///C:/Projects/Shockwave/src/log.js:6:33)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
code: 'ERR_OUT_OF_RANGE'
}
```I understand what this error means but I keep getting it when using interaction.guild.id and I am not sure what to do to fix it?
Are you casting the ID to a number at any point?
not that im at all aware of
the chain of me using the id is a bit confusing since it goes from a command to a function to my db handler
erroring at every step of the way
Ah, I have guildId set to a strict interger in the db handler, could that be the issue?
Yes that is where I assumed the issue probably was. It's not necessarily an issue to do that, you just need to ensure that the JavaScript side of that logic always handles the id as a string and the DB itself does the conversion to and from int to str