#djs-help-v14

78874 messages · Page 4 of 79

vital barn

how do i do this

sharp ginkgoBOT

node --env-file=config
Loads environment variables from a file relative to the current directory, making them available to applications on process.env.

pseudo urchin

any documentation for components v2 or am I not looking correctly 😭 ?

sharp ginkgoBOT
pseudo urchin

ah I see, it seems that my cache is using the old style and not the new one

is this part of the website documentation still up? if I go on incognito or a different browser I get the updated one

rose tangle

use ctrl + f5

pseudo urchin

sweet thanks

hearty adder

what r ideal limits for caching with reactionmanager and reactionusermanager for reaction roles in a server with abt 400 members

rose tangle

that's really not that big

you shouldn't need explicit limits

hearty adder

if i have a bot only for js that server is it unnecessary to put limits on caching

rose tangle

yeah, caching size shouldn't be an issue

it isn't for almost all users

it's only when you really start to scale

hearty adder

should i start caching anything if the server member count hits a higher number

loud quartz

You should not worry about it

Unless you grow to several thousands servers

rose tangle

what we're talking about is limiting or clearing that cache

rose tangle
wary coral

what is the best what to capture a guildScheduledEvent that is recuring getting canceled. Events.GuildScheduledEventUpdate does not seam to fire. when the recuring event gets canceled.

halcyon bison

if you mean the entire event series being cancelled, you're looking for GuildScheduledEventDelete

but if you mean a single event in the series, there isn't an event for that yet
the cancellation of a single event in the series in new enough that no part of it is documented in the api

wary coral
prisma ruin

how would i retrieve a container from a message?

sharp ginkgoBOT
prisma ruin

appreciate it

pseudo urchin
export default {
    data: new SlashCommandBuilder()
        .setName("test")
        .setDescription("test"),

    async execute(interaction: ChatInputCommandInteraction) {
        const container = new ContainerBuilder()

        const text = new TextDisplayBuilder().setContent("Hello World")
        container.addTextDisplayComponents(text)
        
        await interaction.reply({ content: "hello world", components: [ container ], flags:[ MessageFlags.Ephemeral ] })
    }

}

Error: data.components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).

am I supposed to wrap the container in a ComponentBuilder or something?

rose tangle

you're supossed to send the IsComponentsV2 flag as well

sharp ginkgoBOT

dtypes v10: MessageFlags - IsComponentsV2
read more

prisma ruin
rose tangle

yes

pseudo urchin

I am assuming that if I don't send a component v2 and have a flag added, it wouldn't error out?

rose tangle

if you send the cv2 flag you can't send anything except components

so you can't "send the cv2 flag and don't send a component", that'd be an empty message

halcyon bison

unless you were just asking whether you can send v1 components in action rows

pseudo urchin
rose tangle

you can't send nothing

pseudo urchin
rose tangle

it is possible to use v1 components

pseudo urchin
pseudo urchin
rose tangle

it's discord's designed way, yes

not a "limitation" per se

it's how it was planned

since you can do content with text components and embeds (mostly) with containers

pseudo urchin

and pinging works as normal with containers?

rose tangle

as if it was content, yes

sharp ginkgoBOT
pseudo urchin

sweet thanks

prisma ruin
rose tangle

no, you can edit them

that's how embed suppression works after all

prisma ruin
rose tangle no, you can edit them
Type 'MessageFlags.IsComponentsV2' is not assignable to type '`${bigint}` | MessageFlags.SuppressEmbeds | "SuppressEmbeds" | Readonly<BitField<"SuppressEmbeds", MessageFlags.SuppressEmbeds>> | RecursiveReadonlyArray<`${bigint}` | MessageFlags.SuppressEmbeds | "SuppressEmbeds" | Readonly<...>>'.```
rose tangle

and how you can now add cv2 components to a message that previously didn't have them

yes, that's currently a typings issue

it says that it doesn't accept that flag, which isn't accurate in runtime, it'll be fixed in next release

it doesn't say that it's readonly though

prisma ruin

oh, im tripping then, my bad

rose tangle

for now you can ts-ignore that

it'll work in runtime just fine

prisma ruin

will do, thx for helping me out

pseudo urchin
open saddle

Ran npm update and it seems to not update discord 14.18 to the latest. (not really sure on how to "force" or just to get it to update)

little pebble
open saddle
unique tinsel
little pebble
little pebble
open saddle

Yeh, that's what im checking for right now, Currently making a new bot for my company, then i gotta update my global bot cause i think it's still on like... 14.9.0 sweats

unique tinsel
dense saffron

You can't reply to interactions with the new components v2?
Right?

cosmic epoch

can someone send me docs to the components v2 webhook thingy on how to make it

rose tangle

components v2 or webhooks with components v2?

cosmic epoch

webhooks with components v2

rose tangle

just send the flag and withComponents: true

cosmic epoch

no like

cuz i want to implement it i alr have withComponents: true i just need a method on how to create the embed with ocmponents

rose tangle

how to create a webhook?

oh

you can't use embeds and v2 components

if you send the IsV2Components flag you can't send anything else apart from components

content, embeds, polls, stickers, etc

cosmic epoch

so this isnt possible for the itme being?

rose tangle

it is, that's not an embed

it's a container

the source code is even linked there

cosmic epoch

i didnt know what it was so i just assumed its an embed

rose tangle

embeds must have a color unlike that component

and you can check the code there

cosmic epoch

aight tysm

unique shoal

And if you're curious how this message was built, check out the source code!

Imagine reading mmLol

vague echo

Made a kinda guide / turtorial for the new components according to the recetnly most asked questions here on that topic

if you have any questions or advices for me to that topic just ping me^^

thin cosmos

In MessageComponentEmoji, can I do emoji: { name: "<:fluxlike: 1031262536240201748 >" }? Or do I have to use the id field and pass in emoji id 1031262536240201748 in this case?

vague echo
thin cosmos
vague echo
thin cosmos
vague echo
vague echo
rose tangle

what is even a MessageComponentEmoji?

thin cosmos
thin cosmos
bleak owl

that’s not a thing…?

rose tangle

oh, yeah that is in dtypes

bleak owl

nvm then

vague echo

true lol thought he just wanna use a custom emoji in his components

rose tangle

probably for buttons

thin cosmos

Yes

vague echo

ye works in the same way like explained

thin cosmos
rose tangle

yeah that's not how js objects work

and you can't have a link button with an emoji

and no idea why you're stringifying that url when it should be a string already Thonk

there are a couple of cursed things in that picture

vague echo
thin cosmos

that wont work with js objects it should be more like this then

  replyOptions.components = [{
    type: ComponentType.Button,
    style: ButtonStyle.Link,
    emoji: {
      id: '1031262536240201748',
      name: 'fluxlike'
    },
    url: `${tweetUrlFormatted}`
  }];
}```
vague echo
thin cosmos
vague echo

👀

rose tangle

oh, must be missremembering then

thin cosmos
vague echo
thin cosmos

Do I have to do :fluxlike: or just fluxlike works?

rose tangle

Cereal already gave you the code

vague echo
thin cosmos

Okay perfect, thank you @vague echo

vague echo

heart

thin cosmos
vague echo

btw general question, does it make sense to change all embeds to components?

still wondering if discord will remove embeds after we have components so-

rose tangle
tall swift

is there any video explaning how to use the new components?

unique shoal

Not one made by us

raven hearth

what's the recommended method of checking current channel type? for checking if interaction is in direct messages

little pebble
raven hearth
little pebble

They do

uncut quest

Someone remember how to log the request body of a command when you get the DiscordAPIError[50035]: Invalid Form Body error ?

thin cosmos

How can I exactly replicate this but with componentsv2? There will be multiple items in the same embed and also multiple buttons.

snow onyx
uncut quest
rose tangle

but what's the error?

it should tell you specifically what validation failed

