#djs-help-v14

78874 messages · Page 64 of 79

tiny blade

is it bannable?

loud quartz

this isn't a job board

coral maple

Can a separator be used inside the section?

unique shoal

No

A section is just for displaying up to 3 text displays next to an accessory

coral maple

ok thanks

what’s the default spacing size used in a separator 3?

abstract flint
    at handleErrors (D:\Data\Coding\Repositories\airmalpi-occ\node_modules\@discordjs\rest\dist\index.js:762:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async SequentialHandler.runRequest (D:\Data\Coding\Repositories\airmalpi-occ\node_modules\@discordjs\rest\dist\index.js:1163:23)
    at async SequentialHandler.queueRequest (D:\Data\Coding\Repositories\airmalpi-occ\node_modules\@discordjs\rest\dist\index.js:994:14)
    at async _REST.request (D:\Data\Coding\Repositories\airmalpi-occ\node_modules\@discordjs\rest\dist\index.js:1307:22)
    at async GuildMemberManager.edit (D:\Data\Coding\Repositories\airmalpi-occ\node_modules\discord.js\src\managers\GuildMemberManager.js:428:15)
    at async Object.execute (file:///D:/Data/Coding/Repositories/airmalpi-occ/commands/admin/gp.js:111:17)
    at async Module.execute (file:///D:/Data/Coding/Repositories/airmalpi-occ/events/interactionCreate.js:12:13) {
  requestBody: { files: undefined, json: { nick: '| FlySnivy' } },
  rawError: { message: 'Missing Permissions', code: 50013 },
  code: 50013,
  status: 403,
  method: 'PATCH',
  url: 'https://discord.com/api/v10/guilds/1157019563066671154/members/468117897697427466'
}```

Missing permissions? The bot is administrator and the role is above all roles. Can somebody give me an hint on how to solve this?
sharp ginkgoBOT
  • Bots cannot moderate (kick/ban/nickname/...) a target with a higher or equally high highest role or the guild owner.
  • Bots cannot modify (edit/add/remove) roles that are higher or equally high compared to the bot's highest role.
  • The Administrator permission does not skip these checks.
tiny blade

i needddd helpppp

steel trail

I assume you're the owner of that guild

steel trail
tiny blade

my api latency is 100ms but db is literally 5000+, what can be wrong? its supabase backend

steel trail
naive hull

Can someone help me with a site where i can learn js fast and free?

More likely bots js

tardy sable
naive hull

Can someone recommend me a site where i can make my own website and run it for free?

unique shoal

No we can't

naive hull

🗿

civic jungle

how to check if interaction.member is a GuildMember?

i tried this

interaction.member instanceof GuildMember```

but my IDE is complaining
halcyon bison
civic jungle

when would that be false?

halcyon bison

If you don't have the Guilds intent, in guilds where the app was installed without the bot scope, and dms

civic jungle

ok, thx

stark adder

heya i have a question that might seem stupid:
``await interaction.followUp({ content: '<@&1271383474326212699>', embeds: [embed], components: [component] });`
but this does not notify people with said role,
even though i see the role getting mentioned,
is there a logical reason for?
or is it a bug?

sharp ginkgoBOT

tag suggestion for @stark adder:
You can control which entities receive notifications via the allowedMentions option. You can:

{ ..., allowedMentions: { parse: ["users", "roles"] } }
ruby bane

by default, interactions only include "users"

stark adder

ah okay,
seems like something that wasn't needed in the past (12 and/or 13),
TY will look into it

tiny blade

in giveaway systems, do we need a realtime listener to db?

civic jungle

what would be the right way to define a type for slash command builder return type?

Right now i have

export interface SlashCommand {
  command: SlashCommandBuilder;
  run(interaction: ChatInputCommandInteraction): Promise<void>;
}

but it doesn't serve me well

sharp ginkgoBOT
wary coral
tiny blade

i have a questionnnnn, how do big bots handle giveaways? like they pool after every 10s to check for active gwys and draws the winner? isnt it is very heavy load?

limpid matrix

How many select menus can my message have? I currently have one for selecting a staff role which works but the second one for a specific channels just failed silently: "The Application did not respond". I use multiple action rows

wary coral
civic jungle
tiny blade

someone gonna reply me

limpid matrix
rose tangle
tiny blade
rose tangle
tiny blade
rose tangle
limpid matrix Same message

then what's erroring? if they're both in the same message it's not possible for one to show up and the second to error due to too many action rows

if that happened then none would show at all

limpid matrix
rose tangle
civic jungle

you can have a union of SubcommandsOnly and OptionsOnly or make it be the return type of #build() and just call build on all your commands

rose tangle

you don't have to adhere to a specific one

cobalt plover
civic jungle

well here's how i typed it:

export type botCommand<T extends SlashCommandBuilder | SlashCommandSubcommandBuilder> = {
    data: T;
    dev?: boolean;
    highRank?: boolean;

    execute(interaction: ChatInputCommandInteraction, ...args: any[]): Promise<void>;
    autocomplete?(interaction: AutocompleteInteraction): Promise<void>;
};
tiny blade
rose tangle
civic jungle
limpid matrix
rose tangle then it sounds like it's something on your collector or listener for that select...
export const chatInput: ChatInputCommand = async (ctx) => {
    await ctx.interaction.deferReply({ flags: MessageFlags.Ephemeral });

    const setupEmbed = new EmbedBuilder()
        .setColor(Colors.Green)
        .setTitle('Ticket Setup')
        .setDescription(
            'Hier richtest du das Ticket-System ein.\n*Nur 15 Minuten gültig.*'
        );

    await ctx.interaction.editReply({
        embeds: [setupEmbed],
        components: [(
            <ActionRow>
                <RoleSelectMenu
                    placeholder="Support-Rolle auswählen"
                    onSelect={onRoleSelect}
                />
            </ActionRow>
        ),

        (<ActionRow>
            <ChannelSelectMenu
                placeholder="Choose a channel"
                onSelect={onChannelSelect}
            />
        </ActionRow>),
        (<ActionRow>
            <Button onClick={onFinish}>
                Setup abschließen
            </Button>
        </ActionRow>)
        ]
    });
};

It doesnt even call the function

rose tangle
tiny blade

ok thanks

rose tangle
limpid matrix

I used commandkit.js i thought the components were from djs

rose tangle

check your imports and you'll see they're not coming from djs

well it's from command kit then

djs doesn't have that react-like syntax for components

limpid matrix
rose tangle

only builders for sending, like the EmbedBuilder you did there

sharp ginkgoBOT

guide suggestion for @limpid matrix:
guide Sending select menus
To send your select menu, create an action row and add the buttons as components. Then, send the row in the components property of InteractionReplyOptions (extends BaseMessageOptions). You can also send action rows inside containers or between other components, when using the display components system.

rose tangle

djs has building and replying in separate parts

limpid matrix
rose tangle

that's why you don't do new SlashCommandBuilder().setExecute() or something like that

rose tangle
limpid matrix
rose tangle

right, try not to ask for help if you don't want it anyways

velvet cipher
limpid matrix
velvet cipher
limpid matrix
zealous knot

Since .setLabel is deprecated, what's the new way of doing labels for text input builders? I can see there's a LabelBuilder class but I'm not sure how to use it

velvet cipher
tardy sable

chill out

tardy sable
zealous knot

Nevermind, the guide has a section covering it

tardy sable

you have to use inside a label

zealous knot

Technically it's not deprecated but will be, so might as well make the move

tardy sable

but i see you already have the guide so i guess you good to go?

zealous knot
civic jungle

im converting my bot from eris.js to discord.js

in eris i had to .acknowlege() an interaction if it takes some time to respond, do I have to do the same in discord.js?

rose tangle

yes, that's a dapi thing, not dependent on the library

in djs you'd defer

sharp ginkgoBOT

guide Deferred responses
As previously mentioned, Discord requires an acknowledgement from your bot within three seconds that the interaction was received. Otherwise, Discord considers the interaction to have failed and the token becomes invalid. But what if you have a command that performs a task which takes longer than three seconds before being able to reply? If you have a command that performs longer tasks, be sure to call deferReply() as early as possible. FAQ.

upper jay

Hi, I'm currently working on a ticket system for my private Discord bot, and I was wondering if it's possible to prevent the ticket creator from mentioning roles in the ticket channel.

I've already tried disabling the MentionEveryone permission, but that doesn't seem to work. Even with it disabled in the channel permissions, the ticket creator can still ping roles and users. Any idea what's going on?

sharp ginkgoBOT
steel trail

Do you mean this? That they can't add users by mentioning the role? Because there's a difference between being able to ping them or add them to a thread

upper jay

Oh no I'm not working with threads. I'm using regular text channels for the tickets. We've had issues in the past where users would just spam @ mentions after creating a ticket, which is pretty annoying. I was wondering if there's a way to prevent that?

steel trail

Sure, that would be the permission you mentioned already. Are you sure you denied it and there's no other overwrite that allows it again?

upper jay

Yes

Permission gets disabled just fine

Yet I can still mention roles and users (this is from the ticket creator's POV)

steel trail

You can't really deny them being able to mention users. You can moderate them when they do that though

upper jay

Oh

steel trail

Are the roles set to be able to be mentioned by everyone maybe?

upper jay

Yeah everyone can mention those roles, and that's fine in other channels. I just don't want them to be able to mention roles specifically in the ticket channels. I'm guessing that's not possible?

steel trail

Nope. But you can make your bot timeout anyone that does so they can't spam it

And ofc also setup automod mention-spam

upper jay

Ah that sucks. Oh well, I'll find a different way I guess

Appreciate the help!

velvet cipher

Maybe I'm missing something but won't the ticket channels only include the creator and the relevant staff members, so it doesn't matter if they can ping other people. Or do you also want to prevent them from pinging the staff?

upper jay

I want to prevent them from pinging anyone, but role mentions are the bigger concern. We have a "role timeout" system where a role becomes unmentionable for a certain duration after it's mentioned, to prevent spam. If users start pinging those roles in ticket channels, the role would become unmentionable, which could stop others from mentioning it when it’s actually needed. It’s a moderator role meant for emergencies, so that could be a problem.

I was hoping to solve that problem by disabling the ability to ping the moderator role in ticket channels, but I guess I’ll just make it so the role doesn’t become unmentionable if it’s mentioned in a ticket channel haha

steel trail
upper jay

Yeah I know, but the system has worked fine for a long time now. The timeout isn’t even that long, it’s only 10 minutes

steel trail

But it sounds easily abusable. If I can prevent other users from reporting me by doing more stuff that's spammy

upper jay

It's a bit hard to explain if you're not actually part of the community. We have our own way of reporting people. The mod role usually only gets pinged if there's a hacker or someone breaking the rules excessively in-game. It's a Discord for a FiveM server

sleek mural

Is there a way to track who moved channels or roles?

celest coral

Hi, how do I fetch messages in a channel before a specific timestamp? I found the MessageManager Class but the FetchMessagesOptions interface expects a message ID for the before attribute.

tardy sable
tardy sable
sharp ginkgoBOT

documentation suggestion for @celest coral:
discord API Reference - Snowflakes
Discord utilizes Twitter's snowflake format for uniquely identifiable descriptors (IDs). These IDs are guaranteed to be unique across all of Discord, except in some unique scenarios in which child objects share their parent's ID. Because Snowflake IDs are up to 64 bits in size (e.g. a uint64), they are always returned as strings in the HTTP API to prevent integer overflows in some languages. See Gateway ETF/JSON for more information regarding Gateway encoding.

wary coral
sleek mural
celest coral

Yep, but I surely cannot put a generated snowflake in the after field right? I guess you're suggesting the same as BakeWithMe. In that case i can just use createdTimestamp on the already fetched messages

velvet cipher
tardy sable
sharp ginkgoBOT
wary coral
celest coral
tardy sable

how would you extract the timestamp from the snowflake?

tardy sable

thanks

red coral

Can cv2 support multiple images in one media thingy? If so has anyone got an example of how it looks?

wary coral
red coral

Cheers

wintry laurel

the first line works for getting a fields "lable" or question right
and the second one gets the user answer

or wait both of those are the same arnt they

anyone know how to get the lable of a field then?

wary coral

they would both return the same value. What do you want the label component values?

you would have that info via knowing the modal the interaction came form

wintry laurel
wary coral

best way to deal with that is to encode it into the custom id

wintry laurel

ok thanks

tardy sable

or you can find in the interaction.fields.fields

wary coral

no? That does not contain information form the label component

tardy sable

Uh yh my bad last time i did this i thought i saw it in there. setting it inside customid is the way to go then

pearl hazel

is there an update with guildmemberadd event ?

rose tangle

about what?

are you having a specific issue?

pearl hazel

ig it's not trigger for all members that join the guild

is there any update for this event last month or nothing change

rose tangle

there's no breaking changes by djs without a major bump

at most maybe you could expect a few breaking changes from the api every once on a while but there hasn't been one for that event in particular

you should either always receive it or not at all if you don't have the intent

maybe it could break if you mess with the guilds cache

pearl hazel

idk i will check more

oh i find it
guild.fetchVanityData() take too much time to respone it may take 30m
why is that ?

pearl hazel
stable sun

You can make use of ClientOptions.rest.rejectOnRatelimit and make it error if the wait time is too long

sharp ginkgoBOT

propertysignature RESTOptions#rejectOnRateLimit discord.js@14.25.1
Determines how rate limiting and pre-emptive throttling should be handled. When an array of strings, each element is treated as a prefix for the request route (e.g. /channels to match any route starting with /channels such as /channels/:id/messages) for which to throw RateLimitErrors. All other request routes will be queued normally
Default value: null

stable sun

new Client({ rest: { rejectOnRateLimit: … }, … });

sharp ginkgoBOT
pearl hazel

thank u

polar karma
worthy sail

I keep on getting rate limits for my bot, i think it is based on channel permissions... but i don't have any clue how to fix it..

  url: 'https://discord.com/api/v10/channels/--------------/permissions/--------------',
  route: '/channels/:id/permissions/:id',```

My bot is growing faster than my knowledge 🤣

No body got any clue :(

velvet cipher

Well it's really hard to help with just that information. You'll need to show the code that's causing the rate limit or give some more details.

rose tangle

pretty much the only advise for ratelimits are to do less requests either way

cobalt plover

is it possible to make text input components with autocomplete?

rose tangle

you could share what feature you're building though, maybe there's a way that does less requests

cobalt plover

oh ok 🙁

coral maple

does component v2 work in dm?

tardy sable
coral maple
if (!interaction.guild) {
      if (interaction.isRepliable()) {
        return interaction.reply({
          flags: MessageFlags.Ephemeral,
          components: [
            new ContainerBuilder().addTextDisplayComponents(
              new TextDisplayBuilder().setContent("> I can’t run this command outside a server")
            ),
          ],
        });
      }
    }
velvet cipher

Flags should be an array and include the IsComponentsV2 flag

coral maple

oh lol my bad i forgot about it

cobalt plover

you can also use SlashCommandBuilder#setContexts to control where a command can be used

coral maple
wary coral

then you want to set the contexts of the command to

SlashCommandBuilder.setContexts(InteractionContextType.Guild)

this will prevent the command from being used in BotDMs

vagrant rampart
sharp ginkgoBOT

tag suggestion for @vagrant rampart:
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
coral maple

Should I check bot permissions per channel or at the guild level? I’m constantly hitting missing permission errors

wary coral

depends on what you are trying to do?

coral maple
wary coral

generally speaking, you should check the channel if you are sending a message

coral maple

ok

proper gorge

does anyone know why I have /test in place even though it's not in the source code? only /link, /stats

tardy sable

you probably register it as a guild command and didnt refresh on startup or vice versa

rose tangle
warm elk
    const username = i.fields.getTextInputValue('username');
    const files = i.fields.getUploadedFiles('files', true).toJSON();

    const response = new ContainerBuilder()
      .setAccentColor(0x0099ff)
      .addTextDisplayComponents(textDisplay => textDisplay.setContent(`Username: ${username}`))
      .addSeparatorComponents(separator => separator)
      .addFileComponents(files.map(f => new FileBuilder().setURL(f.url)));

    await i.reply({
      components: [response],
      files,
      flags: MessageFlags.IsComponentsV2
    });

Whats wrong with this?

tardy sable
sharp ginkgoBOT

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]
});
wary coral

