#djs-help-v14

78874 messages · Page 44 of 79

eternal drift

I'm blind and can't find what I need in the docs

snow onyx

What parts

Ideally you should be looking at the actual interaction class you are expecting, like the one below

sharp ginkgoBOT
eternal drift

Ah ok, that makes more sense. I assume CommandInteraction is just a base

kindred bolt

why doesnt my code work ? it doesn't put any status on the bot, it's a user application bot

i wanna do something like this

sharp ginkgoBOT

guide Popular Topics: Frequently asked Questions - How do I set both status and activity in one go?
read more

dense jackal

@kindred bolt ^^

kindred bolt
rose tangle
kindred bolt
spring sparrow

Hello I have this command now the issue is intially this command works well and shows me the data from my MongoDB database now when the data size is more than 5 I am using pagination to show that.. So I am using buttons underneath the embed, Now the issue is when I click this button ➡️ I get interaction failed message on discord no errors in the console now I am not understanding what is the issue here

This is my full code: https://sourceb.in/bZ4YkJJudh

rose tangle
rose tangle
spring sparrow
rose tangle

to me it sounds like it's the interaction lifetime

spring sparrow

yes I fixed that!

rose tangle

you don't want to make async actions before replying

spring sparrow

basically when I am checking with customId over there its returning me the page as an output now when I did interaction.customId it now retruned me the full customId

which is custom-page-all

rose tangle

otherwise it may not work all the time

depending on your db's ping, which is impossible to predict

spring sparrow

okay I did not get this one..

what do you mean by interaction lifetime here?😅

rose tangle

you only have 3s to reply to interactions

you don't know how much it'll take for you to get the data from your db

generally it won't take much but it's still an unpredictable variable

spring sparrow

okay now I understand that!

rose tangle

so you should defer at the top, before querying, and after the query you can edit the defer to the actual response with the db's results

spring sparrow

yes you are correct db ping can sometimes get high and can take more time during read operation

spring sparrow
kindred bolt

😢

rose tangle

show your code

loud quartz

quite a bit late, but was scrolled up - yes, thye don't because nothing is actually updated. the timestamp is only set once, when timing out. afterwards it pretty much stays there forever and is just compared to for if the member is still timed out or not.
the only other case when it's changed is when you're manually removing the timeout, in which case it'll get set to null instead of a timestamp.

bitter pivot

Am I being really silly - does DJS support select menus in modals yet? If so, which builder is it? I'm trying with StringSelectMenuBuilder but it's giving me an API Error saying I'm using the wrong type

loud quartz

we would post there if this feature that is still being released by discord was supported

bitter pivot

Ohhh is it not fully out yet

I'd just seen a post about it and assumed it was out fully because it'd been announced.

loud quartz

discord announcing something does not mean we (discord.js) automatically support it

we have to actually implement stuff and then make a release with that new stuff

bitter pivot

No I'm aware - I saw this a little while ago, and just ran with the assumption

tardy sable

is it true djs is waiting for file upload before releasing modal update?

bitter pivot

im hoping not 🙏

tardy sable

i just checked the prs again and idk what theyre waiting on, they just did pr for file uploads

loud quartz

on free time

loud quartz

maintainers don't exist solely to maintain d.js and sleep

they have lifes too

tardy sable

im aware

bitter pivot

lmfao i dont think he was talking about djs
was he not talking about a file uploads pr on discord's api repo

tardy sable

but i ask because theyre now working on file uploads when that isnt even announced yet by discord dev

loud quartz

we have such PRs too

bitter pivot

fair enuf

bitter pivot

who knows tbf

tardy sable

BlueShrug thats why i think they wait for file uploads to release the entire modal update

bitter pivot

yea would check out, but i hope it don't happen cus discord took years to release this update, it'll take them more years for file uploads

loud quartz

if it took them years of not working on it

a week or two won't make a difference

anyway

bitter pivot

what

loud quartz

they were not working on this stuff for past years

bitter pivot

i cant help but assume you're just trying to ragebait 😭
everything we've said you have a stark opinion

loud quartz

everyone keeps asking, the answers are the same

no ETA on when we release it, for now we don't support it

bitter pivot

we are well aware this is open source, and that people maintain it for free - or rather some of the core maintainers are sponsored. we're not in here demanding anything, i asked "hey, has this feature that got released by discord a few weeks ago been ported to the api wrapper yet"?

like, jheez, we get it

loud quartz

and i have said no, pointing to where you can find out when it will be

bitter pivot

^ you actually didn't even remotely, you just said "soon we're all volunteers stop asking". it wasn't exactly a helpful answer.

loud quartz

but this is getting offtopic

bitter pivot

im not moving to another channel just to fuel a random debate with some random proficient discordjs user 🤣 im in the middle of working on a bot, but ive wasted a load of time now having to talk through this

loud quartz
sharp ginkgoBOT
fallow finch

Is it possible that subcommands could have different permissions set for them

snow onyx

no

tardy sable
fallow finch

Alright thanks

brittle current

anyone knows how to use new modal components in js

snow onyx

its not yet released in discord.js

brittle current

ok thx

lofty topaz

how can i add file such as this #announcements message
can i get a code such as this to learn how can i do this?

dense jackal
sharp ginkgoBOT

guide Popular Topics: Display Components
read more

dense jackal

read this guide to see how to create such messages

lofty topaz
last mango

Is the modals select menu feature added?

dense jackal

no

last mango

Okay

lofty topaz

check this

dense jackal

where did you get f.setFiles() from?

f is already an instance of FileBuilder

lofty topaz
dense jackal

what "...", I am asking you a question

lofty topaz

check this

@dense jackal Now?

dense jackal

don't wait for me to tell you if its right or not, you can test that stuff yourself as well, but if I remember correctly this is how you can use it yes

lofty topaz
bitter pivot
sharp ginkgoBOT

documentation suggestion for @lofty topaz:
class FileBuilder discord.js@14.22.1

lofty topaz

[antiCrash] :: Uncaught Exception/Catch (MONITOR)
CombinedPropertyError (1)
Received one or more errors

input.url
| MultiplePossibilitiesConstraintError > s.string().url()
| Invalid protocol for file URL. Must be attachment:
|
| Expected any of the following:
| | - attachment:
|
| Received:
| | 'https://cdn.discordapp.com/attachments/1411745112236625951/1418319468114870272/King.txt?ex=68cdb070&is=68cc5ef0&hm=61c79e7332557dfa423ad5dfb5378ed2119669205196a145aebfc06377d7cb25&'

at _ObjectValidator.handleIgnoreStrategy (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2119:72)
at _ObjectValidator.handleStrategy (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1983:47)
at _ObjectValidator.handle (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2089:17)
at _ObjectValidator.parse (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at FileBuilder.setURL (/home/container/node_modules/@discordjs/builders/dist/index.js:1585:36)
at CustomClient.<anonymous> (/home/container/index.js:2269:7)
at CustomClient.emit (node:events:529:35)
at MessageCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/MessageCreate.js:32:14)
at module.exports [as MESSAGE_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31) uncaughtException
sharp ginkgoBOT

guide Popular Topics: Display Components - File
read more

dense jackal

read this part of the guide ^

bitter pivot
bitter pivot
dense jackal
worthy drift

no, you need to recreate the attachment through AttachmentBuilder.
Had the same issue with my message logger

bitter pivot
dense jackal

weird

ThumbnailBuilder#setURL() does support it

bitter pivot

Then again, if you have the URL for something already why would you want to build a file, it's already a file

bitter pivot
dense jackal

for setting the URL of an thumbnail accessory in a section?

there's no other way I can think of to put an arbitrary url in the sections accessory

lofty topaz
dense jackal `FileBuilder#setURL()` should be able to support arbitrary URLs as well

