#djs-help-v14
78874 messages · Page 54 of 79
Ik
if your app reaches 100 slash commands you need to rethink how your commands work
I haven't been developing a discord bot for about a year, and about a year ago, there were occasionally problems with discord. At the very least, it could even be slowness.
Its private app for only one server its like all in one bot for one server
there arent any problems with slash commands. you just have 3s to respond to the interaction if you dont defer
OK. I will do it. thanks.
even all in one bots arent close to 100 slash commands
Seen one on yt 200 commands
all probably unorganized and not a thought of grouping them into subcommands
i have prob every feature added to my private bot and im at 70 commands
OK thanks
Ok 😁
Major Discord bots still support prefix commands. I wonder why.
because most of them are old. people are used to their prefix commands of years ago
and they have the message intents so have no reason to remove them
ok
It was there already and going from prefix to slash commands isn't a hard task imo
And now click on the other link. The one to the guide. The second one Mafia caused to be sent by docs bot
they problem is solved, I was converting /cmds to !cmds with chatgpt, so all was good but in middle it convert the cmd to module.export = commandname
then logic of that, because of this module.export in middle it was not taking, Now its solved,
btw, thanks you helped me
i was going to ask about something forgot what it was now im annoyed i cannot remember
yo
erm hi?
so could someone help me:
rawError: { message: 'Unknown Message', code: 10008 },
code: 10008,
status: 404,
method: 'PATCH',
url: 'https://discord.com/api/v10/webhooks/1415662862310834318/aW50ZXJhY3Rpb246MTQzMjM4MTM1NTY3Njc5NTA1Mzp5RzZwOHBKU3dPSnNzQkVzU0ZkZ2phWnBOVXVhNGdya2Y1VGZSMDgweml3b29TNEtJdHJvWEppV0Yzd25UQndoa0d4NDlvZm03SXhhSlpNSWthYVNDeFJXMHpqckt3RDFiMUlnT1U2SkJVU0ptN3hnMXVrNm9xYnltU2hnSUtvNA/messages/%40original'
}
keep on getting this error whenever i did my setup command on my bot
you're going to need to show your code and explain your goal
You’re trying to edit an interaction reply that doesn’t exist (anymore)
so basically i want to make a setup command that can create roles, channels categories and don't know why it's not working
oh, my bot ping was quite high tbf, once it reached like 2796 ms
use like pastebin for this pls
or the like
so, i've actually never heard of pastebin
Lot easier for those on mobile to see your code if it’s on one of those services rather than an attached file that would have to be downloaded
you can't deferReply after showModal. showModal is the response to the interaction
oh, alright so i'm guessing that was the problem
so hey @wary coral what should i do about this userside error though?
i'm sorry if i'm asking again and if it's rude, i'm just a new dev, sorry if i pinged you when i wasn't allowed to and all that
do you get an error from the bot?
thats not something user sided. check what youre doing after modal submit
content: 'Processing...',
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: { message: 'Unknown Message', code: 10008 },
code: 10008,
status: 404,
method: 'PATCH',
url: 'https://discord.com/api/v10/webhooks/1415662862310834318/aW50ZXJhY3Rpb246MTQzMjM4NDYyMzIwNzM4MzA2MDp4eHlPVnJQaUlxQUV0OWJ5RzRPUHdobFpPQ1lMN1Nzc0U4d3JlQ1dWQUw4Y0lIT3NVakZzdmtISll2V0ZFcGw5cmU3N25kbFR6cUhobm9KR1ZmYm8zOHJnc2g2T2tjbVBOcnhkTEJmUHF0YkRqbzU0N3dGUkYyVmUwNWhNU3g0Ug/messages/%40original'
show the code first in pastebin
use the submitted interaction, not the original command interaction
you need to reply to submitted not interaction
oh, thanks
sorry for pinging you all, thanks for the help
Hey, we can now edit ephemeral message?
Like a counter for example
you always could
ah
ChatInputCommandInteraction#editReply() discord.js@14.24.0
Edits a reply to this interaction.
// Edit the initial reply to this interaction
interaction.editReply('New content')
.then(console.log)
.catch(console.error);
usable for every repliable interaction, not just slash commands (chat inputs)
thanks
why does member.guild.members.cache.size sometimes return the incorrect member count?
before checking this, i call await guild.members.fetch(); if they haven't been fetched for that guild since the bot has restarted
i got this issue recently and my fix is that i wasnt fetching members properly on startup
are you modifying your cache somewhere?
its impractical to manually fetch each guild's members on startup
nope
you can use the count on the guild
Guild#memberCount discord.js@14.24.0
The full amount of members in this guild
will that always be correct?
it would be whatever the Discord API gives you. it would probably close enough
bet ty
actually for a few commands i need the cache to filter for bots. for those cases would it just be worth re-calling await guild.members.fetch(); and would it always return the proper count?
would that matter the apps are such a small number compared to total server size
i mean its just useful to know the bot count
youd normally only need to fetch members once, after that the cache updates accordingly
im just confused as to why my cache is displaying less members than there are
is it a big difference?
yes, it's showing 6 compared to 300
try to fetch members on startup and then see cache
it fixes on bot restart but breaks after a few days
its not practical to fetch all guild's members anyways
I'm not sure what's the expected behavior
you want the cache to be accurate, but you don't want to fetch all members
there's no way for the cache to be accurate if you don't have all members
before checking the cache i call await guild.members.fetch(); if they haven't been fetched for that guild since the bot has restarted
i dont think that work cuz therell always be one or more members in the cache. so you will never fetch
if they haven't been fetched for that guild since the bot has restarted
how are you checking that?
import type { Guild } from "discord.js";
const fetchedGuilds: string[] = [];
export async function fetchMembers(guild: Guild) {
if(fetchedGuilds.includes(guild.id)) return;
await guild.members.fetch();
fetchedGuilds.push(guild.id);
}
and where do you use that?
await fetchMembers(member.guild);
console.log(member.guild.members.cache.size);
should be fine, how big are the guilds you're working with? where is that last snippet?
the bot is in one guild with 40k members, 18k, 11k, 5k, 3k, 1k. but the ones we're getting reports of are only 100-400 members
i simplified it
// Join Logs
await fetchMembers(member.guild);
logger.channel({
guild: member.guild,
moduleName: "serverGate",
settingKey: "joinLogsChannel",
title: "Member Joined",
color: "green",
thumbnail: member.user,
customDescription: `${formatDescription([
{ name: "User", value: formatUser(member.user.id) },
{ name: "Bot Account", value: member.user.bot ? emojis.success : emojis.error },
{ name: "Account Created", value: time(Math.round(member.user.createdTimestamp / 1000), "R") }
])}`,
footer: formatPlural(member.guild.members.cache.size, "member")
});
that's just one example where i use it. see another below
await fetchMembers(interaction.guild);
const totalCount = interaction.guild.memberCount;
const botCount = interaction.guild.members.cache.filter(m => m.user.bot).size;
interaction.reply({ embeds: [
plainEmbed(`This server has **${formatNumber(totalCount)}** total members (${formatNumber(botCount)} are bots).`)
] });
can you show your client constructor?
export const client = new Client({
partials: [Partials.Message, Partials.Channel, Partials.User, Partials.GuildMember, Partials.GuildScheduledEvent, Partials.ThreadMember],
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.DirectMessages, GatewayIntentBits.DirectMessageTyping, GatewayIntentBits.GuildModeration, GatewayIntentBits.GuildWebhooks, GatewayIntentBits.GuildExpressions, GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildScheduledEvents, GatewayIntentBits.GuildVoiceStates]
});
should be fine, the only thing I could think of is timeout errors since members go through the gateway
though if you only want the bot count I'd just fetch once on start, not cache and update the number on join/leaves
is it fine to fetch all members of all guilds on bot start tho?
why not?
idk its just a lot of api requests
Its cached to an extent
so you mostly ask about the api spam, not when you're doing it (on start)
wdym
if you're asking whether fetching all members at once is fine
not whether doing it on start is fine (but wouldn't in other times)
im asking if fetching all members from all guilds on startup is fine
How many guilds with how many members?
rn the bot is in 380 guilds. one server has 40k servers, 18k, 11k, 5k, 3k etc but i want to future-proof too
fetching all members is a single request by the way, not one per member
thats still 380 requests
and is fine for discord's ratelimit
yes but like i said i want to future proof too
with that many members you should expect much more requests anyways
that should always be fine
the ratelimit is 1 per guild every 30s
Why do you wanna fetch all guild members btw
so as long as you don't request more than once for that same guild, pretty sure it should work
thats what was suggested to fix my bug
original issue: #djs-help-v14 message
you already do that, we're suggesting it to do on start
yes for every guild at once
you'll eventually fetch every guild, you won't hit any ratelimit and you won't cache them, so it's fine
but my issue still stands, even after fetching the guild the cache is still wrong
^^
whats the fix for that
you increment the timeout, but for that you should know whether that's the issue in the first place
are you catching and logging errors somewhere?
yes to a logs channel
every single error?
is that on start?
yeah
getting Members didn't arrive in time a lot too but i think thats when the bot is removed from a guild
sounds like unavailable guilds then, nothing to be worried about
well that'd be this
so that confirms it's the issue
i dont understand why its only me having this issue tho
"only me" as in comparing with?
idk.. are other people having this issue and if so how r they fixing it
yeah, that can be a common issue when fetching members on big guilds
Fetching members can time out on large guilds, as they arrive in chunks through the WebSocket connections.
- You can specify the
timeoption inFetchMembersOptionsto specify how long you want to wait. - Make sure you have the required
GuildMembersgateway intent enabled
but this issue also happen in smaller servers too
I'd still recommend you fix it, just increase the time option to something you're reasonably comfortable to wait out
okay will do- what's the max and are there downsides to setting it to the highest possible amount?
you could end up with hanging promises, but other than that I'm not too sure, probably someone on the team knows
if there weren't that many downsides they probably wouldn't have added the option at all
(the error comes from djs, not the api)
how would i check if a channel is marked as nsfw?
BaseGuildTextChannel#nsfw discord.js@14.24.0
If the guild considers this channel NSFW
thank you
how would I do so in DJS? When I try to add a label component in witnout a input field it throws an error
you'd not use labels, if you don't want inputs
ModalBuilder#addTextDisplayComponents() builders@1.13.0
Adds text display components to this modal.
add the text display to the modal directly
ah I see. Didnt know you could do that. Thanks a lot
@fiery epoch please use #app-commands or the hide option for personal docs usage
when using component v2, is there way to output in a Container, what was previously known as fields?
no, containers aren't embeds
they don't have fields
yeah I figured that out, is there no alternative way?
using embeds
can't say much more without knowing what you actually want to achieve
1 sec
@loud quartz like this
so inline fields? not really
I see
thanks
Do we use GuildMember.roles.cache.has() or has that changed?
what's your actual question?
SO i wanna check if a user has and id. Tried using cache.has() and that always returned true. Has it changed?
what makes you ask
Nvm, i was checking if roles existed in the guild which it does, so fixed it now
i can check how many channels in category with channel.parent.children.cache.size right?
Yes
Hi, in the message update event the only difference is the content scan version. Can I use the oldMessage.equals(newMessage) to fight against this?
Well it would be oldMessage.equals(oldMessage, newMessage)?
Ah it looks to be used to not do that, ig I’ll have to write my own
thanks
where do i find all the GuildChannelCreateOptions? because here i only see parent and type. isnt there permissions too? https://discord.js.org/docs/packages/discord.js/main/GuildChannelCreateOptions:Interface#type
Click on what it extends
where?
thanks
Error [ShardingInProcess]: Shards are still being spawned.\n at ShardingManager._performOnShards (/usr/src/app/node_modules/discord.js/src/sharding/ShardingManager.js:297:13)\n at Shard._handleMessage (/usr/src/app/node_modules/discord.js/src/sharding/Shard.js:408:22)\n at ChildProcess.emit (node:events:519:28)\n at emit (node:internal/child_process:949:14)\n at process.processTicksAndRejections (node:internal/process/task_queues:91:21)","name":"Error [ShardingInProcess]"
can someone tell me where this error could be coming from
dont think im doing anything while its starting up
well im setting presence
what operations can i do while its sharding and which ones cant i?
You can set presence on the client constructor rather than on the clientReady event (which is recommended especially if you don't plan on changing it)
Very few operations you should do while its still sharding
ClientOptions discord.js@14.24.0
Options for a client.
ohoo didnt know
alrihgt im not doing much else
hi
how can i "refresh" the attachment url that was submitted in modal?
you cant
okay so its still happening,
kinda bad to track down
is accessing client.guilds.cache.size a problem
no
The error is coming from shards handling a message - so something that is broadcast across them
Local cache access and even most API calls might be fine
its only on my first shard
i start an api server, but that doesnt immediately use the client
okay there might be requests coming in very soon
starting the api server only when all shards are ready is a good idea then probably right
that worked thanks :)
Yeah an API request that does a broadcast eval would absolutely cause that

Cant showModal on a modal
I forgot I asked this and got an answer yesterday 🪦
yo https://pastebin.com/Juv6NeKg
idk why my code keeps on making channels in the root and not the categories when i setup my server
-# this pastebin is set to 10 minutes
looks like im too late lol
is there something like channelType enums but for modals?
There's only one type of modal - what is it youre looking for
to know if a modal is string select, user etc
Thats its field, not the modal itself
yh then that. is that there something to identify with in djs?
thanks
I think it uses that
yh it looks like it
Hi — is there any way to get the total number of bots in a Discord server without enabling GatewayIntentBits.GuildMembers? Right now I only have interaction.guild.memberCount. Any suggestions?
Not that I know of
Is the bot can make post forum?
yes
GuildForumThreadManager#create() discord.js@14.24.0
Creates a new thread in the channel.
// Create a new forum post
forum.threads
.create({
name: 'Food Talk',
autoArchiveDuration: ThreadAutoArchiveDuration.OneHour,
message: {
content: 'Discuss your favorite food!',
},
reason: 'Needed a separate thread for food',
})
.then(threadChannel => console.log(threadChannel))
.catch(console.error);
ForumChannel#threads discord.js@14.24.0
A manager of the threads belonging to this channel
Alright thanks
is there an event for GuildAuditLogEntryEdit ? for move member and disconnect
Not that I'm aware of
Audit logs only emit an event on create...they're an unreliable source for detecting actions
Hello! Is it possible to see which options a user has selected in Channels & Roles via a bot?
no
Ah, even if directly using the Discord API?
correct
received components are not builders, you cant modify them
ohhh I see. How would I go about disabling them then?
You can construct a new builder from them, or use the original builders from when you sent them
You have to edit the message to send the modified components either way
We might need some better guides on this, bit weird to explain
So I basically have to create a copy of the original component and then edit it from there?
embed resend guide is a good starting point logic-wise
Ah I think I get it now. Thanks a lot
Resending a received embed
To forward a received embed you retrieve it from the messages embed array (message.embeds) and pass it to the EmbedBuilder, then it can be edited before sending it again. We create a new Embed from EmbedBuilder here since embeds are immutable (their values cannot be changed directly).
read more
I also tried .editReply
You should be doing modalInteraction.editReply
Although, a bit skeptical on this usage since it’s not clear whether the awaitMessageComponent succeeded and the error occurred in the .then block
I tried that too it gives the same error
Then you didn’t save the code
Or the error occurred elsewhere
TypeError: response.editReply is not a function
at D:\Github Repos (Local)\TSA-Worklog-Discord-Bot\slashCommands\worklog\user.js:162:44
at runNextTicks (node:internal/process/task_queues:60:5)
at process.processTimers (node:internal/timers:511:9)
at async D:\Github Repos (Local)\TSA-Worklog-Discord-Bot\slashCommands\worklog\user.js:117:21
I set the time to 120ms and was trying to get the buttons to disable after that time
and I didn't do anything else besides letting the collector end on itself
response is not modalInteraction
isn't response the message that gets sent(which includes the buttons)?
It sort of is, but that doesn't mean it has editReply() methods or similar. Following modalInteraction.reply(), you'd want to use modalInteraction.editReply() any time you want to edit that initial reply
ModalSubmitInteraction#reply() discord.js@14.24.0
Creates a reply to this interaction. Use the withResponse option to get the interaction callback response.
// Reply to the interaction and fetch the response
interaction.reply({ content: 'Pong!', withResponse: true })
.then((response) => console.log(`Reply sent with content ${response.resource.message.content}`))
.catch(console.error);
Take a gander at the return type of reply()
hm I'll try that
sorry it took so long, was fixing some other bugs that occurred. But it works now, thanks!
can i only enable caching for specific users, specific channel's messages, specific guilds etc?
Strictly enable/disable? No. You can however utilize sweepers to sweep caches and remove elements you deem unneeded to be cached
Sweeping caches
In addition to limiting caches, you can also periodically sweep and remove old items from caches. When creating a new Client, you can customize the sweepers option. Below is the default settings, which will occasionally sweep threads. Take a look at the documentation for which types of cache you can sweep. Also consider what exactly lifetime implies for invites, messages, and threads!
read more
Has anyone already managed to create a model with file uploads?
can i assume every snowflake id is unique?
snowflake ids from other categories is unique too?
ex. message id and channel id
Well no. Guild ids and channel ids can be the same
wat
Ancient guilds can have a channel id that matches the guild id
Also the everyone role has the id of the guild id
they’re only unique within the same type of entity they represent
hello i have been creating a slashcommand, for the command has a permission of .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild), and i need to add a userid on that command so i can use it. for example i will just add my userid so i can use that slashcommand.
You can’t
Slash command permissions are ultimately controlled by guild admins and can only be restricted by roles and channels
How to load button in interaction?
Chat is
const command = interaction.client.commands.get(interaction.commandName);```
what about button
Does the button still work when the bot restarts?
The button will still send an event
If your bot is still listening after a restart it'll work
on ButtonStyle.value is one of them just black colour? im doing a roulette (basic just black/ red bet allowed)
i only ask as it doesnt say the colour
no theres only blue (primary), grey (secondary), green (success), and red (danger)
grey will subside
...
const container = new ContainerBuilder();
container.addSectionComponents(
this.createEligibilitySection(event),
)
private static createEligibilitySection(event: VoteEventConfigSchema): SectionBuilder {
const section = new SectionBuilder().addTextDisplayComponents(
(textDisplay) => textDisplay.setContent(this.buildEligibilityContent(event))
);
return section;
}
// buildEligibilityContent return string
``` and then i sent the `container`, i received:
```yaml
2025-10-28 20:27:25 - ERROR - Encountered error on chat input subcommand "vote" at path "D:\...
\src\commands\subcommand\Vote.ts" CombinedError (2)
2025-10-28 20:27:25 - ERROR - Received one or more errors
2025-10-28 20:27:25 - ERROR -
2025-10-28 20:27:25 - ERROR - 1 [ExpectedValidationError: s.instance(V)]
2025-10-28 20:27:25 - ERROR -
2025-10-28 20:27:25 - ERROR - 2 [ExpectedValidationError: s.instance(V)]
Section needs an accessory, either a thumbnail or a button
If you don't need that, don't use section
Use text display directly
Ahhh, tysm
how many members can you fetch at once (of a guild)?
as in, one can do guild.members.fetch('id') or guild.members.fetch([array. of many ids?..])
you can fetch all guild members by just doing guild.members.fetch()
api limit for that is 1 every 30s
ok but what about those 2 scenarios I mentioned?
you individual fetch user by user then
theres no fetching by array of ids?
no
if you want to fetch a big array of ids, youd just fetch all members then and get what you want from cache
There is, actually
Look 5th example
GuildMemberManager#fetch() discord.js@14.24.0
Fetches member(s) from a guild.
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
cc @tardy sable
oh okay thanks didnt know
{
global: false,
method: 'GET',
url: 'https://discord.com/api/v10/guilds/GID/members/userID',
route: '/guilds/:id/members/:id',
majorParameter: 'GID',
hash: 'e06f83c33559dfd4dc34f5666fdfa1d3',
limit: 5,
timeToReset: 250,
retryAfter: 250,
sublimitTimeout: 0,
scope: 'user'
}
coz I got this error, dunno what it means exactly, like a fetch users all the time
There's not an error
ya rate limit im guessing
And if you're logging stuff in your code, would be a good idea to log what it is
so what is that rate limit log, im fetching too many users per guild, or im fetching the same user multiple times? but fetch auto checks if user is in cache first? so how could I fetch it multiple times?
You're fetching too many times
Doesn't matter who
Api won't willingly let you spam it just became you're fetching the same user
whats the limit on that?
How do I get my bot to have the status like discohook's where they have their URL?
Doesn't matter
Also, dunno if you missed it
You can fetch with an array of ids
I already have that. I'm talking about the one next to the avatar
would be useful to know how long id need to wait before fetchig the next id (im looping through user ids tasks)
You have that right there in your log
That's not custom status. Read the post
i mean b4 that rate limit is triggered
Rate limits are dynamic anyway
And again - use an array
Although if you have to fetch this many individual ids, you could just fetch all members in one go
Ah, it wasn't clear that this is a custom status. Thank you.
**if **this rate limit refers to specifically fetching a guild member, then im sure im barely fetching many for such guild. For other guilds I have much higher volume and never saw such rate limit message. Im very confused 😄
Making requests in a loop will get you ratelimited sooner or later
I have no idea what do you do in your code or why
How many you can fetch? All in one call
Can you fetch multiple ids in one go? Yes
Is there a ratelimit? There's ratelimit everywhere
i mean surely is not 30 secs between each members fetch, coz otherwise my bot would have been blocked loooong ago. so must be 1-2 secs at the most per guild
It's once every 30s for fetching all
i go 1 by 1
Then don't
What exactly do you expect me to say at this point
fetch all is capped, at like 1k or 10k per fetch, if a guild is very large that'd be wasteful im assuming
It is in fact not capped
It's called all because it fetches all
Now, sure, you will receive all members which can take memory
really? i remember for big server you could only fetch so much at the time
Yesn't
There's a REST way to fetch which is limited, and there's gateway way to fetch, which is not
The gw one is the one that fetches all in one go and is limited to 1 every 30s per guild
but ye if id need to fetch say 5 per guild, calling all on a big server is not memory efficient
Then use an array
I'm saying this continuously
You can do that
is there a max quantity on that in the array?
There's always a limit
You can check what's the limit in the dapi docs
doesnt say the limit on the array (max values amount)
Requesting user_ids will continue to be limited to returning 100 members
It does
Hello, is it possible to obtain a list of users who have installed my application?
no
okay thx
@rustic estuary @versed current both your issues are fixed in 14.24.1 (just released #announcements message), thank you for reporting!
yay :) Thanks!
Actual 🐐
thanks for the quick update
I get this error when responding to an autocomplete - any idea what it is?
if (interaction.isAutocomplete()) {
const guild = await client.guilds.fetch(process.env.SERVER_ID || "");
const interactionMember = await guild?.members.fetch(interaction.user.id);
if (
(interaction.commandName === "listing" && interaction.options.getSubcommand() === "edit") ||
interaction.options.getSubcommand() === "bump"
) {
const focusedValue = interaction.options.getFocused();
const isAdmin = interactionMember.permissions.has(PermissionsBitField.Flags.ManageMessages);
const listings = isAdmin
? await dbQuery("SELECT * FROM listings")
: await dbQuery("SELECT * FROM listings WHERE userID=?", [interaction.user.id]);
return interaction.respond(
listings
.filter(({ listingID }) =>
focusedValue.length ? (listingID as number).toString().includes(focusedValue) : listingID
)
.map(({ listingID }) => ({ value: listingID, name: listingID }))
.slice(0, 25)
);
}
Would you like me to repost it using that?
yeah, mostly for convenience when on mobile
Many of us are frequently on mobile
there's no preview so it'd need to be downloaded, which is an inconvenience
the code or the error or both
the file, which I assume is the error
looks like you took too long to reply
I replied instantly 😉
oh to reply to the user from the bot?
it isn't advised to do api/db calls before replying, usually you'd defer but you can't defer autocompletes
yes
the only solutions are to either have everything you need cached so you only do the quick filtering logic, or accept it'll fail every once in a while
I assume I cant respond to the user twice
yeah you can't, though I'm unsure what that'd fix
so i have a scenario like this
message w/ embed and ButtonBuilder -> button press (calls showModal()) -> modal submitted
can i get the message directly from the modal submit interaction? (aka .isModalSubmit() is true)
ModalSubmitInteraction#message discord.js@14.24.0
The message associated with this interaction
oh damn thank you sm
just thought it wouldn't be possible because i thought a modal is not really related to the message but rather the button interaction itself 
it counts as a component interaction since it comes from the button
ahhh got it now, thanks again
What was .setLable changed to:
and .addComponents too
Hover over the strikethrough and your IDE should tell you
I'm looking to create a command that can be used to ban someone from my server. Is it possible to also have this command remove the previous 7 days of messages by a user (like the behavior in Discord upon banning someone)?
BanOptions#deleteMessageDays discord.js@14.24.0
Number of days of messages to delete, must be between 0 and 7, inclusive This property is deprecated. Use deleteMessageSeconds instead.
Oops wrong one. Ban seconds (as the docs say above)
i have a modal built w/ an image upload option, im fetching the image with interaction.fields.getUploadedFiles('proofImage').first();, question is, how do i send it spoilered?
prepend SPOILER_ to its name
does client.channels.cache always yield every channel in a server
If you have Guilds intent it should for every guild you have a bot user in. Not all threads though
okay good, and I do
and also, channel.messages.fetch({limit: 100}); would this fetch every message or does the api sometimes skip some or something
Why would it skip some? It'll fetch last 100, not every msg tho
I was wondering if there was some sort of caching with that
fetchMany requests will always be an API call and doesn't care about if any data was cached prior
I've been noticing some issues with my bot lately about unknown interactions, and especially it being inconsistent. So I timed how long it takes for it to respond to an interaction slash command. The first image is completely fresh initialised discord.js bot handling (await interaction.reply('pong') while the latter image is responding directly using discord API (await interaction.client.rest.post(\/interactions/${interaction.id}/${interaction.token}/callback`, { body: Response });`), but is using discord.js to receive the interaction (same as the one using discord.js to respond)
How can the difference or well especially the variance be so big? Each ping command was executed with about 2-3 seconds in between them, and even if you wait 15 seconds between running the interaction it will still vary a ton.
Can anyone explain to me what is going on 😭 (I'm using djs v14.24.1)
The new components of the users modal and in this format that pulls them?
const users = interaction.fields.getUserSelectValue("user")
Thanks!
I'm having the exact same issue, drives me nuts
how does interaction.channel.send() perform in comparison?
that does completely different things
I'm aware
it is not comparable in behavior
I meant in terms of latency, stable/still unstable
is checkAdmin removed?
interaction.member.permissions.has({ checkAdmin: true })
interaction.channel.send is fine as for latency. Odd you're having the same issue though
same results for me too. Strange indeed
interesting. why does djs almost takes triple the time to respond
how are you measuring it
https://discord.js.org/docs/packages/discord.js/14.24.0/PermissionsBitField:Class#has
It's still there according to the docs
Im having a bug where non member admins throws error RangeError [BitFieldInvalid]: Invalid bitfield flag or number: [object Object].
how are you using the has()
const start = performance.now();
await command.execute({ interaction, client });
const duration = performance.now() - start;
console.log(`Command executed: ${command.data.name} - ${duration.toFixed(2)}ms`);```
and how are you responding to the interaction in that command code
like my example
!interaction.member.permissions.has({ checkAdmin: true })
This is an API issue, nothing related to the library
then it works just fine
given how you're not even really giving it any permission whatsoever to check for
then how is it only an issue when using the library to connect to he API?
wdym? isnt it supposed to be used like that
no, it takes a permission you want to check
oh okay thanks
not an object telling it to ignore checking all perms if it happens to have admin
module.exports = {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("Replies with pong!"),
async execute({ interaction }) {
await interaction.reply({ content: 'Pong!' });
},
};```
Extremely unlikely for that to be the case, your description matches with issues already reported on other venues
even the part about manual REST.post not being this much around?
if I edit the discord.js source code with the same route but my own body it doesn't have the issue
the POST /interactions/*/*/callback has had intermittent increased latency from the start of october 13-14
so what about their second screenshot
Sorry correction to my earlier deleted message, the problem goes away if I comment out auth: false under InteractionResponses.js in the discord.js node module.
I'm not quite sure what auth: false does exactly though-
It removes the auth header
Why would you have put it there in the first place...
it's relevant for webhooks mostly
I didn't put it there. that's the source code
which is like, what interactions are
Ahh
but why would commenting out auth: false fix the latency issues?
That fixed it for me too, wild
howd u know where to look lol
tag suggestion for @drifting tartan:
You can control which entities receive notifications via the allowedMentions option. You can:
- Set a default on the client
- Set for a specific message
- Use the
repliedUserkey to disable in-line reply mentions
{ ..., allowedMentions: { parse: ["users", "roles"] } }
searched through the discord.js library until I found something that had to do something with reply. But I don't think this is really a fix, but I don't have enough knowledge of the discord API to know why this is causing this
im trying to figure out why it wont set sendmessages to enabled for interaction user, what am i doing wrong?
await interaction.channel.permissionOverwrites.edit(interaction.user.id, { SendMessages: true });
sendMessages is currently on false
Thats not the format that permissionOverwrites.edit takes
oh wait im looking at the wrong thing
From what i know about that option, it's used for passing (or not) the usual auth header to the request, which is normally required, obviously.
But there are things that don't require your app's token to perform, for example executing webhooks. In fact, without that setting, if you would be to try and execute a deleted webhook and get a 401, discord.js would happily assume that it's your bot token that's expired and pretty much log you out, as it would prevent you from using an invalid token.
You might need to also pass { type: OverwriteType.Member } as the third parameter
since interactions are pretty much just webhooks with a fancy magic for how they display to the user, i'd assume that this is the reason the auth: false is there. so that if you reply after the interaction token expires discord.js doesn't "confuse" it with your bot token expiring
yeah more of a bandaid fix until its looked into
I've had this issue for ages, maybe since v13, i cant rember tbh. but recently got worse
Since yesterday or so, Discord is suffering from latency issues with interactions. They're looking into it (still unresolved)
just weird i dont see many others besides you with the same thing
Ah, I see. So with the auth header you'd probably end up with your bot being logged out eventually? And the issue right now is because discord is experiencing latency issues but that only happens if the auth header is excluded?
i have no idea or any input as to why this is happening as it is, but yeah. there is a potential that d.js will unset your app token if you hit 401 on any webhook stuff
you can use the most recent d.js version to access it
you can use the most recent d.js version to access it
LabelBuilder#setFileUploadComponent() discord.js@14.24.0
Sets a file upload component to this label.
Or ur just asking what the file upload is?
why would message.member on a message from a guild be null? in the messageCreate event
guild member cache settings
so the cache is full for that guild?
no
Webhooks? Do they have a member
i havent changed the guild member cache settings, its default
that didnt change anything so i tried to console log to see what it was doing and console logging this it just keeps console logging duplicates with no end.
for (const overwrite of interaction.channel.permissionOverwrites.cache.values()) {
if (overwrite.id !== interaction.guild.id) {
await overwrite.edit(overwrite.id, { SendMessages: null, type: overwrite.type });
console.log(`Set overwrite for ${overwrite.id} to SendMessages null`)
}
}
its a real message from a user, not a webhook
they do not, no
I said third parameter, not as an option in the second
Not sure what you mean by logging duplicates
the same ids
like the channel has 4 permissions overwrites. and doing that it just keeps logging the same id over and over
ill try passing as third parameter to see if it fixes
same issue
looking into this further, it seems i am receiving the message from a guild, it has a valid author and is not a webhook, but i cannot fetch that member manually, its as if they are not in the server
Can you share your code for doing that? Are you getting Unknown Member?
Is your bot actually in the guild and not just as app commands?
If that is logging four times the same value I'd assume you accidentally assign to the id somewhere in your code and alter cache
this is messageCreate event, not interactionCreate
aka if (overwrite.id = guild.id) instead of ===
const message = client.channels.cache.get("1405902117117497456").messages.cache.get("1432833080565043291")
const guild = message.guild
return guild.members.fetch(message.author.id)
this returns a collection of 0
uhhh
there is a chance of course that they left the server now, but message.member was null and erroring for multiple messages in a row
It should never return a collection of 0, unless youre fetching something undefined, and theres somehow nothing in the cache
Its a fetch, it should be throwing an API error if the value passed is invalid
That just shouldnt be happening at all
yeah no, thats not what fetch returns

i did just ```js
const guild = await client.guilds.fetch("911223311135047680")
const member = await guild.members.fetch("1234567891234556")
console.log(member)
in my ready event and it still returns an empty collection with a completely made up member id
Can you show your client constructor please?
if you're passing an id like that, and it still returns a Collection, something is quite wrong somewhere
ya
globalThis
Can you try logging client.users.resolveId("id you were trying to fetch");
Im looking at the fetch logic and trying to work out how it could be returning a 0 collection here, and the only spot I can think is that somehow you've stored an empty collection against people's IDs in the guild member cache
Or its not resolving and trying to do a fetch that somehow doesnt return any results
djs version?
i tried in blank bot and yes it errors when trying to fetch unknown user, ima debug whats causing that
The way you map your intents seems kinda odd too since the strings are already accepted there anyway
i assumed they werent when i read the update to discord.js v14 guide which i did that
If I had to guess I'd say tipaka was on the right track: why do you use globalThis?
to access the client across every file without needing to manually pass it across
You already dont since its attached to most structures, e.g., message.client
Considering you also have https://github.com/ewanhowell5195/benchbot/blob/e350f1ee75c8ef7fc77783dc7baa782e188d58cd/index.js#L35 this I'd wager REST might get confused when detecting what runtime it runs in
You're replacing node's native fetch with that from node-fetch library
If I was node I'd get confused too
native fetch was not a thing when i started this bot, and caused issues when it was first added, so i kept node-fetch, i probably dont need that anymore, i can try removing it
global pollution, prototype pollution
as you can see it never ends up working well
no its just logging the same values over and over again and im not modifying cache as far as im aware. made a post cuz i dont get it anymore https://discord.com/channels/222078108977594368/1432845294512378016
the collection issue it was caused by me adding a String.prototype.limit
i know its bad to extend prototypes, but does this mean that somewhere in discord.js its just checking for a limit function to exist rather than checking the type?
LimitedCollection exists
and it's incredibly popular way in typescript to make type guards - check for existence of a property, for example
No, not a function. But GuildMemberManager#fetch() takes either a string or an object containing a limit property. You gave it both at the same time and broke the conditional logic
ah, so even simpler than that lol
And by that your string then gets spread into an object (and the id is gone, but limit is now set to a function and that gets sent over the websocket... quite interested to see the actual request that gets made by that 
i am removing the prototype now. meant to clean up stuff like this for a while but put it off, better late than never
i guess i will just have to wait and see if the issue I came here with still occurs
Fascinating
Getting white screen with CSP violation error when launching activity:
Refused to frame 'http://localhost:5173/' because it violates CSP directive
Setup:
URL Mapping is done
Discord SDK configured
What am I missing?
You should ask in ddevs, the d.js library doesn't have support for this
you mean ddevs discord?
Yes, there's an invite in #useful-servers
figured it out i think. i believe its a user that has been invited to join the voice channel of a server as a guest, so they are in the server, but not a member, and they are sending messages via the voice text chat
Interesting
And we couldnt arrive at an "Unknown Member" error because of the other stuff
if (q.type === "file_upload") {
return new ActionRowBuilder<FileUploadBuilder>().addComponents(
new FileUploadBuilder()
.setCustomId(`q_${i}`)
.s(q.question)
.setRequired(q.required ?? false)
);
}
how can i pass label to options
The ActionRowBuilder approach is deprecated, switch to LabelBuilder and you wont have this problem
LabelBuilder#setFileUploadComponent() discord.js@14.24.0
Sets a file upload component to this label.
oh do i need to switch all my code cause i used action row builder everwhere
Not until v15
But you might as well start writing new code this way
The new components must use label though iirc
only modals should use LabelBuilders, any other ActionRowBuilder usage should probably stay. if that wasn't already clear enough
question how can i get the answers to the modals
and yes i figured as much but was not sure
no, any usage of action rows in modals is deprecated missread, thought you meant that older action rows were fine
you're meant to move your older code to labels, and use them for new components
which answer?
or well, from which component type
the answers to the modals that the user does when submit
there's no component named "answers"
but I'll assume you mean a text input component
ModalSubmitFields#getTextInputValue() discord.js@14.24.0
Gets the value of a text input component given a custom id
you get that via <ModalSubmitInteraction>#fields
ModalSubmitInteraction#fields discord.js@14.24.0
The fields within the modal
what is the limit in modals
limit of?
nvm i found it it can be a limit of 5 questions
5 elements, yes
do unfurled media items under media gallery items have a file size limit when it comes to external URLs?
ive given videos like 100mb large a shot and they seem to work out fine
that's pretty much just an embedded video so I wouldn't think so
that's more of an api question though, ddevs would be a better place to ask
ahh. gotcha
how do I add file uploads component in my modals?
Add them in a label and add the label to the modal
ModalBuilder#addLabelComponents() builders@1.13.0
Adds label components to this modal.
LabelBuilder#setFileUploadComponent() discord.js@14.24.0
Sets a file upload component to this label.
is there a function or something that i can call that triggers discord to open an image in the modal / overlay view? context is i'm building an embed and it has an attached img that's taller than it is wide, so if using setImage() it makes the embeds very tall while setThumbnail() makes the img a bit too small. i know on desktop you can click the thumbnail to pull up the picture in the overlay/modal view i'm talking about but that behavior isnt reflected on mobile.
my idea is to use a button on the embed to call whatever makes discord pull up the larger preview, but want to know if that's even possible? my fallback is to make the button temporarily remake the embed as setImage for 10s or so before reverting to the setThumbnail version (unless someone has a better idea/implementation)
No
Discord doesn’t have support for images in modals at this time
Have you tried the media gallery component?
Or you don’t want to use components v2?
Media Gallery
A Media Gallery is a display component that can display a grid of up to 10 media attachments. Each media item can have an optional alt text (description) and can be marked as spoiler. You can use the MediaGalleryBuilder and MediaGalleryItemBuilder classes to easily create a Media Gallery component and its items:...
read more
Oh, interesting, does this allow you to customize the placement of the img inside an embed/container?
The original thing I was talking about is this view when you click an image
Not sure if that's called a modal or how that's officially named
You mean clicking on an image to get the full view?
Doesn’t it to that already if you just send an image normally?
Not a modal btw, just client-side stuff
Yeah, it does however if the image in an embed is the thumbnail, mobile users cant click the thumbnail to see the full view
Components v2 is its own animal. Takes over the entire message
You have more freedom over placement to a point
I see, and I assume there's no way to trigger or call client-side stuff through discordjs
That’s correct
Blame Discord for that
🙃 ok thanks for the guidance! i'll take a look more at components to see if there's something there that can work
is there a place to see more examples of componentsv2 in action and what's possible?
The guide I sent earlier has all of that
const targetMember = interaction.options.getMember("member");```
Is there a way I can force this code to get the GuildMember data directly?
Do you mean how it's currently a union of APIInteractionGuildMember and GuildMember?
I don't want to use APIInteractionGuildMember.
BaseInteraction#inCachedGuild() discord.js@14.24.0
Indicates whether this interaction is received from a cached guild.
Use this typeguard, handle the case when the interaction is not in a cached guild
Guys are there good example of what v2 components can do?
The announcement of the version that released them
Thanks
Thanks. I guess I'll have to fix this manually on the Typescript side.
How did I put programming code inside a frame?
With components v2, is it possible to place a mediagallery component inline with text component(s)? or is a mediagallery always on its own line and only thumbnail works?
A media gallery always is its own line. There is no concept of "inline" in cv2, only accessory of a button or thumbnail belonging to a section
And even those can be below on mobile, you define context, not layout
You control the content, discord takes care of layout
Gotcha, thanks
Why when I execute a cmd to make a thread it appear a notification, but when I make a thread based on message create event, it don't appear any notification? I had the same exact code:```js
// CMD:
const msg = await interaction.channel.messages.fetch(messageId);
if (msg) {
await msg.startThread({
name: ${threadName},
autoArchiveDuration: "10080",
reason: Thread created by ${interaction.user.tag},
});
return interaction.editReply({
content: "Successfully created the thread!",
});
}
// messageCreate:
if (
message.channel.id == weekListChannelId &&
!message.channel.isThread()
) {
await message.startThread({
name: ${message.content},
autoArchiveDuration: "10080",
reason: "Auto-thread for week report",
});
}
The former was a reply to your message, no?
An inline reply
The bot replied to your message, then started a thread on its own message
You mean like this? I try to make the thread with a message that does not mention / reply, but it still appear a notification
You still want to send the AAA message?
Just without the ping
To clarify, the ping is from using message.reply on your message, nothing to do with the thread
Hi,
Is there any way to get the actual HTML that Discord will render for a message's content ?
Thanks
No
Best you can do is generate the html based on the markdown
Pretty sure there’s packages that convert entire messages to html for you alr
Oh yeah, I get it now, thanks!
remark-html and showdowns are two of the more popular ones
you'd def. have to handle mentions and custom embeds yourself, though
hey all, just wondering what the main difference is between interaction.channelId and interaction.channel.id
Nothing
interaction.channel is a getter that does client.channels.cache.get(interaction.channelId)
channelId is guaranteed to exist, channel isn’t
database.findOne({ channel: interaction.channelId }, (err, thread) => {
if (!thread) return interaction.editReply('**CHANNEL NOT FOUND**');
};```
hm okay, well i have an odd issue that could be unrelated but thought id ask here
i have this running via a button and i have to spam it to work
its confirmed in the db so not sure why its bugging
What type is it stored as in the db?
a seperate model i removed for simplicity here
Should also be checking for errors
There’s won’t be thread if err isn’t undefined/null
Or at least log it
right
Hi, I have a question about file upload in modals.
Where are the file stored after upload? I noticed they are url.
Discord CDN
So they is the same problem if an user upload the image in the server and want to access it days later?
Idéa is to just to store it in an embed but I'm not sure how much time the image will stay
you'd need to reupload it, not use the ephemeral attachment URL you get in modal submission
And embed doesn't allow upload in thumbnail, only URL…
Does it works if I upload the image the bot is in ? Or I will face the same problem (as now image/file are not uploaded forever)
Does Guild#edit options support Url for Icons ?
Yes
tag suggestion for @unreal stone:
Files in embeds should be attached via the message option object and referenced in the embed:
const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);
channel.send({
embeds: [embed],
files: [attachment]
});
with guild.icon how ?
Wdym? You just provide a url
Guild#edit() discord.js@14.24.0
Updates the guild with new information - e.g. a new name.
// Set the guild name
guild.edit({
name: 'Discord Guild',
})
.then(updated => console.log(`New guild name ${updated}`))
.catch(console.error);
await guild.edit({ icon: … })
i am confused by this
It’s a union of types
BufferResolvable is either a Buffer or url as string
Base64Resolvable is a Buffer or base64 string as a string
Or null to remove the icon
You just click on it to see what it is
what?
yes, but if you want to change the token you can't do that in the middle of your execution
you'll 100% need to restart
then yeah that's usually fine
you shouldn't be running two bots from the same process, ideally both should be in different ones
depending on how you obtained those tokens
it is, it's just a matter of good practices and maintainability
oh, if you're talking about getting tokens then yeah you can't ask users for them
you should still run each bot/app in its own process, so they're independent from each other
That won't reload anything. It just reconnects the websocket running the same code as before
👆 this and just restart the whole process
Thank you ! It works like a charm. But I have a question. There is a way to fetch the attachment from the message ? message.attachments return an empty Map.
Way too complicated when a simple restart is easier
And you made all those 1000 bot tokens yourself?
const modal = new ModalBuilder()
.setCustomId('limit_users_vocals_modal')
.addLabelComponents(
new LabelBuilder()
.setLabel('Limit users')
.setDescription('Use 0 to reset.')
.setTextInputComponent(
new TextInputBuilder()
.setCustomId('limit_users_vocals_text')
.setStyle(TextInputStyle.Short)
.setRequired(true)
.setMinLength(0)
.setMaxLength(99)
)
)
return interaction.showModal(modal);
any idea of why is it giving ValidationError: Expected a string primitive?
From an account created two weeks before today?
is there a docs page or example code for using the new modal builder with label and text display builders
i'm asking bout this rn hahaha
Then you won't have any issues running your two bots as seperate processes
haha cool! im trying to use the new file upload
@steel trail do you know something?
i think it's just
.setFileUploadComponent(
new FileUploadBuilder()
.setCustomId('blablabla')
.setMaxValues(1)
)
#rules 5 and you're missing modal title
Next time share the full error
oh ok
.setCustomId('setupadvertise' + interaction.id)
.setTitle(t('descAndReq.modal_title'))
.addComponents([
new ActionRowBuilder<TextInputBuilder>().addComponents([
new TextInputBuilder()
.setCustomId('description')
.setValue(existingData?.description || '')
.setLabel(t('descAndReq.description_label', { type, targetAudience }))
.setStyle(TextInputStyle.Paragraph)
.setMaxLength(1000)
.setRequired(type === 'Clan' ? false : true)
.setPlaceholder(
type === 'Clan'
? t('descAndReq.description_placeholder_clan')
: t('descAndReq.description_placeholder_alliance')
),
]),
new ActionRowBuilder<TextInputBuilder>().addComponents([
new TextInputBuilder()
.setCustomId('requirements')
.setLabel(t('descAndReq.requirements_label', { type, targetAudience }))
.setValue(existingData?.requirements || '')
.setStyle(TextInputStyle.Paragraph)
.setMaxLength(1000)
.setRequired(true)
.setPlaceholder(t('descAndReq.requirements_placeholder')),
]),
]);```
this is the code I have rn but I am trying to change it and remove the deprecated components
sorry for the inconveniece
Label component is just the new way to use for text input or other type of non -top level modal components. There's nothing more to it than that really
thank you guys
what is text display component?
guide suggestion for @fading girder:
Text Display
Text Display components let you add markdown-formatted text to your message and directly replace the content field when opting to use display components. You can use the TextDisplayBuilder class to easily create a Text Display component. Sending user and role mentions in text display components will notify users and roles! You can and should control mentions with the allowedMentions message option. The example below shows how you can send a Text Display component in a channel.
read more
wait so I can add role select, string select, etc too inside modals?!
All select menus can go in a modal
yo awesome, I just found it out now 😭
need advice; so i am making a bot that sort of logs actions in a channel. i can easily get who banned who and why just by getting GuildBan from the guildBanAdd event, however this is not the same case with kicks, as there's not a seperate event for that - only guildMemberRemove. question - is querying the audit log really the most efficient way to find out if its a kick and who performed it? or is there something im missing
guild ban event also emits the executor?
audit log only exposes that so yh
if you look at the docs you can see what the event emits
how many label builders can I add in a modal
Max 5 top-level components
The limits haven't changed
yh it doesnt, or am i not seeing it?
Should be under the Client class iirc
(event) Client#guildBanAdd discord.js@14.24.0
Emitted whenever a member is banned from a guild.
The issue with that is Discord isn't Markdown-compliant, and in a dangerous way : it detects links where it shouldn't.
And without knowing how it does that, I'm having trouble detecting these 😭
I sense an XY problem. What is the actual problem you're trying to solve?
This : #archive-offtopic message
And I don't see any other solution.
Why adding addTextDisplayComponents before setLabelComponents not working ( as in that wont display at all ) in a modal but works when i use addLabelComponents instead ? is this intentional ?
because set overwrites
like = would
use add* instead of set*
but would that affect display components ?
for ref my dummy code where i tested all 3 cases
https://gist.github.com/CaptSpider4/7291e17b4c4f99c5392d7359ce913327
setLabelComponents shouldn't exist anymore now that you can add things that aren't labels to modals. But removing it would be a breaking change so 🤷♂️
alr so it would be better for me to use addLabelComponents itself right since both accepts arrays that wouldn't be a problem
You should only use setX if you want to completely overwrite what you have in it, yes. Not if you want to ... add to it
in my real code i loop through my question and create label components for it and push to a array and use that inside setLabelComponents so i guess its a 1 function change for me i will do it thanks for the info i didn;t know about addLabelComponents until today so i used to do setX
Odd question but is it known if discord gonna be deprecating the old components at all and making v2 default?
old components?
Straight embeds vs modals?
embeds are not components
and v2 isn't "replacing", it's adding more
buttons and selects are not going away, and yet aren't under v2
and embeds are not going away either
you can use them just fine, and links will continue embedding
hi
can i make a file upload in module and when the module is submitted the img is sent as an attachment in a embed or what
ModalSubmitFields#getUploadedFiles() discord.js@14.24.0
Gets file upload component
That returns a collection of attachments. You can then use that attachment however
thanks i was searching all over the docs
Is there any method to collect the results of a poll and if so what’s the event for that called?
I encountered the error DiscordAPIError[50240]: You cannot remove this app's Entry Point command in a bulk update operation. Please include the Entry Point command in your update request or delete it separately.
Can I make it so that it doesn't cause an error but without breaking it?
this.application.commands.set([
...this.commands.map(command => command.data),
...this.userContextMenuCommands.map(menu => menu.data),
{
type: 4,
name: 'launch',
description: 'Launch an activity',
}
]);
I think that should work, yeah, but do you actually have an activity to launch?
There's messagePollVoteAdd and messagePollVoteRemove
Is there any for end of poll? And can bots distribute their own poll?
Bots can, yeah
I think you just get a messageUpdate when the poll finishes, Im not sure
Ok cool does a poll require having more than one answer? I was thinking of using one for a giveaway thing to negate having to handle times for ends of giveaways or stuff like that
no idea
But that would only really work if I could collect who all added to the poll but I guess I could just use the event for that and store them temporarily
You can
Poll#answers discord.js@14.24.0
The answers of this poll
PollAnswer#voters discord.js@14.24.0
The manager of the voters for this answer
yes
Huge thanks
Then yeah, you need to make sure you include the command
Hello in new StringSelectMenu how i can set a value? old one have setValue but now i cant see that option
from a select menu interaction or a modal?
String select menus to my knowledge have not had set value. To set the default value of a string select menu, the string select menu option must have default set to true
selectmenu interaction
oh i see
What event to know if someone boost the server?
theres no event for boosts...the only ways to check is the system message for when they boost or the role being assigned
Hmm... Okay
in the same action row, can there be both dropdown and a button?
no
If I update to latest d.js version, can I still use older embeds v1 class? new EmbedBuilder()
Embeds are still embeds; components are what got a v2 and those are merely an addition, not a replacement
so new EmbedBuilder() (which is v1) would still work, embeds v2 would just have a separate class
its not embeds v2, its components v2 but yes, you would still be able to use the EmbedBuilder
but you cannot use a embed & v2 in the same message youll get a incompatible error
Yes, components v2 don't allow any other content, be it plain content, embeds, sticker_items, poll (or attachments not used in any component). Apart from that and they can look similar there is no connection between embeds and components v2
cv2 is a way to make a message from components alone, instead of having five separate parts you can't arrange the way you want
FileComponent discord.js@14.24.0
Represents a file component
are there any breaking changes from @14.16.3 to @14.24?
Are you using typescript?
no
Then you should experience no problems
i dont like that 'should' 
I am not making a guaranty but there are not library breaking changes
Minor versions do not contain breaking changes. Changes to typings aren't considered breaking
how can i make my bot have no status like this (it's not online, invisible, dnd or idle)
tag suggestion for @coarse meteor:
HTTP-only applications receive interactions through HTTP webhooks instead of the Discord Gateway. Bots that are not connected to the Gateway, but use HTTP interactions appear as online without a status. Discord.js does not support HTTP interactions. Use discord-interactions instead.
interesting
Hello, I'm trying to create a /backup command (with subcommands), but the problem is that when creating roles, the order isn't respected, and the roles of the bots present on the old server are created (which I don't want). Furthermore, only the categories are created, but not the channels. Here are my files:
are there example methods for the new modals? the docs are not really example friendly
may the lord bestow a blessing upon thee
Hey, why exactly were the docs moved? Like the guide ones
My guess is a combined reason of it being migrated to the monorepo as well as just to update it
plus it looks much nicer
Well, this doesn't 
path is a bit different
It doesn't look like linking a discord.js guide there is appropriate either way
You might wanna updated some strings there too, like the copy id ones, they're outdated
Can you create an Attachment using a Discord cdn url? Or would you have to download the attachment and reupload it?
that's what the attachment builder does
fetches the url and sends the buffer
but there's no guarantee that by the time you try to download it, the url still works
so does just putting the link into the send
Can anyone help me? :(
oh ok
np
on giveaway boat, in the raffles pagination there's an option to show the user's username instead of the mention. i know the bot can't fetch users on demand, does anyone know how they do that without hitting the api rate limits? the only thing i can think of is caching users when the bot logs in. also, is there any other solution?
i know the bot can't fetch users on demand,
but it can
is there any errors, any warnings?
nothing
weird
maybe another one can help you because i see nothing
The problem is that the bot doesn't assign roles in the correct order, and it doesn't create any voice or text channels, only categories.
try to do some debugs
Why not just use the Server Templates feature?
It's just to back up a server
Well I know that channel positions are extremely weird to work with and the one that DiscordJS uses is not the one the API uses directly
You could instead store your channels inside of each other rather than independently
(Store categories, put text/voice channels inside category, etc) and iterate over it yourself
Or iterate by channel.type creating categories first
Does Event.MessageDelete not fire if the message is not cached?
no
that would be a partial message and they do get emitted
I was reading some chatter from this really old issue: https://github.com/discordjs/discord.js/issues/2415
And I'm seeing a behavior where "old" messages being deleted are not getting the MessageDelete event fired at all
to clarify, you would need to enable the Message partial in order to receive events with partial messages
Partials
One example leveraging partials is the handling of reactions on uncached messages, which is explained on this page. Prior you had to either handle the undocumented raw event or fetch the respective messages on startup. The first approach was prone to errors and unexpected internal behavior. The second was not fully fail-proof either, as the messages could still be uncached if cache size was exceeded in busy channels.
read more
Oh
Had no idea about Partials, ok thanks that would be it
Hey guys
What kind of language is this, DJs?
djs isn't a language, it's a javascript library
the language would be javascript
I understand. Can I ask about regular JavaScript?
as mentioned previously, this channel is for discord.js
if you have a javascript question unrelated to discord.js, you can post in #1081585952654360687
alternatively, you might be more interested in a more general server from #useful-servers
so when i tested it in vs code it works but when its on hosting it returns: YouTube API: Request failed with status code 403
that is unrelated to d.js
srry
can bot set a server only avatar?
GuildMemberManager#editMe() discord.js@14.24.0
Edits the current application's guild member in a guild.
any idea when will we can be able to set VC channel status via djs? i think currently its not possible
discord py can do it i heared
as soon as discord documents it
Which might be never
how do i make a message not ephemeral bc right now I have
flags: MessageFlags.Ephemeral
just remove that
just... dont set the flag? 
you can't change the ephemeral state of a message, if that's what you're asking
anyone know why i keep getting this js at Object..js (node:internal/modules/cjs/loader:1893:10) at Module.load (node:internal/modules/cjs/loader:1480:32) at Module._load (node:internal/modules/cjs/loader:1299:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:244:24) at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5) { code: 'TokenInvalid' }
it keeps saying token invalid even while the token is valid
having the full stack trace would be useful
[dotenv@17.2.3] injecting env (0) from .env -- tip: ✅ audit secrets and track compliance: https://dotenvx.com/ops
Started registering slash commands.
Error: Expected token to be set for this request, but none was present
at _REST.resolveRequest (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1381:15)
at _REST.queueRequest (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1341:46)
at _REST.request (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1307:33)
at _REST.put (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1290:17)
at C:\Users\Crew\Desktop\maharaja\src\Functions\handleCommands.js:23:28
at client.handleCommands (C:\Users\Crew\Desktop\maharaja\src\Functions\handleCommands.js:33:11)
at C:\Users\Crew\Desktop\maharaja\src\index.js:25:12
at Object.<anonymous> (C:\Users\Crew\Desktop\maharaja\src\index.js:27:3)
at Module._compile (node:internal/modules/cjs/loader:1760:14)
at Object..js (node:internal/modules/cjs/loader:1893:10)
C:\Users\Crew\Desktop\maharaja\node_modules\discord.js\src\client\Client.js:217
if (!token || typeof token !== 'string') throw new DiscordjsError(ErrorCodes.TokenInvalid);
}```
what's in handleCommands.js
should I send the code
log process.env.token and check its value, it seems to be something besides a string (i would guess it's undefined)
the thing is
when I ran this same code last week, it worked without any issue, when I opened it today it shows this
ok and? did you log the value of the variable?
a normal user or member fetch first checks if in cache right?
Correct
unless you set { force: true } to force a fetch
also deleted users wont throw errors?
If a user is deleted, they'll be removed from the cache and if you attempt to fetch them with their former ID, you'll get an Unknown User API error
ok thanks
Hi all, wanted to get some help on this quickly.
Struggling on getting a response sent to a Modal using the promisified method...
I haven't done ts in a while so please be gentle haha
const filter = (i) => {
return i.user.id === interaction.user.id;
};
interaction
.awaitModalSubmit({ time: 60_000, filter })
.then((interaction) => interaction.editReply('Thank you for your submission!'))
/**Keep getting No modal submit interaction found... */
.catch((err) => console.log('No modal submit interaction was collected'));
I copied this straight from the website (as my previous implementation wasn't working either...); it prompts up the Modal correctly, but after I click Submit the bot gets stuck on "Bot is thinking..."
I am aware that I have not done <ChatInputCommandInteraction>#deferUpdate() in the filter (apologies if I have put the wrong class name here but you get what I mean I hope), as the framework I am (unconsensually) using automatically does this. The frameowrk is robojs if that is of any relevance.
Djs version 14.21
(the "website" is https://discordjs.guide/legacy/popular-topics/collectors#await-modal-submit)
Please ping in replies, TY for any assisstance
In your then() callback, I think it'd be wise to use a different name for the parameter than interaction again, otherwise you get confused between which interaction you're working with. Your issue here is that you aren't responding to or acknowledging the ModalSubmitInteraction after receiving it
Noted about the name -- re the ack for the ModalSubmitInteraction, would resolving that be putting a deferUpdate() in the filter? Sorry, I haven't worked on djs in a while
can I send an container with mention but make it to not send a notify?
yes, same way you would any messages
You can control which entities receive notifications via the allowedMentions option. You can:
- Set a default on the client
- Set for a specific message
- Use the
repliedUserkey to disable in-line reply mentions
{ ..., allowedMentions: { parse: ["users", "roles"] } }
thanks
No, you'd want to put it in your then() callback, assuming the original component that opened the modal is a message component like a select menu or button
The original component is just the Interaction command itself
You wouldn't be able to use deferUpdate() in that case, since there's no message to be updated
What is your end goal after you receive the ModalSubmitInteraction? Send a basic message in chat?
Yeah pretty much
You'd want to use reply() then
Ahhh, let me give that a try
That worked! Thank you
is this the same case for channel.messages.fetch()?
I have tested this before and this resulted in different results sometimes I got a very basic user object sometimes it errored
I think this one just straight up fetches
Yes
It depends on what intents and partials you have in your client options
basically anything thats able to force fetch?
Yes
thanks
If I timeout a user, do I have to input the duration in ms or can I use like days?
numOfDays * 86_400_000
It must be in ms, so yeah, do the math
fine xd
Can we arrange the order of the cmd names (for example, depending on how we arrange the subcommands), or is this arranged directly by Discord? I'm pretty sure I put the subcommand accept first, I don't know why it became the fifth one
Discord does that. You have no control over that
The app launcher, at least on mobile allows you to sort commands though
Ohh, that is right actually
is there any way to remove a modal from a users screen?
i have some code that shows a user a modal and upon the modal being submitted some information gets logged and then an embed updates. everything else works as mentioned however the modal doesnt disappear from the users screen only says "something went wrong, try again" is there any way to remove a modal from a users screen upon the modal being submitted manually because it seems like it doesnt want to do it automatically
is there any way to remove a modal from a users screen?
no
"something went wrong" implies you didn't respond to the modal submit interaction
if the modal is popped from the interaction on a button/select menu, you can respond to the submit interaction with an update which will update the message the button/select menu is on that prompted the modal
if the updated embed is not the origin of the modal, consider responding to the modal with just a simple acknowledgement that the data was successfully updated (ephemeral channel message with source)
but im able to retrieve the data that was submitted into the modal... thats why im so confused
Responding to the modal is separate from receiving the data. You always get the data from the modal submit, but then you need to respond to the interaction within 3 seconds. If your response takes longer than 3 seconds then you need to defer
ok thanks
Why would you close a modal without notification for the user. Thats a massive no no for UX. Just give them an ephemeral response with an OK or something.
the embed is updating upon the modal being submitted
DiscordAPIError[0]: 405: Method Not Allowed
at handleErrors (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async SequentialHandler.runRequest (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1163:23)
at async SequentialHandler.queueRequest (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:994:14)
at async _REST.request (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1307:22)
at async C:\Users\Crew\Desktop\maharaja\src\Functions\handleCommands.js:23:17 {
requestBody: { files: undefined, json: [] },
rawError: { message: '405: Method Not Allowed', code: 0 },
code: 0,
status: 405,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1409253135754596412/commands/undefined'
}``` can I know why im getting this
What's your code?
Looks to be an undefined command
Then use interaction.update(...) to do the updating
anyone?
Show your file tree
And show the file of the command
Open the Commands folder in the tree
theres nothing there
Then how are you expecting a command to work?
give me a minute
@distant inlet I've added a command it still shows it
nor is it creating the command in the server
I have the idea that you have no idea what you are doing
why you have prefix while you try to create a slashcommand
the bot has both slash commands and prefix commands how is it that hard
Please just follow this guide: https://discordjs.guide/legacy/app-creation/project-setup
@distant inlet
You use the wrong route, you want applicationCommands not singular
Oh yeah I get it now, thanks man
@distant inlet itd be more helpful if you actually "help" someone
WTf dude..
You mean spoon feeding you the correct code? And me sniffing in empty air to find your errorin first sight? You are better of interacting with GPT then with humans.
Stop it, they are right. Let it go
What a nonsense they are right.. they come here about commands not working. With an empty commands folder.. uhu I was so unhelpful
No.. they aren’t?
It wouldn't matter if the command folder was empty or not, ill show you right now.
You can drop it too
no, please just drop the conversation
giving someone code isn’t helping them. It is being a human version of their GPT slave.
Nobody asked for giving them code. Now drop it
okay
Helping would be providing guides, explaining what code goes where and why it works, or something else doesn’t.
My first act of helping them out was to** spoon feed** them** on how to ask for help**, by providing the code and file tree. Without that act of help nobody could have sniffed in empty air what the fault would be. But it's okay, I'll never try to help someone again over here with that absurd time out. Because yeah.. they are so right.
Error: Webhook send timeout
at Timeout._onTimeout (/home/container/commands/slash/Admin/panel.js:156:54)
at listOnTimeout (node:internal/timers:581:17)
at processTimers (node:internal/timers:519:7)
Error: Webhook send timeout
at Timeout._onTimeout (/home/container/commands/slash/Admin/panel.js:156:54)
at listOnTimeout (node:internal/timers:581:17)
at processTimers (node:internal/timers:519:7)
why webhooks getting timedout
my own bot can send but webhook cannot sended
issue from my server or discord provider?
Seems like the type for "content" is missing, or im doing something wrong here
It is typed as a TextDisplayBuilder too
i mean i can cast the type, but question still stands
where do you get component from?
containerbuilder
then it is a union type
ContainerComponentBuilder discord.js@14.24.1
The builders that may be used within a container.
Id and type is the only propertes that they all share
gotcha
you could type guard it but using instanceof
instanceof
The instanceof operator tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object. The return value is a boolean value. Its behavior can be customized with Symbol.hasInstance.
how author can be null in partialmessage?
partial message only shows message id, and a few minimal other stuff but I forgot
Only ids are guaranteed for partial structures
Or by checking the .type property
then im guaranteed to have author when i fetch message (on message update event)?
but why new message can be partial message?
I think so, messages can be partial because they're not cached
what about message delete event
how i can make embed like this any docs? I am using yt dlp and i want my video to be inside this embed
If not cached you can't fetch it as Discord will tell that data doesn't exist anymore
can i fetch oldMessage too?
I think this is just EmbedBuilder#setImage()
no idea lemme try
will i just get newMessage then?
can i assume that only content, editedAt/Timestamp is changed between newMessage and oldMessage?
oldMessage could be probably partial while newMessage is usually not unless you disabled caching for messages
can i assert it? or "usually" so make fetching logic?
You would usually have a fetching logic using Message#partial to check if it's partial and you would try to fetch
Don’t worry I got 1 hour
It can't
Not even then. newMessage will always be a full Message
We won't support TOS violations
I think it shows up as Message | PartialMessage in the event then or I'm mistaken I haven't looked at MessageUpdate event in a few months
mb
No, only oldMessage does
then why signature shows it can be partial
wdym? bc they def cant be partial
Client<boolean>.on<"messageUpdate">(event: "messageUpdate", listener: (oldMessage: DiscordMessage<boolean> | DiscordPartialMessage, newMessage: DiscordMessage<boolean> | DiscordPartialMessage) => Awaitable<void>): Client<boolean>
i think this is called method signatures
what version of djs are you on?
const modal = new ModalBuilder()
.setCustomId(`rankImage_${interaction.id}`)
.setTitle(`123`)
.setLabelComponents([
new LabelBuilder()
.setLabel(`1`)
.setTextInputComponent(
new TextInputBuilder()
.setCustomId("link")
.setRequired(false)
.setStyle(TextInputStyle.Paragraph)
),
new LabelBuilder()
.setLabel(`2`)
.setTextInputComponent(
new TextInputBuilder()
.setCustomId("brightness")
.setRequired(true)
.setStyle(TextInputStyle.Short)
),
new LabelBuilder()
.setLabel(`3`)
.setTextInputComponent(
new TextInputBuilder()
.setRequired(true)
.setStyle(TextInputStyle.Short)
)
])
await interaction.showModal(modal)
Error: Expected a string primitive
at _StringValidator.handle (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2615:70)
at _StringValidator.parse (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
at validateRequiredParameters (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:906:21)
at TextInputBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:1528:5)
at LabelBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:1757:29)
at C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:2857:64
at Array.map (<anonymous>)
at ModalBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:2857:35)
at ButtonInteraction.showModal (c:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:402:46)
at Object.run (C:\Users\AnthonyVault\Documents\GitHub\wetbot\slash-commands\rank-set.js:76:35) {validator: 's.string()', given: undefined, stack: 'Error: Expected a string primitive
at _St…b\\wetbot\\slash-commands\\rank-set.js:76:35)', message: 'Expected a string primitive'}
your missing customId on TextInput in label 3
i fixed it thanks tho
is it changed between versions?
i think it isnt
It shouldn't have but in case it is a bug
so i can assert it?
Question about the .setAccentColor() of ContainerBuilder, how to use a #123456 hexa color ?
it is correct in the current version
https://discord.js.org/docs/packages/discord.js/14.24.2/ClientEvents:Interface#messageUpdate
messageUpdate : [ oldMessage: OmitPartialGroupDMChannel<Message | PartialMessage>, newMessage: OmitPartialGroupDMChannel<Message>, ]
is there type guard checking message is partial or not?
message#partial is a Boolean you can use that
What version are you using?
npm ls discord.js
Because we can't really help you without knowing that
im on 13 because that one made really hacky patch that forces me to in 13
wait this is v14 channel..? if you guys cant help thats ok ill find my way
v13 is deprecated and unsupported for a long time; you really should update
realistically, this should set the status right?
nothing i've done has made the bot appear online
const client = new Client({
intents: [GatewayIntentBits.Guilds],
presence: {
status: 'online',
activities: [{
name: 'everyone get petted!',
type: ActivityType.Watching
}],
},
});
What patch is that?
so you think it is because of some weird bugs right?
its legacy idk
You don't even know why you're using a deprecated version?
Update then
ok ill try
i've also tried:
client.on(Events.ClientReady, readyClient => {
client.user.setPresence({
status: 'online',
activities: [{
name: 'everyone get petted!',
type: ActivityType.Watching
}],
});
client.user.setStatus('online');
console.log(`Logged in as ${readyClient.user.tag}!`);
});
Doing both of those right after another without awaiting will cause the second call to overwrite the presence the first one sets
What exactly is showing/not showing when doing the stuff in constructor?
I only did one at a time, the one not in use was commented out.
the bot remains in the offline appearance, and I haven't managed to get it out of that.
I can't see anything in the linked thread that I haven't done.
Is the bot actually logging in, if it doesn't show as online it probably isn't
well the bot responds to commands
Does it show as an actual user in members list?
Or is it just added as an app and not a full bot user