uncut quest
DiscordAPIError[50035]: Invalid Form Body
5.options[5].options[3][UNION_TYPE_CHOICES]: Value of field "type" must be one of (3, 4, 5, 6, 7, 8, 9, 10, 11).
    at handleErrors (file:///home/lilly/Desktop/Coding/Lilly%20redo/node_modules/@discordjs/rest/dist/index.mjs:686:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async SequentialHandler.runRequest (file:///home/lilly/Desktop/Coding/Lilly%20redo/node_modules/@discordjs/rest/dist/index.mjs:1087:23)
    at async SequentialHandler.queueRequest (file:///home/lilly/Desktop/Coding/Lilly%20redo/node_modules/@discordjs/rest/dist/index.mjs:918:14)
    at async _REST.request (file:///home/lilly/Desktop/Coding/Lilly%20redo/node_modules/@discordjs/rest/dist/index.mjs:1231:22)
    at async file:///home/lilly/Desktop/Coding/Lilly%20redo/dist/deploy.js:9:5 {
  requestBody: {
    files: undefined,
    json: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object]
    ]
  },
  rawError: {
    message: 'Invalid Form Body',
    code: 50035,
    errors: { '5': [Object] }
  },
  code: 50035,
  status: 400,
  method: 'PUT',
  url: 'https://discord.com/api/v10/applications/775530257645830145/commands'
rose tangle

looks like commands[5]

uncut quest

from start or from end ..

rose tangle

from start? that's how arrays work

uncut quest

they also dont log in the same order than all my commands

snow onyx

lilly... please xD

uncut quest

so 5th command could be technically my 17th on my command list..

rose tangle

I'm pretty sure at least the error description is accurate on the indexing

could log both just in case

snow onyx

just log the 5th array entity before registering

stable sun

Do you load commands asynchronously?

Or in parallel, to be precise

rose tangle

or small footer/author text

-# at most this (-#)

uncut quest

technically my 5th in the array ( knowing that it starts at 0 ) so my 6th command technically is that ..

 LockCommand: {
    name: 'lock',
    description: 'Lock a channel',
    description_localizations: { fr: 'verrouille un canaux de discussion', ja: 'チャンネルをロックする' },
    options: [ [Object], [Object] ],
    default_member_permissions: '0'
  },

doesnt exactly fit the error

even the one before that

rose tangle

pretty sure it's not the 5th in the array, but literally the one at index 5

rose tangle
stable sun
uncut quest

i just said that ..

rose tangle

thought you meant you accessed [6]

rose tangle

or is it random per rest call?

uncut quest

you ask to log ...? no?

rose tangle

well you said your 5th command is your 17th

so log that one

other than that, probably only a good old .find() would help

uncut quest
stable sun

The order changed again?

Nvm

rose tangle

commands.find((cmd) => cmd?.options.find((sub) => sub.type === subcommandType && sub.options.find((subOption) => ![3,4,5,6,7,8,9,10,11].includes(subOption.type))))
I think?

snow onyx

this can only be the Pet, Poll or Settings Command

clear garnet

The error also mentions options[5], so that can help narrow it down to your pet and poll command since those have 6 or more options in them based on the entire log you sent
*And settings command, capyblappy added

thin cosmos
uncut quest
rose tangle

you'll have to ask discord that

stable sun

I usually do util.inspect with infinite depth

rose tangle
stable sun

Although, I initially did this for shapeshift

uncut quest

ah... yeah ... my bad

so my 5th in the error was my 10th in my log ...

how... helpfull OMEGAlul

thank you nontheless ❤️

cosmic epoch

so

am i the only one that cant open the source code mts

uncut quest
cosmic epoch

i need more info on the components v2

uncut quest

thats not what i asked

rose tangle

just open it in notepad

cosmic epoch

thx

uncut quest

Someone has a guide or a bot example with a user install command made with djs ?

sharp ginkgoBOT
uncut quest

well yeah that part is done, i was wondering if theres more than that

steel trail

Not really. Deploy and handle the interactionCreate as usual, just not assuming it‘s in a guild or you got access to the channel to send

Well, maybe you want contexts: [..] too

uncut quest

alright , cuz this was happening so i was wondering if i was missing something important

steel trail

Does your interactionCreate maybe check inCachedGuild()?

uncut quest

oh right it does

if (!interaction.inCachedGuild()) {
    return;
}```

i guess i need to remove that check right

i guess i will need to debug deeper than expected now , thanks

cuz my interaction goes immediately in <cached>

so this is happening :
Argument of type 'ChatInputCommandInteraction<CacheType>' is not assignable to parameter of type 'ChatInputCommandInteraction<"cached">

stable sun

Yea, can’t assume that it’s cached anymore

uncut quest

imma blame crawl's framework for the moment

stable sun

Was thinking abt adding a field that specifies whether the interaction must be cached, but it might not translate to TS well

uncut quest

theres 2 type , cached and the other was what , raw ?

little pebble

Yes

uncut quest

holy saint mary joseph

oh , it was simpler than expected

ebon belfry

Does anyone happen to have any suggestions what I could do regarding this one? :)

uncut quest
stable sun

It’s defined the same way, except that you can’t modify the Array

ebon belfry

I'm not sure, I wrote this code a long time ago and was directed to use _hoistedOptions, maybe that was before data existed

The data field would definitely be suitable, thank you for your advice!

coarse storm

I see there is no .from() method for the new component types. does that mean that when editing the message, I will have to read and update the json itself?

polar flare

Hello does anyone know what the rate limit for .setActivity() is for RPC

nimble otter
hushed mirage

how to make this status in your discord bot?

zenith violet
hushed mirage
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

zenith violet

If its not documented we dont support it

unique shoal

Making your bot appear as on mobile is technically not in line with Discord's guidelines, no

hushed mirage

Okay

nimble otter
worthy sail

where do i put the isComponentsV2 flag?

nimble otter
nimble otter
worthy sail

thnx

worthy sail
nimble otter

Flags isn't really a thing in this case, you have to import it, and it's MessageFlags

nimble otter
unique shoal
nimble otter

well, looking at the docs i don't see anything that declares this as a requirement, just a guide. some libs even provide this option natively. doesn't seem like anything "against discord's guidelines", just a way to indicate good practices (+ the device is still the lib you are using)

and given the fact that these fields are free for you to insert literally any string, since you can write your own lib, this has no relation to any risk

sharp ginkgoBOT

class ContainerBuilder discord.js@14.19.1
A builder that creates API-compatible JSON data for a container.

grave pond
                    const resultsContainer = new ContainerBuilder({
                        components: [
                            {
                                type: ComponentType.TextDisplay,
                                content: `${raceResults}`,
                            },
                            {
                                type: ComponentType.TextDisplay,
                                content: `Race ID: ${race.raceId}`,
                            },
                            {
                                type: ComponentType.Section,
                                accessory: {
                                    media: {
                                        url: message.guild.iconURL(),
                                        type: ComponentType.Thumbnail,
                                    }
                                }
                            },
                        ],
                    });

im getting serialized error

crimson gale

that's not saying a whole lot

grave pond

nvm im using embeds containers are very confusing

umbral jetty

So far I haven't understood how to use this ContainerBuilder, can someone explain?

gritty lily

I'm guessing it isn't possible to have 2 buttons as accessories for 1 section

Nvm, I thought it said addButtonAccessory hence why I asked, realised it said set so obviously only 1.

barren nacelle
boreal anchor

what function is used for collection button responses from container buttons

boreal anchor
vital raven

Have you updated to the latest version?

boreal anchor

14.19.1

steel trail

My bad

boreal anchor
steel trail
boreal anchor
steel trail

Yeah, don’t use componentType restriction for now

boreal anchor
steel trail

You didn’t await the reply

So guess your issue is unrelated to the mentioned bug after all

boreal anchor

sorry for troubling you

wild thunder

Trying out the new V2 components, and I have optional flow which is giving me a type problem:

    await interaction.deferReply();

    if (!member) {
      return await interaction.editReply({
        content: 'Did not obtain a Member instance for Yourself',
      });
    }

    await interaction.editReply({
      // Type 'MessageFlags.IsComponentsV2' is not assignable to type
      // 'BitFieldResolvable<"SuppressEmbeds", MessageFlags.SuppressEmbeds> | undefined'.
      flags: MessageFlags.IsComponentsV2,
      components: [container],
    });
little pebble
orchid moth

Does anyone know why it’s not catching errors here? The catch block isn’t catching the error

      try {
        commandData.execute.command(interaction as Discord.ChatInputCommandInteraction, { subcommand: commandNameData.subcommand, group: commandNameData.group });
      } catch (error) {
        logger.error('There was an error while executing a command:');
        logger.error(error);

        return interaction.error('Komut çalıştırılırken bir hata oluştu.');
      }
steel trail

Because you don’t await the promise probably

And there is no error method on ChatInputCommandInteraction Thonk

orchid moth
shadow pier
orchid moth

to reduce the boilerplate

shadow pier
orchid moth

blobreachReverse

now that I look at it, doing interaction[(interaction.deferred || interaction.replied) ? 'followUp' : 'reply'] actually makes more sense

shadow pier

what flag is 1 << 15, just use Enums

stable dagger
orchid moth

that's why the IsComponentsV2 enum isn't there yet

sharp ginkgoBOT
shadow pier

@orchid moth MessageFlags.IsComponentsV2 is there

orchid moth

I haven't updated to the new version yet

shadow pier
shadow pier
polar karma

the docs are out for 14.19.x wdym

orchid moth
shadow pier

unless you are talking about the guide

orchid moth

I mean, im talking about the guide ofc

I wouldn't even be able to use components v2 right now without any docs from discord anyway

neon stump
        return ctx.sendMessage({
            components: [
                new ContainerBuilder().addSectionComponents(
                    new SectionBuilder()
                        .addTextDisplayComponents(new TextDisplayBuilder().setContent(ctx.locale('cmd.premium.content')))
                        .setButtonAccessory(
                            new ButtonBuilder()
                                .setLabel(ctx.locale('premium.support'))
                                .setStyle(ButtonStyle.Premium)
                                .setSKUId(client.env.SKU)
                        ),
                ),
            ],
            flags: MessageFlags.IsComponentsV2,
        });

Uncaught Exception: RangeError: Premium buttons cannot have a custom id, label, URL, or emoji.

polar karma

wdym "ofc" you said docs, they are two very different things. please be mindful of the words you use

agile nest

can i edit a button inside of a container

halcyon bison
shadow pier
neon stump
orchid moth
orchid moth

I'm not in a hurry anyway

shadow pier

People come in this channel to give help and recieve help anyways, you wouldn't be wasting anyone's time kekw

steel trail
agile nest
orchid moth
steel trail
agile nest
orchid moth
steel trail
agile nest

never changed button from actionrow

message is the one im trying to edit button on right?

wait but how do i get first message

shadow pier
orchid moth

I had no idea it contained text CAUGHT

steel trail
agile nest
feral thunder

What does external mean here? It cannot be assigned as a property so how to add a reason when editing a soundboard sound?

steel trail
steel trail

In this case discord-api-types it doesn’t make sense… lemme check that

sharp ginkgoBOT

method SoundboardSound#edit() discord.js@14.19.1
Edits this soundboard sound.


// Update the name of a soundboard sound
soundboardSound.edit({ name: 'new name' })
  .then(sound => console.log(`Updated the name of the soundboard sound to ${sound.name}`))
  .catch(console.error);

feral thunder
little pebble

Yeah, it's not in the typings, will be fixed in the next patch release

steel trail
feral thunder

Alright, thanks

topaz bluff
runic wren

I like that you can tag a role and get pinged inside TextDisplayBuilder

half rover

can we use select menus in containers?

vital raven
half rover

anyone tried before cuz i didn't see anywhere

vital raven

Try it, you'll be first

steel trail
half rover

can you send me just one example

sharp ginkgoBOT
steel trail

In there do the same thing you‘d do for ActionRows outside of a container

shadow pier

what is default value of allowedMentions

polar karma
shadow pier
polar karma

did you try it

shadow pier
dapper cave

can you use ephemeral and componentsv2?

rose tangle

yes

dapper cave

how the cuz I cant get it working am I tweaking???

shadow pier
dapper cave

oh its | im cooked

weak karma

hey so i made couple of slash commands and they dont seem to be registering anyone know why. I got this error earlier but was able to register them after Could not register commands! SocketError: other side closed but they dont show up

dapper cave

my dumbahh did [MessageFlags.Ephemeral, MessageFlags.IsComponentsV2]

shadow pier
steel trail
raven hearth
shadow pier
solid burrow

is it possible to perform a channel search for messages using discord.js like from:ronykax in:#general?

little pebble
raven hearth
steel trail
raven hearth

how can a interaction not be in a channel

shadow pier
steel trail
dapper cave
zenith violet
steel trail
zenith violet

and should not happen when registering

unless you register them every time your bot start, which you shouldnt

shadow pier
weak karma
steel trail
zenith violet
shadow pier
steel trail

Because now you‘re deactivating all mentions (since you didn’t pass any).

shadow pier
shadow pier

can bots forward messages yet?

sharp ginkgoBOT
shadow pier
steel trail

It‘s a Message. So yes

compact swan

what is this rightclick context menu stuff called? and how do I achieve something like this using djs?
to then for example read out the content of a message wihch got rightclicked

sharp ginkgoBOT

guide Other Interactions: Context Menus
read more

compact swan

oh it is a context menu lol.
Thanks

shadow pier
steel trail

oh so how would that work if Message.Ephemeral was set?

crimson gale

-# potatodetective hi noulith

weak karma
unkempt quarry

What is manageexpressions called

I wanna check that in role perms ManageExpressions this isn’t working

sharp ginkgoBOT
steel trail
unkempt quarry
nimble otter
barren nacelle Batty what is the **buildStrategy**?

basically, it's the function that customizes how the websocket should behave/initialize. and the init i used is exactly the same as the one used internally, except it changes how the browser identifier is defined (being Discord iOS instead of @discordjs/ws x.x.x. but the device field is kept as @discord/ws...)

covert vine

why so many channel types that should have a name attr dont?

zenith violet

DMChannels dont have names

covert vine

what about the other ones?

zenith violet

They do

covert vine

why does it say it doesnt

zenith violet

It doesnt

Read the last line

covert vine

yes, but the first line

zenith violet

thats because your variable is typed as that

it can be any of those

but a DMChannel doesnt have a name

so it'll complain

distant estuary

how disable (This interaction failed) ?

zenith violet
distant estuary

for buttons

sharp ginkgoBOT

method ButtonInteraction#update() discord.js@14.19.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);

distant estuary

ty

soft lance

Why does this fail?

polar karma
soft lance

and the embedbuilder is from discordjs, so I think it goes here

nimble otter
soft lance
nimble otter
soft lance

okay

nimble otter
minor maple

helloo, i don't know why i have this error can u help me plss

nimble otter
minor maple
crimson snow

Is there some sort of inline on TextDisplayBuilder()?
So that you can but them side by side instead of on top of each other

nimble otter
compact swan
rose tangle

both create a interaction, yes

whether you can use one file or need multiple, depends on your setup

djs doesn't handle that part, you program that

compact swan

okay that confirms part of it, how can I deploy both then?

rose tangle

they're just commands with a different type

you deploy them the same way

and can deploy them alongside slash commands

and should, actually

compact swan

no like i mean do i make two entries and one has type: 3 in it?

clear garnet

If one of those entries is a slash command, then yea

You follow the same steps you would when deploying slash commands, except for the command's data, you're constructing a context menu command rather than a slash command

compact swan

alr thanks

neon crag

Hi, do you know how to shrink the embed?
To have it like that

And not like that
with the components V2

rose tangle

what?

maybe you're mistaking embeds with containers?

you can't have embeds when using v2 components

neon crag

yes container mb

halcyon bison

regardless, there is no means of controlling how discord renders anything

neon crag

it's much smaller here

rose tangle

what is much smaller?

neon crag

the length

burnt quartz

i think i found a bug, but unsure if it is a bug with discord.js or with discord itself

// normal message

const messageSent = await message.reply({
  content: "test",
  allowedMentions: { parse: ["users"] }
})

await messageSent.edit({
  content: "test test",
  allowedMentions: { parse: ["users"] }
})

// components v2

const messageSentComponents = await message.reply({
  components: [
    new Discord.TextDisplayBuilder().setContent("test")
  ],
  allowedMentions: { parse: ["users"] },
  flags: Discord.MessageFlags.IsComponentsV2
})

await messageSentComponents.edit({
  components: [
    new Discord.TextDisplayBuilder().setContent("test test")
  ],
  allowedMentions: { parse: ["users"] },
  flags: Discord.MessageFlags.IsComponentsV2
})```

if you send a message and then edit the message, when using `allowedMentions: { parse: ["users"] `, it is not meant to ping the user it is replying to.
when using components v2, when editing the message, it seems to edit it to ping the user.
could someone else try this and see if it happens for them too?

both messages should not be pinging the user its replying to
halcyon bison

just curious since there was a bug relating to allowedMentions fixed in the latest version (14.19.2), what version did you test this on?
if not 14.19.2, does the issue persist after updating?

burnt quartz

14.19.1

let me try, didnt notice the update

burnt quartz

it now pings on the first message, then edits it to have no ping

behaviour has completely changed in 14.19.2

it now pings by default to replied user, when replied user is not specified

first bot is on 14.19.1, second on 14.19.2

assuming this is a bug, ill make a bug report

halcyon bison

I'm actually unable to reproduce the new behavior on 14.19.2
I can reproduce the first behavior on 14.19.1, but if not reproducible after fixing the previous bug with allowedMentions, I'd lean towards it being fixed

burnt quartz

even when running that exact code i sent?

halcyon bison

yes

rose tangle

can you show your client constructor?

burnt quartz
globalThis.client = new Discord.Client({
  shards: "auto",
  intents: [
    "Guilds",
    "GuildMembers",
    "GuildBans",
    "GuildEmojisAndStickers",
    // "GuildIntegrations",
    // "GuildWebhooks",
    "GuildInvites",
    "GuildVoiceStates",
    "GuildPresences",
    "GuildMessages",
    "GuildMessageReactions",
    "GuildMessageTyping",
    "DirectMessages",
    // "DirectMessageReactions",
    // "DirectMessageTyping",
    "MessageContent",
    // "GuildScheduledEvents",
  ].map(e => Discord.GatewayIntentBits[e]),
  partials: [
    "User",
    "Channel",
    "GuildMember",
    "Message",
    "Reaction",
    // "GuildScheduledEvent",
    "ThreadMember"
  ].map(e => Discord.Partials[e])
})
rose tangle

hmm looks fine

though your maps are unnecessary

but nothing that should change the mentions

could reinstall just in case ig

barren nacelle
burnt quartz

still happens after a reinstall npm r discord.js npm i discord.js

ill do some more testing including a blank bot to see what happens

halcyon bison
burnt quartz

ok cool thanks

i was worried somehow my bot was breaking something and i had to spend hours digging through it to figure it out lol

idle comet

hey there I'm updating and I wanted to see if this was the best/correct way to get button components off interaction.message.components

let componentRow = ActionRowBuilder.from(interaction.message.components[i] as ActionRow<MessageActionRowComponent>)

// pre discord.js 14.19.2
// let componentRow = interaction.message.components[i];
wary coral
burnt quartz
tardy sable

why is it for an message delete event and it had an attachment it most of the time successfully adds the attachments and sometimes its invalid like this

halcyon bison
idle comet hey there I'm updating and I wanted to see if this was the best/correct way to g...

gonna be honest, I'm a little confused by both of your code snippets

  • all of a message's components will always be in <Message>.components, regardless of components v2 or not
  • at no point should you be modifying existing data from the api, so even before components v2, you should've been creating a new builder (assuming you use the builders)
  • neither of you are getting a button component specifically, but if you are just looking to get the row the button is in, sure that's fine
burnt quartz
tardy sable
burnt quartz

race condition?

clear garnet
tardy sable
burnt quartz

no im saying its a race condition. thats why it sometimes works and sometimes doesnt work

tardy sable
clear garnet

Yes, nothing you can do about that. Discord doesn't promise how long an attachment will persist after the message it resides on is deleted

tardy sable

thanks for clarifying

also i heard about proxy urls being able to fix this, is this true?

halcyon bison
clear garnet
halcyon bison
tardy sable

the only way is to save the attachment somewhere before its deleted then?

burnt quartz

the only way to get around it, which you definitely should NOT do, is manually download every attachment so you have a copy of it when the original message is sent

unique shoal
burnt quartz
tardy sable
unique shoal

This is exactly why Discord attachment URLs expire

tardy sable

lol i see

how do bigger bots always attach attachments then? is it cuz they use webhooks or something?

unique shoal
idle comet
unique shoal

This is a typeguarding issue, as FileComponent is a valid TopLevelComponent but would not have child components

If you check the type of the componentRow first to confirm its an ActionRow, this should address it

idle comet
wary coral

No, typeguard was not need for components v2 to work so it was left out. would be a nice qulity of live tho

Think about making an issue for it as a feture request

hexed marsh

If there's an option to do interaction.awaitModalReply is there a way we can easily capture a button interaction event without having to create an explicit event listener for every button click event?

idle comet

ah yeah it would make sense for this one imo
ty guys! 😄

halcyon bison
sharp ginkgoBOT

documentation suggestion for @hexed marsh:
method Message#awaitMessageComponent() discord.js@14.19.1
Collects a single component interaction that passes the filter. The Promise will reject if the time expires.


// Collect a message component interaction
const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
message.awaitMessageComponent({ filter, time: 15_000 })
  .then(interaction => console.log(`${interaction.customId} was clicked!`))
  .catch(console.error);

guide suggestion for @hexed marsh:
guide Message Components: Component interactions - Component collectors
read more

hexed marsh

NICE!

manic stone

How to I set a timer? Like if someone uses a command they have to wait 15 minutes to do it again

something like this but for 15 mintes

sharp ginkgoBOT
unique shoal

Otherwise, cooldowns are covered in our guide

sharp ginkgoBOT
manic stone

thanks

toxic moat
(container.components![2] as TextDisplayComponent) = (new TextDisplayBuilder().setContent("**Amount to deposit: **\n> " + inlineCode(`${amount}$`)))```
am i missing something obvious?
`Type 'TextDisplayBuilder' is missing the following properties from type 'TextDisplayComponent': content, id, type, equals`
unique shoal

A builder is not a component

Where has container.components come from? They generally arent designed to be modified directly like this

You can try calling toJSON on the builder to do this

compact swan

const message = interaction.targetMessage;

console.log(message);

-> undefined

am I missing something?

unique shoal

targetMessage is a getter, if you have message caching disabled or for other reason it isnt cached, this can happen

compact swan
makeCache: Options.cacheWithLimits({
                MessageManager: {
                    maxSize: 100,
                },
                GuildMemberManager: {
                    maxSize: 50,
                    keepOverLimit: (member) => member.id === member.client.user.id,
                },
                UserManager: {
                    maxSize: 100,
                },
            }),
            sweepers: {
                ...Options.DefaultSweeperSettings,
                messages: {
                    lifetime: 3_600,
                    interval: 3_600 * 3,
                },
                users: {
                    interval: 3_600,
                    filter: () => (user) => user.id !== user.client.user.id,
                },
            },

?

unique shoal

Hmm, though it should always arrive with the interaction

Can you log interaction.options directly

That is your client, not the interaction

Think we found the problem

compact swan

aha omg thanks lol
i was passing my client first then interaction, but in the command i was using interaction first

zealous bison
unique shoal

Discord native emojis I think, the unique comes through as the id

zealous bison

emoj is an instance of GuildEmoji

i wanted to know if there is any case in which a server emoji can be null

unique shoal

I mean, if the docs say its nullable there must be, at least according to Discord

Discord docs say "can be null only in reaction emoji objects"

toxic moat
unique shoal

Yeah - much like embeds, the component structure you receive is intended to be read only. Modifying it invalidates the cache

toxic moat

thought i was already able to as i assigned it to my container obj

unique shoal

I mean it is editable, but you cant assign a builder to it

Its more like a raw JSON component

toxic moat
unique shoal

no idea

toxic moat
unique shoal

A ContainerComponent has neither of those...

sharp ginkgoBOT
unique shoal

data.content

actually wait idk

Again these arent meant to be edited at all

toxic moat

im trynna edit a message with a edited component that i get from another message, am i not able to do that?

i could just make a loop but thatd make my code slower if i can just change that directly

toxic moat
toxic moat

actually no, it doesnt work like that, typescript just isnt throwing a syntax error

gentle cargo

Does setDefaultMemberPermissions(permissionflagbits) hide the command from people without the permission

unique shoal

Yeah

gentle cargo

What about for role equivalent is there like a setDefaultMemberRole

Or do I have to make the command check for the user role after the execution

burnt pilot

DiscordAPIError[50035]: Invalid Form Body
data.components[0].accessory.emoji[MODEL_TYPE_CONVERT]: Expected an object/dictionary. Promise {

Can someone help me with this?

 const sections = new SectionBuilder({
        components: [new TextDisplayBuilder({
            content: `## Sistema de Vendas\n- Status Vendas: ${statusvenda}`,
        })],
        accessory: {
            type: ComponentType.Button,
            custom_id: 'vendastoggle',
            label: 'Alterar Status',
            style: 2,
            emoji: client.db.General.get('ConfigGeral.Vendas.Status') == false ? ":desligar:" : ":Ligado:"
        }
    })