Also attachment is for attachments to your message which you need to re-upload. You can't just attach the ephemeral attachment from the modal

candid osprey

Q1: To implement DAVE (e2ee) on discord.js/voice, do I only have to install @snazzah/davey: ^0.1.6 ?

Q2: where can I see if there are any breaking changes from v0.16.0 to v0.19.0 of DJs/voice ? I know that with djs there are usually migration steps on the wiki/documentation page

snow onyx

there are generally no breaking changes on a minor version

rose tangle

I'd just check the release notes of each release since it's not that many

rose tangle

not sure if djs completely adheres with that though

stable sun

More specifically, when the major is 0, any changes in the "minor" place is considered a breaking change

halcyon bison
candid osprey

Perfect, thanks!

gleaming badger

can subcommandgroups not have options?

bleak owl

that is correct, they can only have subcommands

they're not meant to have options, that is what subcommands are for

gleaming badger

I mean for the sub commands under subcommandgroups

bleak owl

im not sure i understand what you're asking

wary coral
gleaming badger

😬 time for debugging

gleaming badger

whats the difference between setValue() and setPlaceholder() for TextInputBuilder?

pliant pendant
gleaming badger
gleaming badger

thank you

pliant pendant

Mhm

radiant raft

hey one question, I've been trying to register my slash commands on my bot

🔄 Deploying commands...
   URL: https://discord.com/api/v10/applications/1418440834931490888/commands
   Commands: 28
   Payload size: 12261 bytes

   Sending request (60s timeout)...
