#djs-help-v14

78874 messages · Page 12 of 79

hexed marsh

That's so ugly the way that looks and works xD

toxic moat

is it possible to add an attachment to a filebuilder?

hexed marsh

Yes

stable sun

Same way as you would with embed

sharp ginkgoBOT

Files in embeds should be attached via the message option object and referenced in the embed:

const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
  .setTitle('Attachments')
  .setImage(`attachment://${attachment.name}`);

channel.send({
  embeds: [embed],
  files: [attachment]
});
hexed marsh
toxic moat is it possible to add an attachment to a filebuilder?

Here's an example for ya.

const json = JSON.stringify(data);
const date = new Date().toISOString().split('T')[0]; // Get just the YYYY-MM-DD part
const buffer = Buffer.from(json, 'utf8');
const file = new AttachmentBuilder(buffer, { name: `infinitea-export-${date}.json` });

console.log(file);
await interaction.reply({
    embeds: [
        new EmbedBuilder()
            .setColor('#2ecc71')
            .setTitle('Thank you for using InfiniTea!')
            .setDescription('We appreciate the time you spent with us. We hope you find a bot that perfectly suits your community\'s needs. Your data export is attached.')
    ]
});

await interaction.followUp({
    files: [file]
});
toxic moat
stable sun

You add file to the message and refer to it using the attachment url scheme

sharp ginkgoBOT

Files in embeds should be attached via the message option object and referenced in the embed:

const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
  .setTitle('Attachments')
  .setImage(`attachment://${attachment.name}`);

channel.send({
  embeds: [embed],
  files: [attachment]
});
toxic moat

ohhhhhhh

thx m8

stable sun

attachment contains the file. EmbedBuilder refers to attachment in setImage, both embed and attachment are sent in channel.send

main mason

does guild.channels.cache (assuming guild.channels.fetch() is run beforehand) return a collection of all channels in the guild, or only all the channels the bot has view permissions for?

bleak owl

all channels in the guild, not including threads which need to be fetched

hexed marsh

How do you specify only a given set of users for the UserSelectMenuBuilder? I've tried both addDefault and setDefault. It appears that it always shows all members, but I'm keenly interested only in the specific users that are online and available in the voice channel.

const selectMenu = new UserSelectMenuBuilder()
    .setCustomId(`kick_${channel.id}`)
    .setPlaceholder('Select a member to kick')
    .setMinValues(1)
    .setMaxValues(1)
    .setDefaultUsers(channel.members.map(member => member.id))
rose tangle
rose tangle

you can however make a string select with only those users

hexed marsh

Oof custom impl then I suppose.

main mason
rose tangle

yes, if you have the Guilds intent

(not including thread channels)

and those channels would be cached in client.channels too, not including DM channels (or threads)

hexed marsh

Oof so if I use a StringSelectMenuBuilder I can't make it "Searchable" if the list exceeds 25... :S

zenith violet

correct

hexed marsh

I'm going to have to get creative asf

icy hamlet

Does the messageCreate event contain the components v2 data yet?

frosty epoch
 const admin = interaction.member.permissions.has(
[PermissionFlagsBits.Administrator, PermissionFlagsBits.ManageGuild],
        false // <-- checks if the member has ANY of the listed permissions
  );

This is returning false even tho I have only mange server perm?

halcyon bison
halcyon bison
sharp ginkgoBOT
icy hamlet
prisma ruin

how do i add emojis to my bot through code?

halcyon bison

<Client>.application.emojis.create()

sharp ginkgoBOT

documentation suggestion for @prisma ruin:
method ApplicationEmojiManager#create() discord.js@14.19.3
Creates a new custom emoji of the application.


// Create a new emoji from a URL
application.emojis.create({ attachment: 'https://i.imgur.com/w3duR07.png', name: 'rip' })
  .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
  .catch(console.error);

prisma ruin
little pebble
simple seal

Why in the mention at phone it appears invalid-user and in the browser the mention is correct

little pebble
hexed marsh

Is there a way I can create a BotDM context command to clear the chat? it drives me mad having all of these DM's that I really want to clear, and you can't send an ephemeral to the dms.

maiden inlet

/Programmer

loud quartz

Also you can send ephemeral replies in DMs

What you can't do is respond in a different channel than the one the interaction came from

hexed marsh

Correct, all of the DM's are coming from server.

So I can't send those ephemerally, but giving people the option to cleanup messages would be great.

loud quartz

There's not much reason to though

There's nothing else ever happening in those dms

People can also just close them anyway

crude locust

why wont guildcreate and guilddelete work when the others do? no errors in logs.

loud quartz

Or just the app

crude locust
loud quartz

Okay, but is it the app with the bot, or just the app itself

What are the scopes

crude locust
loud quartz

You could think of the bot as a discord account for your app

Application commands are called application commands because they work via and belong to the app

The bot account your app has is just a way for your app to interact with users and members in servers (and send/receive DMs)

crude locust

ohh right, yeah, this is an old fashioned bot

loud quartz

Since it's the bot that will become a guild member that can then get permissions to do actions in the server

crude locust
loud quartz

Hm

crude locust

doesnt even use slash commands, just uses prefixes, hence i think of the bot account and the app as one

loud quartz

Which requires a bot to be able to view channels, yeah

Anyway, not sure why that doesn't work

You could try updating anyway, but doubt that would fix it

crude locust

hm, i just ran npm i, ill look what the latest is

loud quartz
crude locust

14.19

loud quartz

.3

crude locust

ye :p

oh wait fuck i was kicking the prod version when i was testing dev, sorry for wasting ur time

that makes a lot of sense

undone coral

someone knows how to make a boost user count?

bleak owl

what would be the point of that?

bleak owl

i’m not sure how this is discord.js related

hexed patrol

I'm struggling a lot with making the message/component attached.

I've tried various videos, github explainations, and I still have no luck. Maybe I'm not using it right but I need some help.

uncut quest

help about what specifically

hexed patrol

Creating the container i think

And then the objects within the container, if that is what it's called

uncut quest

have you check the source code provided ? theres literally one in that screenshot

hexed patrol

What source-code?

uncut quest
hexed patrol

I tried opening that and It didn't work

uncut quest

you can open it with any text editor honestly

hexed patrol

Alright thanks, whole time it was opening with my media apps

hexed marsh

Okay guys, I have a challenging one for ya's. So I have this "Private" mode toggle that I'm triggering when a user joins a channel and sets it to private. This portion works just fine, however when a user is dragged into the channel, they cannot speak which is intentional, because they do not have the "Speak" permission. The problem comes whenever I set the channel back to "Public" so to speak, the user who was previously suppressed, stays suppressed.

// Update channel permissions
await channel.permissionOverwrites.edit(guild.roles.everyone, {
    Connect: isPrivate ? false : true,
    ViewChannel: isPrivate ? false : true,
    Speak: isPrivate ? false : true,
});

// Get all members in the channel.
const members = channel.members.values();
for (const member of members) {
    if (isPrivate) {
        channel.permissionOverwrites.create(member, {
            Connect: true,
            ViewChannel: true,
            Speak: true,
        });
    } else {
        channel.permissionOverwrites.delete(member);
    }
}

I attempted to directly unmute the individual, however that failed to actually unmute the user. Instead they had to disconnect and reconnect in order to speak again.

hexed patrol

Nevermind.

hexed marsh

Yeh it's the darnedest thing.

I suppose I could just remove the "Speak" given that the outside users can't actually see the channel anyway.

uncut quest

have you try with edit instead of create ?

Create , is creating permission for a user , Replace if one present

Edit , is editing permissions for a user or creates if none present

unborn minnow

This is interesting behaviour though, because if edit works instead of create, that would imply that the "create" method is being invalidated by some discord system for assigning permissions

So "everyone"-level permission overwrites seems to take precedence over member-level permission overwrites.... but that makes no sense crySparkle

hexed patrol

I tried incorporating given resources into my existing commands and I'm receiving this error:

[ERROR] Uncaught Exception: CombinedError (2)
  Received one or more errors

  1 ExpectedValidationError > s.instance(V)
  |   Expected
  |
  |   Expected:
  |   | [Function: ButtonBuilder]
  |
  |   Received:
  |   | undefined

  2 ExpectedValidationError > s.instance(V)
  |   Expected
  |
  |   Expected:
  |   | [Function: ThumbnailBuilder]
  |
  |   Received:
  |   | undefined