stable sun

emoji: { id: "…", name: "…" }

burnt pilot

ah oh yes true thank you

unique shoal
gentle cargo

just like permissionflagbits

unique shoal

Not with the bot API, it operates only on permissions

Modifying role configuration requires an Oauth2 grant

Otherwise - yes, this is what changing server settings will do

hazy crypt

why does a button interaction from components2 have no ButtonInteraction.component?

unique shoal

Works for me using both ActionRow buttons and Section accessory buttons

hazy crypt
tribal warren

Hey!
I'm pretty sure it's impossible, but I'm asking just in case I missed something.
Is it possible to add a field to upload a file in a modal?

polar karma

No

snow onyx
half rover

oh got it. im wondering when we able to use select menus in modals too

btw it would be amazing if we could ensure that the sizes of these select menus fit exactly into the container

or as much as the length of the embeds

zenith violet

those are questions for discord

half rover

i wish we can manage that but when :D

unique shoal

Never

signal jewel
tame eagle
const container = new ContainerBuilder({ components: interaction.message.components[0].components })
const section = container.components.find(e => { return e.data.data.id === 144 })
const accessory_btn = new ButtonBuilder()
    .setEmoji(stringEmoji)
    .setDisabled(true)
    .setStyle(ButtonStyle.Secondary)
    .setCustomId("0")