(node:22440) Warning: Accessing non-existent property 'getBuildingLevel' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:22440) Warning: Accessing non-existent property 'getConstructionSpeedBonus' of module exports inside circular dependency
    Response received!
   Status: 429 Too Many Requests
   Rate Limit Scope: shared
   Rate Limit Remaining: 0
   Rate Limit Reset After: 34.082s

  Rate limited! Waiting 36s before retry...```

but I just keep getting 429 status, whenever I try to do it on another bot it actually works fine
wary coral
radiant raft

it's been like this for hours, like 5 hours I suppose

sharp ginkgoBOT

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
wary coral
neat nimbus

Best way todo this?

bleak owl

best way to do what exactly?

neat nimbus

to update the orginal message

bleak owl

"Best" is subjective. does your code work?

neat nimbus

atm yes but looking to compact more of the code

bleak owl

that looks pretty compact to me

neat nimbus

did the issue of the menu not resetting get fixed

bleak owl

what issue?

neat nimbus

like the data when moving from one role menu to next one use to keep the data

next coral

Does anyone know how to disable the default kick and ban command from the server?

If i implement my own commands into my discord bot and submit the command, discord uses the default kick or ban command from Clyde

bleak owl

not possible

also not really a d.js question

undone glade

How to move member between voice channels

next coral
sharp ginkgoBOT
undone glade

ty

rocky vessel

Hi,
I'm trying to remove role "A" and add role "B" but instead bot removes role "A" and then add roles "B" and "A"

        console.log("To remove:", toRemove); //["A's id"]
        console.log("To add", toAdd); //["B's id"]

        if (toRemove.length > 0) {
          await targetMember.roles.remove(toRemove, reason);
        }

        if (toAdd.length > 0) {
          await targetMember.roles.add(toAdd, reason);
        }
tardy sable

are you sure your roles are correctly assigned in toRemove and toAdd?

rocky vessel

should I fetch targetMember's roles before adding or smth?

tardy sable
rocky vessel
To remove: [ '966135859583795230' ]
To add [ '995881716923240449' ]

there is only 1 role in To add list but my bot adds 2 roles

tardy sable

then it must be something outside that code snipping affecting it

maybe youre reassigning that variable somewhere?

rocky vessel
rocky vessel Hi, I'm trying to remove role "A" and add role "B" but instead bot removes role ...

this is the only place where roles are added
here's full logic

        const desired = i.values.filter((id) => adminRoles.includes(id));

        const currentAdminRoles = adminRoles.filter((id) =>
          targetMember.roles.cache.has(id)
        );

        const toRemove = currentAdminRoles.filter(
          (id) => !desired.includes(id)
        );
        const toAdd = desired.filter((id) => !currentAdminRoles.includes(id));

        const reason = `Zmiana ról przez ${ctx.user.username}`;

        console.log("To remove:", toRemove);
        console.log("To add", toAdd);

        if (toRemove.length > 0) {
          await targetMember.roles.remove(toRemove, reason);
        }

        if (toAdd.length > 0) {
          await targetMember.roles.add(toAdd, reason);
        }

it's too simple to be broken :/

wary coral

set the array instead of the variable in the function. do you see the same outcome?

rocky vessel
wary coral
rocky vessel
wary coral I am saying to put the value hard coded into the functions for testing

yeah i got it.

        if (toRemove.length > 0) {
          await targetMember.roles.remove("995881716923240449", reason);
        }

        if (toAdd.length > 0) {
          await targetMember.roles.add("966135859583795230", reason);
        }

^works fine but

        if (toRemove.length > 0) {
          await targetMember.roles.remove(["995881716923240449"], reason);
        }

        if (toAdd.length > 0) {
          await targetMember.roles.add(["966135859583795230"], reason);
        }

^produces same result

tardy sable

that just wouldnt make any sense, what djs version are you on?

rocky vessel
tardy sable

how do you know bot added 2 roles? in audit log?

tardy sable

try this on a new member, audit logs can stack

rocky vessel

i just removed and added random role to other member to prevent aduit logs from stacking. That's not the case here

same thing with different member

tardy sable

thats also a screenshot from a discord client it looks like? view it on native desktop app

rocky vessel
tardy sable
rocky vessel

yup

tardy sable
rocky vessel

one is "Moderator" and one is "Support" (or "admin org2")

tardy sable

only explanation is that you're modifying the roles again on somewhere else in your bot

rocky vessel

but they didn't

tardy sable

so the hard coded example does not add 2 roles?

rocky vessel
wary coral

It is possible a bug I am going to try and reproduce

rocky vessel

I'm using outdated command handler called gcommands but I don't believe it's the culprit

I should have mentioned this at the beginning, but as I said, I don't think it matters.

I tried to downgrade d.js to 14.25.0 and 14.15.1 but the problem still occurs thinkw

tardy sable
rocky vessel

Ik it's very weird. I never had such issue (and I'm making bots since 2021). I may be just cursed or smth

tardy sable
loud quartz

You could also try with using a single set

I believe this might be a cache-related issue and the fact that there's separation here between the rest api and gateway, and awaiting only awaits the rest call

That said, unsure if it's actually the case, and if it's even applicable in this case

rocky vessel

Users can have a lot of roles and i only want to edit a small part of it. I don't think using .set will be the best option here

for example

A
B
C
D
E
[...]
adminRoleA 
adminRoleB
adminRoleC 

I'm only interested in editing adminRoles

loud quartz

You can absolutely do it with set

Grab roles they have, filter out roles they need to lose, add roles they need to get, call set with that

One api call for both adding and removing

rocky vessel

hmm I thought it would be really api intensive call for some reason

I guess I'll try that, thanks!

loud quartz

Discord just does like a member roles = what you passed in set

Which does mean that you have to keep any managed roles in the list, since you cannot remove them

rocky vessel

oh I see, smarter every day

clear jolt

please can a good discord.js person dm me, I need help and it will take like 10 min so is too long for here please

@loud quartz can you?

sharp ginkgoBOT

To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.

tardy sable
loud quartz
clear jolt

ok i will try

clear jolt

is this a problem with node

loud quartz

What even is that

clear jolt
loud quartz

Doesn't sound like it's d.js

tardy sable
loud quartz
clear jolt
loud quartz

Absolutely not

clear jolt

oh... do you know what this is a problem from

loud quartz

No idea, and as this is not discord.js, this is not a channel for guessing what this is and what's the issue

clear jolt

ok i need help with another isuse

does this make any sense

verbal plinth

I specified a customURL when creating the client for rest. But is it possible to use a different one for Channel Create, for example, i.e., only for a specific endpoint?

loud quartz
loud quartz

But you're free to point it to a proxy of your own where you can send anything anywhere

verbal plinth

mhm okay

clear jolt
loud quartz
clear jolt

bro i got reccomended this server for this stuff i dont know im sorry

loud quartz

Did you write this code?

clear jolt
loud quartz

Then that's why it doesn't work

clear jolt
loud quartz

Which part

clear jolt

all of it

loud quartz

The network part that has no relation to your code whatsoever, or the code that uses an undefined variable

clear jolt

it worked for 1 month then yesterday it break

leaden wadi

what am I missing for this to detect all non user messages?

it works on most bot messages

just not ones from the same bot?

trying to prevent users from using bot commends in certain channels

tardy sable

also i think you dont have to add webhookid and applicationid i think they count as bots too

tardy sable
leaden wadi

this is what happens when you work on someone else's bot </3

tacit pulsar

im not at home right now, anyone know if the file upload field in a modal follows the server's upload size limits?

tacit pulsar

ty!

fluid ferry

I feel like I'm missing something for creating message ContextMenus (relevant part of the guide attached). currently, I handle commands in a /commands directory, which contains folders (for organisation) which contain all of the command files. my command handling code is attached. all commands that I have created use a generic base type called Command, which all have the properties data, execute, aliases. I'm not sure how I'm supposed to push a context menu command to this setup

I need to create a context menu for reporting messages. I'd also like it to trigger a modal where the person reporting the message can provide a reason, which will then be sent to the mod channel in the server (so if there's anybody with thoughts on how to do that, I'd appreciate them)

fluid ferry

alright I figured out creating the commands -- basically just had to do the same thing and deploy them in their own way

tiny blade

im backkk

im thinking of making a discord bot game where bot will ask random words including specific letters, answer under 10s

user reply with any english word valid word with that letters, how bot will know that is valid word?

using api will be slow? and no way people store whole english directory in bot code

stable sun

I’m sure someone has done that

tiny blade

i saw this game in bleed bot

stable sun
stable sun

You can prob find some api online too

tiny blade
stable sun

Maybe

Depends on how fast you need it

And reliably

tiny blade
stable sun

Who said searching a text file would be faster tho?

I guess you could index it beforehand and make a special search algorithm to make it faster

tiny blade

bruh my hosting platform bugging hard while saying 460k words

stable sun

You would still have to read the entire file

tiny blade

i just created and tested, it was hella instant.

stable sun

Ok

Are you just loading the entire file into memory?

tiny blade

my ai knows better

stable sun

Ah, you just made a CGPT prompt

stable sun

` Is "${word}" a valid English word? Only respond with simple "yes" or "no". Do not add any additional explanation, reasoning, or gratuity to your response. `

tiny blade
stable sun

Ah, you use Gemini. Clever guy

tiny blade

nuh uh

stable sun

Then you are lying

tiny blade

lol no

the one i use is kinda underrated, rarely people use it for bot dev

i have made literally a whole website + dashboard for my bot and discord bot with it

with ticket system / staff applications / staff stats/ suggestions / appeal system / games / custom commands / auto moderation / leveling / and other small feaues, like it have everything you ever saw in a discord bot

stable sun

I wonder if you can code an entire Discord bot by delegating majority of logic to ai prompts and the code only checks the result of those prompts

tiny blade

if hit limits, thats pain, i will have to start new chat and explain every shit of my code

tiny blade
stable sun

If not, then DeepSeek?

snow onyx
thin pagoda

hi, i need a small help,
my bot have 5k servers and 1m users
but i only used 1 cluster and the shards are auto but it used 5 shards so some one can tell me which number i can use instead auto ? I'm not well knowledged about clusters stuff GF_PepeCry

vast frigate

do role mentions work in ephemeral interactions?

initial testing seems to say that they do not

but I'm just checking

stable sun

You likely have smth else going on if markdown isn’t being displayed normally

vast frigate

interesting

oh wait

just realized none of the markdown is working 😳

stable sun

Maybe you have some escape markdown function?

vast frigate

It's possible I suppose. I am just getting back into this codebase, which is a bit old

but I don't really remember writing anything like that

stable sun

Show code

vast frigate
export async function handlePrintLevelsInteraction(interaction: Command.ChatInputCommandInteraction, level: number) {
    try {
        const totalXp = totalXpFormula(level);
        getLevelFromXp(totalXp);
        const levelMappings = xpCache;
        const levelsStringArr: string[] = [];
        const promises: Promise<void>[] = [];
        levelMappings.forEach((xp, level_) => {
            promises.push(
                new Promise<void>(async res => {
                    let levelRoles = await getLevelRolesByLevel(level_);
                    let gainedRoles = levelRoles.filter(role => role.gained).map(role => `<&@${role.roleId}>`).map(str => '+' + str);
                    let lostRoles = levelRoles.filter(role => !role.gained).map(role => `<&@${role.roleId}>`).map(str => '-' + str);

                    let allRoles = gainedRoles.concat(lostRoles);

                    let rolesString = allRoles.join(", ");

                    if (level_ <= level) levelsStringArr[level_] = (`**Lvl ${level_} - ${xp}**${rolesString.length > 0 ? '\n' : ''}${rolesString}\n`);

                    res();
                })
            )
        });

        await Promise.all(promises);

        const levelsString = levelsStringArr.join('');

        await interaction.editReply({content: levelsString });
    } catch (error) {
        throw error;
    }
}
vast frigate
stable sun

The role mention is backwards in the code

Doesn’t match what you showed

vast frigate

oh don't mind that, that was just me gaslighting myself

as a possible fix being I had it backwards

tiny blade

can someone send docs link of guild tags

vast frigate

Also the exclamation marks was from the lostRoles line, but I changed it before copying that snippet

tiny blade

like how to fetch a server guild tag

vast frigate

anyway honestly this is probably actually maybe a Sapphire.Js question, so I'll ask there instead. Thanks for the time and attention to this matter o7

pearl hazel

it's return null

loud quartz
tiny blade

i want to give users role if they have equiped guild tag of current server

snow onyx

then you will need to loop over the users and check User#primaryGuild#identityGuildId

sharp ginkgoBOT
stable sun

Prob easier to make them run a cmd to receive it

tiny blade

pain for 'em

stable sun

Does adding guild tag trigger user update event?

loud quartz

Yes*

*but sometimes no

our user update is extracted from discord's guild member update

stable sun

Yea

loud quartz

So for uncached members we have no way to know it was user that was updated and not member

stable sun

Just requires the user to be cached

It should be controlled by partials tbh

Although yes, that reasoning makes sense

loud quartz

Partials would be the exact same, but more often

stable sun

False positive vs false negative

loud quartz

Yeah, it's our own doing for end user convenience

stable sun

Can still have both the event and command as fallback for his case

thin pagoda
loud quartz

Ratelimited while doing what

stable sun

We can try to help you optimize your code to not hit rate limits

thin pagoda
thin pagoda

like add multiple clusters

velvet cipher

Rate limits are based on your bot's token/account, so having more clients/clusters doesn't help at all with that

The only way to "fix" being rate limited is to fix your code so that it doesn't spam the API

fathom warren

or add cd handler cuz interactions might trigger ratelimits when invoked too frequently as well

fathom warren

so the only thing you can do is to slow down user from interacting to prevent request overflow

wary coral
thin pagoda
verbal plinth

Is it possible to send a webhook in a thread?

unique shoal

Yes, with the threadId parameter

fathom warren
sharp ginkgoBOT

method Webhook#send() discord.js@14.25.1
Sends a message with this webhook.


// Send a basic message
webhook.send('hello!')
  .then(message => console.log(`Sent message: ${message.content}`))
  .catch(console.error);

thin pagoda

how much cluster and shard

rose tangle

djs doesn't have clusters

if you're using an external package you should ask them

thorn sphinx

how do i make commands work in dms (sorry im new to djs and js)

fathom warren

slash or legacy

sharp ginkgoBOT
thorn sphinx
oak cosmos

is there a way to use a api's .mp3 extention as a audio inside a container?

novel mauve

you can use the File component to display it, but it won't have a player

turbid flame

how do i set an image inside a container builder?

sharp ginkgoBOT
wary coral

or do you want a thumbnail?

turbid flame

thumbnail

sharp ginkgoBOT

guide Thumbnail
A Thumbnail is a display component that is visually similar to the thumbnail field inside an embed. Thumbnails are added as accessory inside a Section component, support alt text for accessibility, and can be marked as a spoiler. You can use the ThumbnailBuilder class to easily create a Thumbnail component: For more information about using attachments in components refer to the guide on attaching images in embeds.

turbid flame

so add a section compontent to the container builder to use the thumbnail?

wary coral

Yes, Note: sections need at least 1 text display

turbid flame

can the text display be empty?

prob gonna do a tias moment lol

uncut lark

I have this flow currently:

Context Interaction -> Send ephemeral defer -> editReply with action row -> button triggers modal

the part I am stuck on is when I receive the ModalSubmitInteraction. I need to update the ephemeral reply that was attached to the button, and I know you need to call .update on the button, but I don't seem to see a way to do that using ModalSubmitInteraction. Suggestions?

wary coral
sharp ginkgoBOT

documentation suggestion for @uncut lark:
method ModalSubmitInteraction#update() discord.js@14.25.1
Updates the original message of the component on which the interaction was received on.


// Remove the components from the message
interaction.update({
  content: "A component interaction was received",
  components: []
})
  .then(console.log)
  .catch(console.error);

wary coral

modal submit has update and defer update

uncut lark
wary coral

check you djs version

uncut lark

I am on latest

proud shoal

Believe it also has editReply, which also works.

uncut lark

editReply threw an error for me: "Unknown Message"

loud quartz

Update only exists if it's a component interaction that triggered the modal

wary coral
uncut lark
sharp ginkgoBOT
wary coral

wait that might be wrong, ya that is wrong

sharp ginkgoBOT
wary coral

that should be the right check

brave iris

Hello, I'm wondering how to tell if a user has a Guild Tag or not, and especially how to find out a precise one.

sharp ginkgoBOT
brave iris
tiny blade

adding status roles in a all in one bot is a bad choice?

wary coral
tardy sable
tiny blade
loud quartz

Discord already shows user status

No need to also do that with roles

tiny blade

...

people do this to give a "supporter role" which is then used for extra perks

alr im gonna remove that shi, also the guild tag one

tardy sable
loud quartz

So that's not really "status"

uncut lark

is this not the right way to get a message that comes from button/modal trigger? This seems to return empty for me.. interaction.message?.fetchReference(); with a typeguard if (!interaction.isFromMessage()) return;

loud quartz

But just arbitrary requirement for arbitrary role for arbitrary reason

tardy sable
tiny blade
loud quartz
tardy sable
tiny blade
tardy sable

a lot of bots do that already, i dont see a big problem in that

tiny blade

its heavy

tardy sable

youre just gonna add a role if they have something in their status. thats nothing heavy

tiny blade

a lot of bots that does it arent all in one bots and the all in one bots just dont do it

tiny blade
uncut lark
tardy sable
uncut lark

so, context -> hidden reply -> button -> modal
^
we want the message from this step

loud quartz
tiny blade

events one, like isnt it like we fetch it?

loud quartz

No, it's not

sharp ginkgoBOT
loud quartz

You don't fetch every single message one by one every time either

tiny blade

wait waht, gimme a sec

loud quartz

Discord sends events

tardy sable
wary coral
uncut lark

I had to do this: ts const messageRef = interaction.message.reference; const referencedMessage = messageRef ? await interaction.channel?.messages.fetch( messageRef.messageId!, ): null;

.message.reference exists on modal submits created from a button context. We assume it's always going to be in the same channel and fetch it that way

(maybe this might be worth adding to ModalSubmitInteraction when type is from a message (using isFromMessage) maybe something like:

interaction.message.getTargetedMessage() as .targetMessage doesn't exist in the ModalSubmitInteraction type

tiny blade
loud quartz
tiny blade

i just realised im also reciving events, not fetching.

loud quartz

Beyond the fact that you have to shard beyond 2500 servers

tiny blade
loud quartz

Separate what

tiny blade

seprate bot, they made two bots, bleed ( main ), bleed vanity for giving roles to user for having a status

tardy sable

you should ask them. theres nothing heavy about receiving events

tiny blade

ok thanks,i was just going to remove it

loud quartz

Because they wanted to, because it's optional functionality, for branding reasons.. we have no idea and no reason to know

tiny blade

one more question, is having a realtime listener to db is heavy ?

tardy sable

wdym with a realtime listener?

tiny blade

listens to every update in db table, im doing this in a way like, bot starts, load all configs of guilds realted to bot in ram cache, uses it, if a column value changes, realtime will know and update the cahce

tardy sable

code optimization is all up to you

velvet cipher

Instead of worrying about something that might be heavy, implement your feature then see if it actually is heavy. Premature optimization is a progress killer for so many beginners and intermmediates.

serene obsidian
tiny blade
serene obsidian

they just never got approved of the presence intent on the main bot and they got tired of having 2-3 "bleed vanity" instances because they kept getting capped at 100 servers, so they tried getting their bleed vanity bot verified with the intent and it worked

tiny blade
serene obsidian

but it took them a few tries i believe

tiny blade

hmmm

velvet cipher
tiny blade

hm

topaz bluff
serene obsidian

but i suggest you use a separate vanity bot

turbid flame

using containerBuilder... is it possible to have text side by side? like how in embeds you can set inLine=true?

topaz bluff

Inline is not possible with Components V2

rose tangle

oops didn't check the whole convo, just noticed it ended, mb

brave iris

Which event should be used to ensure that the person who removed or added the Guild Tags is correct?

loud quartz

"event to ensure"? there's only one event, when it changes

velvet creek

which PermissionFlagsBits we need to use to toggle them?

flint pier

(Use `node --trace-warnings ...` to show where the warning was created) (node:98794) TimeoutOverflowWarning: 2866389078 does not fit into a 32-bit signed integer. Timeout duration was set to 1.
what is error?

rocky vessel
velvet creek
wary coral

On a channel or role?

velvet creek
halcyon bison
velvet creek
halcyon bison

ManageRoles

flint pier
halcyon bison

your warning suggests otherwise
either way, this is related to setTimeout, not a discord timeout, so this is unrelated to discord.js

ripe topaz

How can I silently reply to a modal?

Basically, I have a button that shows a modal, after its filled out it sends a message to a pre-defined channel, but the modal window errors out

halcyon bison

you cannot silently reply to any interaction
the closest is for components (and modals originating from components) you can do an empty edit (or deferUpdate and never actually update)
otherwise you'd need to reply and delete the reply, but imho it's better UX to at least reply ephemerally with a success message

ripe topaz
sharp ginkgoBOT
  • ReferenceError: "x" is not defined: learn more
  • TypeError: Cannot read properties of undefined/null (reading "x"): learn more
ripe topaz

this thing

halcyon bison

I'm not sure to what part of that you were saying "not in this case", but either way my answer is the same

those are your options

ripe topaz
tiny blade

what's the common way of building a music system??

halcyon bison

that's an incredibly vague question with many different answers, and at first glance, I'd say none of them are djs related
if you have a question about something more specific, feel free to ask
but forewarning, your first step should be to find a tos-compliant source of audio since most of the ones people ask about (youtube and spotify) don't have a tos-compliant means of streaming

tiny blade
wary coral

yes, both YouTube and Spotify do not allow the restreaming of their content via their API. And they have and could take leagl action against people for doing it

tiny blade

and then what should be the source? any idea?

wary coral

We will not help you create an app that Violates any services terms of service

wary coral
tardy sable
tiny blade

weird

wary coral
tiny blade

nothing, i just though yt/spotify is good to go with

im confused what to do now, soundcloud doesnt feels good ( i just have a internal feeling )

tardy sable

also worth saying to not overwhelm yourself with an all in one bot when you arent that familiar with djs. start with perfecting one system, otherwise you just gonna end up recoding everything anyways

vagrant rampart

How to get bio of guild member?

tardy sable
vagrant rampart
steel trail

Keep this channel on-topic, troll elsewhere

tiny blade

i just.... gave the only possible solution

sleek mural

Is there a way to get the amount of bots in a server? Without fetching all members and filtering out humans

halcyon bison

not without doing that, no

steel trail
sleek mural
steel trail

So you just want to have the number because you want to? Or do you have actual users wanting such information in there

tiny blade
sleek mural
tiny blade

i searched up and there are alot of flaws in soundcloud

sleek mural
tardy sable
halcyon bison
sleek mural
tardy sable
halcyon bison

*after fetching once

tardy sable

wanted to add up on that* recommended to fetch all members at startup then

sleek mural

Ia it a good idea to fetch eveerything on startup once?

steel trail

It's not really worth to apply for guild members intent if that's the only thing you need it for

Especially since it won't get approved for more than 100 servers

vagrant rampart

My bot has banner set in specific guild, but when i fetch my own API:

const guild = await client.guilds.fetch(guildId);
            const member = await guild.members.fetch(client.user!.id);

            const hasCustomProfile = member.nickname !== null || member.avatar !== null;

            return {
                nick: member.nickname || client.user!.username,
                avatar: member.avatarURL() || client.user!.displayAvatarURL(),
                banner: member.user.bannerURL() || client.user!.bannerURL() || null,
                bio: null, 
                isCustom: hasCustomProfile,
                isPremium,
            };

I receive

{
    "nick": "Siema xd",
    "avatar": "https://cdn.discordapp.com/guilds/1032657339649622036/users/905135889305440297/avatars/bfef9fa4909748a860737f7167629c9b.webp",
    "banner": null,
    "bio": null,
    "isCustom": true,
    "isPremium": true
}

Avatar is okay - its per server avatar as it is, but banner is always null. Why is that?

halcyon bison

I imagine you'd need to force fetch your client member much like how you'd need to force fetch users to get global banners

wary coral

fetch("id", true) see below. it skips the cache

halcyon bison

not sure if any of the fetch methods take multiple parameters anymore
but there's also <Guild>.members.fetchMe({force: true})

vagrant rampart
const guild = await client.guilds.fetch(guildId);
            const member = await guild.members.fetch({
                user: client.user!.id,
                force: true,
                cache: false
            });

            const hasCustomProfile = member.nickname !== null || member.avatar !== null;

            return {
                nick: member.nickname || client.user!.username,
                avatar: member.avatarURL() || client.user!.displayAvatarURL(),
                banner: member.user.bannerURL() || client.user!.bannerURL() || null,
                bio: null,
                isCustom: hasCustomProfile,
                isPremium,
            };

still the same

but ill try what duck sent

vagrant rampart
sharp ginkgoBOT
vagrant rampart

it looks like some kind of bug with bannerURL() (?) when i wrapped it with then and console.logged i have banner hash

halcyon bison
vagrant rampart

joe_fall_backwards_dead

stupid mistake, thx lmaoo

halcyon bison
vagrant rampart

yeah

hazy delta
message.attachments.each(a => {
    a.url
});

everytime I run this code, it gives a url that says "This content is no longer available." even when I go to it right away

am I missing something? I thought the url should be visitable later and render the image

tardy sable

because you cant guarantee the attachment will still exist if its deleted

tardy sable
hazy delta

no. messages are still up, and even when I visit the url as soon as it logs in console, it does it

tardy sable
hazy delta

@tardy sable really weird. it seems to be working now. I deleted the file and reprogrammed it.. to my knowledge exactly the same. thanks anyhow

I'm running some tests with my code, and it seems that about once every 10 times I initiate the project, I get this:

node:events:496
      throw er; // Unhandled 'error' event
      ^

Error: socket hang up
    at connResetException (node:internal/errors:787:14)
    at TLSSocket.socketOnEnd (node:_http_client:519:23)
    at TLSSocket.emit (node:events:530:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ClientRequest instance at:
    at TLSSocket.socketOnEnd (node:_http_client:519:9)
    at TLSSocket.emit (node:events:530:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'ECONNRESET'
}

Node.js v20.11.1

any idea what this is about?

sharp ginkgoBOT

tag suggestion for @hazy delta:

Errors such as ECONNRESET, ConnectTimeoutError, SocketError: other side closed indicate a network issue

  • Free or shared hosting providers often come with significant limitations
  • Another indication of these issues are 'Unknown Interaction' errors.
golden laurel

There's no limit. Just keep in mind that you can only have 40 components max

coral maple

What's the difference between displayName and globalName

clear garnet

In context of a User, displayName will try to return globalName first, however will fall back to username if globalName is null

In context of a GuildMember, it has similar behavior but with nickname - which can be null - also being taken into consideration before the other two

coral maple
cerulean patio

Quick question, does the latest version of v14 support setting a bot's avatar per server?

bleak owl

yes

sharp ginkgoBOT
cerulean patio

yeah just searched and found it, ty

serene robin

When I click on my button I get this error.

node:events:497
      throw er; // Unhandled 'error' event
      ^

ValidationError: Expected a string primitive
    at _StringValidator.handle (C:\Programming + Coding\DiscordBots\Frost_Manager\frost-manager\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2615:70)
    at _StringValidator.parse (C:\Programming + Coding\DiscordBots\Frost_Manager\frost-manager\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
    at TextDisplayBuilder.toJSON (C:\Programming + Coding\DiscordBots\Frost_Manager\frost-manager\node_modules\@discordjs\builders\dist\index.js:2074:33)
    at C:\Programming + Coding\DiscordBots\Frost_Manager\frost-manager\node_modules\@discordjs\builders\dist\index.js:2868:64
    at Array.map (<anonymous>)
    at ModalBuilder.toJSON (C:\Programming + Coding\DiscordBots\Frost_Manager\frost-manager\node_modules\@discordjs\builders\dist\index.js:2868:35)
    at ButtonInteraction.showModal (C:\Programming + Coding\DiscordBots\Frost_Manager\frost-manager\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:402:46)
    at Object.execute (C:\Programming + Coding\DiscordBots\Frost_Manager\frost-manager\handlers\buttons\client-add-button.js:40:27)
    at Object.execute (C:\Programming + Coding\DiscordBots\Frost_Manager\frost-manager\events\interactionCreate.js:14:28) 
    at Client.<anonymous> (C:\Programming + Coding\DiscordBots\Frost_Manager\frost-manager\index.js:37:46)
Emitted 'error' event on Client instance at:
    at emitUnhandledRejectionOrErr (node:events:402:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
  validator: 's.string()',
  given: undefined
}

Node.js v20.17.0```