bleak owl

show your code!

hexed patrol
if (interaction.commandName === "lock") {
        const rolesToLock = [
            "1360382321211080805", // member
            "1360382319285764227", // goat
            "1360383170184478720", // bot
            "1366071144049803365", // partner
            "1360382317419433994", // staff member
            "1366081883519058020", // partner manager
            "1360383220188975114"  // management
        ];

        const channel = interaction.channel;

        await Promise.all(
            rolesToLock.map(roleId =>
                channel.permissionOverwrites.edit(roleId, {
                    SendMessages: false
                })
            )
        );

        const container = new ContainerBuilder();

        const text1 = new TextDisplayBuilder().setContent('## Channel Locked');
        container.addTextDisplayComponents(text1);

        const text2 = new TextDisplayBuilder().setContent([
            `- Channel\n  - <#${channel.id}>`,
            `- Locked By\n  - <@${interaction.user.id}>`
        ].join('\n'));

        const section2 = new SectionBuilder()
            .addTextDisplayComponents(text2);

        container.addSectionComponents(section2);

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

Alright, thanks

topaz bluff

If you don't want to add a button or section. Just add the text directly to the container

hexed patrol

Alright

unborn minnow
tardy sable

An partial message only has channel, message and author id right?

clear garnet

In d.js land, a partial message is only guaranteed to have the message ID itself. Everything else is up in the air. An example of this is an event from the messageDelete event on an uncached message, where event from the API only provides the ID of the message and nothing else

Sorry, just checked. The channel ID is also provided, so the channel & message ID are the bare minimum you'll have

hexed patrol
obtuse laurel

Code: https://pastes.dev/WjOfbkKtYI
Error: https://pastes.dev/n9Rp9YGSP2
The error stack is not helping here at all, only going back to node_modules
In the code, the first console.log works fine and logs the container. From that, I assume containers[currentContainers] is not the issue, so whatever is adding onto it is the issue.
But the error happens after console.log(1) runs, and never gets to console.log(2).
The error is that content of some text display is undefined, but I don't really add anything that is undefined.

halcyon bison

the error means that there's a text display without content
I do see you setting the content of the one text display in this code, so I have to assume the issue is either in containers[currentContainers] or there's something more to your code that you haven't shown in this bin (or your code isn't saved)

obtuse laurel

I also tried to do this:

console.log(
  components[0].components.find(
    (comp) =>
      (comp.data.type === ComponentType.Section &&
        comp.data.components?.find((x) => !x.content)) ||
      (comp.data.type === ComponentType.TextDisplay && !comp.data.content)
  )
);

it logs this:

TextDisplayBuilder {
  data: { type: 10, data: { type: 10, content: '-# Page 1/2' } }
}

which is interesting because typescript should have caught it, right? if it was there at all

halcyon bison

you've shown so little of your code, I don't even know how this new code block relates to your other code

obtuse laurel
fading girder

What is the limit on adding custom perms for users in a channel? as in how many users can I add manually

halcyon bison
halcyon bison
fading girder
halcyon bison

sorry to clarify, you mean you're denying a role from viewing a channel, but allowing a subsection of that role's members?

obtuse laurel
halcyon bison yes you're correct that it should look like that and that *is* likely the issue ...

https://pastes.dev/VmIZZRxBhL I switched up the code a little bit, and this is the entire code for pagination, nothing removed.
And as for the command itself: https://pastes.dev/3qUkEAoS1L this is the code from the building of the containers to calling the pagination function, nothing removed in between

I don't think I have removed any code in between in the code I sent before, only the code after (which shouldn't matter), and the code before (which is a check with early return)
And I also don't think the code isn't being saved since the new logs I added worked
and yes, same error

steel trail
obtuse laurel
steel trail

After, before passing to editReply

fading girder
obtuse laurel

https://pastes.dev/Q2SCbeSPKw
The TextDisplayBuilder causing the issue is still there:

TextDisplayBuilder {
  data: { type: 10, data: { type: 10, content: '-# Page 1/2' } }
}
steel trail
halcyon bison
obtuse laurel
PS D:\Projects\VerveVote> npm ls @discordjs/builders
sapphire-template@1.0.0 D:\Projects\VerveVote
├─┬ @sapphire/framework@5.3.4
│ └── @discordjs/builders@1.11.2
└─┬ discord.js@14.19.3
  └── @discordjs/builders@1.11.2 deduped
fading girder
obtuse laurel
halcyon bison

I only just noticed you're importing ButtonBuilder and TextDisplayBuilder from @discordjs/builders directly
I can reproduce this when doing so, but frankly I didn't think discord.js was changing the builders in any way such that that should even happen
but tldr I believe ContainerBuilder doesn't recognize those as instances of the same class, so it's passing the object to the TextDisplayBuilder Constructor

steel trail
obtuse laurel

interesting, I was importing by using autocompletions in vscode, never noticed that

looks like it works fine now

half rover

Can we get the details of the receiving event by applying to the server via the bot?

i need these question answers

halcyon bison

no, that has yet to be documented in the api

half rover

damn that would be awesome with some ai

winter merlin

In discord.js v14, I want to reliably get the members who have access to a specific channel.
To do that, I believe I need to write something like this:

const members = await Guild.members.fetch();
const channelMembers = members.filter(member => 
  Channel.permissionsFor(member).has('ViewChannel')
);

However, this approach likely comes with rate limits and may take some time to process.

Is there any other way to reliably get the members who have access to a channel?

crimson gale

you can shortcut to TextChannel#members, but under the hood that does the same thing.
there is no endpoint to just list the members that can see a specific channel

it won't incur rate limits. GuildMemberManager#fetch sends a gateway command which then sends the guild members via the websocket connection
however, that comes with its own caveats, yes

  • waiting for chunks may take some time
  • in very large servers it may back up the event queue to the point where receiving interaction creates may take longer than you have time for the initial reply (think of it like: the command execution is sitting in a traffic jam, but needs to be responded to within 3 seconds) - we are however talking hundreds of thousands if not millions of members until it gets that bad

as a small additional sidenote: per convention class names are capitalized in js. while the code may work, naming your guild instances Guild will likely lead to confusion both by helpers as well as potentially yourself (syntax highlighting, conflicts when actually trying to construct instances from classes, etc.)
to illustrate that: const Guild = new Guild(). instead it's recommended to go with lowercase for instances const guild = new Guild()
-# ofc i'd not recommend constructing guilds manually at all, this is just an example to illustrate the issue/point of confusion

winter merlin
winter merlin
indigo nest

Hello guys, question about discord auth API. Is it against the TOS to share user data taken from the oauth2 (like servers the user is in) with admins for moderation purposes?

zenith violet
indigo nest
steel trail
winter merlin

👍

half rover

is there anyway how can i use everyone or here with components v2

shadow pier

when can these properties be null?

indigo nest
shadow pier

my bad

Specifically its <InteractionCallbackResponse>.resource.message

native marten

hey folks I am having this error can someone please help me i am using discord.js after a long time

crimson gale
zenith violet
fleet granite

Guys

Utkarsh Mitr

native marten
native marten
fleet granite

Kya haal he

kek laugh

native marten

I am doing great and how are you doing?. Please refrain from chatting here and please go ahead in #archive-offtopic

native marten
sharp ginkgoBOT
zenith violet
sharp ginkgoBOT

The order of function parameters must match between definition and function call.

function execute(client, interaction) { ... };
execute(interaction, client);
  • mismatch! you pass an interaction where the client is expected
  • mismatch! you pass the client where an interaction is expected
ivory sable

is the character limit in text display 4000 characters same as text input?

loud quartz

No idea

Discord didn't document any such limits for cv2

You could try asking in ddevs, maybe someone there might know

ivory sable

yeah I don't see a limit in the documentation, guess there's only one way to find out then

oh, that makes more sense than limit testing myself lol

loud quartz

Tbh they would have to test themselves too lol

crimson gale

so someone in ddevs does the limit testing for you kek

loud quartz

Maybe if enough people ask there someone notices them not existing and documents them in any capacity shrugCat

half rover

cv2 is absolute cinema

steel trail

Because InteractionCallbackResponse is the same result interface for all the different ways you can respond to an interaction. And a modal or a deferral has no resource associated with it

steel trail

Same way starting an activity as response to an interaction has a resource, but no message

shadow pier

ahh

steel trail

Technically that interface could be typed with a generic to not be nullable depending on interacting response type, but that‘s ts shenanigans

ember crest

how to enable commands in userDM?

sharp ginkgoBOT
ivory sable
crimson gale

is that the API or our builders assuming

ivory sable

Good question

 at Object.run (C:\Users\user\WebstormProjects\discord-bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2422:79)
    at C:\Users\user\WebstormProjects\discord-bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:67
    at Array.reduce (<anonymous>)
    at _StringValidator.parse (C:\Users\user\WebstormProjects\discord-bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:29)   
    at TextDisplayBuilder.toJSON (C:\Users\user\WebstormProjects\discord-bot\node_modules\@discordjs\builders\dist\index.js:1708:33)     
    at C:\Users\user\WebstormProjects\discord-bot\node_modules\@discordjs\builders\dist\index.js:1870:64
    at Array.map (<anonymous>)
    at ContainerBuilder.toJSON (C:\Users\user\WebstormProjects\discord-bot\node_modules\@discordjs\builders\dist\index.js:1870:35)       
    at C:\Users\user\WebstormProjects\discord-bot\node_modules\discord.js\src\structures\MessagePayload.js:151:46
    at Array.map (<anonymous>)

is all I got

ember crest
half abyss

have this error in terminal (at the bottom)

zenith violet
sharp ginkgoBOT

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


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

crimson gale

i'd recommend reading responses you get, if you want to solve your errors

ivory sable

albeit that's the whole component, not just textDisplay

crimson gale

there you go

loud quartz

NOTED

ivory sable

not surprising, but nice to know

half abyss
rigid crest

time for a dumb question, but why didnt grids get included with v2?

i had a moment and was pondering going though my channel update logger and was like "How could i add a table into the component without it being jank" then it hit me, a reasonable feature that could of been added wasnt added cuz discord is still in the ice-age with v2 so heres to hoping it may be possible to have a native table grid

but is there anything with the components that are planned to work like tables?

spark hare

How can you register all slash commands as user installable dogeHaHa

steel trail
rigid crest

figures it would come down to a mobile thing

ember crest

why commands not show in userDM? commands already deploy by clientID.

loud quartz

Did you deploy them globally?
Did you set the commands to have proper contexts?
If you mean all DMs, did you set proper integration types for the commands?
And did you install the app to your user account?

indigo nest

Heya, is there a guide to the new components v2? Can’t find it

ember crest

Did you deploy them globally?

yes. Routes.applicationCommands(clientId)

Did you set the commands to have proper contexts?

yes. .setContexts([InteractionContextType.PrivateChannel]) only

If you mean all DMs, did you set proper integration types for the commands?

yes

Did you install the app to your user account?

yes.

if im missing something, let me know.

snow onyx
shadow pier

is max limit of role select menu 25?

snow onyx
half abyss
polar karma
half abyss
polar karma

That means one, not two like you provide

sharp ginkgoBOT

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


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

shadow pier
polar karma

Your syntax is outdated by multiple versions, so either you are updating an old project or following a very outdated guide

Or using AI

snow onyx
half abyss
half abyss
polar karma

That's the correct syntax, yes

half abyss
steel trail

get what? you cut all of your error

half abyss
zenith violet

You didnt define guild

formal wigeon

in components v2, how do i make it so the text components are inline?

steel trail

you don't

formal wigeon

so it can only look like this?

snow onyx

yep

formal wigeon

greatt

steel trail

well, you can make longer lines any way you want

but they might wrap on mobile and look worse than you intended

formal wigeon

yeaa

waiting for that feature, it works now but it will be nice to have it, if it is a feature they want

crimson gale

it's a feature that's very likely not happening

the devs making components v2 have stated multiple times that not having horizontally aligning components is a deliberate choice

formal wigeon

well whould be good is either multiple per section, that they go next to eachother if they have space, or you can specify that. But it would b a good feature to have.

crimson gale

i personally agree with the devs that it would not
see embeds; they optionally respect the inline specification, and people abuse it to display table-like data and completely ruin it for mobile users

formal wigeon

I mean yea, it shouldn't be used for that but with right now it may use a lot of vertical space while the horizontal is so less. So that could ruin it.

steel trail

only because you choose to write only two words per line

shadow pier

Can i select some default roles in the role select menu?

default it will be populated by how many roles?

loud quartz
shadow pier

role select menu

loud quartz

Okay but what about it?

Given how you yourself have to explicitly set the defaults, not entirely sure what you're asking about

shadow pier

I think i got it nevermind

bleak owl
pearl dome

hey, how to make multiple buttons in one section? like this

bleak owl

put them in the same action row

pearl dome

i use v2 components, does action row work on this?

velvet bloom

Is it possibale to use js to connect to http things.
Like lets say theres an game i want my bot to connect to, to do stuff like ''!playercount'' ''!load all players'' etc

sharp ginkgoBOT
tiny condor
velvet bloom
tiny condor

An api is possible with pretty much any language

velvet bloom

Sure buddy

main mason

Why is Events.MessageCreate not firing for messages sent in DMs until the bot itself sends a message to that user?

sharp ginkgoBOT

To receive direct message events on "messageCreate" with your bot, you will need:

halcyon bison

Probably the partial

main mason
wooden jetty

i have uploaded emojis to the bot
how can i get all of them in a array for later use?

halcyon bison

you'd need to fetch them with <Client>.application.emojis.fetch()
this resolves with a Collection (or you could also then access <Client>.application.emojis.cache)

sharp ginkgoBOT
red coral
.setColor(resolveColor(rr.color ?? "#FAFA00"))
Argument of type 'string' is not assignable to parameter of type 'ColorResolvable'.ts(2345)

What do I do with this?

austere blade

why when editing an embed it then says "this interaction has failed"?

but then edits anyway?

red coral

On discord? You don't acknowledge the interaction

You may use .edit not .update for example

red coral

Like do as ColourResolveable?

rose tangle

yes

austere blade
red coral
snow onyx
wooden jetty
sharp ginkgoBOT

documentation suggestion for @wooden jetty:
method ApplicationEmojiManager#create() discord.js@14.19.3
Creates a new custom emoji of the application.


// Create a new emoji from a URL
application.emojis.create({ attachment: 'https://i.imgur.com/w3duR07.png', name: 'rip' })
  .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
  .catch(console.error);

red coral

imagine that

austere blade
red coral

We need more context, can u show more of what you're doing?

austere blade

so im editing an embed and after the edit 2 buttons appear, after updating it is saying interaction failed whilst button1 appears to be loading.

red coral

I'm talking code

austere blade
interaction.update({ embeds: [resend], components: [new ActionRowBuilder().addComponents(button1, button2)]});```

edit: my apologies
rose tangle

"interaction" is apparently not an interaction

red coral

context, we need more then just what causes the error

rose tangle

could log it to see what it actually is

austere blade

ill log the interaction

austere blade
red coral

.update doesnt exist on that, again can you show more code for context

austere blade
red coral .update doesnt exist on that, again can you show more code for context
const message = await interaction.reply({ embeds: [embed], components: [row] });
        const selected = await message.awaitMessageComponent();
        const brand = selected.values[0];
        if (selected) {
            const resend = new EmbedBuilder()
                .setDescription(`# ${brand}\n\n` +
                    `email: \`${interaction.options.getString("email")}\`\n` +
                    `product name: \`N/A\`\n` +
                    `price: \`N/A\`\n` +
                    `shipping: \`N/A\`\n` +
                    `image: \`N/A\``)
                .setColor(process.env.default)
                .setFooter({text: "only press 'send' button when the details above are correct"});

            const button1 = new ButtonBuilder()
                .setCustomId("step1")
                .setLabel("step 1")
                .setStyle("Primary");

            const button2 = new ButtonBuilder()
                .setCustomId("step2")
                .setLabel("step 2")
                .setStyle("Primary");

            interaction.update({ embeds: [resend], components: [new ActionRowBuilder().addComponents(button1, button2)]});```
red coral

selected.update then, since awaitMessageComponent returns a MessageComponentInteraction

austere blade

how does one make an interaction handler file?

so for instance a button has a custom id, upon the user pressing that button it gives them a modal etc.

and then in the same file have the same setup for another button with another id?

signal jewel

check if interaction is from a button then switch statement on the custom id?

austere blade
sharp ginkgoBOT
rose tangle

there's .isX() methods for every X interaction type

austere blade

oh right thankyou

so after this how would i switch statement the custom id of a button?

something like interaction.customId?

rose tangle

yes

sharp ginkgoBOT
rose tangle

quite literally that

you can also see the docs for each class in the docs website

austere blade
chilly iron

either im going insane or something else but why do select menus want a different format when passing unicode emojis

buttons accept this

{ id: null, name: '😭', animated: false }

and select menu options just want the '😭' passed directly

rose tangle

are you importing both from djs?

chilly iron

yop

rose tangle

the builders right?

chilly iron

for select menus the builders and for buttons the json thingy

dont know if that makes a difference

rose tangle

then yeah that makes sense

the api only supports the full object

chilly iron

ahhh

rose tangle

builders accept that "partial" string and then makes the full object itself

because they're meant to be utilities

chilly iron

yeah thanks for clearing my doubts about this

i thought i was going insane

halcyon bison

the builder should actually also accept the object
if I had to guess, you're receiving a type error?
if so, it's because id is expected to be string | undefined

chilly iron

yeah

austere blade

interactionHandler.js:

module.exports = {
    name: 'interactionCreate',
    async execute(interaction, bot) {
        if (interaction.isButton()) {
            switch (ButtonInteraction.customId) {
                case "step1":
                    interaction.showModal(apple1());
            }
        }
    }
}```