section.setButtonAccessory(accessory_btn)
await interaction.update({ components: [container] })
Error: Expected a string primitive
    at _StringValidator.handle (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2615:70)
    at _StringValidator.parse (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
    at TextDisplayBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:1708:33)
    at C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:2169:64
    at Array.map (<anonymous>)
    at SectionBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:2169:35)
    at C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:1871:64
    at Array.map (<anonymous>)
    at ContainerBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:1871:35)
    at C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\discord.js\src\structures\MessagePayload.js:151:46 {validator: 's.string()', given: undefined, stack: 'Error: Expected a string primitive
    at _St…js\\src\\structures\\MessagePayload.js:151:46', message: 'Expected a string primitive'}
keen widget

Can someone help me out, what am I doing wrong here with the new Container component?

const container = new ContainerBuilder();
container.addMediaGalleryComponents((gallery) =>
    gallery.addItems((item) =>
        item.setURL("https://...")
    )
);
container.addTextDisplayComponents((textDisplay) => textDisplay.setContent("Hello World"));

await channel.send({
    components: [container]
});
unique shoal

Not setting the flag

keen widget

Oh is there a flag I need to set on the client?

loud quartz

On the client? No

In the send

The components v2 flag

keen widget

Ah, perfect thank you

signal jewel
balmy kraken

at this line const command = interaction.client.commands.get(interaction.commandName) it throws an error saying that interaction.client.commands is undefined, even though thats how it is in the tutorial

unique shoal

Its like that in the tutorial if you define it in the earlier steps of the tutorial

balmy kraken
unique shoal

maybe

balmy kraken

thats not possible, this part appears at the end of my bots startup when all commands are already registered

its only initializing the interaction listener

unique shoal

Can you share your code? I cant confirm otherwise

balmy kraken

sure, sec

the thing on pastebin is my extended client that has all methods for using the bot, deploying listeners happens in start()

unique shoal

Well you define Bot.commands, but at no point do you define client.commands

You dont seem to be following our tutorial

Which is fine, but some aspects wont work the same as you're discovering

balmy kraken

this.client.commands then?

unique shoal

Uhh, maybe, if this is bound to your event listeners

It doesnt appear to be

Im not sure exactly what this Bot class achieves

How would you access it from within a command?

This class doesnt extend client, it has a client as a child property

balmy kraken

yeah the naming is unfortunate

i made it just to group all of bot startup code in one place, for my own convenience

unique shoal

Well your commands are attached to the Bot class and not client, so its up to you to either move them, or provide access to get one from Bot

balmy kraken
unique shoal

Yeah I think I misunderstood what you meant before, thats right

gentle cargo
snow onyx

yup

sharp ginkgoBOT
balmy kraken

what parameters does the interaction.respond() method take, in context of returning a choice for autocomplete?

docs say ApplicationCommandOptionChoiceData but i cannot tell what it is

sharp ginkgoBOT

method AutocompleteInteraction#respond() discord.js@14.19.1
Sends results for the autocomplete of this interaction.


// respond to autocomplete interaction
interaction.respond([
 {
   name: 'Option 1',
   value: 'option1',
 },
])
 .then(() => console.log('Successfully responded to the autocomplete interaction'))
 .catch(console.error);

unique shoal

array of names and values

gentle cargo

Also if I just put like
Try:
--code
Catch:
Return

And it gets an error will it say this interaction failed or will it do "this application is thinking" forever

unique shoal

If you successfully defer and then error later it will be thinking forever

If youre unable to defer/respond at all, it will fail

gentle cargo

So if I only put a return it will fail?

unique shoal

It isnt that simple

It all depends on what has or hasnt been successfully executed before the error

signal jewel

for permissionOverwrites.edit, does setting, let's say SendMessages: null set it to what it originally was?

context is for a lockdown - set it to false on lockdown, then to null when lifting the lockdown

sharp ginkgoBOT

documentation suggestion for @signal jewel:
typealias PermissionOverwriteOptions discord.js@14.19.1
An object mapping permission flags to true (enabled), null (unset) or false (disabled).{
'SendMessages': true,
'EmbedLinks': null,
'AttachFiles': false,
}

agile viper

what's wrong here?

const {
  ButtonBuilder,
  ButtonStyle,
  ContainerBuilder,
  TextDisplayBuilder,
  SeparatorBuilder,
  ActionRowBuilder
} = require('discord.js');

module.exports = {
  name: 'inscribir',
  aliases: ['ins'],
  args: false,
  run: async (message, client, args) => {
    // Texto principal
    const text = new TextDisplayBuilder()
      .setContent('**Inscripciones abiertas**\n¡Ya puedes inscribirte al evento!');

    // Separador visual
    const separator = new SeparatorBuilder();

    // Botón en un ActionRow
    const button = new ButtonBuilder()
      .setCustomId('inscribir')
      .setLabel('Inscribirme')
      .setStyle(ButtonStyle.Primary);

    const actionRow = new ActionRowBuilder().addComponents(button);

    // ContainerBuilder con los componentes correctos
    const container = new ContainerBuilder()
      .addTextDisplayComponents(text)
      .addSeparatorComponents(separator)
      .addActionRowComponents(actionRow);

    await message.channel.send({
      components: [container.toJSON()]
    });
  }
};
agile viper

only works with interaction?

dense jackal

and I think its not needed to use .toJSON() for your container, just container is enough

dense jackal
sharp ginkgoBOT
agile viper
sharp ginkgoBOT
agile viper
dense jackal

no not really

why did you remove the components:

boreal anchor

how can i remove buttons from a container by editing the message?

dense jackal

so if you look at the JSON body of your message, you should see the id field with the value you can use to identify and modify the component

boreal anchor
dense jackal
covert vine

where do i get the channels of a CategoryChannel

sharp ginkgoBOT
covert vine

right i looked into that object and havent found anything in it

snow onyx

its literally just categorychannel.children.cache - returns a collection of channels

covert vine

im so dumb

balmy kraken

how can I constrain the possible choices in a command option only to the choices offered by autocompletion?

snow onyx

You cant, a user can always submit the currently entered text

radiant epoch
ConnectTimeoutError: Connect Timeout Error (attempted address: discord.com:443, timeout: 10000ms)
    at onConnectTimeout (/home/container/kaeru/node_modules/@discordjs/rest/node_modules/undici/lib/core/connect.js:237:24)
    at Immediate._onImmediate (/home/container/kaeru/node_modules/@discordjs/rest/node_modules/undici/lib/core/connect.js:206:11)
    at process.processImmediate (node:internal/timers:478:21) {
  code: 'UND_ERR_CONNECT_TIMEOUT'
}

What the hell is this error

First time seeing it

related to me okay

umbral jetty
hoary path

hello :) i cannot get my discord.js bot to stop pinging me when i reply, i have changed my client constructor to this.client = new Client({ intents, allowedMentions: { repliedUser: false } }); and have even tried adding allowedMentions to my replies but it won't stop pinging me whenever it replies, how can i stop it from pinging me (djs version: ^14.19.2)