I will provide my code if needed.
oak cosmos
serene robin
oak cosmos

if proofs is empty, then youll get that error.

serene robin

It isn't.

oak cosmos

try debugging, log ur proofs and see if its empty

serene robin

It isn't empty.

oak cosmos

could i see the logged proofs

serene robin
oak cosmos

like the logged proofs, console.log(proofs).

serene robin
oak cosmos

not the whole text input builder.

oak cosmos

should work now.

serene robin

I figured it out thank you for the help though.

oak cosmos

can u tell me what the problem was

serene robin

I had modal.addTextDisplayComponents instead of modal.addLabelComponents.

rose tangle

btw in the future you should post both the code and the error, not just the error

helps to do less assumptions and mistakes about what your code actually looks like

oak cosmos
oak cosmos
rose tangle

it isn't

the file component simply displays it as a file, no kind of preview

oak cosmos

oh dang

subtle girder
escapeMarkdown(message, {
        codeBlockContent: false,
        codeBlock: true,
    });

does this escape ``` but

    at _StringValidator.handle

won't changed to

    at \_StringValidator.handle
stable sun
subtle girder
stable sun
oak cosmos

rate this pls

warm charm
oak cosmos

what color? Its a definition finder

verbal plinth
wary coral
verbal plinth

thanks

oak cosmos

whats a cheap vps?

loud quartz
subtle girder

There's a message sent by bot,
the message has the content and a component (StringSelectMenu)
but why interaction.update({content: "", embeds: [embed], components: []})
won't delete the StringSelectMenu component?

loud quartz

Where's the interaction coming from

tardy sable

<@&839912195994812420> scammer

latent wolf

any1 can send the thing of container - the link pls

sharp ginkgoBOT
wary coral

please use #app-commands or the hide option for personal use of commands

tiny blade

lavalink is against tos also?

tardy sable
tiny blade

sorry

polar olive

Hi, does anyone know how to mention someone in a container without pinging them? Like embeds do.

tiny blade

can anyone send a simple container code .js?

crimson gale
sharp ginkgoBOT

guide suggestion for @tiny blade:
guide Container
A Container is a layout component which groups its child components inside a visually distinct rounded box with an optional accent color on the left, similar to the message embed look. Unlike embeds, not specifying a color will make the left side of the Container component match the background color. You can mark Container components as spoiler, which blurs all content inside the container. You can use the ContainerBuilder class to easily create a Container component. - a Separator component;...

polar olive
crimson gale same as you would with message content, the `allowedMentions` option

I know embeds can render <@user> / @everyone without triggering notifications.

My question is: is there any non-embed message container (e.g. rich container, component tree, system-like payload) that can render a <@user> mention without notifying the user, similar to embeds?

I’m aware pings are only processed in content, but I’m wondering if there’s any internal flag, suppressed-mention container, or non-public field used by Discord that isn’t exposed in the public API.

crimson gale

what

polar olive
crimson gale what

Is there any way to show <@user> as a real mention (blue + clickable) without sending a notification, outside of embeds?

palitoonerd

crimson gale

notifications are controlled via allowed_mentions on the API level, allowedMentions on the wrapper level

sharp ginkgoBOT
crimson gale

if the mention syntax is rendered clickable or not depends on if that entity is cached on the viewing client

it always resolves if you choose to notify, because the message itself will include the required data if notification is enabled
there have been effort on discord's end to always render these regardless, but it keeps being turned on and off

ripe topaz

I'm not even sure what this error means :/

rose tangle

embeds: [pages[page - 1]]

if that's outside the range then you'd send embeds: [undefined] which isn't a valid embed object

ripe topaz

L113

it's clamped

I'll log embeds ig, but I doubt this is it

rose tangle

the last index is length - 1

ripe topaz
rose tangle

ah, right, do some logging then

ripe topaz

I did, the embed is there

rose tangle

I believe that error is caused by not passing an object

rose tangle
ripe topaz

huh

loud quartz

if it's NaN then you shouldn't use it directly, btw

ripe topaz

Somehow, between the assignment and sending it becomes undefined

ripe topaz
loud quartz

And i misread

ripe topaz

:)

loud quartz

So sending it again doesn't change anything in any case

Regardless if i did or not

Anyway

ripe topaz

it can be better, i agree

ripe topaz
loud quartz

Uh

If i glance at the code right, on collect you only set the page number

And I didn't see you ending the collector

And code using the page number is outside of that

ripe topaz

on collect i set the page var, and after that update the embed with the correct one

This thing is what's updating the embed

the page is just set above and used here, all in the collect event

istg djs should have a built in way to paginate embeds

tiny blade

how a bot can set status of a voice channel

tardy sable
ripe topaz

@loud quartz @rose tangle Fixed it, turns out I made a logic error on line 115, I was setting page instead of num like intended heh

rose tangle

it's always the little things

tiny blade
topaz bluff

It's not documented by Discord so pretty much no library will support it

tardy sable
tiny blade so in py?

idk which library supports it but djs not yet and i think its undocumented by discord too

sharp ginkgoBOT

discord.js does not support features until they are officially documented.
While there might be a way for these features to work, it can change at any time without any notice

tiny blade

and maybe that bot is discord.js

topaz bluff

I doubt it

tiny blade

lets try asking 'em, gimme a sec

tardy sable
loud quartz

There's a lot of stuff discord client does that's not available to bots and therefore undocumented

But undocumented stuff can change or go away at any point, and d.js simply avoids dealing with that

tiny blade

ye ik

bruh im so dumb, just get to know that we can use lang other than js or py to make bots also

rythm uses kotlin

topaz bluff

A bot can be made in any language that can perform HTTP requests and form/read JSON.... So pretty much all of them

tiny blade

hmm

wary coral
tiny blade hmm

That PR is not meagered also it is a draft and therefore not documented.
djs does not support voice channels status currently

tiny blade

hehe

snow onyx

Slight difference between not possible and undocumented Capysmuga

loud quartz

As i already said

And so did they

tiny blade

ikik

tiny blade

is it possible to make last seen command?

without storing users status

loud quartz

No

gleaming badger

can I set url for non link styled buttons?

bleak owl

not really, no

gleaming badger

alright, thanks

mental idol

Hello discord.js support,

how can I interaction dynamic custom IDs?

For example:
staff_apply_reject_1
staff_apply_reject_2
staff_apply_reject_3

stable sun
mental idol

interaction or reply

stable sun

Use the interactionCreate event, check if the interaction is a button, then check the custom id and reply accordingly

mental idol

like this:

        if (interaction.isButton()) {
            let button = interaction.client.buttons.get(interaction.customId);

            if (!button) {
                const buttonKey = Array.from(interaction.client.buttons.keys()).find(key => interaction.customId.startsWith(key + '_'));
                
                if (buttonKey) {
                    button = interaction.client.buttons.get(buttonKey);
                }
            }
            
            if (!button) {
                console.error(`No button matching ${interaction.customId} was found.`);
                return;
            }

            try {
                await button.execute(interaction);
            } catch (error) {
                console.error(error);
                
                if (interaction.replied || interaction.deferred) {
                    await interaction.followUp({
                        content: "There was an error while executing this button!",
                        flags: MessageFlags.Ephemeral,
                    });
                } else {
                    await interaction.reply({
                        content: "There was an error while executing this button!",
                        flags: MessageFlags.Ephemeral,
                    });
                }
            }
            return;
        }

Or is there a better way?

stable sun

Better is subjective at this point

You could make 1 file per button

tardy sable

Yh how you make your navigation is up to you

stable sun

I prefer to include the command name in the custom id and have them in the same file as the command

tardy sable

same, most organized Shrug

mental idol

Because I tested it and it works, but something happened or interfered with the interaction of another button

stable sun

Something like ban:confirm:123456

topaz bluff

Your custom_id is storing the state of the interaction... I don't see you separating the id from the state in that snippet

tardy sable
stable sun
topaz bluff

_ are also used to combine words... : are not... so you could do some_thing:id_here

stable sun

Yea, that would explain why it looks weird to me too

tardy sable
mental idol

But something strange happened, or I don't know how to explain it.

Let's say there's a reaction staff_apply_reject_1, and it doesn't have a corresponding file or response. So it responded with another button.

Why?

topaz bluff

Log your raw CustomID and ensure that it's not being generated incorrectly

mental idol
topaz bluff
stable sun

The array find look suspicious

mental idol

But why did he do that?

Because I misspelled the custom ID?

stable sun

Should start by logging the custom id and the button key right before the button.execute

mental idol

Do you mean I should reverse it?

stable sun

Huh?

I asking you to console.log stuff

tardy sable
mental idol

ok

inner cipher
const { EmbedBuilder } = require('discord.js');

module.exports = {
    name: 'messageDelete',
    async execute(message) {}

Event is not executed.

Partials are on. Intents are on.

const { Client, GatewayIntentBits, Collection, Partials } = require('discord.js');
const client = new Client({ 
    intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages,
        GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildMembers, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessageReactions], 
    partials: [Partials.Message, Partials.Channel, Partials.Reaction]
});

Another event is executed (MessageReactionsAdd)

I have no clue what im messing up

topaz bluff

Have you tried adding a log message outside of the module.exports as well as another one at the beginning of the execute()?

inner cipher
module.exports = (client) => {
    client.eventHandler = async (eventFiles, path) => {
        for (const file of eventFiles) {
            const event = require(`../events/${file}`);
            if (event.once) {
                client.once(event.name, (...args) => event.execute(...args, client));
            } else {
                client.on(event.name, (...args) => event.execute(...args, client));
            }
        }
    };
}
```event handler