anotherFile.js:

```js
if (selected) {
            const resend = new EmbedBuilder()
                .setDescription(`# ${brand}\n\n` +
                    `email: \`${interaction.options.getString("email")}\`\n` +
                    `product name: \`N/A\`\n` +
                    `price: \`N/A\`\n` +
                    `shipping: \`N/A\`\n` +
                    `image: \`N/A\``)
                .setColor(process.env.default)
                .setFooter({text: "only press 'send' button when the details above are correct"});

            const button1 = new ButtonBuilder()
                .setCustomId("step1")
                .setLabel("step 1")
                .setStyle("Primary");
            
            const button2 = new ButtonBuilder()
                .setCustomId("step2")
                .setLabel("step 2")
                .setStyle("Primary");
            
                selected.update({  embeds: [resend], components: [new ActionRowBuilder().addComponents(button1, button2)] });
        }```

why is the modal not showing up when i click the step1 button on the edited embed?

edit: no error in terminal
rose tangle

so that's basically switch (undefined) {

austere blade

o

rose tangle

not "the (static) customId property in the ButtonInteraction class"

austere blade

o

rose tangle

the latter wouldn't make sense, it'd need to update the property whenever a button is received, it'd be a pain for concurrency

austere blade

so what ur saying is what im trying to do is impossible?

oh wait, the way ive gone about it is just wrong

rose tangle

notice how you did interaction.isButton() and not BaseInteraction.isButton()

it's the same thing

austere blade

yeah i get it now haha

sharp ginkgoBOT

Explaining <Class> and Class#method notation: learn more

austere blade

so like, how would i tell the customId of a button used in the interaction?

austere blade
rose tangle ^^

im slightly baffled... what would i put in the switch statement?

sorry for all of the questions

rose tangle

you need to access the customId property of that "interaction" variable, that is a ButtonInteraction

that's what ButtonInteraction#customId means

the same way you accessed and called the isButton method of that "interaction" variable

austere blade
bleak owl

i suggest looking at the docs instead of wondering what methods or properties to use

rose tangle

id is a different property ^^

austere blade
half abyss

can i put booth overwrite in the same i send in last image

rose tangle
austere blade
rose tangle

yeah, so access the customId property

it's the customId of the button pressed

austere blade

yeah the button pressed was made in another file, im trying to make a file solely for interaction handling

rose tangle

the interaction holds the customId property of the button that was pressed

that's why it says Button__Interaction__#customId

instead of, say, ButtonBuilder#customId, if that were a thing

austere blade
rose tangle
rose tangle

but then again, I'm not sure how you managed to write the isButton check at all, that's how you access a property and then call it

half abyss
austere blade
rose tangle
rose tangle
rose tangle

yeah just pass the name as well inside of the object and it'll work

austere blade
rose tangle

there's no GuildChannel channel type

in runtime it'll read like type: undefined, and then it'll fallback to the default GuildText channel type

there's also no Permission class, and it wouldn't make sense for it to have a "gateway intents" property

and a "gateway intents" object surely wouldn't hold permissions like ViewChannel

that whole line doesn't make much sense

foggy mortar

Out of the blue I'm having shards dying left right and centter. Did any breaking changes occur on Discord's side?

rose tangle

well, what type do you want

half abyss
rose tangle

yeah, but there's many channel types

though from your use case it sounds like you want a regular text channel

so GuildText

or just don't specify a type

since GuildText is the default

rancid folio

Question — I've seen music bots be able to give you like an infinite amount of options in command options, i.e. doing /play {song name} and it comes up with autocomplete options as you type.

Can something similar be done with string select menus and autocomplete? Or are string select menus strictly limited to 25 options?

stable sun
rancid folio

👍 roger, ty.

fast void

hi

what's the color for invisible embed?

half abyss
rose tangle

sounds like you're accidentally calling it somewhere below

using ;s would fix that

polar karma
half abyss
rose tangle

if it's the same error, the answer is the same

half abyss
rose tangle

just in case can you console.log(guild)

half abyss

in the guild.channel?

rose tangle

wdym?

half abyss

in this?

rose tangle

no, you can't log inside .create()

or well, I guess you can but that'd be weird

log before that call

half abyss
rose tangle

the first line says it's a client, not a guild

half abyss
rose tangle

that your "guild" variable isn't a Guild, it's a Client

client.channels.create() isn't a thing

half abyss

so i should change to Client.channel and not guild.channel

steel trail

no

you should get an actual Guild, not just call your variable guild

rose tangle

(naming it "guild" doesn't automatically make it a Guild instance)

half abyss

Like GuildMessages etc?

rose tangle

I'm not sure what you're talking about

rose tangle

but in that example, "guild" is a Guild

your "guild" is a Client

so not the same thing

rose tangle

the variable name is independent from what it actually is

you can't call a variable mee6BotToken and then expect it holds the mee6's bot token, for instance

clear garnet

Whatever you defined your guild variable as is incorrect, and is what you need to fix. If guild is a parameter of a function, then your parameter ordering is likely incorrect and is something you need to fix

autumn brook

Can someone fix this code for if u have a certain role (role id) in a discord server u be able to run the commands /db-add and db-remove ??

quiet hinge

How do I do If I don't want to send a reply after a button is pressed? <Interaction>.deferReply() send the message "... the bot is thinking"

rose tangle

since that's spoon-feeding and not learning

autumn brook
rose tangle

ideally you should always let the user know their button press did something

not replying is not good UX

quiet hinge

I'm making a menu

So when the user press the button, the message get edited simulating a changing of page

rose tangle

then reply with an update

(interaction.update)

sharp ginkgoBOT

method ButtonInteraction#update() discord.js@14.19.3
Updates the original message of the component on which the interaction was received on.


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

half abyss

do i need to make like
let supportChannel = guild.channel.create?

quiet hinge

Oh so instead of <interaction>.message.edit i do <interaction>.update

rose tangle

yes

quiet hinge
rose tangle

also message.edit won't work if it's an ephemeral message

autumn brook
sharp ginkgoBOT
autumn brook
rose tangle

and then .has(id) on that

rose tangle
autumn brook
rose tangle

look at the docs I shared

rose tangle
quiet hinge

If I want to update a button, is better to create a new button and substitute the old one or edit the one that is already attached to the message?

rose tangle

you shouldn't edit the message if that's what you mean

like message.components[0].components[0] = newButton

quiet hinge

Yeah I'm making a new button it's way easier

indigo yarrow

is there a specific stage when i need caching ?

rose tangle

caching is already built-in?

indigo yarrow
rose tangle

depends on your bot then

it's entirely up to you tbh

indigo yarrow
steel trail

First step would be checking you only use the intents you need

Next step checking what your bot actually does and if/what cache it relies on

Not having cache/sweeping it won’t make your bot faster. It might even make it slower because you need to fetch more

indigo yarrow

oh

alright thanks ill check it

shadow harness

Is there any way to detect what device a user is on? I have a 20-char ID, but found out it can't be copied on mobile, so I want to DM it to them only if they're on mobile...

If it's not possible I'll figure something else out, just wanna know if it's possible

steel trail

this can be perfectly copied on mobile maybe try a codeblock?

prisma ruin

if i pass an emoji object to a string does it automatically dfisplay an emoji when discord sends the message?

steel trail

If it‘s an actual instance of the class, yes. If it‘s just a plain json object, no

prisma ruin
steel trail

Those are instances of the ApplicationEmoji class, so yes

prisma ruin

my friend told me i could just get emojis from this.application.emojis

steel trail

Yes, that customEmojis collection is redundant

prisma ruin
steel trail

If you only remove the collection but kept the create calls like they currently are (which already check cache before doing so in your code) your cache would be accurate

ruby bane

is the AutoModerationActionExecution#channel the channel the action logs to, or the channel the matched execution was sent in? for example, if i log to #mod-only or something, and someone says something to trigger automod in #gen, does AutoModerationActionExecution#channel.id resolve to gen or to mod-only?

sharp ginkgoBOT
halcyon bison

(So #gen)

ruby bane

yeah but that didn't seem to do what i needed either way

still weird, are you unable to read msg content from automod? its resolving, just not there:

  override async run(message: Message) {
    if (message.type == MessageType.AutoModerationAction) {
      console.log("Automod msg");
      console.log(message.content);```