misty pilot
sharp ginkgoBOT

tag suggestion for @radiant epoch:

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.
obtuse laurel

I'm posting this command to discord:

new SlashCommandBuilder()
  .setName(this.name)
  .setDescription(this.description)
  .setContexts(
    InteractionContextType.Guild,
    InteractionContextType.BotDM,
    InteractionContextType.PrivateChannel
  )
  .setIntegrationTypes(
    ApplicationIntegrationType.GuildInstall,
    ApplicationIntegrationType.UserInstall
  )
  .addSubcommand((subcommand) =>
    subcommand
      .setName("server")
      .setDescription(
        "Run this as a server-wide event and have multiple people win the event."
      )
      .addIntegerOption((option) =>
        option
          .setName("max_wins")
          .setDescription("How many people can win the event.")
      )
  )
  .addSubcommand((subcommand) =>
    subcommand
      .setName("personal")
      .setDescription("Create a game only you can participate in.")
      .addBooleanOption(ephemeralOption)
  )

It keeps erroring:

2025-04-29 17:37:26 - ERROR - 1.options[0][TAG_FIELD_MISSING]: Field "type" is required to determine the model type.
2025-04-29 17:37:26 - ERROR - 1.options[1][TAG_FIELD_MISSING]: Field "type" is required to determine the model type.