its strange because I pulled both out of a project that is still suppposed to work

topaz bluff

Well first thing, looks like your args are mismatched between your event file and your event handler. Your execute should always end with client as you're passing it as well as the events args... So async execute(message, client) .... Technically you don't need to pass the client at all to events as the client is included in most events anyways

Second, you should add another log right after your const event for something like console.log("Loaded event file: ", event.name) to make sure it's getting loaded at all

inner cipher

thats weird.. its not loggin anything...., like nothing at alll

loud quartz
inner cipher
const functions = fs.readdirSync(`./systemfunctions`).filter(file => file.endsWith('.js'));
const eventFiles = fs.readdirSync(`./events`).filter(file => file.endsWith('.js'));

(async () => {
    for(const file of functions) {
        require(`./systemfunctions/${file}`)(client);
    }
    client.eventHandler(eventFiles, "/events");
    client.login(process.env.BOTTOKEN);
})();

So than id assume its in here? but this always has run fine ?

loud quartz

well, something is wrong, so check where does it stop

check what the variables contain

inner cipher

I am now even more confused I am uploading files to a vps and testing from there. But for some reason. It does not seem to pick them up as it runs fine locally

this honestly might be something totally different than. Forget Ive said anything -> I am working in the wrong directory

facepalm

thanks to both of you for your help anyway. Happy Holidays.