logs: 

Automod msg
""

halcyon bison

well if you're receiving a Message, it doesn't sound like you're working with an AutoModerationActionExecution object
but you do need the MessageContent intent to receive the content for both the autoModerationActionExecution and messageCreate events

ruby bane

Okay, so originally i was using the Message check i just showed you, which didn't work, so then i tried AutoModerationActionExecution, which also just logged nothing, its like the bot wasn't noticing there was anything from automod (yes they can see the same channels, it has permissions, etc), so i moved backed to msgs

I have the intent, and everything about the code works when moved out of the message type condition, just when added to it, does not work (this code is to resolve discord servers via url).

halcyon bison

could you show that you have the intent?
could you show your Client constructor?

ruby bane
halcyon bison

you will also need the GuildModeration intent to listen to the autoModerationActionExecution event
as for the content, I imagine the AutoModerationAction message's content isn't necessarily the automodded message's content

spark hare

Does ComponentType work for components v2 too?

halcyon bison

yes

spark hare

alr ty

ruby bane

found the issue, its not considered message content, but rather an embed description

sharp ginkgoBOT
bleak owl

please try not to delete your messages, it disrupts support flow

upbeat cedar

Hello, please tell me how to make a button in embed not on the right opposite the text but at the bottom and several buttons?

loud quartz

