#djs-help-v14
78874 messages · Page 42 of 79
I think it's too much work for something “irrelevant” that only changes the aesthetics, but thanks for your help
Hello, does changing the bot's status every 15-30 seconds cause the bot to appear offline for a few seconds and then immediately appear online again? And does it keep repeating this?
why do you change the status so fast
to display things like the total number of guilds, the number of users and some short texts
there’s absolutely no reason you need to change the status that fast
change it once per hour or something
if i'm sending something that might have discord formatting in it, but i just want to show it raw, is there any method djs builds in that can allow me to escape what i need to, or do i need to write my own?
we have a bunch of functions for escaping markdown, yes
found it, { escapeMarkdown } = require('@discordjs/formatters');, ty
huh, can't find module, should have it from npm install discord.js, right?
discord.js exports it
just import it from it
so just { escapeMarkdown } = require('discord.js') instead?
nope message.channel.send(`Output:\n${escapeMarkdown(output)}`); ^ TypeError: escapeMarkdown is not a function
huh
lmme double check im using v14 ig
npm ls discord.js
ty
not sure how i've been on 13.6 thinking i was on 14...
yeah, that would do it
but
miiiiight be that 13 exports formatters as a whole (as in, not all separate functions)? don't remember
ima try the .util since i saw searching here that that was changed
works now, ty
Another potential method if js supports it is escaping the markdown. \*text* will ignore the formatting so you could in theory "\text" if "\" works in js
i thought of that, but if i did, i would need to figure out every place i needed to put the \
Regex time lol
or just use what we already made for this
instead of reinventing the wheel
Also completely valid
or, hear me out, i use the already made util for this purpose
is there any way to get the name of a tag for a fourm channel/thread channel by the id? i want to get a threads appliedTags but i need the names not the ids
Are modal components supported in d.js yet?
No they're not. SoonTM
grab them from the forum channel itself
oh ok and just map the ids
good idea idk why i didnt think of that
yeah
hey can anyone help? i made some commands to show user profile badges with !userinfo but the only badges that show up are old ones like early supporter dev etc the new badges like nitro booster up, mission quest the bot cant detect pls help me out
nitro badges and some other badges are not available to bots as they are not contained within the public flags bitfield
nitro status can only be obtained via OAuth2, and other badges only via fetching user's profile which is not accessible to bots
when you do roles.create() how do you specify the removal of permissions? like they cant send messages (for a muted role)
i have this now
const muteRole = await message.guild.roles.create({
name: "Muted",
permissions: [
],
color: Discord.Colors.Red,
reason: "Muted role setup by bot."
});
role has no concept of taking away permissions
role can either give permissions or not
if you need to deny a permission, you do it via permission overwrite on channels
in your case, you would need to go over every channel in the server and deny the send for that role in each of them
oh bet ty
i lowk forgot that and merged the channel permissions with role permissions in my head 😭
does v14 only support text inputs and not string selects rn?
Correct. There is a pr for their support tho, if you want to follow that
can we give select menus a default selected value?
documentation suggestion for @brittle dawn:
UserSelectMenuBuilder#addDefaultUsers() builders@1.11.2
Adds default users to this auto populated select menu.
example for user select, but yes you can have default values for any type of select menus
alr ty
i dont think it exists for string select menu
It naturally exists for string selects
djs 13 nuked extending structures right?
I mean nothing really prevents me from simply modifying the prototype and adding properties
In a way that they would be internally used by the lib, yes
Sorry elaborate, what do you mean
I'd just rather add my guild settings into my guild instead of using collections
My current approach is just adding properties to the Guild prototype
Which is a bad idea and primary reason structures were removed
#6027 in discordjs/discord.js by 1Computer1 merged <t:1625397995:R>
fix(Structures): remove Structures
The suggested approach is to use a function with the structure as one of the values you pass in, then return the data you want
It is on the string select menu option.
documentation suggestion for @brittle dawn:
StringSelectMenuOptionBuilder#setDefault() builders@1.11.2
Sets whether this option is selected by default.
Like the example in the PR?
Yeah
Or any other way. What I do is i have my own class that doesn't extend Client but only has it as a property, and there i can keep whatever i want since it's my own class. I just pass that class to places from handlers
wondering how long itll take to support new modals or is djs waiting for the entire new modals update before releasing?
we don't give estimate release times, it will be released when it's ready
Isn't there already a pr open
Yeah that makes sense
yh but thats only for the select menu support i think, now theres user select, text display etc
d.js will always wait for discord to release and document the features, then it will eventually be added to the library. there is still no given timeline on any release beyond "after discord documents it"
In modals? Zamnnnn
const collector = msg.createMessageComponentCollector({
filter: (int) => int.user.id === message.author.id,
idle: 60 * 1000,
})
how do you have multple component types? Like cast the types to be that?
check the type in collect
Hello!
When using the new components, my messages are always mentioning me, how can I disable this ?
Thanks!
can you not pass multple in the generic? That's what i mean
well, can you?
i have no idea hence im asking.
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"] } }
well, you could try, but even if you do and it happens to work.. you'll be left out with union of them both and will have to check in the collect anyway
so skip it and just check in collect
Ah I checked back and saw i did ask before,and i can do <ComponentType.Button | ComponentType.StringSelect>
why slash commands not working in dms but in other server works
Do you have the contexts and integration types stet correctly?
nah i dont have contexts
is Bun not supported in discord.js with sharding enabled?
null is not an object (evaluating 'this.shard.ids')
works fine with Node
that's something bun will have to fix in their side then
djs doesn't specifically support other environments, but since it works on node it should work for them, otherwise it's their issue
Every now again, my shard goes into the reconnecting state. Is this normal?
Fwiw nothing seems out of place... Everything works as normal. Just curious if that's normal behavior
discord periodically asks connections to reconnect
Ah ok, good to know, thanks
Error:
TypeError: interaction.user.displayAvatarUrl is not a function
Code:
.setFooter({ text: `Requested By: ${interaction.user.username}`, iconURL: interaction.user.displayAvatarUrl() })
User#displayAvatarURL() discord.js@14.22.1
A link to the user's avatar if they have one. Otherwise a link to their default avatar will be returned.
displayAvatarURL
casing matters in programming
so just interaction.user.displayAvatarURL
correct
you typed Url, it's URL
it's still a function you need to call
is there a way to use showModal with raw JSON the same way you can send raw components? i'm trying to send a modal without using any builders (i think they're confusing and just like the raw text more)
e.g.
const modal = JSON.stringify({
type: ComponentType.Section,
data: {
custom_id: "updateModal",
title: "Modal",
components: [
{
// valid labels/options snipped for length
},
],
},
});
// rest of code...
await interaction.showModal(modal); // "No overload matches this call."
via client.rest right?
idk how that works tho, but I heard thats a way to send raw api stuff using d.js
why are you stringifying it?
it worked without error but not actually showing it
show your code
thought it would work, tried both ways though and it didnt
they did in the screenshot
Is there a way to make the text in an embed title not bold?
the new one
no, that's just how discord designed it
if you want something that's unsupported by djs you'll need to do a raw api call
but currently djs will still error anyways when receiving the modal
so it's not really useful to send it
well just for visual purposes
roger on the api call, are the errors just something with discordjs right now or is that cuz of no builders?
which errors?
it's how djs currently works, it's "hardcoded" for text inputs
alr, thanks
Will modal components be released in another v14 version or v15 when that’s ready?
v14, and it'll be in v15 as well of course
Gotcha
anyone else's bot no longer connecting to discord? i.e. my ready event is no longer firing?
Unable to fetch this user.
+cr 1326108023529148477
I'm not sure what you're trying to do but this certainly isn't the place
sorry
PermissionOverwriteManager discord.js@14.22.1
Manages API methods for guild channel permission overwrites and stores their cache.
@teal obsidian please use #app-commands or the hide option for personal docs usage
my bad pal
i just wanna make sure, im doing this correctly right?
category = await message.guild.channels.create({
name: "Jail System",
type: Discord.ChannelType.GuildCategory,
});
category.permissionOverwrites.set([
{ id: message.guild.roles.everyone.id, deny: [Discord.PermissionFlagsBits.ViewChannel] },
{ id: jailRole.id, allow: [Discord.PermissionFlagsBits.ViewChannel] },
]);
you can pass the overwrites directly when creating the channel
issue is that its not hiding the channel for everyone, and i cant figure out why
Can someone help?
well you're not awaiting that .set(), maybe there's an error you're omitting
embeds can't have more than 25 fields, you added 26
i lowk forgot the await
You are trying to add more than 25 fields to an embed somewhere
Edit: weird. message didn't load
you could also do this
CategoryCreateChannelOptions#permissionOverwrites discord.js@14.22.1
Permission overwrites of the new channel
sounds like you have 26 commands
what would you suggetst doing?
if you really want to keep the same embed design, paginate
if your command is a help command, i'd say replace it with like "please specify the command you want help with" etc etc. i have like 400 commands and thats what i did
i want it to show what commands there are them be able to do /help [command] for more info on that command
My bots ran perfectly fine for over a month, all of a sudden both disconnected and can no longer connect
tag suggestion for @sleek brook:
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
then yeah do what amgelo said and paginate it
@halcyon bison also did, nothing gets logged
my bot conects fine might just be your connection
export default class Client extends DiscordClient {
// ...
constructor(token: string, options: Options) {
super(options);
this.login(token);
this.development = options.development;
this.registerEvents();
this.on("debug", console.log);
this.on("error", console.error);
this.on("warn", console.warn);
this.on("ready", async () => {
// ...
});
}
connection is fine
curl -v https://gateway.discord.gg returns a proper TLS handshake
if absolutely nothing is being logged, I have to wonder if your custom class is somehow interfering
even without properly connecting to discord, you should at least get a log along the lines of
Provided token: **************************************
Preparing to connect to the gateway...
idk how to do that
lmao this fixed it thanks
@teal obsidian I'd recommend doing this since you'd only do a single api call
yeah im about to fix that too, thanks
The bots ran fine for over a month
I've been doing it with classes like this for years, never had issues like this
that's great
even so, I'm just telling you that regardless of anything, the debug event should emit with some base logs
therefore something is interfering with djs base functionality
if you just did console.log() to the top of that constructor would it actually show anything
It runs fine on my machine in it's docker container, but on my VPS nothing happens. I added some extra logs in there and they fire, but no event ever fires
then it doesn't sound like a code issue nor something we can really help with
contact your host
also this is more of a design issue but constructors should only initialize internal state of the object, they shouldn't have side effects, including logging to the gateway
What will they be able to do? I mean the container perfectly connects to discord, curling returns a correct TLS handshake and I ran a quick script:
const WebSocket = require("ws");
const ws = new WebSocket("wss://gateway.discord.gg/?v=10&encoding=json");
ws.on("open", () => {
console.log("WebSocket connected to Discord");
});
ws.on("message", (data) => {
console.log("Message:", data.toString());
process.exit(0);
});
ws.on("error", (err) => {
console.error("WebSocket error:", err);
});
ws.on("close", (code, reason) => {
console.log("WebSocket closed:", code, reason.toString());
});
This clearly connects to the gateway, so it's discord.js that's hanging for some reason
What will they be able to do?
What will we be able to do?
I doubt this would be the cause of it, but I can try
if it works on your machine but not on your vps it's something on your vps, not on your code (which includes djs), since it's the same code and there isn't anything trying to detect whether it's on your vps or in your machine and doing different stuff
It's not a connectivity issue, nor a firewall issue. So why would it be hanging though?
¯_(ツ)_/¯
I'd try logging and see where it stops
Logging what? I can put logs in the constructor... they fire..., in said constructor I have the above event handlers but none fire
logging mock values to indicate where they are
if it doesn't work only on your vps there isn't much we can suggest
it's not like djs has special logic for when it detects it's in a vps or something
Ofcourse not, I'm just confused as to why it basically hangs silently, the process stays alive but no events are fired
you could add logs inside the copy of your library for debugging
or override methods to add logs given you already have a custom class
fair enough, I'll do some digging. Thanks anyways
Right so it hangs on Preparing to connect to the gateway...
Ok, so very stupid but turns out discord rate limited the VPS somehow, guess I'll have to look into why that happened
Yes that’s normally a cf ban. Anywhere from like hours to an entire 24 hours. Is it a shared ip? If not then you might have spammed the api too much
Could be a shared IP, I’ll need to look into it. Not sure how much the API is spammed though as it’s running a bot for a client. It changes a lot of user’s roles and nicknames so that might be the culprit. Any way to prevent this from happening in the future?
Looks like my provider uses unique IPs so I guess that’s indeed the culprit…
I believe cf bans you from making a lot of bad requests in a short amount of time. I believe… Jusr don’t do that or don’t have a host with a shared ip
Bad requests in what sense?
As in requests returning non successes?
im trying to figure this out, it seems to not be working,
category = await message.guild.channels.create({
name: "Jail System",
type: Discord.ChannelType.GuildCategory,
permissionOverwrites: [
{
id: message.guild.roles.everyone.id,
deny: [Discord.PermissionFlagsBits.ViewChannel]
},
{
id: jailRole.id,
allow: [Discord.PermissionFlagsBits.ViewChannel]
},
],
});
this is correct right?
dw its working now lmfao you can ignore me
Barely readable as that is, looks like based on the error you forgot to set the IsComponentsV2 message flag
?
!
MessageFlags#IsComponentsV2 discord.js@14.22.1
Allows you to create fully component-driven messages
full words please, and #how-to-get-help
Thx
Since discord.js doesn't support the new modal features yet, is there a way d.js will let me sent raw JSON?
Yes, make a request using <Client>.rest
REST#post() discord.js@14.22.1
Runs a post request from the api
ty
This doesnt mean you can correctly receive the interaction though
ah yea, I forgot about that part...
Hey, does anyone know if it’s possible to create rounded embeds in Discord? And if so, how would I do it?
what’s a round embed?
are you referring to a container?
Through raw event? Never really messed with it
That's a lot of work lol
guide suggestion for @mossy path:
Popular Topics: Display Components - Container
read more
Thank You
Bro
?
you leaked the IP address XD
ok

He's got too much aura to type full sentences
please keep unnecessary comments to yourself
how do I get a list of all slash command options in a chatinputcommandinteraction as json? (so similar to the original discord response)?
interaction.options.data
Thanks!
Hi im new but want to know that is JavaScript same as node.js etc i have no knowledge just asking as i have watched few vids. of js beggining
this is more of a discord api than discordjs question, but what exactly is the rate limit? is it 50/s per token or 50/s per token per channel ??
i keep finding info that contradicts each other
its dynamic
there is no fixed ratelimit in most cases
i keep reading that there's is a 50/s limit, and that no auth header => applied to ip
Is there a way to have a table in a message? Or at least columns, I feel like I've seen it possible to have two columns in components, but I can't find it in the documentation now
That’s the global limit. Which really you shouldn’t be hitting. The one for channels for example is down to the route, and as was said those are dynamic rate limits
Not really, you’d have to make it yourself by adding a column by a max length of the string or something. Not natively
I see, thank you. I was probably thinking of embeds
Hi, I’m working with Discord.js and I created a modal with user select and role select menus. But when I submit the modal, my InteractionCreate event doesn’t trigger at all. Instead, I get this error:
at ModalSubmitFields.js:23:23
Correct. You can't currently use select menus with DiscordJS because the interaction data would be malformed and won't trigger
oh alright ty
idk why my application is not running.
I started it two months ago and it went idle and i saw yesterday it was offline but the server was running and when i restarted the bot comes up but no response at all, there are no errors
Sounds like an issue with your hosting.
hmm
any idea?
okay i found the issue
If you host it locally on your PC does it work? If it does then we can't help here as it is outside the scope of Discordjs nv what was your issue
applications commands aren't reloaded
You should be manually deploying commands when changes are made and have good logging to ensure they're deploying correctly
no i have a handler for that but its stuck for some reason
see it reloads fine on my pc and i didnt make any changes since 2 months
Correct. One of the reasons doing it manually has advantages. You limit the logic...you can add more logging for better debugging, and you add fewer things your client has to do to start up
Also, just helps against rate limiting
i guess its a host issue i'll contact them
I have a button interaction that replies with an ephemeral message which has another button inside of it.
Once I click that button, it is possible to get that message and modify it from the new interaction data? Or do I have to hold a reference to that message from the original interaction instance
I'm trying to edit/delete it from the new interaction instance, but I keep getting errors like the message doesn't exist
<ButtonInteraction>.message is the message the button is on
since it's ephemeral it can only be edited through the interaction webhook, so you'd need to use <Interaction>.update() if you haven't already responded to the interaction or <Interaction>.editReply() if you have
can i reply interaction using @discordjs/rest? for new modals experiment?
sure, but the main issue is receiving the modal submit
djs isn't currently equipped to handle modal submits containing anything other than text inputs, so it'll error when receiving the interaction
Activity discord.js@14.22.1
Represents an activity that is part of a user's presence.
is inline false by default
it's not present by default, and that behaves like inline: false
that's how discord designed it, and technically it can change
@amber bison please use #app-commands or the hide option for personal docs usage
u wanted to say it can't?
no, technically it can, since we're not discord, we don't know what they'll do
but I doubt they'd change that
I'm trying to say that it being default to false and it being not present are different things
how can i do members.fetch('id") but first it looks in cache, if not found then fetches it
is that default maybe
yeah that's what all fetches do
unless you explicitly pass { force: true }
that wont check for cache right
correct
what if i do force:true, cache: false
then it won't check in cache and won't save it either
thanks
are there rate limits for members.fetch("id") forcefully, also same way for channel role and guild fetching
there's ratelimits for every endpoint
can i find it for this
there's no completely accurate list of ratelimits, they're mostly considered dynamic
but if you have the Guilds intent you won't need to fetch channels, roles or guilds
Ratelimits are dynamically assigned by the API based on current load and may change at any point.
- The scale from okay to API-spam is sliding and depends heavily on the action you are taking
- Rainbow roles, clock and counter channels, and DM'ing advertisements to all members are all examples of things that are not okay
but is it safe to always forcefully fetch every single time
why would you need that if they're cached anyways though
well sadly idk is it cuz of me i do have that intents but still sometimes like 95% of time it is working and cached but sometimes it errors like its not in cache
so i just want to forcefully fetch everything and thats it
well if it's not in cache it'll fetch
but maybe it can be in cache but not latest data
that depends on your intents and what object
for these if you have that intent they'll always be up to date
hmmm even role.members ?
roles.fetch forcefully wont update role.members, right
no, that's a special case
you'll need to fetch all members for the role members cache to be updated
but my biggest problem are members
any particular reason you need all members of a role? maybe there's another approach
on start i fetch everyone and i have all intents like guilds and guildmembers
and sometimes they arent in cache...
just some verification system with huge amount of members like 10k
and server has 500k members
my question was about what you're doing though, not with how many people
that doesn't seem right unless you're manipulating the cache manually
just going through them, comparing their roles with data in db and doing something else
i dont its normal settings and yeah i know it doesnt but it is like that
how do you know it's like that?
on a button i do members.cache.get("id"), it gives me error saying member doesnt exist, when i do userinfo and check their roles they're legit on server
thats all literally, so simple bot just to test is cache always working and its not
maybe because of too many members i have no idea
can you show your code where you do the get and the error, client constructor, and where you fetch the members?
const client = new SapphireClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
],
partials: [Partials.User, Partials.GuildMember, Partials.Channel, Partials.Message],
cronTasks: {
defaultTimezone: container.config.guild.timezone
}
});
private async fetchMainGuildMembers() {
const mainGuild = this.container.client.guilds.cache.get(this.container.config.guild.id);
if (!mainGuild) {
this.container.logger.error('Main guild not found');
process.exit(1);
}
await mainGuild.members.fetch();
this.container.logger.info(
`Fetched ${mainGuild.members.cache.size} members from the main guild`
);
}
in clientReady.ts
ofc i actually execute that function dw
and as i said i have button interaction handler, on click ALL i do is members.cache.get("id") and reply with is user on server or not
would still be helpful to see it
import { ApplyOptions } from '@sapphire/decorators';
import { InteractionHandler, InteractionHandlerTypes } from '@sapphire/framework';
import type { ButtonInteraction } from 'discord.js';
@ApplyOptions<InteractionHandler.Options>({
interactionHandlerType: InteractionHandlerTypes.Button
})
export class BotInteractionHandler extends InteractionHandler {
override parse(interaction: ButtonInteraction) {
if (!interaction.inCachedGuild()) {
return this.none();
}
if (interaction.customId.startsWith(`${this.name}-`)) {
return this.some();
}
return this.none();
}
override run(interaction: ButtonInteraction<'cached'>) {
const member = interaction.guild.members.cache.get(interaction.customId.split('-')[1]);
return interaction.reply(member ? `Hello, ${member.toString()}!` : 'Member not found.');
}
}
nothing really to see i aint doing anything wrong im sure my code is right it just doesnt work sometimes
guys what is it
A command file doesn’t default export a class
you can double check the id, log it when the member isn't present
make it default export a class
that's not a djs error or issue
as i said ID is always correct and im sure there is NOTHING wrong literally
it's a js one
i think that it works fine with small amount of members like 5k but with 500k its a problem
where i need to make it, in handler or command
well either it's not or sapphire or you are doing something with the cache, assuming you do call that method you shared before, and the button interaction is from that main guild
...
you're not using cache limits so that shouldn't be an issue, the only default limit is for messages
like chewinky said, in your command file that isn't currently exporting it
that issue is entirely unrelated to djs
it's with your own code to read command files
yeah but you dont understand, sapphire doesnt modify anything and I do not modify anything, i have default simple bot made just for testing is cache working fine, code i sent you looks perfectly fine and it is, 95% of members are fetched okay the rest is not
every command file have ts
your error suggests otherwise
bruh
i changed TestCmd to BanCmd and it works ._.
¯_(ツ)_/¯
maybe it wasn't saved before
it was
then your code wouldn't have errored
anyways, the issue is solved
ye
but the mongodb always needs to change my ip adress cuz my wifi router changing ip every day
well as I said the only default limit is for messages, not members
Are InteractionResponses cached? I can't find where it might be
No
What do you need it for?
I have a button inside an ephemeral interaction reply. I want to edit/delete that interaction message from the new interaction, but I have to reference the original instance of the interaction reply to do that
So I was wondering if d.js held it in cache and I wouldn't have to cache it myself
ButtonInteraction provides what you need
interaction.update, interaction.deleteReply after a update call
interactions are very short lived (relative to the bot's lifetime), caching them would be a waste of resources for most use cases
No, I don't think I'm explaining it right:
- User presses button in a server message which creates a
ButtonInteraction - I reply to that
ButtonInteractionwith an ephemeral message - this reply message also has button inside of it - User presses button inside of the ephemeral interaction reply
- Replying to it will just create a new interaction reply message
- I don't want this; I want to edit/delete the first initial reply message which holds the button
But I can't get a reference to the first interaction reply to update it without holding a reference to it
interaction.update also acknowledges the interaction
like a .reply
Never mind, that's not what I'm saying lol. I know what .reply is/does, but it's not calling the function on the correct interaction instance
you want to edit the server message in step 1? "User presses button in a server message"
Yes, but from a second interaction. Which means I have to cache the first interaction so I can call .edit on the first (cached) reply message
so the server message comes from the interaction? and why not use the message?
wat
I can't edit the message like that. ButtionInteraction holds a reference to the message, yes, but since it's ephemeral (or an interaction reply/both?), calling edit doesn't work and the API rejects the request
you just said "so I can call .edit on the first (cached) reply message" though
Well yea, because it's the cached InteractionReply, not Message
I see, I thought you meant a Message since you said you'd call it on the message
Yea, it's all good, I'm just bad at explaining lol, sorry
so from what I understand:
- Somehow, message A is created, which holds a button A ("User presses button in a server message").
- Button A, when pressed, creates an ephemeral message B, which holds button B ("I reply to that ButtonInteraction with an ephemeral message")
- Button B, when pressed, wants to edit/delete message A (" Iwant to edit/delete the first initial reply message which holds the button")
correct?
No, message A spawns both message (InteractionReply) B and button B. Button B will edit message (InteractionReply) B
if B wants to edit itself, just call .update then?
.update will edit the message the button is on
...
Ok, let me try...
Nope, doesn't work. I just used interaction.update("HELLO") and I get 500035 "Invalid Form Body". Unless I can't change it to just string content
is it a components v2 message?
Yea. I can't even overwrite it as the legacy type?
no, you can't downgrade
once it's marked as such you need to use components entirely
if you just want text, use a text display component
Interesting, ok, good to know. I thought you just couldn't mix them
So this works, but only if I'm updating it with the same message structure 🧐
If I try to update with a new message, I get a an error from d.js instead: ExpectedValidationError: Expected
what do you mean by "update with a new message"
Just change the message. Change how it looks. New text, new components etc
I don't understand, can you show the code instead?
the one that errors
ValidationError suggests there's something wrong with the builders and their values you set, not with what you're actually doing
can you show the full error?
also you're meant to use interaction.editReply instead of the deferredReply.edit
though I think they do the same thing anyways
given that does work
yeah looks like it's just an alias
sounds like you have a section without an accessory
Yea, I remove the button. I can't edit/update the message like that?
you can't have a section without an accessory
it's a required field
you'll need to use a text display instead
I swear... I'm so dumb...
The second message was a copy/paste of the first, but when I removed the button, I forgot reduce it to just a label, so it was building a section without an accessory this whole time.......................................................
I appreciate you sticking around and helping, ty. I need a new brain
no worries, it's pretty much always the little things
hello
hi, i have a question
does d.js got this update or no?
no, it's still being worked on
uh is there any ETA for this?
no
okay..
If I want someone's banner in full size, what size should I use? <user>.bannerURL({ size: ? })
Hi do you have a trial code for Embed ?
That’s the biggest anyway
guide suggestion for @copper dawn:
Popular Topics: Embeds
read more
ok
Is this the api Discord ?
discord.js is a 3rd party library that interacts with the discord api
But in the console it appears because api Discord
you're still using the discord api regardless of library or not
and your components are missing a type, as shown in the error
I did not understand, can you explain?
discord.js is a 3rd party library that interacts with the discord api. your error is a discord api error, but you are using discord.js to interact with the api
Do you have any test code I can try to see what is required?
no
its a very simple error to fix
Ok
Look at the guide previously linked. But like no said the issue is with component type
How can I fix it?
Ok 😮💨
This may also be because you did not specify the isComponentV2 flag, no?
that would depend if they are using components v2
Btw, the current version of Discord.js isn't supporting selectors in modal or its already working with ?
it will be soon
No
-# not soon?! 
Is there are a reason that every other time my bot that registers guild commands the commands disappear?
Probaby just need to reload your Discord app
Make sure youre only registering when you need to
can someone tell me how I can create a message .. or embed where an image banner is on top then comes the tex/description and then a dropdown/select menu and all of this inside a container?
this looks so clean but I don't know if I should share this here
guide suggestion for @pure ridge:
Popular Topics: Display Components
read more
oh wow .. that's awesome thank you
Okay I will try to do that instead of registering every login haha
is there a way I could automatically detect changes and register if so? (I would need a way to fetch existing registered commands info)
Does command replies' allowedMentions overwrite the client's allowedMentions?
E.g. if I set the client's to parse: ["users", "roles"] but the reply's to parse: ["users"], what happens?
-# I want this specific reply to only ping users, NOT roles.
If you put it in the reply it’ll take that, then the default in the client options
hello
how can i set custom status for my app
ClientUser#setPresence() discord.js@14.22.1
Sets the full presence of the client user.
// Set the client user's presence
client.user.setPresence({ activities: [{ name: 'with discord.js' }], status: 'idle' });
ClientUser#setActivity() discord.js@14.22.1
Sets the activity the client user is playing.
// Set the client user's activity
client.user.setActivity('discord.js', { type: ActivityType.Watching });
You can use this if you just care about the activity, not the status state (online, idle, DnD, invisible)
but this shows this
i actually meant something like this
That is an undocumented feature and is not supported by discord.js
how does it work then
still not
it only shows basic activity presence
Can you show your code
client.user.setPresence({
activities: [{
name: `${servers} servers | ${users} users`,
type: ActivityType.Streaming,
url: 'https://twitch.tv/discord'
}],
status: 'online',
});```
voila
You're using Streaming type, not Custom
you're not following the example at all 
when i use custom :
const { Client, GatewayIntentBits, ActivityType } = require('discord.js');
new Client({
intents: [GatewayIntentBits.Guilds],
presence: {
activities: [{
type: ActivityType.Custom,
name: "custom", // name is exposed through the API but not shown in the client for ActivityType.Custom
state: ":lemon:"
}]
}
});```
it doesnt even show

and that's the client you're always using?
you're not creating a new one?
because if you create a new one and not doing anything with the one you have, that won't do anything
How are you logging in with that client if you're not assigning it to a variable

Is there a guide for adding attachments to a non components v2 message?
AttachmentBuilder discord.js@14.22.1
Represents an attachment builder
You mean just an AttachmentBuilder? You can create that and send it in the files: [] of a message
Popular Topics: Embeds - Attaching images
read more
thanks! I couldn't find the page and the attachmentbuilder constructor signature was confusing
client.user.setPresence({
activities: [{
type: ActivityType.Custom,
state: `${servers} servers | ${users} users`
}],
status: 'online',
});```
error
TypeError [InvalidType]: Supplied activities[0].name is not a string.```
what happened to your previous code
great the issue was that state wasnt valid i replaced it with name
you need to provide both state and name iirc
does this work ?
client.user.setPresence({
activities: [{
type: ActivityType.Custom,
name: `${servers} servers | ${users} users`
}],
activities: [{
name: `${servers} servers | ${users} users`,
type: ActivityType.Streaming,
url: 'https://twitch.tv/discord'
}],
status: 'online',
});```
did you try it?
also activities is an array
no need to pass it twice
hmm
if you set a property twice you're overriding the last one
that is effectively equivalent to this code
true just saw that, so how can i set both at the same time ?
well it's an array, technically you can pass as many as you want
but afaik discord only reads the first one
why do you want to set both anyways?
you've been shown already how to achieve what you wanted
i want something liek that
client.user.setPresence({
activities: [{
type: ActivityType.Custom,
name: `${servers} servers | ${users} users`
}],
activities: [{
name: `Use .help & .invite`,
type: ActivityType.Streaming,
url: 'https://twitch.tv/discord'
}],
status: 'online',
});```
this is wrong but u get the idea
I don't quite get it
like the custom status and the activity presence at the same time
how would that even look? (in discord)
these two at the same time
have you seen that somewhere?
I'm not too knowledgeable on statuses but I don't think that's possible
nop any bot has either custom status or activity presence
but iv seen a bot switching between these two automatically
well you can make it switch, that's indeed possible
just send one, wait, and send the other
but I'm pretty sure both at the same time isn't possible
probably but the "why" is always here
¯_(ツ)_/¯
you'll have to ask discord that
@discord why
also how did u put an emojis inside a ``
just put the unicode emoji after the backticks
😭
works the same for codeblocks

:flag_ps:
custom emojis aren't unicode
anyways this is getting offtopic
flag_ps isnt a custom
we can continue in #archive-offtopic if you want
sure
code to reply to new modals in discord.js interactions while the module is not updated. I saw that a lot of people were looking for it.
import { ButtonInteraction } from "@app/typings";
export const requiresDatabase = true;
import { token_beta } from "@app/config.json";
import { REST } from "@discordjs/rest";
const restBot = new REST({ version: "10" }).setToken(token_beta);
export const id = 'sheet_notes_delete'
export async function execute(interaction: ButtonInteraction) {
restBot.post(`/interactions/${interaction.id}/${interaction.token}/callback`, {
body: {
"type": 9,
"data": {
"custom_id": "bug_modal",
"title": "Title of modal",
"components": [
{
"type": 10,
"content": "Text Display Content",
}
]
}
}
});
}
the issue isn't sending though, it's receiving
😔
Lads, is there a workaround for sending components V2 in Modals?
or will djs validate it before and therefore not allow sending anything with the new components?
You can already send it. Recieving will error though
So no workaround
For GuildMessageManager.fetch() https://discord.js.org/docs/packages/discord.js/14.22.1/GuildMessageManager:Class#fetch
Does it default to a max of 100 or something? Is there a limit? I am trying to fetch all messages in a "ticket" channel, but it seems to only fetch some of the latest messages (still a lot ), even if all the messages were sent within like the last 20 minutes or something. I just tried it and it only fetched 48 messages, while there were more
Max is 100 yes
Weird
Not at all
I just tried it, it only got 48, but there were maybe like 60 or smth
It defaults to 50 if limit is not set
Hi, i'm trying to use a ChannelSelectMenuBuilder but it doesn't display all the channels, whereas using StringSelectMenuBuilder everything is fine, is this a limitation?
But max limit is 100, any more than that, you'll need to paginate
How's that work?
Any docs for that?
It can only display 25 at a time, you can use search bar in it to search for channels
my ChannelSelectMenuBuilder only displays 15 channels out of the 22 displayed with the StringSelectMenuBuilder, idk why
Typescript error with command loading... SlashCommandBuilder#toJSON is throwing an error when I try to insert it into a list of RESTPostAPIChatInputApplicationCommandsJSONBody. Should this go in GH bug reports?
Do you have channelTypes set?
I'll check it, thanks
Yeah, ChannelType.GuildText but it's not display all the text channels
Show the code and full error
Is there any way to know the amount of messages in a channel without fetching them? Or do you just go until you reach the end lol
import type { Collection, RESTPostAPIChatInputApplicationCommandsJSONBody } from "discord.js";
import type { Command } from "@/types";
import { base } from "@/globals";
export default async function <
T extends Collection<any, Command> | RESTPostAPIChatInputApplicationCommandsJSONBody[]
>(list: T, filter?: string[]) {
for (const path of new Bun.Glob("*.ts").scanSync(`${base}/commands`)) {
const cmd = await import(`${base}/commands/${path}`);
const command = (cmd?.default ?? {}) as Command;
if ("data" in command && "execute" in command && !filter?.includes(command.data.name)) {
if ("push" in list) {
list.push(command.data.toJSON());
} else {
list.set(command.data.name, command);
}
} else {
console.warn(`The command at ${path} is missing either "data" or "execute" properties!`);
}
}
return list as T;
}
```I can pass either an empty array, or a Collection depending on what I need to do. Either loading for the app (Collection), or loading to push to Discord (array)
Oh, unfortunate.
Do you know any ETA of this?
And here's the error
Can you do npm ls discord-api-types or whatever Bun equivalent of that is?
Seems to be types mismatch, make sure you are importing the type from discord.js, and not separately from discord-api-types
No eta, it will be release when it is ready
My code is exactly copy-pasted, I never use discord-api-types at all
No, there's no way to know for bots. That is pretty much it. But also keep it mind to not abuse the endpoint and try to fetch like thousands of message.
oke 👍
Still can you do what I asked please?
Wrong reply i think 
Actually reading the error this time, looks like it's just a type mismatch between @discordjs/builders.RESTPost... and discord-api-types.RESTPost.... Doesn't affect functionality whatsoever, works fine, just big spoopy red line 👻
Ok weird, types are different between d.js packages. Lemme check one sec
Yeah, /builders have different version than d.js
May have been missed by us
Oh, yeah...sorry
np ^^
@golden zenith
Alrighty then, here's your unofficial bug report 😆 Thanks for the lightning-fast replies
On another thought, can you nuke your node_modules and lockfile and install fresh?
do you have any idea why it does that?
Sure, lemme try it real quick. Should I purge bun's cache as well?
Aight, well it will only be for tickets, so shouldn’t be that many messages
Sure, yeah. d-type is not pinned by packages, so fresh install will get the latest minor version
remember to delete lockfile too
Ah hey would you look at that.
I know what's wrong! Ain't got no gas in it! (my head)
Do searching for those channels that are missing ends up showing them?
Yep, only the ChannelSelectMenu... missing them
No i mean searching the channels inside the select menu
sorry ! Nop, they are not displayed
They probably are not text channel then. They may look like it but it could be something like announcement channel
nope it's a text channel, the StringSelectMenu displays it correctly, but the ChannelSelectMenu does not. I also noticed that all bots using ChannelSelectMenu are unable to display everything
How does string select display correctly? It just displays whatever you provide. Other type of select menus are autopopulating. If they are not showing the channels, then idk it maybe permissions thing perhaps. Idk if user's permission affects what is shown in the menu. It probably would if I had to guess
the string select works because we provide the options manually, while channel select auto-populates
See my other point. It maybe due to that too.
Yep it depends on user's permission, but I have the crown with the highest role, and my bot has the highest role too
Then I have no idea, sorry.
Also, can you show your code. And how you are looking for that channel in the menu?
Maybe that can clear something perhaps
Yep, here's the code:
container.addActionRowComponents(row =>
row.setComponents(
new ChannelSelectMenuBuilder()
.setCustomId("logsChannel")
.setPlaceholder("Select a channel.")
.addChannelTypes(ChannelType.GuildText)
)
);
and certified bots using the same thing have the problem too
At this point this is not d.js issue. You can try in ddevs
I don't think discord even filters it
Based on their documentation they do not
"Options are automatically populated based on available channels in the server and can be filtered by channel types"
Am I doing something wrong? Im using Events.ClientReady to listen to ready events and the value of the enum is updated to clientReady
Update. Can't send it with raw data. This error comes:
DiscordAPIError[50035]: Invalid Form Body
data.components[0].component[UNION_TYPE_CHOICES]: Value of field "type" must be one of (3, 4, 5, 6, 7, 8, 19).
-# What ever 19 is lol
Because it's a text input (which has type 10)
Blame Discord
For not updating their docs? I will do that.
Not updating their code
Unless they changed it to 19?
idk haha
Try type 19 and see what error it gives you
but this error above originates from djs, not discord
give me a second
d.js just formats the error
DiscordAPIError is otherwise an error directly from Discord API
okay 👍
bruh
DiscordAPIError[50035]: Invalid Form Body
data.components[0].component[STAFF_REQUIRED]: The Maze isn't meant for you.
I guess I'll go over to DDevs 😂
my bad, I tried to use a text display inside a label, but in modals its only allowed as a top-level component,
Now it works
good job :)
_Now I'm waiting patiently for djs to get support for the interaction responses for that 👀 If I had the knowledge I would help, but that's too much for me 😅 _
Hi, i'm sorry if this was answered again and again but I read through a few messages and I'm still wondering which is best.
I'm trying to log the ban/unban event (and later on, other events) and rn what I do is listen to the Events.GuildBan(Add|Remove) event then fetch the log for the executor. Would it be best to just listen to the AuditLog event create?
I don't know which is best and recommended and I struggle finding any information. What are the pros, what are the cons, etc. of one another?
you can log through audit log event create to avoid too many api requests
but problem with audit logs are they dont always create new entries but stack upon each other if the executor is the same user
Does every AuditLogCreate triggered gets the same informations as the event equivalent?
so they arent 100% accurate
no, another reason why they arent accurate cuz they dont contain a lot of info. but with unban and ban they contain the user id of the one unbanned or banned
Well rn my only issue is the fact that the guildBan event doesn't contain the ban reason nor the executor for some reason. That's why I'm trying to fetch the auditLog
that's an issue. I see thank you. So basically, it depends on the event and what gets saved
yh ban event doesnt emit reason youll have to get through audit log
yes overall user related audit logs are easy to get right
Thank you very much for the answers!
how can i add this line inside an embed?
If you want the text only in an embed you can do this:
const embed = new EmbedBuilder().setTitle("your text");
await channel.send({ embeds: [embed] });
Otherwise you can check the EmbedBuilder data ig to custom the embed further
documentation suggestion for @frozen sonnet:
EmbedBuilder discord.js@14.22.1
Represents an embed builder.
that's not what iam asking, i just saw the OwO bot use these line in it's embeds and i wanted to know how to use them myself
You pass an array of one of the types listed there
What exactly is it you want to do? That determines how you should use it
This is the new Components V2 and the use of separators
That's what iam looking for, Thanks for the help!
idk..i am too confused
can you pass content in deferReply?
interaction.deferReply({ content: 'test' })
No, only flags, and only ephemeral flag at that
ty
If you want content then just reply. Not defer
yh ik but i was wondering if defer supported that since defer doesnt show (edited)
So you wanted to edit without editing... that's not possible indeed
doesnt deferreply technically edit the message since it first defers?
Do you know what the word "defer" means?
deferReply() defers the reply, editReply() edits the reply
yh ik just nvm then
is there a way to center a button inside a section?
Is there information on when the label component text input change is being released?
We don't do ETAs
Okay
Popular Topics: Display Components
read more
Same way you would with anything else. Components V2 is just message data
well your text display has no content
how does it have no content? you just didn't set anything
If you're using some other library...we can't gaurentee it will work. I don't know how discobase formats message data...or if it works with djs
also you misspelled separator in your imports but there's no issue with that since you're not using them
client.on('messageCreate', async (message) => {
if (message.content === 'ping') {
const section1 = new SectionBuilder()
.addComponents(
new TextDisplayBuilder().setContent(`__** — hello....**__`)
)
.setThumbnailAccessory(
new ThumbnailBuilder({
media: {
url: 'https://media.discordapp.net/attachments/1260967890426003497/1270708616101494856/main_logo.gif'
}
})
);
const section2 = new SectionBuilder()
.addComponents(new TextDisplayBuilder().setContent('اختر القناة:'))
.setAccessory(
new ChannelSelectMenuBuilder()
.setCustomId('channel-select')
.setPlaceholder('اختر القناة...')
);
const section3 = new SectionBuilder()
.setAccessory(
new RoleSelectMenuBuilder()
.setCustomId('role-select')
.setPlaceholder('role...')
);
const container = new ContainerBuilder().addComponents([
section1,
section2,
section3,
]);
await message.channel.send({
flags: MessageFlags.IsComponentsV2,
components: [container],
});
}
});```
this error :
node:events:486
throw er; // Unhandled 'error' event
^
TypeError: (intermediate value).addComponents is not a function
at Client.<anonymous> (C:\Users\\Downloads\qwqw\indexv2.js:34:8)
at Client.emit (node:events:508:28)
at MessageCreateAction.handle (C:\Users\\Downloads\qwqw\node_modules\discord.js\src\client\actions\MessageCreate.js:32:14)
at module.exports [as MESSAGE_CREATE] (C:\Users\\Downloads\qwqw\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\\Downloads\qwqw\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketManager.<anonymous> (C:\Users\\Downloads\qwqw\node_modules\discord.js\src\client\websocket\WebSocketManager.js:236:12)
at WebSocketManager.emit (C:\Users\\Downloads\qwqw\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
at WebSocketShard.<anonymous> (C:\Users\\Downloads\qwqw\node_modules\@discordjs\ws\dist\index.js:1190:51)
at WebSocketShard.emit (C:\Users\\Downloads\qwqw\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
at WebSocketShard.onMessage (C:\Users\
\Downloads\qwqw\node_modules\@discordjs\ws\dist\index.js:1007:14)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:391:10)
at process.processTicksAndRejections (node:internal/process/task_queues:92:21)
Node.js v24.7.0```'
it's true, that doesn't exist
consider using <ContainerBuilder>.addSectionComponents() instead
documentation suggestion for @wide light:
ContainerBuilder#addSectionComponents() discord.js@14.22.1
Adds section components to this container.
let me see
<SectionBuilder>.addComponents() does not exist
SectionBuilder#addTextDisplayComponents() discord.js@14.22.1
Adds text display components to this section.
You also can't have a Section without a TextDisplay component, so section3 is invalid
i Trayed but its the same , if ur free could u type it for me please?
no, im not going to do it for you...but i can link the guide
Popular Topics: Display Components
read more
Is there any way to fetch user's serverTag like for example mine is r/BD ? From any events or data?
User#primaryGuild discord.js@14.22.1
The primary guild of the user
Hey there, I just joined the server. Is the modals update already out?
No
Hello, <MessageType>.interaction.commandName is deprecated, but when I replace by MessageInteractionMetadata I don't find commandName, it's not available anymore?
oh okay thanks
Why is the Voice Connections still zero? My code : ```js
async function getDetailedBotStats(client) {
const stats = {
guilds: client.guilds.cache.size,
users: client.users.cache.size,
channels: client.channels.cache.size,
commands: client.commands ? client.commands.size : 0,
emojis: client.emojis.cache.size,
wsPing: client.ws?.ping ?? null,
readyAt: client.readyAt,
cachedUsers: client.users.cache.filter((user) => !user.bot).size,
cachedBots: client.users.cache.filter((user) => user.bot).size,
};
try {
stats.voiceConnections = client.voice?.connections?.size || 0;
} catch {
stats.voiceConnections = 0;
}
return stats;
}
I don’t see where voice.connections exists
Adapters also returns 404 https://discord.js.org/docs/packages/discord.js/14.22.1/ClientVoiceManager:Class
I have no idea how you’d get the connections size tbh amgelo was typing maybe they know
yeah it's an internal object
but they just want the size so
I ask gpt how to code it and he give that, I thought that'll work
I mean that’s why chatgpt isn’t the best as it’s not trained on the latest stuff
And how would that work?
Probs just .adapters.size
yeah, adapters is a map
Why was it renamed then from connections to adapters, isn’t connections a bit more intuitive
well they're adapters so it's more accurate
alright alright
I try to console adapters and it show Map(0) {}, why it says like that?
And I've tried this, but it still says 0
prob worth asking in #998942774994927646
Oh I think it's because Riffy. I made the bot join the voice with Riffy not @discordjs/voice
Yeah it now count perfectly
im unable to register/update slash commands in my testing guild, it usually works fine but today it just won't load sometimes, no code changes (i've tried to run the code that was working fine last week too), is anyone else encountering this issue?
what happens when you run the deploy script
i tried to skim everything, am i reading at modal components are still not fully implemented, and while you can manually trigger sending a modal with the new stuff, we cant receive the data properly yet?
Correct
Is this "file drop" a real component that actually exists?
Ask ddevs tbh
it isn't
wow what a scam
why would they design that image with a mouse dragging the file 💀
maybe a future component?
but yeah it's very missleading now that you mention it lol
My thoughts is it was just a stylized "download" but ya is indeed misleading to a drag/droppable component
Whats the difference between "ID" and "CustomID" on comp v2 buttons? I remember working with the original components you just used customID to identify which button it was and there was no ID field
it doesn't make much sense for interactive components but it does for non interactive ones
those don't have a customId
and the purpose of the id is basically the same as the customId
so it's just if you'll never use the customID for interaction?
(i.e. I don't need to worry about it?)
treat it as a customId that every component can hold
since only interactive components have customIds
but with cv2 not every component is interactive
alright thank you
if you want you can ignore it, discord auto generates it for you
also, speaking of buttons, what type of SKU's are valid here? (this might just be a question of what type of purchases are currently valid on discord)
Overview: Monetizing Your Discord App - Types of SKUs
read more
d.js does not have support for anything besides text inputs in modals yet
And to add to this, unlike other "unsupported features" for DJS...this one you can't just bypass by sending the request yourself
Because DJS will be unable to receive the interactionCreate event for the modal data so you won't actually be able to use the modal
ok i got you thanks for your help

Is there any way to make an emoji appear full sized in a container with other text components there too? I tried putting the emoji in it's own text display component but it still shrinks to the size it would if it had text around it
No
The only case where emoji gets bigger is when it's alone (or with other emotes, up to a limit) in a message as a whole
Understood, I guess best workaround is just to put a # behind it
thank you! 
does anyone have a working command handler
@subtle swan the deployment script from the guide 100% works...what is the console output you're getting after running it?
And are you deplying to a guild or globally?
none
Ok...so that's not an issue of the script then
Can you paste your code?
Where's the imports?
at the top
const { REST, AuditLogEvent, Routes, Client, GatewayIntentBits, Collection, ActionRowBuilder, ButtonBuilder, Partials, ButtonStyle, EmbedBuilder, Events, ChannelType } = require('discord.js');
const { config } = require('dotenv');
const fs = require('fs');
const path = require('path');
const { messages, cooldown, prefix, ownerID, eventPrize, minLength } = require('./config.json');
config();
const settings = require('./config.json');
const GUILD_ID = '1268262061364740207'; // your guild id
const CLIENT_ID = '1280854361081249802'
const bot = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildBans
],
partials: [Partials.Channel],
partials: [Partials.GuildMember]
});
Oh well ya. That script is designed to be run standalone, not part of your index.js
oh
Deploying your commands on startup is bad practice, especially during development
oh
That script is designed to be run manually whenever you make changes to your commands, because you rarely need to do so and it avoids the 24 hour rate limit if you hit it
ohh is that why my commands randomly stopped loading?
Slash commands only need to be registered once, and updated when the definition (description, options etc) is changed. As there is a daily limit on command creations, it's not necessary nor desirable to connect a whole client to the gateway or do this on every ready event. As such, a standalone script using the lighter REST manager is preferred.
This script is intended to be run separately, only when you need to make changes to your slash command definitions - you're free to modify parts such as the execute function as much as you like without redeployment.
Ya you've probably hit the rate limit. If you've been restarting your application many times recently, then that would happen
client.on('messageCreate', async message => {
if (message.content.toLowerCase() !== '!components') return;
const components = [
new ContainerBuilder()
.setAccentColor(0xFF0000)
.addSectionComponents(
new SectionBuilder()
.setThumbnailAccessory(
new ThumbnailBuilder()
.setURL("")
)
.addTextDisplayComponents(
new TextDisplayBuilder().setContent("Example components:"),
),
)
.addActionRowComponents(
new ActionRowBuilder()
.addComponents(
new StringSelectMenuBuilder()
.setCustomId("")
.setMaxValues(2)
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel("Test selection")
.setValue("")
.setDescription("test")
.setDefault(true)
.setEmoji({
name: "😜",
}),
new StringSelectMenuOptionBuilder()
.setLabel("qqwqw")
.setValue(""),
),
),
),
new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setLabel("Button")
.setCustomId(""),
),
];
await message.channel.send({ components });
});```
node:events:486
throw er;
DiscordAPIError[50035]: Invalid Form Body
components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
at handleErrors (C:\Users\\Downloads\bott\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\\Downloads\bott\node_modules\@discordjs\rest\dist\index.js:1163:23)
at async SequentialHandler.queueRequest (C:\Users\\Downloads\bott\node_modules\@discordjs\rest\dist\index.js:994:14)
at async _REST.request (C:\Users\\Downloads\bott\node_modules\@discordjs\rest\dist\index.js:1307:22)
at async TextChannel.send (C:\Users\\Downloads\bott\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:195:15)
at async Client.<anonymous> (C:\Users\\Downloads\bott\bot.js:63:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:391:10)
at process.processTicksAndRejections (node:internal/process/task_queues:92:21) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: [
{
type: 17,
accent_color: 16711680,
components: [ [Object], [Object] ]
},
{ type: 1, components: [ [Object] ] }
],
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: 'Invalid Form Body',
code: 50035,
errors: {
components: { '0': { _errors: [ [Object] ] } }
}
},```
you have empty url in your thumbnailbuilder and empty values in your button and menu
const components = [
new ContainerBuilder()
.setAccentColor(0xFF0000) // Optional: Set an accent color
.addSectionComponents(
new SectionBuilder()
.setThumbnailAccessory(
new ThumbnailBuilder()
.setURL("https://media.discordapp.net/attachments/1260967890426003497/1270708616101494856/main_logo.gif?ex=68c6aa1e&is=68c5589e&hm=72c85c5bddf0cd339873659dd77a7b37b1e4b1d08cce16931303787a0fe336d8&=&width=288&height=288")
)
.addTextDisplayComponents(
new TextDisplayBuilder().setContent("Example components:"),
),
)
.addActionRowComponents(
new ActionRowBuilder()
.addComponents(
new StringSelectMenuBuilder()
.setCustomId("99fca274f90a4070beb7086fdf335bfc")
.setMaxValues(2)
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel("Test selection")
.setValue("1")
.setDescription("test")
.setDefault(true)
.setEmoji({
name: "😜",
}),
new StringSelectMenuOptionBuilder()
.setLabel("qqwqw")
.setValue("1"),
),
),
),
new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setLabel("Button")
.setCustomId("11"),
),
];```
this
this is the main one
U need to set v2 flag
How ?
The ephemeral option when replying to an interaction will be removed in v15
- {..., ephemeral: true}
+ {..., flags: MessageFlags.Ephemeral}
``` Read [here](<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR>) on how to specify multiple flags
Same thing, except the flag should be IsComponentV2
await message.channel.send({
flags: MessageFlags.Ephemeral,
components: components,
content: "Here are some example components for your Discord bot!"
});
no
change .Ephemeral to IsComponentsV2
yes yes its works , thx for it
what does this mean and what can be done
and more importantly, what does it have to do with djs 
that's an issue with your npm installation
and it also links an article you can check
its first time installing after learnng js
but npm isn't made by djs
this channel is for djs help
alr
what are the intents I need to define so I can use slash commands in a group chat/dm? can use them fine in guilds and in the bots dms, but not outside of that
intents mandate what events and data from those events you receive
not how your bot can be used
you're most likely missing the appropriate contexts and integration types for those commands
SlashCommandBuilder#setContexts() discord.js@14.22.1
Sets the contexts of this command.
SlashCommandBuilder#setIntegrationTypes() discord.js@14.22.1
Sets the integration types of this command.
thank you!!
help
please look at #how-to-get-help
okie!
Hello. How to run a bot?
Where can I read an instruction?
Home: What's new
read more
This is the guide for getting started with d.js, if that's what you need ^
Yes, thank you very much. In Russia, Discord hasn't worked for over a year, now it's working, I've returned to my page, to my bots, but I've forgotten in a year how I created them, programmed them and entered them online. That's why I asked for a link to the guide to repeat and practice.
it just won't load the commands. there is an await so the scipt just gets stuck there
sounds like you've been ratelimited because of deploying too many times
are you running the script on every start? that's a common cause
yeah, is there another way to update che commands?
well, deploying only when you change them
manually
that's why it's supposed to be on a separate script
so you run it manually
oh ok, i thought it wouldn't be much of a problem if i only loaded them in a guild, thanks
it's pretty much the amount of requests you do, not to where you're deploying
got it, still odd i never got this issue before tho
im getting this error and idk how to solve it anyone know what does this mean
❌ Errore nel deploy: DiscordAPIError[10002]: Unknown Application
at handleErrors (C:\Users\detto\Desktop\Foxnet Discord Bot\node_modules\@discordjs\rest\dist\index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\detto\Desktop\Foxnet Discord Bot\node_modules\@discordjs\rest\dist\index.js:1163:23)
at async SequentialHandler.queueRequest (C:\Users\detto\Desktop\Foxnet Discord Bot\node_modules\@discordjs\rest\dist\index.js:994:14)
at async _REST.request (C:\Users\detto\Desktop\Foxnet Discord Bot\node_modules\@discordjs\rest\dist\index.js:1307:22) {
requestBody: { files: undefined, json: [ [Object] ] },
rawError: { message: 'Unknown Application', code: 10002 },
code: 10002,
status: 404,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1416020164822175700/guilds/1412456143460237600/commands'
}
✅ Evento caricato: clientReady
🔄 Deploy di 0 comandi...
❌ Errore nel deploy dei comandi: DiscordAPIError[10002]: Unknown Application
at handleErrors (C:\Users\detto\Desktop\Foxnet Discord Bot\node_modules\@discordjs\rest\dist\index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\detto\Desktop\Foxnet Discord Bot\node_modules\@discordjs\rest\dist\index.js:1163:23)
at async SequentialHandler.queueRequest (C:\Users\detto\Desktop\Foxnet Discord Bot\node_modules\@discordjs\rest\dist\index.js:994:14)
at async _REST.request (C:\Users\detto\Desktop\Foxnet Discord Bot\node_modules\@discordjs\rest\dist\index.js:1307:22) {
requestBody: { files: undefined, json: [] },
rawError: { message: 'Unknown Application', code: 10002 },
code: 10002,
status: 404,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1416020164822175700/guilds/1412456143460237600/commands'
}
Ids are strings
you didn't deploy that much before then
and don't deploy on every start
im not doing that , thats the problem i deployed 1 time and the commands still didnt register
I mean your log says you're also loading a clientReady event
a deploy script doesn't do that
and Jira already told you the issue
i think i got it
im using yaml for store tokens and the rest of things
right, make sure it's a yaml string and not a number
like Jira said
and don't deploy on start to avoid future issues, like the one the guy above your question has
import * as fs from "fs-extra";
import * as yaml from "js-yaml";
import * as path from "path";
export class Config {
public data: { Token: string ,
GuildId: string ,
ClientId: string
};
private configDir = path.join(__dirname, "..", "Config");
private configFile = path.join(this.configDir, "config.yaml");
constructor() {
if (!fs.existsSync(this.configDir)) {
fs.mkdirSync(this.configDir);
}
if (!fs.existsSync(this.configFile)) {
this.data = {
Token: "Token Here",
GuildId: "Guild ID Here" ,
ClientId: "Client ID Here",
};
const yamlStr = yaml.dump(this.data);
fs.writeFileSync(this.configFile, yamlStr, "utf8");
} else {
const fileContent = fs.readFileSync(this.configFile, "utf8");
this.data = yaml.load(fileContent) as { Token: string , GuildId: string , ClientId: string};
}
}
}
``` this is my config loader idk if the problem is how the yaml is made or its the config loader passing wrong types
well how does the file look like
specifically the application and guild ids
GuildId: 1412456143460237486
ClientId: 1279825611526770688
i taked the token away
then you're saving them as numbers
not strings
wrap in "" or ''
i feel rlly dumb , ty i resolved
now it doesnt give errors anymore but the commands still arent on the server
this.guilds.fetch / guild.roles.fetch
I had cache.get and fetch, but they both throw errors, what can I use that will work on every request with no limit?
const guild = this.guilds.fetch("XXXX");
const role = guild.roles.fetch("XXXX")
const guild = this.guilds.cache.get("XXXX");
const role = guild.roles.cache.get("XXXX")
all of these throw:
TypeError: Cannot read properties of undefined (reading 'fetch')
- fetch returns a promise, you're not awaiting them
- you need the Guilds intent for guilds and roles to be cached
you'd also need to provide context as to what "this.guilds" is
const guild = await this.guilds.fetch("418801915162263574").catch(() => null);
if (!guild) return console.log("❌");
const role = await guild.roles.fetch("1416513979592999032").catch(() => null);
if (!role) return console.log("❌");
I have guilds intent
this.guilds is like client.guilds -its just when I created the client..
member.roles.add("1416513979592999032")
like this for example, will it work the same?
if I just add it, and its a valid ID ofc
yes, that works as well
but I'd look into why you're having this issue in the first place, it's not normal behavior
GuildMemberManager#addRole() discord.js@14.22.1
Adds a role to a member.
yes, thse usually worked so thats why I asked maybe new limit or som'
but as long as this role is constant and doesn't change, then I dont see a problem using straightup the ID
the only limit is for the message cache
unless you provide your own limits, ofc
well if that doesn't work, who knows what other thing doesn't as well
hello
im new to javascript
no i just came to chat
#archive-offtopic then, this is a help channel
ok thx
Worker threads are slightly more efficient as they have lower memory usage and dont need to rely on IPC for shard communication
If youre just starting sharding its unlikely you need to rely on process isolation
what stuff
only for when you actually need to communicate with other shards for some reason
no not usually
Unless its from the cache of a different guild on a different shard
sure
are yoiu at a guild count where you need to shard at all>
so youre already sharding?
Well no, using internal sharding is generally less scalable
It "works" but that doesnt make it the best option
Simple doesnt make it good
This will be less scalable if you intend to keep growing Im pretty sure
Im not a sharding expert though so Im not entirely certain
no, i dont know
Here are my slash-commands: const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);
for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.warn(`WARNING: The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
// Обработка команд
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
});
// Логин бота
client.login(token);
- please, look at them, do you think they are correct or not? How can I run them?
I use Java script for these commands, but I don't know they are correct or not and how to make them running.
Please, help me run slash commands in my bot.
are you just asking if it's correct?
or do you have an error?
throw new Error(`No compatible encryption modes. Available include: ${options.join(", ")}`); ^ Error: No compatible encryption modes. Available include: aead_aes256_gcm_rtpsize, aead_xchacha20_poly1305_rtpsize, xsalsa20_poly1305_lite_rtpsize
What is Error I'm Suddenly Getting Out Of An Completely Stable Running Bot
probably because of DAVE, but I don't know how that works, ask in #998942774994927646 so it doesn't get lost
Update your /voice
This means your bot is successfully joining the voice channel, but it can't find any common encryption modes between what the Discord voice server offers and what your audio stack can handle.
npm i @discordjs/voice@latest
-S?
Sorry..
prism-media?
Where did you pull that from
I modified it, I had put too much
From ai?
Please don't
No, I copied my 3 lines.
Thanks It Fixed
Hi! The Checkbox and boolean component will work in Modal? IN this latest version?
No
that's not a thing in discord
that's an edited image
"Wanted Features for Modals"
Yes, discussion about wanted features
not "Current Features for Modals"
So, will they implement this in future? Any idea?
No
ask discord
maybe they will, maybe they won't
the only thing they added recently was select menus and text displays for modals
I think discord forget about this discussions.
not really
doesn't mean it's high priority or anything though
Ok, does the StringSelect work in discord js now? I mean did discord js updated to the modal?
not yet, that's still a WIP
-# 👍
you can follow that pr in the meantime
yo
can i redirect to a page from a discord bot as a backend to a frontend website
because im just getting 404 not found from thjis code:
FRONTEND:
document.getElementById("connectBtn").addEventListener("click", () => {
const clientId = "1239372532511932458"; // your Discord app client ID
const redirectUri = encodeURIComponent("https://crsl.page.gd/api/auth/discord/redirect");
const scope = encodeURIComponent("identify email");
const responseType = "code";
const oauthUrl = `https://discord.com/oauth2/authorize?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=${responseType}&scope=${scope}`;
window.location.href = oauthUrl;
});
discord.js does not support oauth2, sorry
bruh what
I'm not sure what support you're expecting here since you're not using djs at all
i never sent that portion
// ----------------- OAUTH CALLBACK -----------------
app.get("/api/auth/discord/redirect", async (req, res) => {
const { code } = req.query;
if (!code) return res.status(400).send("Missing code");
try {
const formData = new url.URLSearchParams({
client_id: process.env.ClientID,
client_secret: process.env.ClientSecret,
grant_type: "authorization_code",
code: code.toString(),
redirect_uri: "https://crsl.page.gd/api/auth/discord/redirect",
});
const output = await axios.post(
"https://discord.com/api/v10/oauth2/token",
formData.toString(),
{ headers: { "Content-Type": "application/x-www-form-urlencoded" } }
);
const access = output.data.access_token;
const userinfo = await axios.get("https://discord.com/api/v10/users/@me", {
headers: { Authorization: `Bearer ${access}` },
});
const discordId = userinfo.data.id;
const username = userinfo.data.global_name || userinfo.data.username;
const existingUser = await ConnectedUser.findOne({ discordId });
if (existingUser) {
return res.redirect("https://crsl.page.gd/?error=already_connected");
}
const newUser = new ConnectedUser({ discordId, username });
await newUser.save();
console.log(`✅ Saved new user: ${username}`);
try {
const user = await bot.users.fetch(discordId);
await user.send(":white_check_mark: Thanks for connecting your account!");
} catch (err) {
console.error("DM failed:", err.message);
}
// :red_circle: Here is where you redirect to your main page
console.log("BACON EGG AND CHEES");
res.redirect("https://crsl.page.gd/success.html");
} catch (err) {
console.error(err.response?.data || err);
res.status(500).send("OAuth failed");
}
});
well djs doesn't support the oauth workflow
my response is the same regardless
whatchu mean
djs doesn’t support oauth
I don't understand
we cannot help you
oauth is literally part of discord, why can't you help
discord, not discord.js
this server is for discord.js
does it really matter?
yes, it does
we are not discord
why, I can't seem to get help anywhere else
because we can’t help with something we don’t support
Did you try ddevs server?
the only place where you're using djs is on
const user = await bot.users.fetch(discordId);
await user.send(":white_check_mark: Thanks for connecting your account!");
so unless that's where you need help and all the other code was sent for no reason, you're in the wrong place
never heard of em
How do I put an actionRow inside an embed?
you can't
you can only put them inside containers, which aren't embeds but they look like them
guide suggestion for @unique rivet:
Popular Topics: Display Components
read more
This would be?
yes, that's a container
if you're using a ContainerBuilder you can use the addActionRowComponents method to add an action row
ContainerBuilder#addActionRowComponents() discord.js@14.22.1
Adds action row components to this container.
According to what I used the container
What I want is that colored line
ContainerBuilder#setAccentColor() discord.js@14.22.1
Sets the accent color of this container.
use that
You should check the docs for the available methods
Sorry I saw it late, I'm not someone who experiments.
Why is my bot not updating
I added a command in a bot but I wanted to switch to another token (nw bot) so in the .env file i changed BOT_ID and TOKEN still not working
show your code and logs
register-commands.js
const { REST, Routes } = require('discord.js');
require('dotenv').config();
const commands = [
{
name: 'hi',
description: 'You send Hi, I send Hi back',
},
];
const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);
(async () => {
try {
console.log('Refreshing application (/) commands...');
await rest.put(
Routes.applicationGuildCommands(process.env.BOT_ID, process.env.GUILD_ID),
{ body: commands }
);
console.log('Slash commands were registered (/)!');
} catch (error) {
console.error(`There was an error: ${error}`);
}
});
index.js
require('dotenv').config();
const { Client, IntentsBitField } = require('discord.js');
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildPresences,
],
});
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}! The Bot is online on Discord.`);
});
client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === 'hi') {
await interaction.reply("Hi, I'm Dank Syndicate server's official bot. At your service. 🫡");
}
});
client.login(process.env.TOKEN);
logs>
C:\Users---\Desktop\Discord Bot>nodemon
[nodemon] 3.1.10
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: js,mjs,cjs,json
[nodemon] starting node src/index.js
[dotenv@17.2.2] injecting env (3) from .env -- tip: 🛠️ run anywhere with dotenvx run -- yourcommand
Logged in as Dank Syndicate Beta#1185! The Bot is online on Discord.
(node:11984) DeprecationWarning: The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead.
(Use node --trace-deprecation ... to show where the warning was created)
in old bot the command was working properly
you're not deploying the command though
you're running your index.js which starts the bot
you need to run your register-commands.js instead
alr let me try
Thanks
Can Modal have a pre filled values? Instead of just placeholder?
Select menus in Modals are coming to d.js soon
Or you mean pre-filled value in text input?
No, I mean pre filled values.
Yah!
Pretty sure you just call setValue
TextInputBuilder#setValue() builders@1.11.2
Sets the value for this text input.
-# 👍
anyone got a link to component v2 page :3
from the guidfe
Popular Topics: Display Components
read more
How to fetch channels by parent id ?
on the assumption you have the Guilds intent, you can get the parent channel by id with <Client/Guild>.channels.cache.get(<parentId>)
on the assumption you were referring to a category specifically, you can then access <CategoryChannel>.children.cache
if you meant threads in a text channel, then you can use <TextChannel>.threads.fetch()
tsym!
Hi! Can we set any desc for the model textbuilder? Is there any method? Because i see it in discord dev guide
Which of these methods is best for me to add options? Or does it matter?
The 2nd is much more readable
the only description I see on the page you linked is for label components which djs does not yet support
if that's what you were looking for and you like following prs, here's the relevant pr https://github.com/discordjs/discord.js/pull/11090
With the map?
-# 👍
To do, if you click on the Modal, is it an Interactioncreate or messagecreate if i want it to generate a new channel privately?
INTERACTION_CREATE and MESSAGE_CREATE are gateway events, and submitting a modal fires an INTERACTION_CREATE event as that’s an interaction
MESSAGE_CREATE event only fires when a message is sent anywhere the bot has access to
Are the new modal components already available in discord.js?
no
you should’ve seen a post in the #announcements channel if it was
kk, thanks
How to upload an emoji to app?
Why is interaction.channel null in a DM text channel?
Because DM channel are uncached
client.application.emojis.create
Thanks monbrey
Ah thanks
hello, this may be a question thats been asked several times prob but does djs support the new modal update or not yet?
Not yet
alr thanks
hi no not yet :/
does djs support the profile set thing so you can change your banner, profile, and name, not username
ClientUser#setBanner() discord.js@14.22.1
Sets the banner of the logged in client.
// Set banner
client.user.setBanner('./banner.png')
.then(user => console.log(`New banner set!`))
.catch(console.error);
ClientApplication#edit() discord.js@14.22.1
Edits this application.
Dunno what you mean by name
its not possible to recreate the embed header in comp v2 right?
like if i want the user's pfp to appear on the corner
I'd like to add app-specific fields to Client (always launched via ShardingManager).
Should I use a class extending Client, use type augmentation or something else?
What's the recommended or best approach in your guys's opinion?
it's technically possible, but very unfeasible
to be most accurate, you'd need to create an emoji of the user's avatar
a more feasible but less accurate recreation would be to just put their avatar as a thumbnail in a section at the top
is creating an emoji of the user and then deleting it bad for performance
Like ram consumtpion and stuff
idk what it affects
I think you'd run into ratelimits really fast
^hence why I called it unfeasible
dangabit
Any ideas regarding this? 🥲 I've never needed to do this before
it's really up to you
the only real recommendation is to check the docs to ensure you're not accidentally overwriting an existing property
How would you do it if you had to? As for the overwriting thing I already checked
The fields are completely unrelated to anything the Client class already has
asking me personally?
I probably just wouldn't attach these things to the client
I thought it'd be a simple way to access my constants in my commands so I don't have to keep importing them each time, or even command cooldown timers
again, totally up to you
I believe we recommend both extending the client or type augmentation in regards to the commonly defined <Client>.commands
We highly recommend you extend the Client structure properly instead of just attaching custom properties like .commands to the regular discord.js Client instance.
- Using typescript, you might want to consider casting or augmenting the module type
er I suppose it just mentions casting instead of extending, but still totally your choice in design
I tried extending it and I ran into issues with <Client>.shard or user being possibly null and stuff like that so I guess it's time for me to learn a bit more about typescript. Thanks for the help ^^
I mean just those properties being possibly null is unrelated
I believe <Client>.shard is always possibly null given that there's no way for typescript to know whether you're sharding or not
<Client>.user is null when the client isn't ready
when accessing <Structure>.client in events (or the emitted param in the ready event) the client would be ready and <Client>.user would be typed appropriately