subtle girder
subtle girder

oh thx

subtle girder

Can I change the resource volume without enabling inlineVolume?

ripe topaz

is it possible to send a message with @ everyone but make it so a few specific users dont get the notification? like the owner or admins of the server

unique shoal

No

It's kinda in the name. Everyone

tiny blade

( not related to djs btw )

tiny blade

can a bot send voice message?

coral maple

Why am I getting this error again and again?

Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
    at target.send (node:internal/child_process:753:16)
    at Gotty.<anonymous> (/Users/Void/workspaces/GoTTY/node_modules/.pnpm/discord.js@14.25.1/node_modules/discord.js/src/sharding/ShardClientUtil.js:37:19)
    at Gotty.emit (node:events:519:28)
    at WebSocketShard.<anonymous> (/Users/Void/workspaces/GoTTY/node_modules/.pnpm/discord.js@14.25.1/node_modules/discord.js/src/client/websocket/WebSocketManager.js:196:23)
    at WebSocketShard.emit (node:events:519:28)
    at WebSocketShard.checkReady (/Users/Void/workspaces/GoTTY/node_modules/.pnpm/discord.js@14.25.1/node_modules/discord.js/src/client/websocket/WebSocketShard.js:184:12)
    at WebSocketShard.gotGuild (/Users/Void/workspaces/GoTTY/node_modules/.pnpm/discord.js@14.25.1/node_modules/discord.js/src/client/websocket/WebSocketShard.js:158:10)
    at WebSocketManager.<anonymous> (/Users/Void/workspaces/GoTTY/node_modules/.pnpm/discord.js@14.25.1/node_modules/discord.js/src/client/websocket/WebSocketManager.js:238:15)
    at WebSocketManager.emit (/Users/Void/workspaces/GoTTY/node_modules/.pnpm/@vladfrangu+async_event_emitter@2.4.7/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)
    at WebSocketShard.<anonymous> (/Users/Void/workspaces/GoTTY/node_modules/.pnpm/@discordjs+ws@1.2.3/node_modules/@discordjs/ws/dist/index.js:1190:51)