you can't put buttons into an embed, at all

you can put an action row with buttons into a container

which is a components v2 thing

upbeat cedar

I know that, but I don't understand how to make not one button but several

rose tangle

just set more buttons in the action row

that's why the action row exists, to wrap many buttons (or one select menu) otherwise you'd just send the buttons directly

unique shoal

Make one button

Make another button

Two buttons

poggies

loud quartz

i said specifically "put an action row"

nothing new about that for past several years

the only new part is the one you're focusing on - single button as part of a section

that's brand new, and not what you seem to want

upbeat cedar

can you give an example or give a method with djs docs

sharp ginkgoBOT
upbeat cedar

this is not it i need component version 2

rose tangle

you still wrap buttons in an action row in components v2

the only exception is inside an accessory, which is not your case

sharp ginkgoBOT
halcyon bison

(in case it helps)

upbeat cedar

aaaah I get it, it turns out it's so easy

raw pebble

Where do I report bugs? I guess the issues tab right?

thanks

bleak owl

yes

unique shoal

happy to chat here first to make sure its actually a bug

raw pebble

it's kind of a bug, on the website, so a broken link is a better way to describe it lol

bleak owl

can you show what link you are referring to that is broken?

bleak owl
unique shoal

1.11.1 waitWhat

Its messing up the version number

Where were you linked from?

Builders?

unique shoal

We might have already known about this one, one sec

Actually yeah it works fine on the normal site

nvm no it doesnt

raw pebble

idk how it directed me to version 1.11.1

unique shoal

uhh yeah so

It works in 1.11.2

So Im saying fixed

raw pebble

thats fine, thanks o7

what's the difference between main and 14.19.3? prolly a stupid question lol

👍

unique shoal

main is anything thats been merged on GitHub

14.19.3 is the stable release

rose tangle

and main will eventually be released as v15

unique shoal

Or 14.19.4... or 14.20.0

rose tangle

wouldn't that be the v14 branch

unique shoal

Its all a mess now tbh

prisma ruin

any previsions of what could be coming in v15

loud quartz

discord-wise? nothing, really. v14 supports everything already as of right now.

discord.js-wise is a bit harder to say, for what it's worth

unique shoal

Who says v15 is even coming at all

main mason

Is there a way for a message.reply() to not even ping the user (similar to how you can turn off a ping when replying while using a normal Discord user account), or can you only suppress the notification (via flags: MessageFlags.SuppressNotifications)

loud quartz

use allowed mentions

there's a field dedicated to exactly that in there

vital barn

if i set allowedMentions in ClientOptions when creating the Client, do I have to set them again when replying to an interaction or message? and if I do, do they override the ones set in ClientOptions?

bleak owl

i’m fairly sure they’re overridden when passing in the message directly

mellow frigate

can i keep selection menu in compnent v2?

unique shoal

yes

mellow frigate

how?

unique shoal

Im not sure I understand the question

mellow frigate

const section2 = new SectionBuilder().StringSelectMenuBuilder(...)

unique shoal

No, not in a section

They go in ActionRows as usual

And action rows can be added to containers

mellow frigate
const section2 = new SectionBuilder().addOptions(
                    new SectionOptionBuilder()
                        .setLabel('Select a country')
                        .setValue('selectCountry')
                        .addComponents(selectCountry)
                );
topaz bluff

Where are you getting this code? SectionBuilder().addOptions() doesn't exist

mellow frigate

copilot :/

i have const selectCountry = new StringSelectMenuBuilder(), how to keep it in section?

topaz bluff

Ok. So don't listen to an AI on a brand new feature

topaz bluff

A ComponentsV2 Section is a very specific thing. It's text with an inline Button or Thumbnail...it's not just la sub-container to hold any component

mellow frigate
obsidian mason

does discord.js automatically retry requests on network errors (like EAI_AGAIN) or do i need to handle that myself

rose tangle

on ws or rest?

though I think the answer is no for both, but I'm unsure how you'd recover from EAI_AGAIN

obsidian mason

on REST

rose tangle

that'd mean that something is wrong with the network itself, far outside the control of the bot

obsidian mason

yeah i dunno, i'm seeing it happen randomly

rose tangle

you probably should ask your host instead

also try to start with the issue itself (getting EAI_AGAIN randomly), not what you're trying to do (retry network errors)