CombinedPropertyError (1)
Received one or more errors
input.url
| MultiplePossibilitiesConstraintError > s.string().url()
| Invalid protocol for file URL. Must be attachment:
|
| Expected any of the following:
| | - attachment:
|
| Received:
| | 'https://cdn.discordapp.com/attachments/1411745112236625951/1418319468114870272/King.txt?ex=68cdb070&is=68cc5ef0&hm=61c79e7332557dfa423ad5dfb5378ed2119669205196a145aebfc06377d7cb25&'
at _ObjectValidator.handleIgnoreStrategy (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2119:72)
at _ObjectValidator.handleStrategy (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1983:47)
at _ObjectValidator.handle (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2089:17)
at _ObjectValidator.parse (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at FileBuilder.setURL (/home/container/node_modules/@discordjs/builders/dist/index.js:1585:36)
at /home/container/index.js:2271:6
at resolveBuilder (/home/container/node_modules/@discordjs/builders/dist/index.js:2224:12)
at /home/container/node_modules/@discordjs/builders/dist/index.js:1795:75
at Array.map (<anonymous>)
at ContainerBuilder.addFileComponents (/home/container/node_modules/@discordjs/builders/dist/index.js:1795:56) uncaughtException

Link not supported

i think

dense jackal

no I just got informed it is not

but if you already have a link, why not paste that link

discord formats it nicely (you can already see it in the error you sent)

bitter pivot
dense jackal

just put the link of the file inside a text display component

bitter pivot
dense jackal

basically yes, people can still click on it and download the file when they click it

lofty topaz

it is the better than link

dense jackal

do you have that file locally

lofty topaz
dense jackal

cool, then just follow the code snippet that's placed on the "File" section of the guide I sent you

const file = new AttachmentBuilder('../assets/guide.pdf'); // << you already have this line

//... container
.addFileComponents(
  file => file
    .setURL('attachment://guide.pdf');
)
//...

await channel.send({
    components: [container],
    files: [file], // << do not forget this line!!
    flags: MessageFlags.IsComponentsV2,
});
lofty topaz
dense jackal ```js const file = new AttachmentBuilder('../assets/guide.pdf'); // << you alrea...

DiscordAPIError[50035]: Invalid Form Body
components[0].components[4].file.url[UNFURLED_MEDIA_ITEM_REFERENCED_ATTACHMENT_NOT_FOUND]: The referenced attachment ("attachment://King.txt") was not found
at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:1163:23)
at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:994:14)
at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1307:22)
at async TextChannel.send (/home/container/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:195:15)
at async CustomClient.<anonymous> (/home/container/index.js:2278:1) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: [Array],
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 32768,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { components: [Object] }
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1362042671799074877/messages'
}
?????

worthy drift

show your code

lofty topaz
worthy drift show your code


const file = new AttachmentBuilder("./King.txt");
const container = new ContainerBuilder()
  .addTextDisplayComponents((txt) => txt.setContent("## ShareBot"))
  .addSeparatorComponents((sep) => sep)
  .addTextDisplayComponents((txt) => txt.setContent("تجربة"))
  .addSeparatorComponents((sep) => sep)
 
.addFileComponents(file =>
  file
    .setURL("attachment://King.txt")
)


  .addSeparatorComponents((sep) => sep);

await message.channel.send({
  components: [container],
Files: [file],
  flags: MessageFlags.IsComponentsV2,
});
worthy drift

in your message payload you used Files instead of files. its written in lowercase only

slim parcel

I made an RP Discord bot, and on the test bot the z.<rp-character id> <message> feature works, but on the verified bot it doesn’t. All the intents are enabled, but it still doesn’t work. Tag me, or reply to this message please

sharp ginkgoBOT

tag suggestion for @slim parcel:
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
cedar kindle

whats the max number of input fields a modal can have?

sharp ginkgoBOT
cedar kindle
dusky tree

how could I achieve this layout with images on the right using discord.js + components v2?

halcyon bison

you can use sections with thumbnail accessories

sharp ginkgoBOT

guide suggestion for @dusky tree:
guide Popular Topics: Display Components - Section
read more

dusky tree
halcyon bison

you asked about components v2 which is mutually exclusive with embeds, so no

(also in general embeds don't have any such capability)

you can however use sections in containers

dusky tree

Mm okay makes sense, that's the issue I've been running into. I'm using slash commands at the response output was an embed which I'm trying to convert to use components v2

halcyon bison

then you should look into containers (on the same page as the guide above, just farther down)

dusky tree

Will do, thank you!

outer plume
hasty osprey

does d.js have anything similar to game.BindToClose: RBXScriptEvent from roblox?

bleak owl

i don’t quite know what that does

unique shoal

Yeah I dont understand the question at all

node has event listeners for process exit

pearl roost

It says that color is deprecated, but when i change the color: into colors:, i will never be able to create the role. Saying that they cannot convert undefined into number. What's wrong here?

sharp ginkgoBOT
pearl roost

make sense

runic basin

Hi, I have a question - I’ve been trying for the past 3-4 hours to hook up ComponentsV2 with a webhook so it can send messages, but the component types keep mismatching. The Discord API keeps complaining that, for example, a Container shouldn’t be Type 17 but Type 1 (Action Row). Is there a way around this? Whenever I try to convert the types, most of the data breaks

stable sun

Component types are the same across Discord tho

halcyon bison

The Discord API keeps complaining that, for example, a Container shouldn’t be Type 17 but Type 1 (Action Row)
I imagine you're just misinterpreting an error along the lines of Value of field "type" must be one of (1,)
this error means you're only allowed to use action rows as the top level component, which suggests you're missing the IsComponentsV2 flag

runic basin
little pebble
runic basin

sry mb xD

runic basin

huh? I think I passed the entire components object correctly, but it still complains - and I even added the IsComponentsV2` flag.

      const payload = {
        components: messageOptions.components ?? undefined,
        username: nickname || messageOptions.username,
        avatar_url: avatarURL || messageOptions.avatarURL,
        flags: MessageFlags.IsComponentsV2,
        files: messageOptions.attachments ?? undefined,
      };
{
  "components": [
    {
      "type": 17,
      "accent_color": 16711680,
      "spoiler": false,
      "components": [
        {
          "type": 12,
          "items": [
            {
              "media": {
                "url": "https://i.imgur.com/v4llTPJ.png"
              },
              "spoiler": false
            }
          ]
        },
        {
          "type": 14,
          "spacing": 1
        },
        {
          "type": 10,
          "content": "> @_lefes_ nie udało ci się zweryfikować!\n- Spróbuj ponownie."
        }
      ]
    }
  ],
  "username": "_lefes_",
  "avatar_url": "https://cdn.discordapp.com/avatars/508345738137305118/3e626c47383aa7040deaf059fd365c1c.webp?size=4096",
  "flags": 32768
}
Failed to send webhook: DiscordAPIError[50006]: Cannot send an empty message
stable sun
runic basin
stable sun

Yes

runic basin

No, I didn’t add it - because I couldn’t find any documentation for it anywhere

pearl hazel

is there a way to put seconds in timestamp or i should do it using footer
embed

runic basin
stable sun Yes

same error..

Sorry for asking something so dumb, but it’s literally the first time I’m trying to send ComponentsV2 through a webhook - with embeds and all. It wasn’t that hard

    try {
      const url = new URL(webhookURL);
      url.searchParams.set('with_components', 'true');
      webhookURL = url.toString();

      const webhookClient = new WebhookClient({ url: webhookURL });

      const payload = {
        components: messageOptions.components ?? undefined,
        username: nickname || messageOptions.username,
        avatar_url: avatarURL || messageOptions.avatarURL,
        flags: MessageFlags.IsComponentsV2,
        files: messageOptions.attachments ?? undefined,
      };
stable sun

Don’t need to set it in the url then. It’s part of the webhook.send method

sharp ginkgoBOT
stable sun

Thought you were using /rest package

sharp ginkgoBOT
stable sun

There’s withComponents along with your normal message options (as camel case)

You won’t get proper autocomplete unless you write the object inside of the webhook.send method, or you type payload properly by TS (or JSDocs if using VSC or any editor that supports it)

runic basin

Thanks, man, that with_components tip really helped me - I just added it to the webhook payload, and the message finally went through

      const payload = {
        components: messageOptions.components ?? undefined,
        username: nickname || messageOptions.username,
        avatarURL: avatarURL || messageOptions.avatarURL,
        files: messageOptions.attachments ?? undefined,
        flags: MessageFlags.IsComponentsV2,
        withComponents: true,
      };
sturdy ravine

lmao

sturdy ravine

are voice channels always cached?
SInce I need to fetch one

snow onyx

guild channels, if you haven't changed the cache limits and if you have the Guilds intent, are always cached, yes.

sturdy ravine

How can I fetch a voice channel?

sharp ginkgoBOT
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
sturdy ravine

THanks! How can I use this djs bot here quickly?

snow onyx

wdym

sturdy ravine

where can I find all events cheat sheet

dense jackal
sharp ginkgoBOT
sturdy ravine

which event is the one that triggers when a user joins a vocal channel

sturdy ravine

Guys can I juse modals inside here for example?
I want to show the user the modal when he joins the channel

    async execute(oldState, newState) {
        console.log("ENTRATO O CHE?")

        const channelJustJoined = newState.channel;



        if (channelJustJoined){

                // Se il canale in cui e' entrato l'utente e' un canale di creazione
                // Create the modal
                const modal = new ModalBuilder()
                    .setCustomId('myModal')
                    .setTitle('My Modal');

   
                // Create the text input components
                // .......
                modal.addComponents(firstActionRow, secondActionRow);

                // Show the modal to the user
                await interaction.showModal(modal);
                
            }

                return;
        }

Does it have to work only by slash command? Can I make a way maybe using DMs?

stable sun

You could send a message in the channel or DMs

sturdy ravine
terse venture

What is "Access to file uploads has been limited for this guild"

unique shoal

A limitation of the ability to upload files in a particular guild

sturdy ravine

I want to check if the interaction triggered is a ButtonInteraction, how can I check if its that or a command?

if interaction == Interaction.ApplicationCommand but for buttons?

maybe if interaction.isButton()?

nova linden

if(interaction.isButton())

sharp ginkgoBOT
loud quartz

That also exists

sturdy ravine

thanks guys, how can I handle my button code? not inside interactionCreate right|? its messy

nova linden

yeh u handle it inside the interactionCreate event

js do something like

if(interaction.isButton()) {
return buttonHelper(interaction)
}

and handle all ur buttons inside here

sturdy ravine
nova linden

if u dont want to put it all inside the createInteraction function then do what i said above

nova linden
loud quartz

Just get it from interaction.member

nova linden
steep birch

Hi all!
I have a question about how this function works:

member.permissions.has('ManageGuild') || ```

Will this also check if the user has "ManageGuild" permissions because of a role the user is in or just check if the user has those permissions (at user level)?
Thanks!
strong nest

Can someone help me create programming code for websites and online games?

snow onyx
snow onyx
steep birch

Perfect, thank you!

ivory valve

Hey!
When a modal is open, there's no way to add/remove fields based on a text input content right?

last mango

How so i make the bot status like this? Like u are online in a mobile

nova linden

client.user.setActivity()

crimson gale

discord.js does not support this, as you have to actively go against discord's specifications

ivory valve
dapper cave
last mango
dapper cave

node-gyp try to not be annoying and error: impossible

silent saddle

Does anyone here know about MetaTrader?

dapper cave
silent saddle
echo anvil

Is there a way to make it so a bot follows-up a command with an ephemeral message asking for user's input. and then follows up the original command/interaction with a public message ? The point being showing the user's original input in chat. Because right now I can't figure this out and end up with something like this

tardy sable

you cant use interaction followup for that since it will show orginal message delete as in your screenshot

echo anvil

but a slash command is not a message, it's an interaction, right ?

even if I pass it around and do originalInteraction.followUp it ends up like this

tardy sable
echo anvil

I will try that

tardy sable
echo anvil

Will do !

it never crossed my mind to get the message, I tried storing the interaction tho

loud quartz

you can followup original interaction ephemerally, and then do another followup to the same interaction non-ephemerally

doing it this way will not require your app's bot to be in the channel to reply to the message, unlike in the code above

echo anvil
export async function chatInput({
  interaction,
  store,
}: ChatInputCommandContext) {
  const ogInteraction = interaction;
  await ogInteraction.deferReply({ flags: MessageFlags.Ephemeral });

  // stuff
  await ogInteraction.followUp({
    flags: MessageFlags.Ephemeral,
    content: "Eph,",
  });

  // other stuff

  await ogInteraction.followUp({
    content: "non eph",
  });
}

That's what I tried before, it act not as you would expect

loud quartz

hm

echo anvil

This interesting, isn't it heh

loud quartz

oh

you don't have 2 followups there actually

you only have one

because you never replied

echo anvil

Mmmh

loud quartz

you said you will reply later, and then never did so, only following up

so the first one is being treated as reply() by discord

echo anvil

Ok let's see

I think what I am trying to do is actually impossible

loud quartz

reply non-ephem with a placeholder
followup ephem asking the user
edit reply to show data taken from user

don't see much point in having 2 followups be public

you can edit the original reply since that will keep the command usage

and you can update the ephemeral followup after taking user input as well

echo anvil

yes, but you can't edit an ephemeral message to be non-ephemeral, that's the problem

loud quartz

why do you need 3 messages

you have a public reply(), and an ephemeral followup

ask the user ephemerally, edit the already existing public message

you can edit both just fine independently, you don't really need to edit ephemerality of them

if you need to separate the original reply() from data provided by user, follow up non-ephemerally

but after you reply()

the actual reply is needed for followups to be followups

echo anvil
loud quartz

then you can have a timeout on your end

but at this point it's either or

either you keep it public to show it publicly how you want

or you reply ephemerally and have a non-ephem point to nowhere when they submit

you can even just leave a defer itself running non-ephemerally

pretty sure if you try to follow up ephemerally it shouldn't get treated as a non-ephem reply

but then i never tried that, so am not 100% sure

echo anvil

I'm trying your proposals to no success

You should try it for fun, it's a head scratcher this one

loud quartz

show

icy hamlet

I'm updating my logging to components v2 and struggling with resending images. I'm taking the message event and extracting the attachments. I'm trying to rebuild them into a gallery but no luck so far. What am I missing here?

const attachment = message.attachments[0].attachment;

const file = new AttachmentBuilder().setFile(attachment);

const exampleGallery = new MediaGalleryBuilder().addItems((mediaGalleryItem) =>
      mediaGalleryItem.setURL(attachment),
    );

await interaction.editReply({
      components: [exampleGallery],
      files: [file],
      allowedMentions: {
        parse: [],
      },
      flags: [MessageFlags.IsComponentsV2, MessageFlags.Ephemeral],
    });
loud quartz

what does "no luck" mean here

icy hamlet

The message sends with a image gallery but the image is "Image not found"

loud quartz

const attachment = message.attachments[0].attachment;
that line looks quite wrong

message.attachments is not an array but a Collection

icy hamlet

Well I threw this snippet together to try and demonstrate. I'm actually using map

loud quartz

then please show actual code

so that we can look at actual issues, not code threwn together that might be wrong in different places

icy hamlet
loud quartz so that we can look at actual issues, not code threwn together that might be wro...

After receiving a message event containing an image and attempting to resend it:

  const [exampleGallery, attachments] = message.attachments.reduce(
    (acc, attachment) => {
      acc[0].addItems((mediaGalleryItem) => mediaGalleryItem.setURL(attachment.attachment));
      acc[1].push(new AttachmentBuilder().setFile(attachment.attachment));

      return acc;
    },
    [new MediaGalleryBuilder(), []],
  );

  const channel = message.guild.channels.cache.get(message.channelId);
  await channel.send({
    components: [exampleGallery],
    files: attachments,
    flags: [MessageFlags.IsComponentsV2],
  });

Send the "image" but the image is blank with "Image Not Found"

loud quartz

what is the attachment.attachment supposed to be?

icy hamlet

What do you mean? It's the field that is returned as part of a message attachment collection. Actually in that collection each attachment has attachment, url, and proxyURL. From what I can tell in the case I'm testing, attachment and url are the same.

loud quartz

Message has a Collection of Attachments, yes

but those Attachments in that Collection are already Attachments

there is no Message.attachments.first().attachment

stable sun

Only AttachmentBuilder has an attachment prop

loud quartz

but on a constructed instance, not as a requirement on passing to it

icy hamlet

Well, when I'm console logging attachment in the .reduce, the object definitely has attachment.attachment

loud quartz

show

code and log

icy hamlet
loud quartz

then it might just happen to be an undocumented property which we serialize

it's still undocumented by us and might not even be there tomorrow, so you can see why i'm reacting this way

if it's the same, use the url since that one actually exists

icy hamlet

Okay, so you're saying I should switch to using attachment.url
When I do that, I get the same result

loud quartz

and what url(s) do you pass to the gallery

icy hamlet
  const [exampleGallery, attachments] = message.attachments.reduce(
    (acc, attachment) => {
      acc[0].addItems((mediaGalleryItem) => mediaGalleryItem.setURL(attachment.url));
      acc[1].push(new AttachmentBuilder().setFile(attachment.url));

      return acc;
    },
    [new MediaGalleryBuilder(), []],
  );

  const channel = message.guild.channels.cache.get(message.channelId);
  await channel.send({
    components: [exampleGallery],
    files: attachments,
    flags: [MessageFlags.IsComponentsV2],
  });
loud quartz

the urls, not variables

icy hamlet

You want the actual URL of the image I'm using?

loud quartz

the one you're passing into the gallery that doesnt' work

halcyon zephyr

is the chunk size limit for all managers (users, messages, etc) the same 100?

icy hamlet
loud quartz

is that what's in the gallery you built or just in the Attachment log

icy hamlet
loud quartz

and is it actually

please just log the media gallery

slate tartan

hi i have one question

i can use title on a container ?

loud quartz

container is not an embed

slate tartan
loud quartz

then use a text component

icy hamlet
loud quartz please just log the media gallery

Here's the media gallery logged

  "type": 12,
  "items": [
    {
      "media": {
        "url": "https://cdn.discordapp.com/attachments/1195823057131012128/1418623823233945640/Byl6BHzEv7tWDGa5QUgztneq8C8TGYelu8ywVMTTRUH2e9keboyLqL4YhmzaU3vjgA.png?ex=68cecbe4&is=68cd7a64&hm=cfb2d1e91a971c30da3a4dcaa1fd39437ec730a2e4544cc7ea3f8f838fc6ec08&"
      }
    }
  ]
}
slate tartan
icy hamlet

I just checked to confirm that the media gallery url is identical to attachment.url

Does discord just not allow images from its cdn to be resent in an image gallery? I don't have this problem with my current components v1 application but that version just resend the image. I don't attempt to place it into an embed

steep birch

Hi!
I'm updating my code to v14 and I'm unable to have the content of the messages deleted again
I was using:

client.on('messageDelete', async message => {
.......
            if (message.content !== null && message.content !== undefined) {
                if (message.content.length < 1024) {
---Return message.content

I'm getting the log of deletion of a message but the message.content is empty every time

rose tangle

sounds like you don't have the MessageContent intent

or they're partial messages

though they'd be null in that case

the !== undefined is always true

topaz bluff

Message#content doesn't claim to be nullable in the docs...isn't it just ""?

steep birch
rose tangle
topaz bluff

o7

crystal cargo

hello, i have an issue with the embed,

first image show the last lines in the embed,
second image show when i do

const lines = description.split('\n');
for (let i = Math.max(0, lines.length - 10); i < lines.length; i++) {
  console.log(`Line ${i + 1}: "${lines[i]}" (${lines[i].length} chars)`);
}```
so, when i log the description, i will see the correct content
but in Discord, few lines will be missing

 Discord.js version: 14.21.0
crystal cargo

I tried to do something like this
embed.setDescription(description.slice(100))
It worked and showed the last lines correctly.
But the length of this is less than 3000

stable sun
crystal cargo

I am trying since yesterday

sturdy ravine

Why is that if

...
                    .addSectionComponents(
                        section => section
                            .addTextDisplayComponents(
                                textDisplay => textDisplay
                                    .setContent("La stanza verra automaticamente **eliminata** se vuota!"),
                                textDisplay => textDisplay
                                    .setContent('Lo staff di **Gaming House** si occuperà della gestione!'),
                            )
                            .setButtonAccessory(
                                button => button
                                    .setCustomId('endbutton')
                                    .setLabel('Avanti')
                                    .setStyle(ButtonStyle.Primary),
                            ),
                    );

If I remove .setButtonAccessory it gives me an error CombinedError: Received one or more errors

stable sun
sturdy ravine
tardy sable
stable sun

Blame Discord

sturdy ravine
stable sun

¯_(ツ)_/¯

stable sun
sturdy ravine

wtf, why do I need a button there If basically a textDisplayComponent is a button that I can even listen to as an interaction

indigo nest

Hey everyone, noticing a problem where when using select menus the value doesn't reset to the placeholder... Same doesn't happen with mobile. Is it a desktop app error or am I doing something wrong?

oh wait no still happens on phone. can i reset without editing the whole message each time someone uses it?

indigo nest
sturdy ravine
hallow mesa
novel mauve
sturdy ravine

WHy

async function chooseChannelName(interaction) {
    console.log(interaction.type)
    const selectedOption = interaction.values[0];
    const channelName = selectedOption === 'private' ? 'Stanza Privata' : 'Stanza Pubblica';
    await interaction.update({ content: `Hai scelto una **${selectedOption}**. Ora, per favore, inserisci il nome della tua stanza vocale personalizzata.`, components: [] });

    // Imposta un collector per il messaggio di risposta
    const filter = m => m.author.id === interaction.user.id;
    const collector = interaction.channel.createMessageCollector({ filter, max: 1, time: 60000 });

    collector.on('collect', async m => {
        const roomName = m.content;
        await interaction.followUp(`Perfetto! La tua stanza si chiamerà **${roomName}**. Procedo con la creazione...`);
        // Qui puoi chiamare la funzione per creare il canale con il nome specificato
        // createVoiceChannel(interaction, roomName, selectedOption);
    });

    collector.on('end', collected => {
        if (collected.size === 0) {
            interaction.followUp('Non hai inserito un nome per la stanza. Per favore, riprova.');
        }
    });

gives me DiscordAPIError[50035]: Invalid Form Body?

bleak owl

please show the full error

sturdy ravine
bleak owl please show the full error
DiscordAPIError[50035]: Invalid Form Body
data.content[MESSAGE_CANNOT_USE_LEGACY_FIELDS_WITH_COMPONENTS_V2]: The 'content' field cannot be used when using MessageFlags.IS_COMPONENTS_V2
snow onyx

yes, you cant update the message to have no components and content when they had componentsv2

sturdy ravine
bleak owl

that's not what the error means. you can't use the content field when using components v2

sturdy ravine

So how would I send the interaction.update?

topaz bluff

you make the update message also componentsv2 or you use a followup instead

making a message an IS_COMPONENTS_V2 message is an irreversible action. as soon as you do it, the content field is permanently removed

sturdy ravine

still need to get acquainted with componentsV2

ty boys

which Componentv2 is basically an input text field?

sharp ginkgoBOT

guide Popular Topics: Display Components - Text Display
read more

topaz bluff

oh text INPUT field...none of them

you can use a modal for text input

rose tangle

a button that does not look like a button isn't really intuitive

rose tangle
rose tangle
sturdy ravine

The TextDisplayComponents seems already like a button and it is actually

its a window menu basically

topaz bluff

textdisplaycomponent is NOT a button in any way. it's purely a DISPLAY component

rose tangle

I think you misunderstand what a text display is, it really sounds like you're referring to something else

a text display quite literally only displays text, like a message's text

sturdy ravine

I mean this one
its basically a button

bleak owl

thats a select menu

sturdy ravine

Yeah meant that, my bad

topaz bluff

it also doesn't take user input. it only uses predefined options

sturdy ravine
rose tangle

then for your original question, you have a section, you still need an accessory

topaz bluff

make a button on your cv2 message that opens a modal...that modal has a text input component...use that text however

gentle oriole

I'm studying Components v2. I got curious, is it possible in cv2 to split text into two columns like it was in fields embed?
like:

field1  field2
text1   text2
topaz bluff

no. there is no inline feature for cv2

sturdy ravine

Guys any idea why on my second discord account the modal from my bot works as expected while on my first account it doesn't show up?

balmy kraken
                    const collector = interaction.channel.createMessageCollector({ time: 15_000 });

                    collector.on('collect', m => {
                        console.log(m);
                    });```

for some reason the message content field appears empty

my bot has the messages content intent

nvm i was missing GatewayIntentBits.MessageContent in my intents

wary coral
silent mirage

Discord bots still can not stream just asking its been a while since i coded on i started coding on V10

bleak owl

they cannot stream

icy hamlet
loud quartz and what url(s) do you pass to the gallery

FYI I'm pretty sure I figured out the problem. My bot is moderating certain images and deleting the original message. For some reason, when resending the image in a components v2 media gallery I get "Image not found", but if I resend the image as a basic file attachment it renders correctly. Both methods use the same message attachment URL. I haven't tested this for an embed. I'm not sure what's causing this distinction.

unique shoal

Deleting the original will mean the image is gone

I don't understand how sending it as a file attachment is the same url?

icy hamlet

If I navigate to the image that was deleted, using the attachment URL, the image is still on the cdn

icy hamlet
unique shoal I don't understand how sending it as a file attachment is the same url?

I've tested this. Components v2 doesn't work, but a basic message send does.

  const [exampleGallery, attachments] = message.attachments.reduce(
    (acc, attachment) => {
      acc[0].addItems((mediaGalleryItem) => mediaGalleryItem.setURL(attachment.url));
      acc[1].push(new AttachmentBuilder().setFile(attachment.url));

      return acc;
    },
    [new MediaGalleryBuilder(), []],
  );

  const channel = message.guild.channels.cache.get(message.channelId);
  // This results in Image not Found
  await channel.send({
    components: [exampleGallery],
    files: attachments,
    flags: [MessageFlags.IsComponentsV2],
  });
  // This sends the image correctly
  await channel.send({
    files: attachments,
  });
loud quartz

wait, actually, why are you both setting gallery to be url of already sent message, and then upload the files from that same message as attachments in that same message

Thonk

icy hamlet

I wasn't sure about that part. The docs were confusing on whether I needed to include the attachment in files in order to send it in a media gallery.

loud quartz

media gallery takes urls

https://my.image.com is a url

attachment://myimage.png is also a url that would be pointing to attached file with that name

icy hamlet

Okay, I commented out the files part of the components v2 message. Same result

loud quartz

then no idea

icy hamlet

It may just be a discord thing

loud quartz

if all the urls are set correctly then it's not looking like our fault

might be better of asking in ddevs

icy hamlet

Yeah, thanks for the help. Thinking about it, I'm not surprised that I can't add an image to a media gallery that's probably marked for deletion but the image definitely hasn't been garbage collected by discord yet. Resending the image in a basic message might not check for whether the original image was deleted

loud quartz

it's deleted immediately

if you're still able to open it in your browser it's because it's cached locally on your pc by that browser

icy hamlet

good point

loud quartz

and eventually still might happen to be cached by the cdn, but that's rarely the case

torn orchid

https://sourceb.in/aKmymrTY7F

 Could not DM family_guy323213: DiscordAPIError[50007]: Cannot send messages to this user
0|Penguin  |     at handleErrors (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\node_modules\@discordjs\rest\dist\index.js:762:13)
0|Penguin  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
0|Penguin  |     at async SequentialHandler.runRequest (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\node_modules\@discordjs\rest\dist\index.js:1163:23)
0|Penguin  |     at async SequentialHandler.queueRequest (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\node_modules\@discordjs\rest\dist\index.js:994:14)
0|Penguin  |     at async _REST.request (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\node_modules\@discordjs\rest\dist\index.js:1307:22)
0|Penguin  |     at async DMChannel.send (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:195:15)
0|Penguin  |     at async Object.execute (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\Messages\hr cmds\moderation\ban.js:54:4)
0|Penguin  |     at async execute (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\Events\PrefixHandler.js:61:4) {
0|Penguin  |   requestBody: {
0|Penguin  |     files: [],
0|Penguin  |     json: {
0|Penguin  |       content: 'You have been banned from **penguin development**.\n**Reason:** t.',
0|Penguin  |       tts: false,
0|Penguin  |       nonce: undefined,
0|Penguin  |       enforce_nonce: false,
0|Penguin  |       embeds: undefined,
0|Penguin  |       components: [Array],
0|Penguin  |       username: undefined,
0|Penguin  |       avatar_url: undefined,
0|Penguin  |       allowed_mentions: undefined,
0|Penguin  |       flags: undefined,
0|Penguin  |       message_reference: undefined,
0|Penguin  |       attachments: undefined,
0|Penguin  |       sticker_ids: undefined,
0|Penguin  |       thread_name: undefined,
0|Penguin  |       applied_tags: undefined,
0|Penguin  |       poll: undefined
0|Penguin  |     }
0|Penguin  |   },
0|Penguin  |   rawError: { message: 'Cannot send messages to this user', code: 50007 },
0|Penguin  |   code: 50007,
0|Penguin  |   status: 403,
0|Penguin  |   method: 'POST',
0|Penguin  |   url: 'https://discord.com/api/v10/channels/1387256255499866232/messages'
0|Penguin  | }
sharp ginkgoBOT

DiscordAPIError: Cannot send messages to this user
Your bot is trying to send a DM to a user, but failed to do so:

  • The user has DMs disabled or the bot blocked
  • The user no longer shares a guild with the bot (make sure to send informational DMs before banning/kicking)
  • The bot is trying to DM itself or another bot
    Note: You cannot check if you can send a DM beforehand but have to handle the rejection case
bleak owl
sturdy ravine
    const mainContainer = new ContainerBuilder()
        .setAccentColor(0x0099FF)
        .addTextDisplayComponents(
            textDisplay => textDisplay
                .setContent('!\n**Choose category'),
        )
        .addActionRowComponents(
            actionRow => actionRow
                .setComponents(
                    new ChannelSelectMenuBuilder()
                    .setCustomId('choose')
                    .setPlaceholder('Scegli la categoria')
                    .setChannelTypes('GuildCategory')
                ),
        )

guys how can I list all categories in my guild.
But this is inside DM

I am using ChannelSelectMEnuBuilder but it lists nothing

red coral

use .setChannelTypes(ChannelType.GuildCategory), not a string

sturdy ravine
red coral

Does the server even have any categories? If not thats your issue, if it actually shows nothing then its probably not something about djs

sturdy ravine
warm sedge

I’m not entirely sure - are the new components for the Discord modals ready and usable, or how does that work?

sturdy ravine
red coral

Yh, there arent any guild channels in a dm lol

red coral
warm sedge
rose tangle

there's no way for discord to know which guild's channels you'd want to show

sturdy ravine
rose tangle

well it's not that hard

just iterate over the channels, if it's of .type category then add it

and done

though it wouldn't work if you have more than 25 categories, that'd be the only issue

rose tangle

for the manually populated menus, yes

string or number currently

you'd use a string in this case, your option value would be the category id

technically there's also a 25 limit for the automatically populated ones, but it's how many it shows at a time, not how many it "holds", if the user types something they can filter and it can show others than the currently 25 shown

sturdy ravine

thanks @rose tangle ❤️

sturdy ravine

Can't I send using a button?

my code is

        await interaction.deferReply();


        const select = new ChannelSelectMenuBuilder()
            .setCustomId('starter')
            .setPlaceholder('Make a selection!')
            .setChannelTypes([ChannelType.GuildCategory])
            //.addOptions(options) --- IGNORE ---
            //.addOptions( --- IGNORE ---
            .setMinValues(1)
            .setMaxValues(10);

        const row = new ActionRowBuilder()
            .addComponents(select);

        await interaction.editReply({
            content: 'Select users:',
            components: [row],
        });
    
rose tangle
sturdy ravine
rose tangle

once the user unfocuses the menu, the interaction is sent

well that's more of a design choice

I don't think one is objectively better than the other

but that's how discord decided it

sturdy ravine

Only because people may unfocus to look at other things because they don't know

rose tangle

if you're making a submission flow where the user needs to select many things before submitting, you could use a modal once djs supports select menus in modals

sturdy ravine

yea sure

sturdy ravine
rose tangle

you used to be able to submit only text, yeah

until a few weeks ago when they added select menus and text displays

but djs doesn't support that yet, it will in the future though

sturdy ravine

uh in modals? sheesh so cool

ripe topaz

Is there a limit to how many options I can provide with an autocomplete interaction?

rose tangle

25

ripe topaz

thanks tip

radiant raft

I've been trying to use thumbnail while using componentsv2 but I've been having issues with it, is there a way to do it?

rose tangle

share your issue

radiant raft

trying to get thumbnail working

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.

rose tangle

you aren't really using a thumbnail anywhere there

sharp ginkgoBOT

guide Popular Topics: Display Components - Thumbnail
read more

rose tangle

here's an example if you need one, it needs to be inside a section

radiant raft

for example like this, I tried to use title but I'm seeing is not possible

Error in specs command: TypeError: (intermediate value).setTitle is not a function

rose tangle
radiant raft
rose tangle

that's what you have already no?

    new SectionBuilder()
        .addTextDisplayComponents(
            new TextDisplayBuilder()
                .setContent(`**Hanma V.0.01**`)  
        )

that text display should contain all the text you want in the section

you can add 5 of them in a single section, though there's no visual difference other than a new line

radiant raft

thanks it worked lol thanks for the tip

silent mirage
      .setAccentColor("#364f6a");
Argument of type '"#364f6a"' is not assignable to parameter of type 'number | RGBTuple | undefined'.

just to confirm this is correct

rose tangle

it's correct

write it as 0x<hex>, 0x364f6a in your case

if you really need it to be a string, like for user input, then you can use the resolver

sharp ginkgoBOT
radiant raft

can someone give me an example using footer with componentsv2 obtaining the iconurl

for example

polar karma

There's no analog in cv2

frosty dagger

any way to fetch multiple channels ? like 20 channels at once

sharp ginkgoBOT

method ChannelManager#fetch() discord.js@14.22.1
Obtains a channel from Discord, or the channel cache if it's already available.


// Fetch a channel by its id
client.channels.fetch('222109930545610754')
  .then(channel => console.log(channel.name))
  .catch(console.error);

topaz bluff
frosty dagger

mainly I have 20 guilds
and 20 define channel
any way to fetch those 20 channel at once

to avoid api rate limit in case

unique shoal

Why are you fetching them though, arent they in your cache?

chrome widget

if i m using interaction.reply()
whats the tag to enter for displaying user selected in the command ?
like
/user {option: user}
reply: {user} is user
its just an xample

worthy drift

const user = interaction.options.getUser('option-name')
depends on what option you pass in

chrome widget
 name:'member',
            description:'The member to ban',
            required: true,
            type:ApplicationCommandOptionType.Mentionable,

        },
        {
            name:'reason',
            description:'The reason for this ban',
            type:ApplicationCommandOptionType.String,
        },
    ],
    permissionsRequired: [PermissionFlagsBits.BanMembers],
    callback: (client, interaction) => {
        interaction.reply(`${ta}`)

how to make it so like: royalmessager was banned from the server for {reason}

ive put optionss: []
then {} and fdefined all the options

snow onyx

why is member a mentionable option

that should be a User option

chrome widget

alr

sharp ginkgoBOT

guide Slash Commands: Parsing options - Command options
read more

chrome widget

tysm

obsidian dust

When is modal components getting added for d.js

unique shoal

when theyre ready + 1 day for every time someone asks

obsidian dust

ehm ok

sand minnow

How to add a String/Channel/Role SelectMenu into a modal

obsidian dust

😭

sand minnow

or can we use discord api to add crySparkle

unique shoal

Not ready in discord.js yet

tardy sable
sturdy ravine
    async addcategorycommand(interaction){

        console.log(interaction.type)
        await interaction.deferUpdate();

        const selectedOption = interaction.values;
        
        await addCategoryToDB(interaction.client.dbPath, selectedOption);

        const mainContainer = new ContainerBuilder()
            .setAccentColor(0x0099FF)
            .addTextDisplayComponents(
                textDisplay => textDisplay
                    .setContent('!\n**Scegli** la categoria del gioco a cui giocherete!'),
            )
            
        
        await interaction.followUp({components: [mainContainer]});
   

    }

ANy idea why I get

DiscordAPIError[50035]: Invalid Form Body
components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
unique shoal

Not setting the IsComponentsV2 message flag

sturdy ravine

ty ❤️

sturdy ravine

How do I modify the content of addTextDisplayComponents of my ComponentBuilder?

wary coral
sturdy ravine
wary coral

it is just the text display in the components or are their other components

sturdy ravine

I think that's not aesthetically pleasing tbh. Tips? ahah

wary coral
wary coral
sturdy ravine

Warning: Supplying "ephemeral" for interaction response options is deprecated. Utilize flags instead
So here is the problem?

        await interaction.deferReply({ ephemeral: true });

or here

        return await interaction.followUp({ 
            content: '', 
            components: [emptyContainer],
            ephemeral: true ,
            flags: MessageFlags.IsComponentsV2,
        
        });
sharp ginkgoBOT

tag suggestion for @sturdy ravine:

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
sturdy ravine

And why do I get this
I need to OR it?

proud arrow

Bitwise OR, yes

sturdy ravine

I need to remove ephemeral from here too?

            return await buttonInteraction.reply({
                content: '❌ Solo chi ha eseguito il comando può utilizzare questi bottoni!',
                ephemeral: true
            });
```?
wary coral

also yes, flags should be used for deferReply

wary coral
sturdy ravine
wary coral

do you need the deferReply?

sturdy ravine

Yea

wary coral

then use it with the ephemeral flag

sturdy ravine

yep

wary coral

sorry missed the "it" in your message

sturdy ravine

will I also need
to have IscomponentV2

        await interaction.deferReply({ flags: MessageFlags.IsComponentsV2 | MessageFlags.Ephemeral });

or just the main ephemeral flag

        await interaction.deferReply({ flags: MessageFlags.Ephemeral });

they are not related aint they

wary coral

you do not need to add the cv2 flag

wary coral
sturdy ravine
wary coral

embeds do not work in cv2 including links embed , Discord events, etc.

heavy sparrow

I still don't understand if the role selection has been added to modal windows or is it still in development?

Error: Cannot properly serialize component type: 18

dense jackal

but yes it is available using the Discord API, and you can show modals with the select menus using client.rest to send raw API requests

there is as of now absolutely no way of receiving modal interactions with select menus as the d.js validators will stop it

heavy sparrow

Got it, thanks

upbeat cedar

Hello, could you please tell me how to move the right-side buttons to the bottom?
This is how it's done in component v1, but I want to do the same in component v2.

const thumbnailComponent = new ThumbnailBuilder({
  media: {
    url: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQXE_Gu7jDGVgOIv6I8iQguv4TXQx8_igS5AQ&s',
  },
});
const container = new ContainerBuilder()
  .setAccentColor(0x0099FF)
  .addSectionComponents(section =>
    section.addTextDisplayComponents(td =>
      td.setContent('# test voice channels')
    )
    .setThumbnailAccessory(thumbnailComponent)
  )
  .addSeparatorComponents(separator => separator);

for (const ch of voiceChannels) {
  container.addSectionComponents(section =>
    section
      .addTextDisplayComponents(td => td.setContent('\u200b'))
      .setButtonAccessory(btn =>
        btn
          .setCustomId(`vcbtn|${ch.id}|${roleId}`)
          .setLabel(ch.name)
          .setStyle(ButtonStyle.Secondary)
      )
  );
}

await message.channel.send({
  flags: MessageFlags.IsComponentsV2,
  components: [container],
});```
topaz bluff

To move buttons to be the same as components V1, just don't use a section. Use an actionrow instead

sharp ginkgoBOT
upbeat cedar
topaz bluff

Correct. There's only right align and left align

upbeat cedar

Is it possible to make something like 5 buttons in a row across?

dense jackal
topaz bluff

you have 2 options for buttons

  • the old style of action rows...1-5 buttons left aligned on a horizontal row
  • a single right aligned button attached to a section component
dense jackal

or use 5 action rows to make it “left vertically aligned”

topaz bluff

Ok yes that's an option as well...a bad one but you do you

dense jackal

yeah its a bad one lol, but its one possible option too

radiant raft
scenic bluff

guys client.application.commands.set takes about an hour to work, but what if i loop through every guild and perform a
guild.commands.set would it immediately update the commands for all servers??

crimson gale

global commands haven't taken substantial time to deploy/roll out for years at this point

scenic bluff

ow guess i was stuck in a cave 💀

topaz bluff

You need to restart your discord app to clear your commands cache on the client
(Ctrl+R)

scenic bluff

oh

crimson gale

that one is quite odd, because there used to be a forward repair mechanism for it, where using it once would re-fetch them so the second would be correct

scenic bluff

seems like it still persists (the duping of commands)

crimson gale

duping? that's something else entirely

sharp ginkgoBOT

If you have duplicate commands on your server, you registered both global and guild commands.

You can remove the duplicates by resetting either the global or guild commands

  • Resetting global commands: rest.put(Routes.applicationCommands(clientId), { body: [] })
  • Resetting guild commands: rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
crimson gale

that means you deployed the same command globally and to the guild

scenic bluff

ah i see, ty

open musk

I’m converting a pdf into an image and trying to send that image through filebuilder in components v2. does filebuilder only accept urls? because using attachment:// doesn’t seem to work

wary coral
sharp ginkgoBOT

guide Popular Topics: Embeds - Attaching images
read more

wary coral

The above guide is for embeds but the principal is the same for components V2

open musk

tysm. after struggling for another 15 minutes i realized i had forgotten to install the required system libraries for the image conversion library to work properly

triste

wraith pewter

Is there any way to set a voice channel's status through a bot?

olive lantern

how do we do components v2?

snow onyx
fathom warren

hello, does known as badge exist somewhere in dapitypes?

sharp ginkgoBOT

guide suggestion for @olive lantern:
guide Popular Topics: Display Components
read more

fathom warren

or it's protected from being exposed? cause i want to check whether user had pomelo experiment and just display badge of it ( e.g in userinfo command )

snow onyx

no, its not a thing

fathom warren

that's a shame

sturdy ravine

guilds are always cached?

snow onyx

if you haven't manipulated the caches and you have the Guilds intent, yes

same as channels and roles

sturdy ravine

how do I get the text from a modal?

sharp ginkgoBOT
crystal cargo

i am getting this error in embed field since long time: Expected: expected.length <= 1024
although i am checking the length to be less than 1024
is there a good way to check string length for Discord or Embed staff

topaz bluff

the method DiscordJS does it is by using zod to validate the object using a schema

export const embedFieldPredicate = z.object({
    name: namePredicate,
    value: z.string().max(1_024),
    inline: z.boolean().optional(),
});

you can implement your own pre-validate it or you can run .toJSON() which will run the built in validate

public toJSON(validationOverride?: boolean): APIEmbedField {
    const clone = structuredClone(this.data);
    validate(embedFieldPredicate, clone, validationOverride);

    return clone as APIEmbedField;
}
wraith pewter

Is there anyway to remove the warning since it isn't coming from any of my files > ```
(node:25940) DeprecationWarning: The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead.
at WebSocketManager.triggerClientReady (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:389:15)
at WebSocketManager.checkShardsReady (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:368:10)
at WebSocketShard.<anonymous> (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:198:16)
at WebSocketShard.emit (node:events:518:28)
at WebSocketShard.checkReady (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:184:12)
at WebSocketShard.gotGuild (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:158:10)
at WebSocketManager.<anonymous> (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:238:15)
at WebSocketManager.emit (C:\Users\ytblu\Desktop\C4 Bot\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
at WebSocketShard.<anonymous> (C:\Users\ytblu\Desktop\C4 Bot\node_modules@discordjs\ws\dist\index.js:1190:51)
at WebSocketShard.emit (C:\Users\ytblu\Desktop\C4 Bot\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31)

stable sun
wraith pewter
topaz bluff

you can also get rid of it by listening to what it says

stable sun

You can use the newListener event to trace who’s adding the listener

sharp ginkgoBOT

node 'newListener'
The EventEmitter instance will emit its own 'newListener' event before a listener is added to its internal array of listeners.Listeners registered for the 'newListener' event are passed the event name and a reference to the listener being added.The fact that the event is triggered before adding the listener has a subtle but important side effect: any additional listeners registered to the same name within the 'newListener' callback are inserted before the listener that is in the process of being added.

dense furnace

Guys I have one design question. Imagine I have a discord bot, but sometimes I want to trigger some events from my HTTP backend server, that is imagine sending an HTTP request to my backend for "Creating a channel", my backen triggers bot's command/function to create a channel. Is this possible and if yes then how to do it? Based on my research, Discord.js does not allow you to expose Bot's APIs as HTTP, so the only way to do so is to run separate app (like express or fastify) as a backend and in the handler of the endpoint trigger the Bot's function. But to be honest I don't like this method because running 2 in parallel with each other is a good idea (based on my experience). So long story short, what are the possible options/strategies to expose Bot's endpoints?

wary coral
hasty osprey

should i use deferReply on every command that uses the database?

i feel like thats a question for this chat

red coral

I mean, imo it depends. A leaderboard were you fetching loads of data? Yes. A simple command? No. But if your db is over the other side of the world then maybe

You have 3 seconds, if your queries are long then yes if not then there’s no need

topaz bluff

It's generally just a good idea to use defer any time you hit an external entity. Those are unreliable and unpredictable

But ya, it realistically doesn't matter for tiny database requests. It adds extra latency on the response for the protection against a very rare circumstance where your DB is hung up on something so much so it takes several seconds to respond

sturdy ravine

is it possible to append information to a modal? Since I recall it from another function I need to pass a parameter

wary coral
sturdy ravine
red coral

Why not? What are you passin?

sturdy ravine

Basically my info is a parameter that can be private or public, but when I handle the modal from interactionCreate I will trigger two different functions based on that previous parameter

I do have a TextInputBuilder component in my modal

wary coral
topaz bluff

Or you can store a Collection of "in progress" interactions keyed by a customID

sturdy ravine
sturdy ravine
topaz bluff

Ya you'll likely have to rework your event handling to allow dynamic customIDs

The simplest one is event-type-ID_HERE and then check a startsWith

sturdy ravine

exactly

Thank you boys, I owe you a beer

topaz bluff

Just make sure you are handling situations where a collector receives the interaction instead of your interactionCreate listener

sturdy ravine
crisp roost

any chance display components work with role select menus (and if they do how would one do it 🙏)

topaz bluff

Yes. You can add any select menu in an action row and put an action row in a container

crisp roost
topaz bluff

Yes. You build them exactly like you would with the legacy components

crisp roost

perfect, thank you!

sharp ginkgoBOT
crisp roost
topaz bluff

Show the whole error and possibly the whole code

This is directly from the guide

    .addActionRowComponents(
        actionRow => actionRow
            .setComponents(
                new UserSelectMenuBuilder()
                    .setCustomId('exampleSelect')
                    .setPlaceholder('Select users'),
            ),
    )
sharp ginkgoBOT

guide Popular Topics: Display Components - Container
read more

limber canyon

Hello, I found an issue with discord-api-types and I hope this is right place for it.

The channel type isn't correctly inferred for the PublicThread & PrivateThread channel types.
The parent_id should be existing in both of these channel types, but instead it has the values null and undefined to it as well.

limber canyon
stable sun

Yea, don’t use that for type narrowing

There’s a type that contains a union of all channels

Or I don’t think -types has this

D.js has the Channel type

sharp ginkgoBOT
stable sun

But this is expected behavior because APIChannel is the base type of all channels, not a union of possible structures of all channel types

limber canyon

APIAnnouncementThreadChannel falls under this fault as well.

stable sun

parent_id would prob have to be moved out of APIGuildChannel

limber canyon

precisely

I will submit a pr in a bit, after reading the guidelines of doing so.

dim lantern

i have project to build website called resume builder so any one have done before , that will be help full i want to submit within 1 day

so any help guys!

dense jackal
dim lantern

which channel should i ask this kind of help

dense jackal

so for your issue/question you should join a server related to web development

trim steppe

Isn't it possible to send an ephemeral embed?

little pebble
trim steppe

How can I do that then?

interaction.followUp({ embeds: [addEmbed], flags: MessageFlags.Ephemeral })
This simply send the embed (non-ephemeral)

wise plaza

Hi all, i am quite new to JavaScript as a language, moving from Golang and Python, im trying to use a Discord UserApp as a starter project to help myself learn and improve. Am i right in saying i need to be setting an InteractionContextType.BotDM and InteractionContextType.PrivateChannel to each of my commands to be able to see and use the commands within dms with another user?

sharp ginkgoBOT

documentation suggestion for @wise plaza:
discord Developing A User-Installable App - Choosing Supported Installation Contexts
read more

wise plaza

Thank you!

dense jackal

wait that’s the wrong one, my bad

wise plaza

ah lmao

sharp ginkgoBOT

discord Application Commands - Interaction Contexts
read more

dense jackal

so for DM with another user only the PRIVATE_CHANNEL one is needed

wise plaza

gotcha, thank you so much ill try it out now

proud arrow
trim steppe

Yes

It sends the embed in de channel I want it to, simply not ephemeral

wise plaza
unique shoal
dense jackal

yeah you need to tell Discord if the reply will be ephemeral or not, so using the flag on followUp() after deferReply() is basically ignored

sturdy ravine

members are always fetched? No right?

wary coral
sturdy ravine
dense jackal
sturdy ravine
dense jackal

yeah, the cache might be outdated ofc

wary coral

If you need the most up-to-date version of the member pass the force option for fetch

dense jackal

when the user you try to fetch interacts with the bot again the cache gets updated

sturdy ravine

question: since I need multiple times the guild, should I make something like

client.mainGuild = //fetch guild here

so I use my guild all the time without fetching it everytime

dense jackal

all guilds should be cached once the CLIENT_READY event fires if you have the Guilds intent

sturdy ravine

got it ❤️

sturdy ravine

how can I check if the bot can send dm's to an user?
In other words if a user has dms closed

wary coral

I'm not sure you can. Until you send a message. Looking at the docs for DM channel, I don't see anything that would test if a message could be sent successfully

I think you just have to handle the error for the message if it gets rejected

sturdy ravine

Another question: is it always better to fetch a guy as user or member? My bot works mainly in dm

dense jackal

then user

unique shoal

I mean, you should call the variable what it actually is

Depending on which one you're fetching

dense jackal

oh yeah if that was the question then I misunderstood

you should fetch the user object and not the guild member object

sturdy ravine

I am not familiar with Modal collectors, do I have to put the collector right before my modal code, or in my interactionCreate?

dense jackal

you should use interaction.awaitModalSubmit() right below the line of interaction.showModal() if you want to use collectors

sturdy ravine
dense jackal you should use `interaction.awaitModalSubmit()` right below the line of `interac...

BEcause right now I basicalyl handle it without collectors in my interactionCreate like this


        if (interaction.isModalSubmit()){
            console.log("Inserito il nome");
            const customId = interaction.customId;

            if (customId.startsWith('channelnamemodal')){
                const privateOrPublicChannel = customId.slice(-2); //pu -> public, pr -> private
                // Nome del canale appena inserito dall'utente con ruolo special
                const customChannelName = interaction.fields?.getTextInputValue('specialrolechannelname');

                return await afterUserChoosePrivateOrPublicChannel(interaction, customChannelName, privateOrPublicChannel);
            }
                

        }

is it bad practice?

dense jackal

not really, collectors are just temporary event listeners

sturdy ravine

Should be fine then, love you b3ssel ❤️

sturdy ravine
dense jackal

yes, but since you have an event listener for the interactionCreate event as well, that modal submit interaction would make the listener execute the code inside it too

sturdy ravine
dense jackal

yeah

the bot will then ignore the code from the interactionCreate block since none of the if statements inside the if (interaction.isModalSubmit()) block satisfy

sturdy ravine

If I don't put a timer (so without collectors) it will wait for the modal forever. Is it actually bad for performance reasons?

dense jackal

if you don’t put a timer you shouldn’t use a collector at all but the main interactionCreate event listener instead

sturdy ravine
dense jackal

just 1 interactionCreate event listener for all incoming interaction events is the best you could do

so performance wise no not an issue, adding new event listeners for the same event is

but as collectors are meant to be temporary its fine to use them, just not without a timer set

crisp finch

Is there a function in DJS so I can make text look like this?

frank slate
sturdy ravine
crisp finch

Right I thought there was a function built in, sort of like quote(), blockQuote(), or codeBlock()

Oh I think I found it

Yeah it's called inlineCode..

dapper cave

how is sapphire getting the category of an auditlogevent "channeldelete"

I can't find it in the entry "parent_id"

"entry": {
      "action": 12,
      "actionType": "Delete",
      "changes": [
        {
          "key": "name",
          "old": "testests"
        },
        {
          "key": "type",
          "old": 0
        },
        {
          "key": "permission_overwrites",
          "old": [
            {
              "allow": "0",
              "deny": "3146752",
              "id": "1410388318457430216",
              "type": 0
            },
            {
              "allow": "1024",
              "deny": "3147840",
              "id": "1410388318557962417",
              "type": 0
            },
            {
              "allow": "1024",
              "deny": "3147840",
              "id": "1410388318570549269",
              "type": 0
            }
          ]
        },
        {
          "key": "nsfw",
          "old": false
        },
        {
          "key": "rate_limit_per_user",
          "old": 0
        },
        {
          "key": "flags",
          "old": 0
        }
      ],
      "createdTimestamp": 1758459417365,
      "executor": "1045011641940574208",
      "executorId": "1045011641940574208",
      "extra": null,
      "id": "1419306409090093108",
      "reason": null,
      "target": {
        "flags": 0,
        "id": "1419306395911721043",
        "name": "testests",
        "nsfw": false,
        "permission_overwrites": [
          {
            "allow": "0",
            "deny": "3146752",
            "id": "1410388318457430216",
            "type": 0
          },
          {
            "allow": "1024",
            "deny": "3147840",
            "id": "1410388318557962417",
            "type": 0
          },
          {
            "allow": "1024",
            "deny": "3147840",
            "id": "1410388318570549269",
            "type": 0
          }
        ],
        "rate_limit_per_user": 0,
        "type": 0
      },
      "targetId": "1419306395911721043",
      "targetType": "Channel"
    }```
dense jackal

maybe they saved the category id somewhere else or they use the “channelDelete” event

dapper cave

and idk if im tweaking or if my code is

dense jackal

the category id is indeed not present on an audit log object

dapper cave

aaaaa

let me try the channeldelete event then holdon

well that worked thank u @dense jackal silly me

sharp ginkgoBOT

documentation suggestion for @crisp finch:
function inlineCode discord.js@14.22.1
Wraps the content inside backticks, which formats it as inline code.

dapper cave

sus

dapper cave
sullen cedar

When v15 gets released?

steel trail

Why does it matter? All new features discord releases get added to v14 anyway atm

sturdy ravine

When does this error trigger?
Error [InteractionCollectorError]: Collector received no interactions before ending with reason: time

steel trail

When you use awaitMessageComponent() or awaitModalSubmit() with time set but there is no interaction within that time and you don't catch that rejection

silent mirage

When i try to make a discord container it wants a thumbnail when i try not to add one it crashes

hallow mesa

Sections require accessories. If you don't want an accessory, just use a text display instead

silent mirage

Got it that probably what i am doing wrong

sharp ginkgoBOT

guide suggestion for @silent mirage:
guide Popular Topics: Display Components
read more

sturdy ravine

Can I have a StringOption in my SlashCommand but that gives predefined options loaded dinamically?

sharp ginkgoBOT

guide Slash Commands: Advanced command creation - Choices
read more

dense jackal

i think this one is better

sturdy ravine
dense jackal

yes I think you can

but I am not too sure if the 3 second respond time applies on here too, someone else has to confirm that

oh wait im mixing stuff up

for dynamic choices you will need to use autocomplete

sharp ginkgoBOT
dense jackal

this guide tells you how to implement

dense jackal
rough iris

when I use this commands 'node index.js or nodemon' I get this err message
How do I solve this problem? (I'm in Turkey and Discord is banned in there. I'm connected to Discord with Cloudflarewarp in Linux) mention me

chrome widget
    callback: (client, interaction) => {
        const targetUserId =  interaction.options.get('user').value;
        const reason = interaction.options.get('reason')?.value || "No reason provided";
    },

    name: 'ban',

how do i change ?.value || "No reason provided"; to >
"No reason provided & banned by (user who ran cmd)_";

kindred moon
chrome widget

um like reason that it shows:
No reason provided and banned by 1377384098196095140

kindred moon

well as i said you can use interaction.user properties and in this case it would be .id

sharp ginkgoBOT

tag suggestion for @rough iris:

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.
chrome widget

permissionFlagsBits.ModerateMembers include which perms

silent mirage
client.on("messageDelete", async (message) => {
  if (message.author?.bot || !message.guild) return;
  console.log(`[Message Delete] Message deleted in guild ${message.guild.name} (${message.guild.id}) by ${message.author?.tag || "Unknown Author"}`);
});


when i delete a message this does not run at all

no erros nothing is logged like event is not being runned

sturdy ravine
rose tangle
silent mirage

no i am deleting a old message

my client

const client = new FrostSentinelClient({ 
  allowedMentions: { parse: ["users", "roles"], repliedUser: true }, 
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent
  ]
});

halcyon bison
halcyon bison
sturdy ravine

Damn I got it sheesh

rose tangle
silent mirage

A class of my client

rose tangle

and how do you call super() on it

or well, how does the super() call looks like

assuming it extends Client

silent mirage
export default class FrostSentinelClient extends Client {
  public commands: Collection<string, any>;

  constructor(options: ClientOptions) {
    const defaultIntents = [
      GatewayIntentBits.Guilds,
      GatewayIntentBits.GuildMessages,
      GatewayIntentBits.MessageContent,
      GatewayIntentBits.GuildMembers,
      GatewayIntentBits.GuildMessageReactions,
      GatewayIntentBits.DirectMessages,
      GatewayIntentBits.DirectMessageReactions,
      GatewayIntentBits.GuildPresences,
    ];

    super({
      ...options,
      intents: options.intents
        ? Array.isArray(options.intents)
          ? [...defaultIntents, ...options.intents]
          : [...defaultIntents, options.intents]
        : defaultIntents,
    });

    this.commands = new Collection<string, any>();
  }

rose tangle

you'll need to pass the partials to your new then

sharp ginkgoBOT

guide Popular Topics: Partial Structures
read more

silent mirage
[MessageDelete Event] Triggered
[ERROR] September 21st 2025, 1:49:37 pm [MessageDelete.execute] Failed to fetch partial message: DiscordAPIError[10008]: Unknown Message
null
[INFO] September 21st 2025, 1:49:47 pm - [Heartbeat][frost_testing_bot] Received heartbeat from server


  if (message.partial) {
    const fetchedMessage = await message.fetch().catch((err) => {
      logger.error(
        `Failed to fetch partial message: ${err}`,
        "MessageDelete.execute"
      );
      return null;
    });

    console.log(fetchedMessage);
    return;
  }

clear garnet

Well, yea, you can't fetch a message that no longer exists

silent mirage

Hmm i am trying to fetch it when i do message delete

clear garnet

And I am saying that you can't

rose tangle

check the warning

silent mirage

Oh so when message deletes i can not get the content deleted

Or the author that deleted it

rose tangle

discord doesn't sent that data, it's gone already

rose tangle

the only way to get who deleted a message is by getting audit logs

worldly zinc

Do I need a discord.js for node.js

rose tangle

though they won't generate for self deletes, and I think deletes from bot's messages

rose tangle
silent mirage

So if i would want all that information i would have to cache and store all messages

rose tangle

"all that" including who deleted it?

silent mirage

Yes who deleted message content

worldly zinc

Ok bit weird my sentence does make sense all I want do I need a discord.js gees man

rose tangle

you'll need to check audit logs for that

so whether you have all messages or not in your cache, that's completely unrelated

silent mirage

Got it thank you so much

rose tangle

you don't get "a discord.js"

again:

if you're just starting in node/javascript development you'll need to learn that first before trying to make a bot, check #resources for some resources to learn

dapper cave

What is the auditlog InviteUpdate useful for if you can't update invites stare

loud quartz

why would we know

we didn't add it nor do we emit it on our own

proper remnant

Guys is it possible to make a bot that records me talking in a voice channel?

rose tangle

yes

the bot would need to be in the voice channel obv

proper remnant
sharp ginkgoBOT

guide suggestion for @proper remnant:
guide Getting Started: Introduction
read more

dapper cave

StageInstanceCreate
StageInstanceUpdate
StageInstanceDelete

Does anyone know what these fire for? I literally can not find it i've tried making stage channels, events in a stage channel, googling it online AAAAAAA shocked

wary coral

I don't believe those are events on Client. What are you trying to do?

dapper cave

slowly losing it fr

wary coral

They might be old codes no longer used. I would refer to the Discord documentation

dapper cave

I first had rolecreate and roledelete in auditlog but those catched like half of the roles added for example if a bot joins it makes a default role it wouldn't catch that then I move it to like a client event and boom it works for all roles

wary coral
dapper cave

lawyer 🔫

me when channelcreate praysob

wary coral

Stage channels used to be more special when Discord made them discoverable. So it's possible they are now just using the channel update type instead of these stage specific ones but I don't know

dapper cave

Alright thx also do u perhaps have a list of like auditlog and guild events for example rolecreate works perfect as a guild event and as an auditlog event it only catches half of the roles AAAA

I cant find any imsad
or im just really noobing rn (I probably am)

wary coral

Using the audit log create event is not perfect. Discord will group similar audit logs together and the additional items to the audit log. Don't fire the event

dapper cave

aaaaaaaaaaaaa ill try putting everything in guild then what I can

worthy shale

hi is it somehow possible to fetch/search servers from discord discovery page?

rose tangle

what would be the use case? 🤔

worthy shale

like yk /server search: anime

and shows up search results

wary coral

I don't believe server Discovery endpoints are made available to applications

worthy shale

ic

well i was just curious, thanks

rose tangle

yeah users can still search that themselves and get a nicer ui a bot can show anyways

dense jackal

https://discord.com/api/v9/discoverable-guilds/search?query=anime&offset=0&limit=12&with_counts=true this is the url used when using server discovery on looking on the network tab on browser

edit: for anyone wondering, its not available using bot auth tokens

worthy shale

hmmm

but surely authorization is thru users token so bot wont be able to fetch that ig

dense jackal

you can always try it out and see what happens

but its not documented at all, so d.js won't support it either -- you have to look on your own

plus since its not documented it can be changed at anytime

loud quartz

not some magic event of everything that's happening

adding an app to a server only produces a log about adding an app to the server

that process might create a role, but that's not what has been done directly so there is no separate log for that

dapper cave

Thanks for explaining also ive moved most to client events instead of auditlog events except ofc like webhookcreate cuz those arent client events

vernal blaze

Can i make questions abt @discordjs/opus here?

golden laurel
vernal blaze
balmy kraken

are DMchannel and interaction.channel functionally the same?

clear garnet

One is a class, the other is something that has a chance of being an instance of that class

balmy kraken

my bot with admin permissions cannot change the server owners nickname, it errors with rawError: { message: 'Missing Permissions', code: 50013 },. Is there something I can do?

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.
latent drift

hi there, bit of a newbie - but I noticed this PR (https://github.com/discordjs/discord.js/pull/11096) how would I go about using UserSelectMenuBuilder in a Modal (if this is currently possible).

When I use this inside a ModalBuilder:

        new ActionRowBuilder().addComponents(
          new UserSelectMenuBuilder()
            .setCustomId('team_members')
            .setPlaceholder("Select up to 8 team members")
            .setMinValues(1)
            .setMaxValues(8)
        ),

I get:

DiscordAPIError[50035]: Invalid Form Body
data.components[1].components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (4,).
bleak owl

this is not possible yet

that’s why there’s a PR

wary coral

and when they do come out would would need to use a LabelBuilder not a ActionRowBuilder

latent drift

since the PR has been merged, when could I expect it to be available publicly?

wary coral
latent drift

alright, tysm!

balmy kraken

im trying to edit roles by doing await interaction.guild.roles.edit(role.role_id, { name: role.role_name, primaryColor: role.role_color })

everyting works as it should, except color. I provide a hexadecimal value for it in a string, ie. #e91e63 and it doesnt change. The request goes through with no errors regarding color and everything else changes as it should

sharp ginkgoBOT
proud arrow

The option is colors which takes an object

balmy kraken

oh right

leaden river

so dynamic slash command options via autocomplete actually work better than I thought… funny how the docs make it seem so rigid. curious if anyone has done a fully DB-driven autocomplete yet?

rose tangle

that's not really feasible unless you really optimize your db and connection

given you only have 3s to reply

I'm not sure how the docs make it seem rigid though

unique shoal

Ive done it pretty easily with a local db, though its definitely more efficient to use caching

chrome widget

whats the error in this?
where the warning was created)
Dank Syndicate Grinders#0636 is online on discordapp.
There was an error running this command: DiscordAPIError[10062]: Unknown interaction
There was an error running this command: DiscordAPIError[10062]: Unknown interaction

sturdy ravine

ANy ide awhy I get this error Value of field "type" must be one of (1,).?

snow onyx
sharp ginkgoBOT

tag suggestion for @chrome widget:
Common causes of DiscordAPIError[10062]: Unknown interaction:

  • Initial response took more than 3 seconds ➞ defer the response *.
  • Wrong interaction object inside a collector.
  • Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance)
    * Note: you cannot defer modal or autocomplete value responses
sturdy ravine
snow onyx

what?

please elaborate kekw

sturdy ravine

Ye I meant like this wtf I've wrote an ActionRowBuilder

    const mainContainer = new ContainerBuilder()
        .setAccentColor(0x0099FF)
        .addTextDisplayComponents(
            textDisplay => textDisplay
                .setContent('Procedi con la __creazione__ della tua stanza personalizzata!\n**Scegli** se renderla `privata` o `pubblica`!'),
        )
sharp ginkgoBOT
snow onyx

You need to provide the IsComponentsV2 message flag if you want to send ComponentsV2

snow onyx

Surprisingly, yes

sharp ginkgoBOT

method Guild#edit() discord.js@14.22.1
Updates the guild with new information - e.g. a new name.


// Set the guild name
guild.edit({
  name: 'Discord Guild',
})
  .then(updated => console.log(`New guild name ${updated}`))
  .catch(console.error);

snow onyx

You can provide features with an edited array of features excluding "COMMUNITY"

halcyon vault

Hi! Still there is startMessage object present in the therad creation event or deprecated?

sharp ginkgoBOT

documentation suggestion for @halcyon vault:
method ThreadChannel#fetchStarterMessage() discord.js@14.22.1
Fetches the message that started this thread, if any. The Promise will reject if the original message in a forum post is deleted or when the original message in the parent channel is deleted. If you just need the id of that message, use id instead.

snow onyx

this is what you should use, I'm not aware of a startMessage property

silent saddle

Does anyone know about MT4 and MT5?

snow onyx
halcyon vault

Is there any initial message can be sent on the thread chanel in the text channel as parent channel?

like initial post in the forum channel.

sharp ginkgoBOT
snow onyx

that?

or do you mean creating the thread directly with a new custom message

halcyon vault

No, just discovered that startMessag object is the message in whihc thread should be started, like i do here in my message.

halcyon vault
snow onyx

Then no.

The first message in the thread will be the starter message

halcyon vault

there is no such option in text channel?

snow onyx

correct

halcyon vault
halcyon vault

-# 👍

distant inlet

Just a quick question, can we use select menu inside a modal?

snow onyx

Its not yet supported in discord.js

distant inlet
proud shoal

When adding localization. If a localization is not supported in say a command description. it defaults to the value set in #setDescription() or am I confusing it.

rare egret

Hi! Are the new modal components available in Discord JS v14?

sturdy ravine
permissionOverwrites.push({
                    id: staffRoleId,
                    allow: [
                        'ViewChannel',
                        'Connect',
                        'Speak',
                        'ManageRoles',
                        'MuteMembers',
                        'DeafenMembers',
                        'MoveMembers'
                                        ]
                });

To disconnect a guy from the vocal chat the permission is Disconnect?

snow onyx
sturdy ravine
snow onyx

Because Discord decided that way?

wary coral

I am going to make a guess the action is the same as moving a member to a different channel. think of it like a move from channel ➡️ null

sturdy ravine

are channels alwasy cached?

sturdy ravine
snow onyx
sturdy ravine
sturdy ravine

Guys is it necessary to try catch every single command or I can only try catch at interactionCreate when I get the interaction?
I also have db connections and stuff in my commands

loud quartz

You have to catch errors and promise rejections

sturdy ravine
loud quartz

Promise can either resolve or reject

Everything you do with discord returns a Promise

Like sending a message, returns Promise<Message>, but that can reject if you for example send too much text, or don't have permission to send in that channel

sturdy ravine

I do use async await

loud quartz

Yes, that's how you handle Promises

They can still reject though

dry flame

How are interactions sent to a user-installed app handled in the context of sharding? As in, how is the shard that will handle those requests selected?

rose tangle

ddevs would be a better place to ask given it's an api question, not a djs one

frosty epoch

for both modal main title an each field title, the chars limit is 45?

snow onyx

yup

visual parrot

Guys, when the builders@v2 coming out?

rose tangle

why?

visual parrot

support

rose tangle

that will be supported in v1 though

if it isn't already, I think the change was merged already

just not released

visual parrot
rose tangle

changes are usually made to main first and then backported to the current major

besides, you can't use builders v2 in djs v14

since it's a new major it's a breaking change, it isn't compatible

you'll only be able to use it when v15 releases

visual parrot

That's so. Alright.

rose tangle

at most you could use it but you'd need to build first and then pass it to djs

can't pass the builder

hasty osprey

is it possible to use custom emojis in buttons

dense jackal

yes

hasty osprey

YAY

broken lake

Is there any way to make this text tinier?

snow onyx

-# is the smallest text you can post
-# is the smallest text you can post

chrome widget

hi! so whats the main difference between

ApplicationCommandOpionType.Mentionable

&

ApplicationCommandOptionType.User
stable sun
chrome widget
rich frigate

hey quick question: if I just use someTextChannel.messages.fetch({limit: 10}); does this fetch the last 10 messages sent, or 10 at random?

rich frigate
fervent ocean

how can I get all users who authenticated with oauth? is that possible?

I'm trying to make them join to my guild, do I have to store something else before that?

halcyon bison
dense jackal

out of curiousity: why doesn't d.js support oauth?

halcyon bison

ok as I started typing I realized there's quite a few reasons to list out
tldr: the bot api and oauth are separate parts of the api, djs just handles bots

ivory wasp

For those that manage large bot applications, what does your memory graph look like? Mine looks like this for 1d and it's just steadily creeping up. Curious if other d.js users see a similar thing (cache growth) or it's something specific to my app?

dense jackal
halcyon bison
sharp ginkgoBOT

guide suggestion for @ivory wasp:
guide Miscellaneous: Cache customization
read more

ivory wasp

I suspected it was the cache growing over time. Hadn't seen this part of the docs, thanks!

burnt sail

Will it still take long to add the select menu to the modal? It's been 12 days and I really want to use it.

topaz bluff

There is never ETAs. It'll be out when it's ready

sturdy ravine

How can I set the content of this TextDisplayComponent after being instantiated?


        const componentText = new ContainerBuilder()
            .setAccentColor(0xFF0000)
            .addTextDisplayComponents(t =>
                t.setContent(`🚫 **AVVISO STAFF | Canale vocale ${channel.name} e' stato eliminato**`)
            )

like componentText.setContent("...)?

topaz bluff

You can either replace the JSON by using container.components[index] or you could use container.spliceComponents() to replace the TextDisplay

rose tangle

are you building from a message or what is your use case?

sturdy ravine
        async function createComponent(interaction, content) {
            const temp = new ContainerBuilder()
                .setAccentColor(0xFF0000)
                .addTextDisplayComponents(t =>
                    t.setContent(content)
                );

            // Crea un ActionRow e aggiungi il ContainerBuilder al suo interno
            const row = new ActionRowBuilder()
                .addComponents(temp);

            return await interaction.editReply({
                components: [row], // Invia l'ActionRow, non il ContainerBuilder
                flags: MessageFlags.Ephemeral || MessageFlags.IsComponentsV2
            });
        }

DiscordAPIError[50035]: Invalid Form Body components[0].components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (2, 3, 5, 6, 7, 8)
I am losing my mind