When I remove both of the subcommands, it works fine. Also tried removing the max_wins option from the first subcommand and it still showed an error for that subcommand. I don't see where I have to put a type for a subcommand.

balmy kraken

can i put custom discord emojis in autosuggested command options?

hoary path

ahh, alright, I'll downgrade to 14.19.1 for now then

burnt quartz

its broken in all 14.19 versions

hoary path

then what should I downgrade to?

burnt quartz
snow onyx

14.18.x but no components v2 then

hoary path

alright, I don't think I have used components v2 ever, so it'll be alright

snow onyx

or keep the version and use REST calls

burnt quartz
proud arrow

This will be fixed in the next release

burnt quartz

its because of this i think

proud arrow

Yes

burnt quartz

idk why it was changed, i changed it back to that and it seems to work fine

proud arrow

This was done fix the previous bug which in turn caused another issue

burnt quartz

this is an inbetween change i believe. the stuff after the // compomponents v2 comment was not there in 14.19.1

so i think it was fixed, then changed again which broke it

because this is what the pull request change shows. it doesnt have the components v2 stuff since that was added, then changed again

idk im just guessing i may be wrong

proud arrow

Yes, I believe the above changes will be what ends up being again. It was simplified thinking only the message by client should have allowed_mentions as setting it for others (message_refrence) produced error. But we didn't account for message reply where this.isMessage was referencing the replied message causing the current issue

vestal sun

i have a question to an <message>.createMessageComponentCollector(...)
on the <collector>.on("collect") - that happens when someone clicks on the message component (in my case a button) right ?
so i could do something like

<collector>.on("collect", interaction => interaction.followup("..."))

?

minor marten

Yes, but followUp only works after replying first.

coral hollow

Sure this is only a quick question.

coral hollow

How do i remove how my bot is addable?

vestal sun

that seems more like a discord question then a discordjs question in #useful-servers the last server there you might find an answer

coral hollow

Kk Thank You

sharp inlet

Hi there! I am trying to use components v2 and I am getting a very absurd error:

Code: ```ts
const container = new ContainerBuilder();
const header = new TextDisplayBuilder().setContent(
[
# ${name},
'- Created by Lunasa',
'This error tends to occur when things are silly.',
'## Fix',
].join('\n'),
);

    container.addTextDisplayComponents(header);
    const fix = new TextDisplayBuilder().setContent(
        'The fix for this is very simple. You just gotta download the attached file and boom!',
    );

    const section = new SectionBuilder()
        .addTextDisplayComponents(fix);

    container.addSectionComponents(section);

    container.addSeparatorComponents(separator => separator.setSpacing(SeparatorSpacingSize.Large));

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

Error:

error: Received one or more errors
 errors: [
  {
    "name": "Error",
    "validator": "s.instance(V)",
    "message": "Expected"
  },
  {
    "name": "Error",
    "validator": "s.instance(V)",
    "message": "Expected"
  }
]

      at new BaseError (1:23)
      at new CombinedError (D:\Development\terra\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1845:5)
      at handle (D:\Development\terra\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1965:23)
      at parse (D:\Development\terra\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
      at toJSON (D:\Development\terra\node_modules\@discordjs\builders\dist\index.js:2170:37)
      at map (1:11)
      at toJSON (D:\Development\terra\node_modules\@discordjs\builders\dist\index.js:1871:35)
      at map (1:11)
      at resolveBody (D:\Development\terra\node_modules\discord.js\src\structures\MessagePayload.js:150:49)
      at D:\Development\terra\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:192:56
wary coral
sharp inlet

bruh, well thanks

wary coral

np

rose tangle
hot marten

Hello, getting this error when using MessageFlags.IsComponentsV2, 1 << 15 works perfectly fine, anyone knows a solution?

Edit: Code above is return await interaction.editReply({

rose tangle

you need to update to 14.19.2

covert vine
let meowceptionChannel = await client.channels.fetch("1364348815095763047");
if (meowceptionChannel.type !== ChannelType.GuildCategory) {
    return;
}

let meowCeptionJSON = {};
for (let entry of meowceptionChannel.children.cache) {
    let channel = entry[1];
    meowCeptionJSON[channel.url] = 0;
};
interaction.reply(JSON.stringify(meowCeptionJSON));
``` i am trying to collect all ids of channels but it doesnt work, i am probably going to do this manually but i really wonder why it doesnt work
it retrieves the id of the channel it sent its first message in only
rose tangle

define "doesn't work"

what does it actually reply (show)? does it error?

covert vine

it retrieves the id of the channel it sent its first message in only

which is weird because it has no relation to it??? maybe it can only see that one channel
oh wait, cached channels....
it doesnt have the other channels cacged

snow onyx

do you not have the Guilds intent enabled or do you overwrite the caches?

covert vine
covert vine
rose tangle

that's a really bad idea

Guilds is the only one that's "important", at least if you want to rely on caches

native plank

Hi, how can we send an ephemeral and compnentV2 message ?

sharp ginkgoBOT

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
crisp finch

If I have this code;

const reason = await this.getReasonViaModal(interaction);
        
const content = // irrelevant, but basically an embed

const response = await reason.reply({
    content,
    withResponse: true,
});

Where reason is of type ModalSubmitInteraction and response is obviously of type InteractionCallbackResponse.

However, the response message has a string select menu, how would I apply a component collector to it, because when I try it errors saying Property createMessageComponentCollector does not exist on type InteractionCallbackResponse.

sharp ginkgoBOT

The fetchReply option when replying to an interaction will be removed in v15.

- {..., fetchReply: true}
+ {..., withResponse: true}