inland pawn
const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.GuildMessageReactions,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.GuildModeration,
  ],
})```

```js
const GuildMemberUpdate = {
  name: Events.GuildMemberUpdate,
  once: false,
  /**
   * Emitted whenever a guild member is updated.
   *
   */
  async execute(
    client: Client,
    oldMember: GuildMember | PartialGuildMember,
    newMember: GuildMember
  ) {
    console.log("update")```

The `GuildMemberUpdate` event is not emitted until the `second time` the event is emitted for a specific GuildMember. Is this a caching issue? I have the GuildMembers prescence enabled, so I don't understand the issue.
clear garnet

It is indeed a caching issue. If you specify the GuildMember partial, the event should then emit all the time

sharp ginkgoBOT

guide Popular Topics: Partial Structures
read more

obsidian mason
earnest schooner

Hello!!!!
Thru the discord api, is it possible to get the connections of the user and a link to them?

Just from the user id, without the user connecting to the bot via oauth

earnest schooner

Ah crap

Okay, thank you!!!

vestal sun

if you need it for roles there is an option in discord

earnest schooner
steel trail
earnest schooner

would be easier than oauth, but like i could add a /connect command

raven hearth
raven hearth
earnest schooner
raven hearth
earnest schooner

so il use a connection with a connect command

raven hearth
balmy kraken

when building select menus, is .setDescription("") required?

indigo nest

Just the label

outer plume

is there a way to know if a guild's server insights are enabled? Doesn't seem to be in guild.features

livid kettle

Gm all. Is there a good resources on using components v2? I don’t see anything on discordjs.guide yet, maybe I’m missing it.

polar karma

It's being worked on, there should be a pr

rigid crest

so ive noticed member tags are sniped in automod, but from what i gathered it prevent messaging? i mean in the server i saw the popup its reason was "tag" is there a way to know through the api if any messages get blocked or sent? Unless its just a member update trigger and not messaging?

umbral jetty

Does anyone know if Components V2 has docs?

snow onyx
rigid crest

oh

snow onyx
sharp ginkgoBOT

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

balmy kraken

can bots send interaction components on DMs as well, or only in slash command interactions?

crimson gale

components can be part of the message payload on regular sends, not just command responses

you need to make sure to set the appropriate message flag / query parameter (latter if webhook)

zenith violet

-# text

warm thicket
misty swift

is it possible to react to a forum post (the actual post and not the first message)

with discordjs ofc

steel trail

Since the first message in a post is the post‘s starterMessage. The one shown at the top, containing the title and the reactions of the post

misty swift
grand scroll

Hey How Can I Disable Send Message Perm But, Still Make Everyone To Use Slash Commands In A Channel?

misty swift
grand scroll
steel trail You can’t

I Don't Want People To Send Messages In The channel.. just a channel reserved For Slash commands. How Can I Do It?

zenith violet

you dont

grand scroll

🥺

steel trail

Have a bot delete all messages sent that aren’t interaction responses. Or disable message history if you simply don’t want users to use it to chat

copper trail

@steel trail

can you help me

bleak owl
zenith violet

also if you're new to js and struggling, learn the basics first. #rules 3,
start in #resources

copper trail

why is the one error i get not in the list of websites

bleak owl

and that error would be?

copper trail

Error: Cannot find module './config.json'
Require stack:

zenith violet

yeah this is just basic js

bleak owl

either the file path is incorrect or the file doesn't exist, really basic js

copper trail

i have the file though

zenith violet

its isnt a djs issue regardless

copper trail

i think i need to continue learning js first

onyx glacier

Greetings! Is there a documentation for the new DiscordComponentV2 system?

sharp ginkgoBOT

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

onyx glacier

Thanks!

nocturne flint

Hey there! Where could i see how this message is build, i couldn't find it in the source code? #announcements message

crimson gale

in the file attached to it

nocturne flint

thanks!

vivid gorge

can bot forward voice messages or copy their link like a video?

halcyon bison

they can do both
voice messages are effectively just messages with an attachment

copper trail

when i run node deploy-commands nothing happens

steel trail

Did you write the actual code file? Did you forget the .js at the end?

tepid maple

Can I send a file with MediaGalleryBuilder or does it have to be a URL?

vivid gorge
halcyon bison

yes I'm sure
not sure which 'new discord function' you're referring to regarding voice messages, but feel free to share your code if you'd like help debugging

sharp ginkgoBOT

tag suggestion for @tepid maple:
Files in embeds should be attached via the message option object and referenced in the embed:

const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
  .setTitle('Attachments')
  .setImage(`attachment://${attachment.name}`);

channel.send({
  embeds: [embed],
  files: [attachment]
});
halcyon bison
tepid maple

Ah great thank you!

vivid gorge
halcyon bison

That's not really new, but yes that is what I was talking about
Bots can forward those, and they can still access the attachment's url

quartz ravine

Is there a way to retrieve the thumbail of a members stream?

halcyon bison

nope

quartz ravine

thanks

topaz bluff
  1. Do you have logging on your side to show if it actually worked or not?
  2. Have you restarted your client after deploying commands? (Ctrl+R) The commands cache on your client needs to be cleared for commands to show up
steel trail

Also clarify on what that „nothing“ is that happens

strong garnet

Hi, who owns the DOC for the V2 components?

snow onyx

Do you need a link to it?

ruby grove

is there a property in User for the new server tags

snow onyx

no

server tags are undocumented by discord, so we dont have it implemented.

you can however do a raw rest api call to get the user, which includes tag data

ruby grove

so the api also doesnt return them?

strong garnet

Nothing special, I just wanted to test these features

sharp ginkgoBOT

documentation suggestion for @strong garnet:
class ContainerBuilder discord.js@14.19.3
A builder that creates API-compatible JSON data for a container.

strong garnet

@snow onyx Thanks

tepid maple

I know this isn't like fully djs but is there anway I can stop people from using slash commands in DM's with my bot?

Or will i have to go into each command and do like (!interaction.guild)?

clear garnet

Set the contexts for the commands

sharp ginkgoBOT
copper trail
copper trail

how to i prevent my bot from not working when my editor is closed

rancid folio

Did d.js recently update logic for command autocomplete? I had an autocomplete command that worked fine a few weeks ago, but I just realized it's been unable to process autocomplete options since I updated to the new version. I haven't changed any other code.

zenith violet
proper phoenix

Can someone help me i am new on making bots can someone helo me from the start?

sharp ginkgoBOT
zenith violet

follow the guide

but make sure you know the basics of js first

proper phoenix

Okay but i dont know do i need bot host or what

rancid folio
zenith violet
proper phoenix

Okay

I want to make utility bot so i hope it is not that hard😃

copper trail
half abyss

wokring on a ticket bot and need to add this. What is the message reaction id and where should i put category id?

zenith violet

we arent 3rd party support

ask the creator

half abyss

okay sorry

nocturne flint

Hey there! I want to send a componentsv2 which is ephemeral, looked up the documentation and couldnt find how to use two flags, i am probably missing something. How can i use two flags for a interactions.followUp?

bleak owl

pass an array of them

nocturne flint

right now i am using this, but the message is not ephemeral

static async onInteraction(interaction) {
        
        let outputContainer = await CreateTicketComponent.create();

        await interaction.deferReply();

        await interaction.followUp({
            components: [outputContainer],
            flags: [MessageFlags.IsComponentsV2, MessageFlags.Ephemeral]
        })

        return;
    }
uneven crater
nocturne flint

Thanks, that worked!

balmy kraken

what causes the data.embeds[0][LIST_ITEM_VALUE_REQUIRED]: List item values of ModelType are required error? Invalid embed array?

uncut mango

does discord.js support gradient roles?
i don't see it in the official docs

rose tangle
sharp ginkgoBOT

tag suggestion for @uncut mango:

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

uncut mango
rose tangle

you're pretty much on your own for finding undocumented features

and also on your own if you decide to support them and they break/get removed

main mason

does Message.deletable represent whether the client user has the permissions / channel access necessary to delete the message, or does it represent something else

rose tangle

the former

sharp ginkgoBOT
rose tangle

you can also check the code to see yourself what it actually checks if you want

main mason
rose tangle
main mason

tysm!!

do SlashCommandBuilder BooleanOptions default to false if not passed?

main mason

thx

main mason

Which channels don't have a .name property defined for them? Just DM channels right?

bleak owl

you could just check the docs

main mason

is there a way to figure out which functions throw what exceptions

formal wigeon

yes, its a new feature they introduced called "Reading"

unique shoal

The error stack thrown and logged with the error tells you think

cedar kindle

Hi guys.
How can i edit a container Component?

nimble otter
devout steeple

I have problem only emoij reaction event

all events works fine, just the messageReactionAdd/Remove()

cedar kindle
nimble otter
cedar kindle
unique shoal

Or interaction.editReply

But yes, you just edit it normally

steel yacht

Hi,
I cannot fit all my data into a single InteractionCallbackResponse, so I would like to send multiple replies, except InteractionCallbackResponse doesn't contain a reply method.
So, how to reply to an interaction reply ?
Thanks

snow onyx

interaction.followUp()

sharp ginkgoBOT
steel yacht

Amazing, thanks !
Does this method exist for normal messages too ?
Nevermind, I thought this method would always reply to the last reply rather than to the original command, I guess that's still fine.

However, is there a method that automatically choose between reply and followUp so I wouldn't have to make the ternary ?
Thanks

snow onyx

defer and then use followup

You can use followUp after a reply was created, or after the interaction was deferred.
Then the first followUp edits the reply and the second followUp sends a new message.

sweet quarry

If i was making a multi-step command would interaction.followUp be the best to use to update question and possible answers?

snow onyx

Depends what "multi-step" here means

If you use buttons etc. you can just reply to the component interaction

sweet quarry

is there a limit on the amount of buttons on one message

snow onyx

well, 5 per action row
and however many action rows you can slap into messages now

with legacy components its 5x5

steel yacht
snow onyx defer and then use followup

Would you happen to have an example code please ?
Here's what I currently have :

const reply = (...args) => submission.replied ? submission.followUp(...args) : submission.reply(...args);
snow onyx

You should defer all interactions anyway

sharp ginkgoBOT
steel yacht

I'm sorry I don't understand, where should that be located, what should in practice be in then and what should in practice be in catch ?

Well, I'm afraid I also just don't know what the word "defer" mean 🤔

sharp ginkgoBOT

guide Slash Commands: Command response methods - Deferred responses
read more

steel yacht

Oh, so I should do deferReply then I can always use followUp ?

snow onyx

yes

steel yacht

Well, actually, that still throws InteractionNotReplied, so I'm still looking for a way to get rid of the ternary

snow onyx

show code

you dont need a ternary at all

steel yacht
const submission = await confirmation.awaitModalSubmit({
    filter: _interaction => _interaction.user.id === interaction.user.id,
    time: 5 * 60 * 1000
});
submission.deferReply().catch(console.error);
for(let i = 0; i < addedEmbeds.length; i++){
    await reply({
        content: i === 0 ? 'The following links were added:' : '',
        embeds: [addedEmbeds[i]]
    });
}
snow onyx

you arent awaiting the deferReply

steel yacht

Oh, so I can't parallelize telling it I'm thinking and doing the actual thinking

snow onyx

huh? you need to wait for discord to acknowledge the thinking state in the first place

steel yacht

Well, that means if my server thinks in less than 3 seconds, then the reply is actually delayed by having to tell Discord it's thinking

I suppose ideally I would fix this with something looking like this :

let isThinkingKnown;
submission.deferReply().then(() => isThinkingKnown = true).catch(console.error);
const
  data = await think(),
  reply = (...args) => isThinkingKnown ? submission.followUp(...args) : submission.reply(...args);
for(let i = 0; i < data.length; i++)
  reply(data[i]);
```But we'd be back to more code.
snow onyx

You either do it with await defer or go back to your ternary, there isn’t really anything else

unique shoal

There's nothing wrong with "more code"

More code, assuming it's purposeful and written well, means more functional

If you want to parallelize it, you can technically store a Promise and await it later

const deferral = interaction.deferReply(); // dont await
const thinking = thinking(); // dont await

await Promise.all(deferral, thinking); // now wait for both to complete
await interaction.editReply({ whatever it thought about })```

or whatever order you want

steel yacht

Nice one !

toxic hornet

Hi, I'm not too familiar with the new way of flags and I keep bumping into this weird type bug ? Is this an actual thing I can't do alongside ephemeral?

snow onyx
toxic hornet

It now doesnt let me use ephemeral

snow onyx

you dont need to provide ephemeral again

or rather cant, putting it in deferReply is enough

toxic hornet

ohh okay ty

steel yacht

How to do confirmation.showModal after confirmation.deferReply() ?

snow onyx

You can't.

steel yacht

So deferring wouldn't be a good practice in this case ?

snow onyx

The modal needs to be shown immediately.

steel yacht

Well, I have a setValue in a modal input, and that data is from the DB

snow onyx

The modal needs to be shown in less than 3 seconds, so if that DB call is fast enough that may work, but its not guaranteed.

steel yacht

It does work, it's just since we talked about deferring being a good practice earlier, I thought I'd add it there too

dense jackal
snow onyx
dense jackal

so your first, deferred interaction will retrieve data from your db, second interaction will show the modal

toxic moat

hello guys

    let text1 = new TextDisplayBuilder()
        .setContent('## :loading: Checking input data...');
    
    container.addTextDisplayComponents(text1);

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

    const message = await interaction.fetchReply();```

how can i do for change what is writed inside text1 after i have sended a message?
toxic moat
shell grove
toxic moat
shell grove
shell grove

Or you can do containerEdit.content = "..."

toxic moat

oh ok

shell grove

But I just find it easier to work with the class

not the classroom btw, the discordjs textdisplaycomponent class

toxic moat

ahahha

shell grove

Youd have to provide code but possible reasons could be:
Multiple listeners, multiple instances

young zodiac

I’ve been reading the v2 docs but can’t find a way to make them inline….. any idea?

snow onyx

put them in the same action row

young zodiac
snow onyx

please take screenshots and not pictures with a camera xD

And that doesn't change my answer. When you add the button to the component, put it in the same action row as the other button.

young zodiac

Ohhhhh i read wrong

young zodiac
snow onyx

I can't answer that, haven't worked with v2 yet

young zodiac

I don’t think so

Mabe Im wrong but it doesn’t look like it’s possible to make them horizontally inline.

safe karma
safe karma

So put the buttons in the action row first, then add the action row to the container

young zodiac

It doesn’t look like we can nest a v1 action row down inside a v2 container…

Mabe Im wrong……….

snow onyx

the "v1 action row" is the same as the "v2 action row"

safe karma

And that puts them inline

young zodiac

Ooo alright lemme try

safe karma

It has been working fine for me past few weeks, only issue I’ve found is that people with outdated app versions can’t see v2 components

polar karma

show the code and errors/wrong output

zinc meadow
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const fs = require('fs');
const path = require('path');
// const { features } = require('process');
require('dotenv').config();

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,               
    GatewayIntentBits.GuildMembers,         
    GatewayIntentBits.GuildMessages,        
    GatewayIntentBits.MessageContent,        
    GatewayIntentBits.GuildModeration,        
    GatewayIntentBits.GuildExpressions,
    GatewayIntentBits.GuildIntegrations,
    GatewayIntentBits.GuildWebhooks,
    GatewayIntentBits.GuildPresences,
    GatewayIntentBits.GuildMessageReactions,
    GatewayIntentBits.DirectMessages,
    GatewayIntentBits.DirectMessageTyping,
    GatewayIntentBits.AutoModerationConfiguration,
    GatewayIntentBits.GuildMessagePolls,
    GatewayIntentBits.DirectMessagePolls,
  ]
});


client.once('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.login(process.env.token);

Heres the code

node index.js
/home/runner/workspace/node_modules/@discordjs/ws/dist/index.js:1151
error: new Error("Used disallowed intents")
^

Error: Used disallowed intents

Why am I getting this error?

Alright I got it!

elfin scroll

Because you are using intents that your bot isn't allowed to use. Check on your bot's page in the dev portal, there's 3 that are priviledged and need to be turned on there as well, you are using at least one in your list (i just scanned quickly).
(i had already typed most of my answer, was that it?)

zinc meadow
elfin scroll

ok, figured i'd post the answer to confirm and help others that could see your question and have the same issue.

ember crest

how to make button works in dm?

safe karma

You can then use collectors, etc to grab the interaction and respond

arctic socket
const { EmbedBuilder } = require("discord.js");
const Event = require("../../structure/Event");
const { featuredChannelId, showcasechannelID, customStarEmoji, embedColour } = require('../../config')



module.exports = new Event({
    event: "messageReactionAdd",
    once: false,
    run: async (reaction, user) => {
        if (user.bot) return;

        try {

            
            console.log(reaction)

        } catch (err) {
            console.error("Error in messageReactionAdd:", err);
        }
    }
}).toJSON();

How do I get information on the message the reaction was placed on?
The reaction gets detected, but it doesn't have any of the information I need

slow pebble

as I take it server member applications aren't yet part of discord.js rght?
re they on the API yet though? lke is it possible to have an event trigger and f.e. send a notfication when a new request comes in?

wary coral
young zodiac

why am i not seeing the option? Small large etc????? when i put const separator = new SeparatorBuilder()
.setSpacing(SeparatorSpacingSize.Small)
its saying undefined

copper trail

anybody know if its possible to forward messages from one channel to another after requesting the command

slow pebble
safe karma
sharp ginkgoBOT
hallow mesa
copper trail

@snow onyxhow would i create it as a command

like input the channel i want to listen to and have it send the messages there

snow onyx

Please stop pinging me, just ask your questions and when someone knows the answer they will respond.

copper trail

sorry

solid summit

is there any guide for changing gradients for role?

polar karma

afaik it's not documented

solid summit
sharp ginkgoBOT

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

hexed marsh

Is it possible to check if a channel is an "Announcement" channel?

solid summit
sharp ginkgoBOT
polar karma

check the channel type

hexed marsh

That's it, couldn't find that darned thing

polar karma
solid summit
snow onyx

This is not a feature thats documented by discord in the discord api, thus discord.js is not adding this as a feature until it is.

solid summit

ok ty, any expected date?

polar karma

ask discord

solid summit

😭 ok

arctic socket
sharp ginkgoBOT

guide Popular Topics: Partial Structures
read more

arctic socket

Thank you

I've got them in both my intents and my partials? Does that mean I can use the fetch method?

topaz bluff

You can always use the fetch method regardless if you have partials or not

arctic socket

Right I see, so something like this?

const { EmbedBuilder } = require("discord.js");
const Event = require("../../structure/Event");
const { featuredChannelId, showcasechannelID, customStarEmoji, embedColour } = require('../../config');

module.exports = new Event({
    event: "messageReactionAdd",
    once: false,
    run: async (reaction, user) => {
        if (user.bot) return;

        try {
            if (reaction.partial) {
                try {
                    reaction = await reaction.fetch();
                } catch (err) {
                    console.error("Failed to fetch reaction:", err);
                    return;
                }
            }

            if (reaction.message.partial) {
                try {
                    reaction.message = await reaction.message.fetch();
                } catch (err) {
                    console.error("Failed to fetch message:", err);
                    return;
                }
            }

            console.log(reaction);

        } catch (err) {
            console.error("Error in messageReactionAdd:", err);
        }
    }
}).toJSON();
copper trail

i cant seem to the message to work

polar karma

gonna need to be more specific than that

copper trail

sorry discord didnt load previous message so i thought i was still on my convo. anyways when i try do the message forward method it doesnt seem to work

tardy sable

is there documentation yet for the new role style colors?

polar karma

no

polar karma
wary coral
grand scroll

Why Isn't Embed Showing Mentions Properly?

wary coral
topaz bluff
copper trail
wary coral could you share the code you are running and elaborate more on what you mean by ...

const { SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('messages') .setDescription('Forwards messages from one channel to another.') .addChannelOption(option => option.setName('source') .setDescription('The channel to forward messages from.') .setRequired(true)), async execute(interaction) { // interaction.guild is the object representing the Guild in which the command was run await interaction.reply("Here are the messages from the source channel" + MessageChannel("source")); // interaction.guild.channels.cache.get('source') is the channel object representing the source channel }, }; this is the code that i have for a slash command but when deploy and test it in my server it responds with an application error

topaz bluff

Are you getting any errors in the console? If not, then your command handler is likely the issue

grand scroll
polar karma

your app client !== your user client

wary coral
topaz bluff
grand scroll

So, I Can't Do Anything About It? it's Specific To The User Who's Viewing This Embed

wary coral

ya the the app displays the user id whan the user is not cached

wary coral
topaz bluff
copper trail
topaz bluff
sharp ginkgoBOT

guide suggestion for @copper trail:
guide Creating Your Bot: Event handling
read more

grand scroll
wary coral

you could use markdown in a textDisplay component. might be worth a shot to test

I have been using cv2 and so far real happy with the resalts

topaz bluff

Oh. Well on mobile you can't really tell (I'm assuming you mean that you're using inline)...but still, I would recommend CV2 if you want to list users who might not be cached

copper trail

bruh i did everything and it still didnt work. command handler is the same

output is nothing

sharp ginkgoBOT

tag suggestion for @copper trail:
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
wary coral

your going to need to work though why you command is not being run by your handler

also in the Discord client I assume you are seeing "The application did not respond" message is that right?

copper trail

from what i have seen it works up until i enter the command

wary coral

what do you mean by work? do you have other commands? or actions related to events

topaz bluff

Go to your client.on("interactionCreate") and add console.log(interaction) or something similar to see if your command handler is even doing anything

Just because the code exists, doesn't mean it's running

copper trail

but anywas im gonna have lunch and try to figure out whats wrong. I have realized that i cant keep asking people for help and not learn it myself

weak karma

hey quick question is there anyway for my bot to add another bot into a server?

zenith violet

no

half night

does components v2 have any coloring options for sections like legacy embeds had that color bar?

sharp ginkgoBOT
wary coral

yes

half night
supple pagoda

can i do this too in components v2? container does not have .setAuthor so i am asking if there is something familiar now?

supple pagoda
wary coral no

so i cant do this little image thingy up there? only in regular embeds?

wary coral
supple pagoda

ok thanks

copper lichen

Guys how do i check is a message has a mention?
message.mentions.has() always says false

copper lichen

user mentions

copper lichen

But if i mention someone its still false

steel trail

Does your bot have MessageContent intent?

copper lichen

yes, also all the guild intents

verbal plinth

Is there an easy way to see if an interaction has already expired?

steel trail
copper lichen

module.exports = {
    name: Events.MessageCreate,
    execute(message, client) {
        if(!message.author.bot){
        console.log(message.mentions.has());
    }},
};```
steel trail
steel trail
wary coral
verbal plinth
steel trail

Great, then catch that and you know

steel trail
verbal plinth
steel trail
copper lichen

Just check for user mentions

steel trail

message.mentions.users.size > 0

If you just want to check if any user was mentioned

copper lichen

And how could I check is my bot is mentioned?

rich terrace

Does anyone understand in Sql database and can help my question in #1374458927193788436 please 🙂

steel trail
copper lichen

Is it practical to go over all mentions, or just parse from the message content?

steel trail
wicked rampart

I just tried to upload an emoji to the developer portal and changed the emoji ID in my bot code to the new ID that's in the portal (replacing an emoji ID that's in a private server) and didn't change any other code. it worked before changing and now it doesn't. I get error: "Emoji must be a string or GuildEmoji/ReactionEmoji"

rich terrace
steel trail
wicked rampart
verbal plinth
steel trail Great, then catch that and you know

Does DiscordAPIError[10062]: Unknown interaction mean anything to you? Are there any explanations for the codes?

Because all I get is that and 404 - Not Found, which comes up in the REST.Response.

steel trail

Oh, wait, why do you use client.emojis.resolve?

client.emojis only contains GuildEmoji

sharp ginkgoBOT

discord Opcodes and Status Codes - JSON
Along with the HTTP error code, our API can also return more detailed error codes through a code key in the JSON error response. The response will also contain a message key containing a more friendly error string. Some of these errors may include additional details in the form of Error Messages...
read more

verbal plinth

It only says Unknown interaction which I already know

sharp ginkgoBOT

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
wicked rampart
steel trail
verbal plinth
hushed mirage

yo bro

steel trail
hushed mirage

I think I found a bug in the discord.js module

steel trail
loud quartz
wicked rampart
steel trail
wicked rampart
hushed mirage

when I delete a channel but do not respond to the interaction, I get an unkown channel error, and I should probably get an interaction error

wary coral
hushed mirage

yes

steel trail

In that case the error is correct

You try to reply in that channel, but the channel does not exist anymore

hushed mirage

no

I think we don't understand each other

steel trail

Show your actual error with stacktrace and code then

hushed mirage

unless it's my bot's fault, never mind

rancid shoal

should i always defer command replys ?

another thing if my command fetches data from my database would you recomened defering the reply ?

steel trail

You should defer before any async tasks, yes

little dragon

Hello, I'm currently making a bot, and I want it to be able to play songs from Youtube. Is there any way to fix this? Because right now, what I have is this:::::: Sign in to confirm you're not a bot

polar karma

no, that violates the youtube tos

rancid shoal