verbal plinth

I get a RateLimitError when using message.edit(). It says retryAfter: 1.05s (I divide retryAfter / 1000). I am currently testing it so that I always try again after 6 minutes. But after 6 minutes, I get exactly the same error and retryAfter is exactly 1.05s again. How can it be that retryAfter is 1.05s and after 6 minutes it is still 1.05s?

steel trail
coral maple
steel trail
steel trail
coral maple
verbal plinth

I'll check that out, thank you.

verbal plinth

Is it possible that discord.js will try a second time?

I checked, and I only use message.edit() in one place in the code, and it is only called once every 6 minutes with this message.

last mango

hi, how do i edit app avatar per guild?

steel trail
sharp ginkgoBOT
last mango

thanks u

last mango
torpid marsh

Hopefully someone can help me...

I get this in my logs:

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'undici@6.21.3',
npm WARN EBADENGINE   required: { node: '>=18.17' },
npm WARN EBADENGINE   current: { node: 'v18.9.0', npm: '9.2.0' }
npm WARN EBADENGINE }

I think I have to update my node, but how?

verbal plinth
vestal sun
torpid marsh

Alright

severe pumice
torpid marsh

But I got it working.

ripe topaz

is it possible to enforce number input in any modal field?

golden laurel

Nope

ripe topaz

someone tell discord api devs to put that on their to-do list

crimson gale
ripe topaz

it's already discussed but it looks stale D:

tardy sable
ripe topaz

speaking of modals, I cant figure out how exactly does deferring work, say I get a button interaction, i show a modal, then how do I reply? using the ModalSubmitInteraction or the button one

cuz i want the button to just show the modal and stop, then the modal should send a message in a specific channel on submit, but that leaves the modal errored unless i do .deferUpdate() (and then i dont actually update anything)

inner cipher

did discord change this/ I cant see anymore who got moved/kicked

crimson gale

look at the audit log data, pretty sure it doesn't have the users that were moved

inner cipher
torpid marsh

Is there some of information about the possible options for components v2?

sharp ginkgoBOT

guide Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.

topaz bluff

Most if not all options are listed here. What specific things are you looking for?

verbal plinth

Is there a rest event that allows me to log all requests that go outwards?

torpid marsh

What it wrong with this code:

const aboutContainer = new ContainerBuilder()
        .setAccentColor(config.general.MessageEmbedItems.color)
        .addSectionComponents((section: SectionBuilder) =>
            section
            .addTextDisplayComponents(
                (textDisplay) => textDisplay.setContent(`# About ${config.app.info.name}`),
                (textDisplay) => textDisplay.setContent(`${config.app.info.description}`)
            )
        )
        .addSeparatorComponents((separator: SeparatorBuilder) => separator)
        .addSectionComponents((section: SectionBuilder) =>
            section
                .addTextDisplayComponents(
                    (textDisplay) => textDisplay.setContent(`# Developers 💻`),
                    (textDisplay) => textDisplay.setContent(`
                        ItzExotical (itzexotical)
                        Jarvo (jarvo01)
                    `),
                )
        )
        .addSeparatorComponents((separator: SeparatorBuilder) => separator)
        .addSectionComponents((section: SectionBuilder) =>
            section
                .addTextDisplayComponents(
                    (textDisplay) => textDisplay.setContent(`# Status 🛠️`),
                    (textDisplay) => textDisplay.setContent(`**📦 Version:** v${config.app.version.string}`),
                    (textDisplay) => textDisplay.setContent(`**📡 WebSocket:** ${i.client.ws.ping == -1 ? 'Ping not measured yet, please try again later.' : i.client.ws.ping + ' ms'}`),
                    (textDisplay) => textDisplay.setContent(`**🟢 Status:** All systems operational\n**Uptime:** ${process.uptime().toFixed(0)} seconds`),
                )
        )
        .addSeparatorComponents((separator: SeparatorBuilder) => separator)
        .addSectionComponents((section: SectionBuilder) =>
            section
                .addTextDisplayComponents(
                    (textDisplay) => textDisplay.setContent(`# Need Help? 🆘`),
                    (textDisplay) => textDisplay.setContent(`Chat with us, and get direct support`),
                )
                .setButtonAccessory((button) =>
                    button.setCustomId('supportButton').setLabel('Support Server').setStyle(ButtonStyle.Primary).setStyle(ButtonStyle.Link).setURL(config.general.support.discord.invite.link!),
                ),
        );
        await i.reply({
        components: [aboutContainer],
        flags: MessageFlags.IsComponentsV2,
        });

Because it gives me that the application did not respond.

tardy sable
tardy sable
verbal plinth
torpid marsh

That is what it gets me

tardy sable
topaz bluff
torpid marsh

Aaahhh