```This returns an [InteractionCallbackResponse](https://discord.js.org/docs/packages/discord.js/14.17.3/InteractionCallbackResponse:Class)
Use `<InteractionCallbackResponse>.resource.message` to get the message
rose tangle

check the last two sentences ^^

crisp finch

Oh

Right cause component collectors can only be applied to messages, right

summer tundra

Hello, just wondering if it's possible to set a context menu command to work as a user-installed bot, i've tried setting integration_types to [0,1] to no avail, i've tried using .setIntegrationTypes([0,1]) and still nothing, i would really appreciate some help with this!

rose tangle

did you re-deploy?

also you should use the enum instead of raw values, but it's the same thing

sharp ginkgoBOT
summer tundra
rose tangle did you re-deploy?

i have a bit of code in my index.js that automatically refreshes, deploys, and removes commands, i can send a snippet if that'd help?

rose tangle

you shouldn't deploy on start

and wdym by "refreshes and removes"?

you only need a single rest.put() or application.commands.set()

there shouldn't be any other calls while deploying

summer tundra

it just checks if there are changes that needs to be made to the deployed commands, and if there are it deploys them

maybe it isn't checking properly, give me a second to have a look

rose tangle

or just deploy manually and avoid that logic altogether

summer tundra

ill just deploy manually and see if that fixes it

well i can use the context menu command in servers the bot isn't in now, but it doesn't show up in dms, strange

crisp finch

if i deferupdate a component on a message, and then edit the message itself, does that resolve the component interaction?

for example, <Component>.deferUpdate() but then I do <Message>.editReply();

zenith violet

not the editReply

and theres also no such thing as <Message>.editReply

you call it on the interaction webhook

sand heart

is userselectmenu builder is new in components v2?

it was there before as well isn't it?

muted aspen

Is there a limit of TextDisplayComponents? I receive the error "Invalid Array Length" if I try to add a 4th section. Each section separated by a separator.

rose tangle

it's not a v2 component

sand heart

thanks

rose tangle

@muted aspen ^^

muted aspen

Oh alright, ty

alpine wadi

How to use v2 components

rose tangle

the same way you use regular components, but also passing the IsComponentsV2 flag

native plank

Is it possible to make a section with only a button and a thumbnail ?

alpine wadi
rose tangle

I'm not sure how'd that look either way, the positioning for both is the same (assuming you mean a button accessory)

rose tangle
alpine wadi
native plank
rose tangle
native plank

An is this possible to add a color ?

rose tangle

to a container, yes

sharp ginkgoBOT
rose tangle

or if you're using raw data

sharp ginkgoBOT

dtypes v10: APIContainerComponent - accent_color
read more

native plank

Perfect, thank you! 🙃

agile viper
ValidationError > s.object(T)
  Expected the value to not be an array

  Received:
  | [ { url: 'https://www.icegif.com/wp-content/uploads/2023/07/icegif-93.gif' } ]
weak karma

hey im having couple of issue's my bot does not seem to want to register slash commands in a guild ive tried removing the bot and adding the bot still nothing but if i make a new server and invite the bot the commands show up so im not sure what im doing wrong. Yes i've restarted my client and tried different clients

rose tangle
rose tangle
agile viper
weak karma
rose tangle how are you registering the commands?
const registerCommandsPromise = (
            guildId
                ? rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commandData })
                : rest.put(Routes.applicationCommands(clientId), { body: commandData })
        ).then(() => ({ type: 'registerCommands' }))
        const timeoutPromise = timeout(
            () => ({ type: 'timeout' }),
            config.timeouts?.commandRegistration || DEFAULT_CONFIG.timeouts.commandRegistration
        )
rose tangle
agile viper
rose tangle

no, the same thing you were doing but without wrapping in an array

rose tangle
alpine wadi
rose tangle

in the 14.19 announcement

fading girder
DiscordAPIError[10062]: Unknown interaction```

I am getting this error on autocomplete. Is this due to timeout?
rose tangle

yes, you replied past the 3s interaction lifetime

covert vine
rose tangle

ideally you should have all autocomplete values ready to reply, without needing external calls (like to a db)

rose tangle
covert vine

also, i cant see the documentation of Client.channels.cache
like what key should .get()

rose tangle

all djs collections are keyed by their snowflake ids

the only exception is probably unicode emojis reactions?

weak karma
rose tangle

are those commands deployed globally?

weak karma
fading girder
rose tangle

or well, either they aren't, or you didn't invite the bot as a member

covert vine
rose tangle
weak karma
rose tangle

you don't need them to "create them" to a specific server if they're deployed globally

by definition if they're deployed globally, they're available to either all servers or none, depending on your context types

covert vine

i literally just split the values logged them and it just works lol

hoary path

hey i'm back :D i now can't send, in the same message, 2 embeds with a URL added to both of them, for some reason

rose tangle

if you're using the same url to both, they're deduped to a single one

hoary path

ahhh, how to circumvent?

rose tangle

don't set the same url

or well, the exact same

if you really need them to have the same url, you could add a # to the end of either

for a browser it should resolve to the same url

weak karma
hoary path
rose tangle

in runtime, post your client login

summer tundra
covert vine

there seems to be this s command which ive used in a different python script, but no matter how many times i update my commands it doesnt go away

dispatchFor(name: string, interaction: ChatInputCommandInteraction) {
    const callback = this.interactionMap[name];
    if (callback === undefined) {
        interaction.reply("Outdated command.");
    } else {
        callback(interaction);
    }
rose tangle
rose tangle
covert vine
syncCommands() {
    (async () => {
        try {
            await this.rest.put(
                Routes.applicationGuildCommands(
                    process.env.GUILD || "MISSING",
                    process.env.UID || "MISSING"
                ),
                {body: this.data}
            )
        } catch (error) {
            console.error(error)
    }
    })();
}
``` i run this everytime i restart the script
topaz bluff

Well you shouldn't run that every time your bot starts...first off

rose tangle

and apparently you're still passing that one command you want to delete

or that code never runs

covert vine

it does run, it does update my commands when i change them

dense jackal

how do you know

rose tangle

are you using builders or raw data?

covert vine
sharp ginkgoBOT
rose tangle

I'm replying to @summer tundra

summer tundra

i'm using a builder

merry lily

hi can somebody help me?

PS C:\Users\stryde\Desktop\gears> npm run deploy

> discord-bot@1.0.0 deploy
> node src/deploy-commands.js

node:internal/modules/cjs/loader:1228
  throw err;
  ^

Error: Cannot find module '../../config.json'
Require stack:
- C:\Users\stryde\Desktop\gears\src\commands\owner\eval.js
- C:\Users\stryde\Desktop\gears\src\deploy-commands.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Function._load (node:internal/modules/cjs/loader:1055:27)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
    at Module.require (node:internal/modules/cjs/loader:1311:12)
    at require (node:internal/modules/helpers:136:16)
    at Object.<anonymous> (C:\Users\hollowed\Desktop\gears\src\commands\owner\eval.js:2:21)
    at Module._compile (node:internal/modules/cjs/loader:1554:14)
    at Object..js (node:internal/modules/cjs/loader:1706:10)
    at Module.load (node:internal/modules/cjs/loader:1289:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\stryde\\Desktop\\gears\\src\\commands\\owner\\eval.js',
    'C:\\Users\\stryde\\Desktop\\gears\\src\\deploy-commands.js'
  ]
}

Node.js v22.14.0
PS C:\Users\stryde\Desktop\gears> 
rose tangle
topaz bluff

Because you can get rate-limited/blocked from Discord. The applicationCommand endpoints are restricted endpoints that only allow a small number of requests

dense jackal
merry lily

ah thanks

rose tangle

when you did update something

covert vine

imagine doing more things manually~

topaz bluff

Manually. When you actually make changes to the data of a command (not the execute...as that doesn't get stored on Discord's servers)

rose tangle
topaz bluff

You shouldn't need to be changing the data of commands very often

weak karma

well what do u want to see

covert vine

i already have to run 2 cli commands to run the script

rose tangle
rose tangle

then do it in bulks

dense jackal
topaz bluff

Again. Not the execute

The data

rose tangle

at one point you won't be changing your command datas at all

covert vine

ok?

rose tangle

and if you're changing constantly, and deploying constantly, you'll reach the ratelimit either way

covert vine

i wont, i dont know why i shouldnt, discord.py users do it the way i do

rose tangle

so you might as well just do it manually

instead of reaching it faster when doing unnecessary calls

topaz bluff

Discord.py and DiscordJS use the same endpoints. It's just as bad practice in python as it is in JavaScript

rose tangle
covert vine
weak karma
rose tangle > and see if your command is there

Collection(17) [Map] {
0|kyots | '1366771764310577262' => <ref *1> ApplicationCommand {
0|kyots | id: '1366771764310577262',
0|kyots | applicationId: '962055416802603098',
0|kyots | guild: null,
0|kyots | guildId: null,
0|kyots | permissions: ApplicationCommandPermissionsManager {
0|kyots | manager: [Circular *1],
0|kyots | guild: null,
0|kyots | guildId: null,
0|kyots | commandId: '1366771764310577262'
0|kyots | },
0|kyots | type: 1,
0|kyots | nsfw: false,
0|kyots | name: 'channels',
0|kyots | nameLocalizations: null,
0|kyots | nameLocalized: null,
0|kyots | description: 'Set the panel, logs, and notify channels for the ticket system.',
0|kyots | descriptionLocalizations: null,
0|kyots | descriptionLocalized: null,
0|kyots | options: [ [Object], [Object], [Object] ],
0|kyots | defaultMemberPermissions: PermissionsBitField { bitfield: 8n },
0|kyots | dmPermission: true,
0|kyots | integrationTypes: [ 0 ],
0|kyots | contexts: [ 0, 1, 2 ],
0|kyots | version: '1366771765031862413'
0|kyots | },

dense jackal

then they aren't aware of rate limits

covert vine

idk man, i think they are as smart as js people

rose tangle
shadow pier

How does autocomplete work, is there a guide thinkLul

rose tangle
weak karma
rose tangle

do you have the Guilds intent?

weak karma

yes

rose tangle

can you check if the guild is in client.guilds.cache

shadow pier
rose tangle

it's unlikely they aren't aware, and it's most likely it was just never mentioned to them

or maybe dpy has some extra logic where it can know when it should actually call the api

🤷

they have their own (optional) command framework after all so it could be possible

weak karma
shadow pier

what seems to be the problem?

weak karma

ah I my slash commands won't register for a server. It's weird because i can invite the bot to a diff server and it will create them. It just won't create them in that one guild

shadow pier

It could be you didn't invite the bot with the Create Application Commands permission

try reinviting the bot?

topaz bluff

Aka, kicking it and reinviting it should fix it

weak karma

is there a limit to how many slash commands a server can have?

shadow pier

yes, 100 per bot

weak karma

that should be okay i only have 17 right now

little arch

why is it still throwing even when I added a try catch?

rose tangle

you aren't awaiting it

topaz bluff

Sorry if it's already been asked. But are you using applicationCommands or applicationGuildCommands?

little arch

it's not about that tho, he's crying about sending the message to dm

rose tangle

are you an admin?

rose tangle

you aren't awaiting it

little arch

aaah mb ty!

dense jackal

but awaiting the cache 👍

weak karma
little arch
dense jackal

yeah you dont have to, so move your await to the ticket_member.send()

rose tangle
sharp ginkgoBOT
rose tangle

(await is a part of promises)

little arch

ik what it is, I just didnt feel like removing it

weak karma
dense jackal
shadow pier
weak karma
dense jackal

oh really oops mb

crisp finch

If I have a command interaction, that gets used by displaying a modal, then when the modal gets submitted, that's a ModalSubmitInteraction.
Now, given this code:

const response = await reason.reply({options here..});

Where response is of type InteractionCallbackResponse,
How can I edit the message of response later, if before I want to edit it, it gets edited elsewhere, and I can't fetchReply that edit, how would I re-edit the message? I can't fetchReply because I call other methods within the class where this is taking place, which use it up and edit it.

rose tangle

and don't say that "it won't create them for that guild" since it sounds like you are deploying per guild

which you aren't

you are deploying globally

shadow pier
rose tangle
weak karma
crisp finch
rose tangle

you should be able to fetch it and use the reply like a regular message then

.edit() and everything

crisp finch
rose tangle

well if you can pass around your response, that already has the message

response.resource.message

rose tangle
merry lily

it says commands are registered but, when i run these commands on my guild, it says sending command, The application did not respond. i think my deploy-commands.js isn't working properly

require('dotenv').config();
const { REST, Routes } = require('discord.js');
const fs = require('fs');
const path = require('path');

const commands = [];
const commandsPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(commandsPath);

for (const folder of commandFolders) {
  const folderPath = path.join(commandsPath, folder);
  const commandFiles = fs.readdirSync(folderPath).filter(file => file.endsWith('.js'));

  for (const file of commandFiles) {
    const filePath = path.join(folderPath, file);
    const command = require(filePath);
    
    if ('data' in command) {
      commands.push(command.data.toJSON());
    }
  }
}

const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);

(async () => {
  try {
    console.log(`🔄 Registering ${commands.length} commands...`);
    
    const data = await rest.put(
      Routes.applicationCommands(process.env.CLIENT_ID),
      { body: commands }
    );
    
    console.log(`✅ Successfully reloaded ${data.length} commands.`);
  } catch (error) {
    console.error('❌ Deployment failed:', error);
  }
})();
rose tangle

if you can use the command then it's deployed correctly

you are just not handling it when you actually receive an interaction for that command

dense jackal
rose tangle

or you're doing it too late and getting (and maybe ignoring) an error

covert vine
sharp ginkgoBOT

method GuildChannelManager#create() discord.js@14.19.1
Creates a new channel in the guild.


// Create a new text channel
guild.channels.create({ name: 'new-general', reason: 'Needed a cool new channel' })
  .then(console.log)
  .catch(console.error);

dense jackal
rose tangle

what you linked is an internal function

covert vine
dense jackal

how would you create a channel then

shadow pier
covert vine

nevermind

merry lily
dense jackal issue is from not replying to the interactionCreate event

this is interactionCreate.js:

module.exports = {
  name: 'interactionCreate',
  async execute(interaction) {
    if (!interaction.isChatInputCommand()) return;
    
    const command = interaction.client.commands.get(interaction.commandName);
    
    if (!command || !command.slashExecute) return;
    
    try {
      await command.slashExecute(interaction);
    } catch (error) {
      console.error(error);
      await interaction.reply({ 
        content: 'There was an error executing this command!', 
        ephemeral: true 
      });
    }
  }
};
sharp ginkgoBOT

tag suggestion for @merry lily:
If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops.

  • Once you do, log relevant values and if-conditions
  • More sophisticated debugging methods are breakpoints and runtime inspections: learn more
covert vine

i guess interaction should have a channela ttribute right

rose tangle

yes

sharp ginkgoBOT
dense jackal

it even has a guild attribute

covert vine

dam

interaction.guild.channels.create() i literally cant find the options without so much digging

ivory valve

Hello, there's a PermissionFlagsBits for "ManagePermissions" of a channel, I only fund ManageChannels and my bot cannot any permission of the channel with this permission

rose tangle
covert vine
crisp finch
rose tangle

it's not an actual message, so you can only edit through the interaction webhook

aka interaction.editReply()

and only for 15 mins

ivory valve

So I added Manage roles permission to MyBotRole, then in permission overwrite I have

{
    id: interaction.client.user.id,
    allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.ManageRoles]
},

But I got a Missing Permissions error sus

topaz bluff
zenith violet
ivory valve

Yes, View Channel, Manage channels and manage permissions are checked in the category where the ticket is created

but if i remove manage roles, it's good

weak karma
ivory valve

It's a category soo

weak karma

don’t you need manage channel perms to update that?

ivory valve

Yes, I tried to had this permission on the creation of the channel

Category has the permission for my bot but it's not working xd

crisp finch

can ephemeral messages not be edited with <Message>.edit?

merry lily

how can i fix this, the problem is after running commands it shows problems in terminal:

PS C:\Users\stryde
\Desktop\gears> npm run deploy

> discord-bot@1.0.0 deploy
> node src/deploy-commands.jsLoaded command: evalLoaded command: ping
🔄 Registering 2 commands...
✅ Successfully registered 2 commands
PS C:\Users\stryde\Desktop\gears> npm start

> discord-bot@1.0.0 start
> node src/index.jsLoaded 3 events
✅ Logged in as Gears#0463
Command eval not found
(node:9688) Warning: Supplying "ephemeral" for interaction response options is deprecated. Utilize flags instead.
(Use `node --trace-warnings ...` to show where the warning was created)
Command ping not found
sharp ginkgoBOT

tag suggestion for @merry lily:

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
ivory valve
steel trail that's ManageRoles in the API

Hmm are you sure? I tried with and the channel is just not created with Missing permission error, I added "manage permissions, manage channels" to everyone on the category and the bot just can't do that

covert vine
covert vine
rigid crest

so im trying to get my upvote/downvote buttons to update when pressed but....

[DEBUG] Button pressed: upvote
[DEBUG] Message ID: 1366811348629196882
[DEBUG] Processing component 0, type: 17
[DEBUG] Processing component 1, type: 1
[DEBUG] Buttons found in ActionRow:
[DEBUG] Button 0: customId = comment_button, label = Leave a comment
[WARN] Could not find one or both buttons in component 1
[DEBUG] Attempting to edit message with updated components...

where are they stored if not actionrow? as when i press i get the confirm messages, but nothing changes

rose tangle

we'd have to look at your code, not just the debug logs