torpid marsh
topaz bluff A section component is required to have an accessory component (button or thumbn...

Okay, I fixed that, but now it still doesn't work...

const aboutContainer = new ContainerBuilder()
        .setAccentColor(config.general.MessageEmbedItems.color)
        .addTextDisplayComponents((textDisplay: TextDisplayBuilder) => textDisplay.setContent(`# About ${config.app.info.name}`))
        .addTextDisplayComponents((textDisplay: TextDisplayBuilder) => textDisplay.setContent(`${config.app.info.description}`))
        .addSeparatorComponents((separator: SeparatorBuilder) => separator)
        .addTextDisplayComponents((textDisplay: TextDisplayBuilder) => textDisplay.setContent(`# Developers 💻`))
        .addTextDisplayComponents((textDisplay: TextDisplayBuilder) => textDisplay.setContent(`
            ItzExotical (itzexotical)
            Jarvo (jarvo01)
            `),
        )
        .addSeparatorComponents((separator: SeparatorBuilder) => separator)
        .addTextDisplayComponents((textDisplay: TextDisplayBuilder) => textDisplay.setContent(`# Status 🛠️`))
        .addTextDisplayComponents((textDisplay: TextDisplayBuilder) => textDisplay.setContent(`**📦 Version:** v${config.app.version.string}`))
        .addTextDisplayComponents((textDisplay: TextDisplayBuilder) => textDisplay.setContent(`**📡 WebSocket:** ${i.client.ws.ping == -1 ? 'Ping not measured yet, please try again later.' : i.client.ws.ping + ' ms'}`))
        .addTextDisplayComponents((textDisplay: TextDisplayBuilder) => textDisplay.setContent(`**🟢 Status:** All systems operational\n**Uptime:** ${uptimeFormatted}`))
        .addSeparatorComponents((separator: SeparatorBuilder) => separator)
        .addSectionComponents((section: SectionBuilder) =>
            section
                .addTextDisplayComponents(
                    (textDisplay) => textDisplay.setContent(`# Need Help? 🆘`),
                    (textDisplay) => textDisplay.setContent(`Chat with us, and get direct support`),
                )
                .setButtonAccessory((button) =>
                    button.setLabel('Support Server').setStyle(ButtonStyle.Link).setURL(config.general.support.discord.invite.link!),
                ),
        );
        await i.reply({
        components: [aboutContainer],
        flags: MessageFlags.IsComponentsV2,
        });
topaz bluff

Doesn't work in what way? What's the error?

torpid marsh

There is no error...

I'll ask my friend who I am coding with... Maybe he can figure out.

verbal plinth

If I use a package for cross-hosting so that the bot can run on two servers simultaneously, will all guilds still be in the discord.js cache on both servers? Or will half of the guilds be in the cache on one server and the other half on the other?

stable sun

Are you sharding?

verbal plinth

yeah

stable sun

Then you will only get the guilds that belongs to that shard

And shard 0 gets all DMs

verbal plinth

Ah, I thought that might be where my high memory consumption was coming from, but that's not it either.

Are all users stored in the cache by default?

stable sun

Only ones that d.js receives

topaz bluff

You can fetch all members on startup and then the gateway events will keep the cache updated

stable sun

Usually become cached from certain events

stable sun
topaz bluff

Yup....I realized after I said it... dumb

verbal plinth

But does that mean guild.members.cache is empty in startup?

stable sun

Not necessarily

Certain intents may cause certain members to be cached upon ready

Guild presences intent would cause non-offline members to be cached

Guild voice states would cause members in vc to be cached

verbal plinth

But with a 30k member Discord, would all members ever be in the cache at startup?

stable sun

It’s unlikely

What intents do you use?

Maybe if the bot runs long enough to where every member eventually becomes cached by some event

topaz bluff

You can also set a limit on the size of your GuildMemberManager cache to x members or set a cache sweeper to clear it every y amount of time

sharp ginkgoBOT

guide Cache Customization
Sometimes, you would like to be able to customize discord.js's caching behavior in order to reduce memory usage. To this end, discord.js provides you with two ways to do so: 1. Limiting the size of caches. 2. Periodically removing old items from caches. Customization of caching behavior is an advanced topic. It is very easy to introduce errors if your custom cache is not working as expected.

verbal plinth

is GuildMemberManager per guild or global?

steel trail

Per guild

verbal plinth

Is there a way to show me what is currently in the cache?

topaz bluff

Several ways. You can use Collection#map for example to only show the userIDs of members in the cache, or just Collection#toJSON and just print the whole collection itself

But you can look through the Collection class to see all available methods

verbal plinth

So it is advisable to limit the GuildMemberManager to 500. When a voiceStateUpdate comes in, for example, the member is added to the cache so that it can be used, and if 500 more events come, the first one is simply removed again.

Now the question is, if you want to use other members and fetch them, what about the rate limit? Is there a list where you can read everything in detail about the rate limit, which route can be requested how often per time, and so on?

topaz bluff
verbal plinth

I'm just afraid of changing something in makeCache or sweeper, because I'm afraid that I'll hit a rate limit or do something careless in the live bot. Of course, I can't test all the changes on the dev bot, because there isn't much going on in the cache there.

last mango

can i set custom status and activity per guild?

stable sun
robust haven

I would like to ask how i can do a selectmenu in modalbuilder

topaz bluff
sharp ginkgoBOT
robust haven
topaz bluff

o7

robust haven
sharp ginkgoBOT
jolly radish

is there a way to update a specific bot message without showing below it the edited text?

bleak owl

not really, no

jolly radish

wikes. I needed to put 7 rows of buttons inside a container builder so I had to send 2 to fit them and when the first one is edited it leaves a space between them ruining the design

bleak owl

do you not want to have the buttons and container together in one message?

loud quartz

35 buttons won't fit

bleak owl

whoops i didn't see rows lol

loud quartz

32 is max

jolly radish

I need a way to somehow get rid of the first edited. I dont mind the second one

bleak owl

not really possible, sorry

jolly radish

can I send both container builders on the same message?

tardy sable

you should be

also dont want to be rude but doing a calculator command in discord isnt really useful

jolly radish
tardy sable

yh you will probably reach the max amount of components in one message

id say add a page button

topaz bluff

Ya. There's more components there just for the buttons than are allowed in a message. You can't exceed 40 total components, that counts containers and action rows

jolly radish

so it counts 35 buttons + 7 action row + 2 containers?

loud quartz
solar furnace

hi, what's the easiest way to kill the bot with a command

tardy sable

"killing" the bot is not something you want to do

sharp ginkgoBOT
tardy sable
topaz bluff

It's just the opposite of client.login()

Instead of waiting for a missed heartbeat

tardy sable

oh okay

slim stirrup

how make dis bottun in embed ?

wary coral
sharp ginkgoBOT

guide Container
A Container is a layout component which groups its child components inside a visually distinct rounded box with an optional accent color on the left, similar to the message embed look. Unlike embeds, not specifying a color will make the left side of the Container component match the background color. You can mark Container components as spoiler, which blurs all content inside the container. You can use the ContainerBuilder class to easily create a Container component. - a Separator component;...

slim stirrup

How do you do this in code though?

tardy sable

follow the guide above

slim stirrup

dis my embed and button wat need for it

bleak owl

please follow the guide sent above on creating containers and adding buttons inside them

tropic locust

Trying to track down a bug (I think) with components V2. I have small thumbnail images that are fetched from a cdn with url version control https:[//]somecdn.com/media/1asafefgg.jpg?v=1234
It seems to be a hit and miss with fetching the image via the url. Old embeds will display the image, componentsV2 thumbnail will not fetch the image, but it will succeed if the image has already been cached by Discord either by an Embed or by it been uploaded in a normal message.

polar karma

You might have better luck in ddevs, as this seems to be an issue with discord getting it, nothing on the library's side

safe wigeon

Example ```js
const url = https:[//]somecdn.com/media/1asafefgg.jpg?v=1234;
const attachment = new AttachmentBuilder(url, { name: some_name.jpg });

const media = new MediaGalleryBuilder()
.addItems([
new MediaGalleryItemBuilder()
.setURL(attachment://some_name.jpg)
]);
container.addMediaGalleryComponents(media);

reply({ components: [container], files: [attachment], flags: MessageFlags.IsComponentsV2 });

When I've had issues with images not loading, even in normal embeds, first turning it into an attachment has fixed it for me. Worth a try :))

balmy kraken

can you use custom emojis in components v2 markdown text?

update: yes i can

patent epoch

It's not very clear to me how client.cooldowns = new Collection(); in index.js gets passed to the interactionCreate.js file - I think that's where it goes wrong, but not sure at all

crimson gale

client refers to an instance of the Client class, an object with methods (functions) and attributes, if you will
the library uses that client to instantiate all other classes, like Message, ...Interaction etc. and passes a reference to itself to those objects
most classes that discord.js gives you to work with have a .client field that exposes said Client instance so you can easily access it

client.cooldowns = new Collection();

as mentioned in that page, in the command files itself, you can access it via interaction.client
and since that is the same instance, it will also have the cooldowns field you attach to it

const { cooldowns } = interaction.client;
patent epoch

so why am I getting a: ReferenceError: client is not defined

I tripple checked everything in the guide, but might have missed something

crimson gale

because you are trying to reference client in a scope you don't have it defined in

hard to say without seeing what you are working with

patent epoch

exactly what is on the page I linked - I followed all the tutorials step by step, everything worked, up until that point

crimson gale

well, apparently not