#djs-help-v14

78874 messages · Page 52 of 79

stable sun

eventFunction just isn’t a function

barren bramble

It is

barren bramble
stable sun

If it was, then you wouldn’t get an error after calling it

If I had to guess before looking at the code, I’d say that you are using an event handler and forgot to export the run/execute function in one of the event files

barren bramble

Let me get a zip

stable sun

Just send the event handler file

barren bramble

ok

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.

topaz bluff

Or pastebin exists

barren bramble

const path = require("path")
const getAllFiles = require("../utils/getAllFiles")

module.exports = (client) => {
try {
const eventsFolders = getAllFiles(path.join(__dirname, "..", "events"), true)

for (const eventfolder of eventsFolders) {
    const eventFiles = getAllFiles(eventfolder)
    eventFiles.sort((a, b) => a > b);

    const eventName = eventfolder.replace(/\\/g, "/").split("/").pop()

    client.on(eventName, async (arg) => {
        for (const eventFile of eventFiles) {
            const eventFunction = require(eventFile)
            await eventFunction(client, arg)
        }
    })
}
}catch (error) {
    console.log(`Error loading event handlers: ${error}`)
}}
stable sun

Crazy part is that there’s no event firing being shown in the stack trace

barren bramble

?

stable sun

eventFunction is only executed when a client event fires. Thus, that event should be part of the stack trace

barren bramble

this is my index.js:
const { Client, IntentsBitField, ActivityType } = require('discord.js');
const mongoose = require("mongoose");
const eventHandler = require('./handlers/eventHandler');
require('dotenv').config();

const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
IntentsBitField.Flags.GuildPresences,
IntentsBitField.Flags.DirectMessages,
]
});

(async () => {
try {
mongoose.set('strictQuery', false);
await mongoose.connect(process.env.mongodb_uri, {});
console.log("MongoDB connected");

    // Event handler
    eventHandler(client);

    client.login(process.env.BOT_TOKEN);
} catch (error) {
    console.log(`Er was een error: ${error}`);
}

})();

stable sun

Log the eventName and eventFile before you call eventFunction

barren bramble
stable sun

Yea

Missing an await before client.login btw, not related to the issue tho

versed current

Guys when I receive a string select menu interaction from an ephemeral message and try to .update(...) it, it ways "Unknown Message" - is this supposed to happen?

stable sun

Show code

versed current

interaction.update(...)

stable sun

... is not very descriptive

versed current

there is nothing more to show really. 😅

stable sun

There's always more to show until you have sent ur entire gh repo

versed current
interaction.update({
  flags: EphemeralV2Flags, // MessageFlags.IsComponentsV2 | MessageFlags.Ephemeral
  components: [new ContainerBuilder().addTextDisplayComponents((t) => t.setContent(`${LoadingEmoji()}`))],
})

I don't know why this wouldn't work

stable sun

Did you dismiss the ephemeral message?

versed current

nope, I ccan send you a recording. one sec

stable sun

Show the full error

Error message and stack trace

versed current

something else broke. I will get back to you asap, sorry

ah wait, it's not even reaching the point where it updates. I think the issue is somewhere else.

ah I found it

stable sun

Was gonna say, Unknown Message doesn't come from interaction.update

versed current

yeah I'm editing ctx.message message before but this was guarded with an if-statement. However, I forgot, I only had the string select as a condition - because before I didn't have a second string select.

-# I'm resetting the first select menu this way

topaz bluff

That's not an embed. It's a container

sharp ginkgoBOT

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

topaz bluff

Yes. They're coming

stable sun

I wouldn't say that

People wanted more rich customization, hence Discord came up with components v2

robust flame

lol

Is it just me?

snow onyx

no, its half the internet kekw

robust flame

wdym

other sites don't work either?

snow onyx

correct, so I assume its related

robust flame
robust flame
snow onyx

what do you need help with?

robust flame

i need to find log channel

import { EmbedBuilder, Events, Guild, GuildBan, GuildMember, Invite, Role, RoleManager, TextChannel, User } from "discord.js";
import bot from "../../core/classes/Bot";
import Event from "../../core/classes/Event";
import GuildConfig from "../../core/schemas/GuildConfig";
import { useI18n } from "../../core/classes/Interaction";

export default class inviteCreate extends Event {
    constructor(bot: bot) {
        super(bot, {
            name: Events.InviteCreate,
            description: 'sadasdawd event',
            once: false
        })
    }
    async exec(invite: Invite) {
        const i18n = useI18n();
        const lang = await GuildConfig.findOne({ guildId: invite.guild?.id });
        const guild = await this.bot.guilds.fetch();

        try {
            const embed = new EmbedBuilder()
                .setColor('Green')
                .setTimestamp() // Добавляет временную метку
                .setTitle(`:True: ${i18n.twl(lang?.lang ?? "en", "logs.title")}\n**${i18n.twl(lang?.lang ?? "en", "guildrolecreate.title")}**`)
                .setDescription(``)
                .setThumbnail(`${invite.guild?.iconURL({ size: 1024, extension: 'jpg' })}`)
            if (lang?.lang && lang?.logs?.enabled && lang?.logs?.channelId)
                (await invite.guild?.channel.fetch(lang?.logs.channelId) as TextChannel)?.send({
                    embeds: [embed]
                })
        } catch (error) {
            console.log(error)
        }
    }
}```
snow onyx

wdym with log channel

you mihgt wanna use channels and not channel

robust flame
robust flame
wary coral
robust flame same

It's there in the error. An invite guild is not the same as a guild object. You'll need to get the guild from cache or fetch it

snow onyx

yes you need to make sure you have the full guild object, not just an InviteGuild
I'm sure there is a typeguard for it, but without docs I have no idea kekw

robust flame
fallow finch

I whipped this out

    if (!invite.guild || invite.guild instanceof InviteGuild) return;``` because I'm a monster

I legit couldn't find a type guard

wary coral
sharp ginkgoBOT
robust flame

it doesn't work and doesn't log anything

import { EmbedBuilder, Events, Guild, GuildBan, GuildMember, Invite, InviteGuild, Role, RoleManager, TextChannel, User } from "discord.js";
import bot from "../../core/classes/Bot";
import Event from "../../core/classes/Event";
import GuildConfig from "../../core/schemas/GuildConfig";
import { useI18n } from "../../core/classes/Interaction";

export default class inviteCreate extends Event {
    constructor(bot: bot) {
        super(bot, {
            name: Events.InviteCreate,
            description: 'sadasdawd event',
            once: false
        })
    }
    async exec(invite: Invite) {
        console.log(invite)
        const i18n = useI18n();
        const lang = await GuildConfig.findOne({ guildId: invite.guild?.id });

        if (!invite.guild || invite.guild instanceof InviteGuild) return;

        try {
            const embed = new EmbedBuilder()
                .setColor('Green')
                .setTimestamp() // Добавляет временную метку
                .setTitle(`:True: ${i18n.twl(lang?.lang ?? "en", "logs.title")}\n**${i18n.twl(lang?.lang ?? "en", "inviteCreate")}**`)
                .setDescription(`aa`)
                .setThumbnail(`${invite.guild?.iconURL({ size: 1024, extension: 'jpg' })}`)
            if (lang?.lang && lang?.logs?.enabled && lang?.logs?.channelId)
                (await invite.guild?.channels.fetch(lang?.logs.channelId) as TextChannel)?.send({
                    embeds: [embed]
                })
        } catch (error) {
            console.log(error)
        }
    }
}```
fallow finch

You need GuildInvites intent

robust flame

TYSM

guys, i have old laptop and my pc, if i host my bot on pc, it works normally, but if i host it on laptop, bot crashes by Unknown Interaction / Missing Access

raven storm

hii

Can someone help me with Railway hosting?

unique shoal

Probably not, no

snow onyx

this support is for djs, not railway

raven storm

I have always used it to host bots

It gets stuck at the npm ci command, I don't understand why... I've just started programming again recently

Or do you know any other free hosting?

fake new, it's started

sharp ginkgoBOT

tag suggestion for @robust flame:
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
snow onyx

LTS (V22.20.0)

use 22.19.0 then I guess
you can also use the latest I assume

versed current
snow onyx

that wasnt a reply to you

the message they replied to was deleted

versed current

ah, ok

hushed monolith

Hey ya'll. So, having some issues with my bot and it's reaction handling. It has worked fine before but now for some reason (i am unsure how long) it doesn't work. There are no errors. Through a lot of debugging I have deduced that the issue is that the bot does not seem to actually listen to the event. I already cache the message in a separate handler which creates / edits the message that the reactions are to be put on, and it puts the reactions onto the post just fine even when I remove all the reactions and restart the bot. (Basically, the message is cached and everything works fine except for listening to the messageReactionAdd and messageReactionRemove events.

I am using Discord.js version 14.10.2.

Here is my event (they are identical with the obvious exception of whether it is adding or removing the roles, don't mind handleReaction function checking if it is add/remove, I used to have these two events in the same file until I did my cleanup today while trying to figure out why it was no longer working.)
messageReactionRemove.js

const Discord = require("discord.js");
const { ensureSettings } = require("../utility/LoadFunctions");

module.exports = {
  name: "messageReactionRemove",
  run: async (bot, reaction, user) => {
    const { client } = bot;
    ensureSettings(client);

    client.log(
      "messageReactionRemove",
      "reaction = " + reaction + " - user = " + user,
      false,
      "debug"
    );
    if (reaction.message.channel.id === channelId) {
      handleReaction(reaction, user, false);
    }
  },
};

const handleReaction = (reaction, user, add) => {
  if (user.id === "314077814741532674") return;
  let roles = client.settings.get(guild.id, "roles");

  const emoji = reaction._emoji.name;

  const { guild } = reaction.message;

  const roleName = roles[emojis.indexOf(emoji)];
  if (!roleName) return;

  const role = guild.roles.cache.find((role) => role.name === roleName);
  const member = guild.members.cache.find((member) => member.id === user.id);
  client.log("Event - messageReactionRemove", "role = " + role, false, "debug");
  client.log(
    "Event - messageReactionRemove",
    "member = " + member,
    false,
    "debug"
  );
  client.log("Event - messageReactionRemove", "add = " + add, false, "debug");

  if (add) {
    member.roles.add(role);
    //sendLog(member, role, guild, "added");
  } else {
    member.roles.remove(role);
    //sendLog(member, role, guild, "removed");
  }
};```

The logs does not work. My event handler loads the event, it shows up in my console along with all the other events which work just fine. (Attached screenshot)

After doing some digging it seemed like I was suddenly missing the Intent for the reactions, so I added it but nada. I also found that if the message isn't cached I need the partial, but my message is cached. However, I decided to add the partials just to be sure and still the events aren't being listened to / giving any response when triggered.

index.js
```js
const { Client, Collection, GatewayIntentBits, Partials } = require("discord.js");
const Enmap = require("enmap");
require("dotenv").config();

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.GuildMessageReactions,
    GatewayIntentBits.MessageContent,
  ],
  partials: [
    Partials.Message,
    Partials.Channel,
    Partials.Reaction,
    Partials.User,
  ],
});```

Anyone that has dealt with this before that might know what's up? I obviously expect at least my *logging* that is triggered whenever the event triggers to go through, but not even that shows up. I am assuming I am missing something very obvious, or maybe my bot is just broke.
plucky atlas
wary coral
hushed monolith

This has been going on for longer than the past few days though. Last successful run of the event was June 30th. I just can't pinpoint when it stopped working because I only noticed this myself the other day.

wary coral
hushed monolith

Will give that a go

polar karma

Shitpost somewhere else

glad stone
const modal = new ModalBuilder()
            .setCustomId("modal3")
            .setTitle("modal (3/3)")

        const label = new TextDisplayBuilder()
            .setContent("Make sure that the email you enter is correct and check your junk email before making a support ticket.");

        const email = new TextInputBuilder()
            .setCustomId("email")
            .setLabel("Email Address")
            .setStyle("Short")
            .setPlaceholder("email")
            .setRequired(true);

        modal.addComponents(
            new ActionRowBuilder().addComponents(label),
            new ActionRowBuilder().addComponents(email));
        
        return modal;```

why is this returning invalid form body?
proud arrow
glad stone

i have removed it from the actionrow and it is still giving me the error

modal.addComponents(
            label,
            new ActionRowBuilder().addComponents(email));```
wary coral

try to migrate to the new modal components in v14.23.2

pallid sparrow

is there a guide anywhere that explains how to use select menus inside of modals? having trouble figuring out where i can put a label thinking_derp

glad stone

so how does one use label instead, the docs arent very clear as their examples are all in json format

wary coral
pallid sparrow

thanks man

oh lord, labels are now a builder

glad stone

LabelBuilder isnt recognised for me

pallid sparrow

update your discord.js version to latest

glad stone

fixed thanks

so the label can only be 45 chars or less.

any way i can make that value more than 45?

snow onyx

no

glad stone

crud...

wary coral

You could add a text display if more information needs to be displayed

But I recommend rewording the question

snow onyx
sharp ginkgoBOT

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

tight thorn

is there any way to send image files / embeds with higher pixel densities, e.g. a 2x image that actually displays at 2x density instead of 2x size?

steel trail

You can't increase the amount of pixels the screen of the person viewing that image has. I don't understand your question really

They also look completely different based on device and screen size of the one viewing it

tight thorn

yeah i guess i could be a problem with also the way the image is generated, too. i'm generating attachments via skia-canvas, which supports a density when generating the output buffer, but an image with density: 2 simply displays as twice as big (but still blurry) on my mbp (which is a high dpi display).

so my question is, is there some way to communicate that this is a high dpi image to discord or via discordjs, for example by tacking @2x on to the filename?

steel trail

dpi is something relevant for printing. As a file that always simply means "bigger size"

tight thorn

a monitor displaying the image it can render it at higher dpi/ppi if it knows to do so.

steel trail

No. Monitors are dumb. All they can do is display pixels. Also none of this has anything to do with djs so you're in the wrong channel

normal flare
tight thorn
steel trail
tight thorn

alright, thanks for your time.

limpid pecan

Does Discord.js support all components in modals yet? Or just select menus and text input?

steel trail

And Text Display

wary coral

Just not file upload as of v14.23.2

sudden totem

Which d.js version I need to update bot guild profile?

hallow mesa
sudden totem

Can i use rest method in the older version?

hallow mesa

Probably

tidal ivy

let's say i have an incoming message
in which case will i be able to reply to it, but not to send a message to its channel ?

await message.reply(...); // fine
await message.channel.send(...); // need to check if channel is sendable first
tardy sable

i think for both you have to check if you can send messages in the message channel

tidal ivy

on a type level i don't need to
i can reply without checking if channel is sendable, but not send message to the channel without checking that

that's why i'm asking, maybe i'm missing an edge case or smth

versed current
tardy sable

i think he means if bot has permissions to send messages

hallow mesa

Replying is just sending with a reference

tardy sable

you dont have to check if bot has permissions to send messages on message replies?

hallow mesa

You do (or catch the error)

tight thorn
tidal ivy
hallow mesa
rose tangle

the sendable check pretty much only exists for that case, currently

rose tangle
tidal ivy

thanks gardeavous

tight thorn
rose tangle

discord api

the last limitation says

For the embed object, you can set every field except type (it will be rich regardless of if you try to set it), provider, video, and any height, width, or proxy_url values for images.

tidal ivy
tight thorn
steel trail
rose tangle

ah, missed that, then yeah where you pointed out it's the only place where it's mentioned

you don't get any device info though, so even then it wouldn't be usable for that case

tidal ivy
tight thorn
rose tangle

yeah, that's how it works

I thought you meant that it's sad it's not exposed because otherwise you (your bot) could do that

steel trail
rose tangle

now I'm not sure what you meant

tight thorn

yes, if you could specify width/height at attachment creation time, and send a buffer with enough pixel information to render at 2x density, then 2x clients could display the image properly.

tidal ivy
rose tangle

just send the attachment with the dimensions you can and discord will figure out the optimizations and whatnot

tight thorn

yeah, that doesn't work, it just displays the image twice as big.

steel trail
sharp ginkgoBOT
tidal ivy

okk thanks it works
i didn't noticed the difference

rose tangle

I'm pretty sure the issue itself still exists though, you can reply without a check, but you can't send without a check

which is inconsistent because replying is just sending

not that it can be easily solved anyways

steel trail

Theoretically the only way to get your hands on a Message in a GroupDM is through interaction methods. so all other methods could be typed to return the OmitPartialGroupDMChannel helper type too... ugly but would get close

and then the methods on interactions could omit the reply method instead (with another ugly helper type if in groupDM)

tardy sable

whats the difference with PermissionsBitField.Flags and PermissionFlagsBits

rose tangle

PermissionsBitField.Flags is PermissionFlagsBits

silent mirage

Does discord allow you to change forms instantly let’s say i select bug report it changes all of the modal to add upload

rose tangle

it isn't possible

wary coral

What you want to do to get that behavior is to have a select menu that then shows the respective modal

rose tangle

sure, defers are part of interactions, not components

distant inlet

Why is my command deployment so slow?

deploy.js

const { REST, Routes } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');
const fs = require('node:fs');

const commands = [];
// Grab all the command files from the commands directory you created earlier
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    commands.push(command.data.toJSON());
}

// Construct and prepare an instance of the REST module
const rest = new REST({ version: '10' }).setToken(token);

// and deploy your commands!
(async () => {
    try {
        console.log(`Started refreshing ${commands.length} application (/) commands.`);

        // The put method is used to fully refresh all commands in the guild with the current set
        // Routes.applicationGuildCommands(clientId, guildId),
        const data = await rest.put(
            Routes.applicationCommands(clientId),
            { body: commands },
        );

        console.log(`Successfully reloaded ${data.length} application (/) commands.`);
    } catch (error) {
        // And of course, make sure you catch and log any errors!
        console.error(error);
    }
})();

Months ago it was instant

polar karma

it should still be instant unless you're rate limited. have you refreshed your user client?

console.log(`Successfully reloaded ${data.length} application (/) commands.`);``` does that log show up in your console?
topaz bluff

Then restart your client and your commands should be updated

(your app, not the bot)

distant inlet

ooh like, discord?

topaz bluff

Yes

distant inlet

That wasnt needed before back then

polar karma

yes it was

topaz bluff

Discord has always cached application commands on the client so you're not constantly fetching them every time you press /

distant inlet

That fixed it, cheers all

topaz bluff

o7

distant inlet
polar karma yes it was

Naah it wasn't. With my previous command added today it also wasn't needed but it took a few minutes.

rose tangle

sometimes it invalidates fine and sometimes it doesn't, life is weird

a restart should always fix it

olive lantern

is there a way to have a role select in my modal?

steel trail

yes

put it in a Label

olive lantern

so a label component?

steel trail

yes

olive lantern
const row1 = new ActionRowBuilder().addComponents(roleSelection)
    modal.addLabelComponents(row1)```
visual musk

hi there, I was wondering if there was a way to use the new components v2 system to use value to place a role in a selectmenu with the value, just like I can with textinputs. I have tried using raw role data in a JSON, and also the role ID, as shown in the segment of code below representing my modal with the select menu and then the middle textinput. I may just be being silly as this is just really using values with a regular role select menu, but any help is greatly appreciated

.addLabelComponents(
                new LabelBuilder({
                    label: "Role",
                    description: "The role assigned to this button",
                    component: {
                        type: ComponentType.RoleSelect,
                        custom_id: "roleSelection",
                        value: '1429907176444399676',
                        required: true
                    }
                })
            )

            .addLabelComponents(
                new LabelBuilder({
                    label: "Emoji",
                    description: "The emoji of the role's button",
                    component: {
                        type: ComponentType.TextInput,
                        style: TextInputStyle.Short,
                        custom_id: 'emoji',
                        value: '🔥',
                        required: true
                    }
                })
            )
distant inlet

Ooh boi ooh boi. I want to sent a message to another discord and a specific channel when doing a slash interact on another guild its discord. How could I do so?

visual musk

apologies for the massive text wall!

sharp ginkgoBOT

tag suggestion for @distant inlet:

const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
distant inlet

I don't have the client from my index.js bot, it's using the interaction from the commands folder

And that interaction is based of the guild it's being triggered on right

@polar karma

sharp ginkgoBOT
visual musk

thank you! :)

stable sun

Interactions don’t "natively support" sending messages outside of the channel the interaction occurred by design

distant inlet
stable sun You still get the channel the same way
const channel = interaction.channels.cache.get(boGlobalLog);
channel.reply(`OK: This server is ${interaction.guild.name} and has ${interaction.guild.memberCount} members.`);

Gives me undefined (reading 'cache')

stable sun

interaction.channels does in fact not exist

You have to do interaction.client to get the client

distant inlet

thats what I meant, so I need the client

stable sun

I usually just pass the client to all my events and commands

distant inlet
stable sun

You just change your event and command handler to pass in the client

rose tangle
rose tangle
distant inlet

I was already wondering why I needed to pass my client

Sorry all, thanks for the help! Must been the beer 😅 🍻

visual musk
sharp ginkgo _documentation suggestion for <@799630161758388264>:_ <:method:12637825709156598...

not entirely sure how to use this with the setup I have:

.addLabelComponents(
    new LabelBuilder({
        label: "Role",
        description: "The role assigned to this button",
        component: {
            type: ComponentType.RoleSelect,
            custom_id: "roleSelection",
            default_roles: '1429907176444399676',
            required: true,
        }
    })
)

I can't use .setDefaultRoles() here, there is default_values: given to me with intellisense instead of what i put as a test default_roles: which didn't work.

I know it's an array, and I've tried using an array with default_values, but to no success

rose tangle

if you're going to use a raw object you might as well just not use the builder

but if you're having trouble with raw data then use the builder

specifically you need default_values, which is an array of { id: string; type: SelectMenuDefaultValueType }

visual musk

thank you for your comments, got it working:
default_values: [{ id: roleData.roleId || '', type: SelectMenuDefaultValueType.Role }]

main axle
wary coral
tardy sable

question, shouldnt message.pinnable be changed to use the pinMessage permission instead of whats it now ManageMessages?

unique shoal

Probably yes

tardy sable
crimson gale

yes, github is where we track issues

tardy sable

thanks

round tundra
unique shoal

You don't

That component is not available in Modals

round tundra

oh okay that makes sense than

olive lantern

how do you get the role ids from a select menu based on the objects (multiple roles)?

sharp ginkgoBOT
tardy sable

map the roles if you only want role id

olive lantern

gotcha, thanks!

wary coral

no, but you can get it with the asset

const asset = member.avatarDecorationData?.asset ?? user.avatarDecorationData?.asset
client.rest.cdn.avatarDecoration(asset)

but there are function on both member and user to get the decoration url

wintry laurel

hey, im just starting off with activities and im getting this error on my bot after turning them on. im trying to make a minesweeper game activity where people use the command to launch the activity, just like /wordle

DiscordAPIError[50240]: You cannot remove this app's Entry Point command in a bulk update operation. Please include the Entry Point command in your update request or delete it separately.

rose tangle

that suggests that (both points):

  • you're deploying on start, which isn't recommended ("after turning them on")
  • on your deploy, you're using a commands.set or rest.put, and you're not passing the entry point command
wintry laurel
rose tangle

that's not part of the problem, the last part of that sentence is

wintry laurel

yea ill read the activites guide again see if i missed something

rose tangle

you just need to pass the entry point command in that data

otherwise you'd be telling discord you no longer want it (delete it), which isn't possible like the error says

wintry laurel
rose tangle

well not according to that error

wintry laurel

yea guess not, ill see

radiant epoch

How can we pass Activity command as a command for bot? I don’t understand how that progress is happening

unique shoal

If you've turned it on, you need to define it

And which handling method you intend to use

radiant epoch
rose tangle

what do you mean by "type"?

the command type (4)?

if yes, that's on dtypes, and every other api resource

sharp ginkgoBOT

dtypes v10: ApplicationCommandType - PrimaryEntryPoint
read more

rose tangle

if you mean a special class, no, no command type has a dedicated class

they're all in the same

sharp ginkgoBOT

dtypes v10: EntryPointCommandHandlerType
read more

soft oracle

Hey guys, I found an issue with the components v2 embed whenever there’s a role mention or a user mention, it actually triggers a notification, unlike the old embed system.
I did some research but couldn’t find any option to enable or disable these notifications.
What’s the solution for this?

sharp ginkgoBOT
sour tendon

How do I set a custom status like this?

clear garnet
clear garnet

-# And if I’m being pedantic, components v2 aren’t “embeds”, they’re just components, separate from traditional embeds

devout valve

Do you know if there is currently a way in discord.js to detect if someone has a tag from my server and use that to assign them a role?

sharp ginkgoBOT
fiery forge

can i get user locale as interaction.locale from message?

stable sun

No

fiery forge

sad

steel trail

Only interactions

vivid iris

Are file uploads allowed in modals now

wary coral
versed current

can I use the interactions package to verify the signature?

proud arrow
glad stone

how do i get an embed to update without the user interacting with it

so when conditions are true in the backend the embed will update

proud arrow

Otherway is to use interaction webhooks (works for ephemeral messages), but that is valid only for 15 min. So if you are planning to wait longer than that, it is not viable

sharp ginkgoBOT
glad stone

thankyou

versed current

I use sveltekit 😅 So I'd have to make a wrapper for that

slow breach

Hello, I'm using Discord.JS 14.23.2 and I'm having a problem with "AttachmentBuilder." I get this error in my console:
TypeError [ReqResourceType]: The resource must be a string, buffer, or a valid file stream.
Here's my code snippet:

const width = 600;
const height = 300;
const canvas = createCanvas(width, height);
const ctx = canvas.getContext("2d");
return canvas.toBuffer("image/png");
}

await interaction.deferReply();
const chartBuffer = await createChart();
const attachment = new AttachmentBuilder({
attachment: chartBuffer,
name: "bot-stats.png",
});

const embed = new EmbedBuilder() 
.setColor(config.color) 
.setFooter({ text: config.footer }) 
.setImage("attachment://bot-stats.png") 

await interaction.editReply({ 
embeds: [embed], 
files:[attachment], 
});```
wary coral
slow breach
wary coral

what type does toBuffer return? this seems to be an issue with the object returned by it

slow breach
wary coral

could you share your full code(file in question) and error(with stack trace)

slow breach
sharp ginkgoBOT

tag suggestion for @slow breach:
To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.

proud arrow
rigid crest

i can do a collector.on(
anotherCollector.on()) right? im trying to think the best way to handle a paginator collectors but still needs to use a purchase system colelctor as each page refreshes the collector

slow breach
wary coral

could you run npm ls

slow breach
wary coral could you run `npm ls`
├── @eslint/js@9.38.0
├── axios@1.12.2
├── canvas@3.2.0
├── chart.js@4.5.1
├── cheerio@1.1.2
├── compression@1.8.1
├── cookie-parser@1.4.7
├── discord.js@14.23.2
├── dotenv@17.2.3
├── eslint@9.38.0
├── express@5.1.0
├── globals@16.4.0
├── luxon@3.7.2
├── moment@2.30.1
├── ms@2.1.3
├── node-cron@4.2.1
├── pg@8.16.3
├── sharp@0.34.4
└── uuid@13.0.0```
proud arrow
proud arrow
slow breach
proud arrow

Or investigate why you are getting that error and fix it. But that wouldn't be related to d.js

rigid crest

it shouldnt effect the page changin which was my worry to start with

proud arrow

Fyi, two collectors csn run independently side by side. If you create it inside another collector, every time that collect event is fired, you'd be creating a duplicate listener

rigid crest

oh

sharp ginkgoBOT
tardy sable
rose tangle

show your code

tardy sable

just move it up

no etas, hopefully soon 🤷

*hopefully quicker than modals took

no?

rose tangle

they're talking about an html transcripts library?

tardy sable

looks like the context is cuz of a package that converts messages to html and containers are new so they dont display there

rose tangle

that's the context

or are you asking whether that library bugs with containers?

if so, according to that convo yeah

though it'd be better to ask the author instead

tardy sable

the discord html transcript package got support for component v2 but the dev isnt active so isnt properly released there

loud quartz

no eta

junior wraith

ok let me crash out again

tardy sable

why you want v15?

junior wraith
loud quartz

there is no new stuff

tardy sable
junior wraith
loud quartz

negative? i am simply replying

junior wraith

ok sir

loud quartz

all the stuff you would have in v15 is what you alreayd have in v14, bearing modal file uploads but that'll come to v14 too

junior wraith
sour tendon
loud quartz

store? you shouldn't do that. the messages are deleted and should stay that way

sour tendon

fair

wary coral

"bugging" in what way?

steel trail

Yes. That code is indeed buggy. And why is it written like you pay per character

loud quartz

one character is one byte. surely you're not running it on 8086

oblique shale

Am i doing something wrong the channel ids dont seem to match?

Copying the channel id using a discord client:

"Channel": 666323496741371914

Channel id from using the following code using a slashcommand:

const data = new SlashCommandBuilder()
    .setName('stickyadd')
    .setDescription('Add a sticky message to a channel')
    .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
    .addChannelOption((option) =>
        option
            .setName('channelx')
            .setDescription('Select a chat to send the message in.')
            .setRequired(true)
    ).addStringOption((option) =>
        option
            .setName('text')
            .setDescription('What text should be stickied?')
            .setRequired(true))

const stickyadd: SlashCommand = {
    category: "moderation",
    data,
    async execute(interaction) {
        const { options } = interaction;
        const channelToSend = options.getChannel("channelx")
        const text = options.getString("text")
        if (!channelToSend || !text) return interaction.reply("Something went wrong")
        const actualChannel = interaction.guild?.channels.cache.get(channelToSend.id)
        console.log(channelToSend?.id) // 666323496741371900
        console.log(actualChannel?.id) // 666323496741371900
    }
}

Returns the following:

"Channel": 666323496741371900
loud quartz

ids are not numbers

what your'e seeing is precisely why

oblique shale

ah

sharp ginkgoBOT
  • Discord ids follow the snowflake format: learn more
  • Discord ids must be represented as strings as they are larger than Number.MAX_SAFE_INTEGER, the largest integer that can be represented in JavaScript
- client.guilds.cache.get(123456789012345678)
+ client.guilds.cache.get("123456789012345678")
oblique shale

Thanks ❤️

nocturne rampart

Hi. Did dicord had any commands changes for public bots? About a month ago commands stopped working on my public bot. It still works in the pivate one though

topaz bluff

No not that I'm aware of

polar karma

define "stopped working"

nocturne rampart

no slash commands are created on the servers. old text parcing and responding works correctly

topaz bluff

Are you deplying commands per guild or globally?

nocturne rampart

globally

wary coral

are you getting any logs from you hosting provider that indicate an error?

zealous bison

does discord.js already support the new modals features?

nocturne rampart

I have code that I run on a release public bot and on a tester private one.
The difference as far as i see is only that flag.

Private bot has slash commands working and private is not. No logs errors.

crimson gale
zealous bison

so good, thank you

steel trail
nocturne rampart

according to the guide

await rest.put(Routes.applicationCommands(config.credentials.applicationId), { body: commands })
    .then(() => console.log('Successfully created all application commands.'))
    .catch(console.error);```
nocturne rampart
stable sun
lean sail

if i have a modal with a stringselectmenu, how can i get the selected value using discordjs if the user can only select one value since the method on interaction.fields returns an array of strings?

steel trail
proud arrow

This is just basic js

nocturne rampart
nocturne rampart

for two guilds out of four it takes a loooong time to recreate commands

but it works

past spear

Hi!
Can we change the status of a voice channel in the current version of djs?

snow onyx
past spear
nocturne rampart

tnx for the help, everybody

steel trail

You should only deploy once. And then leave it untouched until you actually change something about your commands

nocturne rampart
steel trail
nocturne rampart
nocturne rampart
novel mauve

if i use this to create a thread, can i later use thread.send() ?

const thread = await rest.post(Routes.threads(config.feeds.macrumors.forum), {
            body: {
                // ...
            }
        })

like will the djs methods work there too? id assume so but just wanted to check

stable sun
novel mauve

ah so i would need to also use rest to send the message inside the threa

stable sun

Yes

novel mauve

thank you 👍

steel trail
novel mauve

no client is available in the context

rose tangle

which is?

steel trail

Then djs won't be available anywhere you pass that thread to either

cold bay

Is there a way to somehow patch discord.js and like publish said patch?

*without cloning the entire repo and whatnot and having to publish some other package to do so

I just want to patch discord.js to send a user agent in the WS

steel trail

We won't support TOS violations

cold bay

I am not self botting

steel trail

I didn't say you are

cold bay

What else would be a TOS violation?

steel trail

What do you want a custom user agent in the ws for?

cold bay

trying to connect discord.js to not discord, and the server errors without the user agent

I've manually edited it and it works, I just want to be able to somehow make that easier for others

steel trail

This channel is for support of djs which - as the name suggests - is for usage with discord. So again, we won't help with that

brittle current
const [Userid] = interaction.fields.getUserSelectValues("king")
``` is this how it should be?

or this

const [Userid] = interaction.fields.getSelectedUsers("king");
sharp ginkgoBOT
wary coral

but it depens on what selectmenu you are using

brittle current

user select

wary coral

than the link method

brittle current

thx

geting undefined

if (interaction.isModalSubmit() && interaction.customId === "alert") {
        const [type] = interaction.fields.getStringSelectValues("typ");
        const Userid = interaction.fields.getSelectedUsers("king");
        const member = await interaction.guild.members.fetch(Userid);

        let typ;
        switch (type) {
          case "1":
            typ = "🚨 10 - 32 Zásahovky";
            break;
          case "2":
            typ = "🛒 10 - 68";
            break;
          case "3":
            typ = "🔫 Aktivní střelec";
            break;
          case "4":
            typ = "🥷 Organizovaný zločin";
            break;
          case "5":
            typ = "🏦 Hlavní banka";
            break;
          default:
            typ = "Nespecifikováno";
        }

        // === Logika alarmu ===
        const joinedUsers = [];
        const alarmText = `
🚨 **POHOTOVOST JEDNOTEK SWEB a SWAT!**  
Došlo k **narušení pořádku ve městě**.  
Všechny jednotky se musí **okamžitě dostavit do města** a zajistit oblast.

**Instrukce:**
- Vybavte se taktickou výstrojí.  
- Vyčkejte na rozkazy velitele zásahu.
**Velitel zásahu:** ${member.displayName}
        `;

in member

2025-10-21T20:24:28.326850298Z     at Object.execute (/home/node/events/interactionCreate.js:139:49)
2025-10-21T20:24:28.326857372Z     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)```
brittle current

they can choose only one user

wary coral

so then you need brackets like [type]

brittle current

did

wary coral

or on the next line do Userids[0] also it is a user onbject not ids

halcyon bison
  1. it's a Collection not an array
  2. I'd also suggest using getSelectedMembers instead and skip fetching them
brittle current

ohhh

wary coral

oh, that is right string select is an array all others are collections

brittle current
 const user = Userid[0]
``` this?

or im dumb

tardy sable

nope thats how you get first value in array

wary coral

I think this is right

const member = interaction.fields.getSelectedMembers("king").frist();
tardy sable

is .members a thing? i think its just getSelectedMembers(id).first() enough

wary coral

your right, misread the typing on the docs. fixed it

brittle current
wary coral I think this is right ```js const member = interaction.fields.getSelectedMembers...
2025-10-21T20:37:00.380461045Z     at Object.execute (/home/node/events/interactionCreate.js:49:77)
2025-10-21T20:37:00.380468579Z     at Client.<anonymous> (/home/node/handlers/eventHandler.js:11:54)
2025-10-21T20:37:00.380474981Z     at Client.emit (node:events:519:28)
2025-10-21T20:37:00.380480672Z     at InteractionCreateAction.handle (/home/node/node_modules/discord.js/src/client/actions/InteractionCreate.js:101:12)
2025-10-21T20:37:00.380486864Z     at module.exports [as INTERACTION_CREATE] (/home/node/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
2025-10-21T20:37:00.380493065Z     at WebSocketManager.handlePacket (/home/node/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31)
2025-10-21T20:37:00.380499017Z     at WebSocketManager.<anonymous> (/home/node/node_modules/discord.js/src/client/websocket/WebSocketManager.js:236:12)
2025-10-21T20:37:00.380505198Z     at WebSocketManager.emit (/home/node/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)
2025-10-21T20:37:00.380511290Z     at WebSocketShard.<anonymous> (/home/node/node_modules/@discordjs/ws/dist/index.js:1190:51)
2025-10-21T20:37:00.380517401Z     at WebSocketShard.emit (/home/node/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)```
tardy sable
tardy sable
brittle current
2025-10-21T20:38:34.684495186Z     at Object.execute (/home/node/events/interactionCreate.js:138:49)
2025-10-21T20:38:34.684498503Z     at Client.<anonymous> (/home/node/handlers/eventHandler.js:11:54)
2025-10-21T20:38:34.684501298Z     at Client.emit (node:events:519:28)
2025-10-21T20:38:34.684504013Z     at InteractionCreateAction.handle (/home/node/node_modules/discord.js/src/client/actions/InteractionCreate.js:101:12)
2025-10-21T20:38:34.684507229Z     at module.exports [as INTERACTION_CREATE] (/home/node/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
2025-10-21T20:38:34.684510786Z     at WebSocketManager.handlePacket (/home/node/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31)
2025-10-21T20:38:34.684513852Z     at WebSocketManager.<anonymous> (/home/node/node_modules/discord.js/src/client/websocket/WebSocketManager.js:236:12)
2025-10-21T20:38:34.684516797Z     at WebSocketManager.emit (/home/node/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)
2025-10-21T20:38:34.684519482Z     at WebSocketShard.<anonymous> (/home/node/node_modules/@discordjs/ws/dist/index.js:1190:51)
2025-10-21T20:38:34.684522298Z     at WebSocketShard.emit (/home/node/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)```
sharp ginkgoBOT

tag suggestion for @brittle current:

  • ReferenceError: "x" is not defined: learn more
  • TypeError: Cannot read properties of undefined/null (reading "x"): learn more
brittle current
if (interaction.isModalSubmit() && interaction.customId === "alert") {
        const [type] = interaction.fields.getStringSelectValues("typ");
        const member = interaction.fields.getSelectedMembers("king").first();

        let typ;
        switch (type) {
          case "1":
            typ = "🚨 10 - 32 Zásahovky";
            break;
          case "2":
            typ = "🛒 10 - 68";
            break;
          case "3":
            typ = "🔫 Aktivní střelec";
            break;
          case "4":
            typ = "🥷 Organizovaný zločin";
            break;
          case "5":
            typ = "🏦 Hlavní banka";
            break;
          default:
            typ = "Nespecifikováno";
        }

        // === Logika alarmu ===
        const joinedUsers = [];
        const alarmText = `
🚨 **POHOTOVOST JEDNOTEK SWEB a SWAT!**  
Došlo k **narušení pořádku ve městě**.  
Všechny jednotky se musí **okamžitě dostavit do města** a zajistit oblast.

**Instrukce:**
- Vybavte se taktickou výstrojí.  
- Vyčkejte na rozkazy velitele zásahu.
**Velitel zásahu:** ${member.displayName}
        `;
tardy sable

dont think the error is there cuz nothing is named users there

wary coral

where do you uses users? it is not in this code snippet

brittle current

nowhere

proud arrow
tardy sable

also i dont think putting your const inside an array is a thing? const [type] unless im wrong

proud arrow
brittle current
tardy sable
brittle current

works now

problem was in allowedMenitons

sharp ginkgoBOT

documentation suggestion for @tardy sable:
mdn Destructuring
The destructuring syntax is a JavaScript syntax that makes it possible to unpack values from arrays, or properties from objects, into distinct variables. It can be used in locations that receive data (such as the left-hand side of an assignment or anywhere that creates new identifier bindings).

silent plover

can someone give me the docs to this?

sharp ginkgoBOT

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

interface APITextDisplayComponent discord.js@14.23.2
A Text Display is a top-level content component that allows you to add text to your message formatted with markdown and mention users and roles. This is similar to the content field of a message, but allows you to add multiple text components, controlling the layout of your message.Text Displays are only available in messages.

silent plover

was searching for this

wintry laurel

is the /wordle activity bot's features exclusive to that bot (like discord partener feature), or is anyone able to do the same thing with their own bot?

what i mean by this is

  1. the authorization / however the bot keeps track of progress on the activity
  2. message updates and stuff

if so, is there any examples somewhere where i can see a example of how this is done? the docs for acitives have you just join a vc and launch it and theres no connection/auth or anything so im not sure what to do

rose tangle

djs doesn't support activities, at most only the entry point command

so there's no djs docs about that

wintry laurel

ah ok that makes sense, so if i wanted to fully utilize these features i would have to do the requests myself?

rose tangle

maybe there's another library, no idea

wintry laurel

alright, thanks. are people working on / is this a expected feature at least?

rose tangle

no, it's a very different workflow

it's the same thing like with oauth

as in, it's very different and not something the library would add

wintry laurel

yea ok i see what you mean now, it would all have to be done on server and stuff i presume

are there any examples that you know of which contain a bunch of code/exmaples of a activity i could check out?

i searched for some time for the wordle / mainstream ones but couldnt find any src

rose tangle

never checked activities ¯_(ツ)_/¯

ask in ddevs

wintry laurel

ok, thank you

zealous bison

i need some intent or anything to receive the guildAuditLogEntryCreate event?

i will combine guildAuditLogEntryCreate + messageDelete to make a feature, but i receive only messageDelete for now

sharp ginkgoBOT

tag suggestion for @zealous bison:

  • Websocket intents limit events and decrease memory usage: learn more
  • See what intents you need here
rose tangle

GUILD_AUDIT_LOG_ENTRY_CREATE is under GUILD_MODERATION

so that'd be the GuildModeration intent

zealous bison

it works now, thank you amgelo love

wintry laurel

how can i launch a activity where it has the initial message? i tried this but that doesnt work and jsut results in the message being unknown and interaction failing

proud arrow
wintry laurel

wait but how would i ensure i get the full 15 mins for the interaction to recive a update from the activity once its done

sharp ginkgoBOT

documentation suggestion for @wintry laurel:
mdn Window: setTimeout() method
The setTimeout() method of the Window interface sets a timer which executes a function or specified piece of code once the timer expires.

wintry laurel

oh right, idk why i thouyght i needed defer reply 😭

proud arrow

It better to not wait exactly 15 min, since that's the interaction token lifespan

Perhaps 12-13

wintry laurel

oh ok

still fulcrum

how do i change the gateway and api url?

stable sun
still fulcrum
stable sun

Specifically from the /gateway/bot endpoint

still fulcrum
stable sun

No

still fulcrum

can i not edit the discord.js package

stable sun

It’s open source

Feel free to fork it and install it

You can’t change the ws url non-invasively (using public methods, config, etc)

still fulcrum

ok, that's fine

do you know where it is, so that i can edit it

steel trail
still fulcrum

thanks

steel trail

Nothing to edit in there for it to work

still fulcrum
steel trail

No. Your REST endpoint just needs to respond with the gateway URL you want to use

thick nymph

Is it already possible to access a users server tag? In the docs there is some content for "guild tag"

sharp ginkgoBOT
patent dune

hey so im trying to make a command usable in user dms but i dont understand how

sharp ginkgoBOT

guide Contexts
By default, globally-deployed commands are also available for use in DMs. You can pass in InteractionContextType to the setContexts method of the builder to restrict the command to only be available in guilds or DMs. It doesn't make much sense for your ban command to be available in DMs, so you can add setContexts(InteractionContextType.Guild) to the builder so that it is only available in guilds: And that's all you need to know on slash command permissions and contexts!
read more

dense jackal

@patent dune ^

patent dune

uh

i have no clue what the builder is

dense jackal

this guide should everything you need, but as it says: your global commands should already work in user DMs

(if your app is a user-app)

patent dune

wait so my slash commands are being registered with the rest api like they are in the example, is that not how i should be doing them?

dense jackal
patent dune

its user installed

doesn't work in dms tho, unless its with the bot

dense jackal

set integration type to user
set context to private channel

.setContexts() can take an array as well if you want the command visible in both guilds, bot dm and other user dms

although I thought that was default if you didn’t specify anything

patent dune

alright sick, so i put a new SlashCommandBuilder into a const, what do i do with that const to get it registered

patent dune

nvm, figured it out, thanks!

tribal birch

Can I know message executor devices

tardy sable
tribal birch

But wasn’t it possible before to get user websocket devices

sharp ginkgoBOT
snow onyx

member.presence.clientStatus, keep in mind that presence may be null if not cached/fetched

snow onyx

I'm aware

steel bronze

does anyone know why member.presence is printing out null even with the Presence Intent enabled and GatewayIntentBits.GuildPresences being on?

steel trail

Because member is offline and you never force fetched their presence

steel bronze
steel trail

Show your client constructor

steel bronze

This one I guess? or

steel trail

You sweep all users...

So why do you expect your member (which does contain a user) to be completely cached with presence

steel bronze

Ahh well well that answers the question thanks lol

jagged rock

is addlabel depracted

in modals

topaz bluff

Nothing of modals is deprecated

Nevermind I didn't see that action rows were removed as a "modal component" in the docs

jagged rock

it says it is

its all good now

polar karma

if it's marked as deprecated, it would tell you what to use instead

topaz bluff
snow onyx

yes because now there is a label component and a LabelBuilder

if you hover over setLabel then it will tell you that as well

jagged rock
topaz bluff

You put them in between the modal and the interactive component

sharp ginkgoBOT
golden laurel
golden laurel
toxic moat

I'm trying to upload the banner of my bot it's a gif but it shows this

wary coral

your gif has transparence not really a djs issue

tribal birch

do I need GuildPresences intent for member.presence

polar karma

yes, the api docs list which intents enable which events/data

brittle current

need help it falls to if (!difficulty || !partner)

 if (interaction.isModalSubmit() && interaction.customId === "heist") {
    const difficulty = interaction.fields.getStringSelectMenuValue
      ? interaction.fields.getStringSelectMenuValue("difficulty").first()
      : null; // fallback, pokud by nefungovalo
    const partner = interaction.fields.getSelectedMembers
      ? interaction.fields.getSelectedMembers("partner").first()
      : null;

    if (!difficulty || !partner) {
      return interaction.reply({ content: "❌ Musíš vybrat obtížnost a partnera.", flags: 64 });
    }

oh im dumb

i see it now

wary coral

getStringSelectValues not getStringSelectMenuValue
also it returns a string array not collection

sharp ginkgoBOT
brittle current

yea i saw it thx

thin reef

what are the cons of passing Partials to the client?

rose tangle

they only do what they're designed for, allow uncached objects to be emitted

whether that's a con depends on your case

thin reef

uh ok thx

topaz bluff
versed current

<@&839912195994812420>

lapis imp

Hello! Does anyone know how to disable some commands in guilds where the bot isn't here?

unique shoal

Cool story bro

steel trail
feral thunder

Supplying only repliedUser to allowedMentions always results in disabling all other mention types, is this intended? It is quite annoying passing the array of mentions to parse each time when only the replied user mention should get disabled. I'd expect it sets unspecified properties to undefined rather than an empty array

rose tangle

djs doesn't set empty arrays as default

maybe you have it like that on your client constructor?

wintry laurel

is there a event for when a client closes my bots activity? or a way to know when the activity launched by .launchActivity() ends?

feral thunder
loud quartz
silent mirage

Hey with the new discord age restrictions is it possible to get the users are verified over 18

topaz bluff

that information is not available to the API

silent mirage

Ahh ok got it

solid mountain

I'm struggling to understand what I'm doing wrong here. I used modal.builders to construct the modal itself.

 const modal = new ModalBuilder()
      .setTitle('Report Message')
      .setCustomId(`message.report-${interaction.targetId}`)
      .addTextDisplayComponents(
        new TextDisplayBuilder()
          .setContent(`**${quotedAuthor}:** ${quotedContent}`)
      )
      .addLabelComponents(
        new LabelBuilder()
          .setLabel(`What's wrong with this content?`)
          .setStringSelectMenuComponent(
            new StringSelectMenuBuilder()
              .setCustomId('b24a4209fe9541b2862d96f64375ddf4')
              .addOptions(
                new StringSelectMenuOptionBuilder()
                  .setLabel('Spam')
                  .setValue('76b41a846d5d488ba60fb6e05d6d79ed'),
                new StringSelectMenuOptionBuilder()
                  .setLabel('Harassment ')
                  .setValue('2361676c89794225af53e0327fd7bba0'),
                new StringSelectMenuOptionBuilder()
                  .setLabel('Hate Speech')
                  .setValue('b46097b2a90a40c584ebb59496ef7c2d'),
                new StringSelectMenuOptionBuilder()
                  .setLabel('Adult Content')
                  .setValue('cd48da04184c473b9629d633377d6a97'),
                new StringSelectMenuOptionBuilder()
                  .setLabel('Something Else')
                  .setValue('423d1ce95b3e4a1580abc71fc583473e')
              )
          )
      )
      .addLabelComponents(
        new LabelBuilder()
          .setLabel('Additional Information (optional)')
          .setTextInputComponent(
            new TextInputBuilder()
              .setCustomId('ec3b4bfb75de40d6a5862bf99f8ea95e')
              .setStyle(Discord.TextInputStyle.Paragraph)
              .setMaxLength(3000)
              .setRequired(false)
          )
      )
      .addTextDisplayComponents(
        new TextDisplayBuilder()
          .setContent(
            "By submitting this report, I agree that it's in good faith and true to the best of my knowledge."
          )
      )
      .addLabelComponents(
        new LabelBuilder()
          .setLabel('Acknowledgement')
          .setStringSelectMenuComponent(
            new StringSelectMenuBuilder()
              .setCustomId('a59240d2b2c1453c8e1081b54e6c6917')
              .addOptions(
                new StringSelectMenuOptionBuilder()
                  .setLabel('I agree')
                  .setValue('8030a917752744b3b83bca271992b6c6')
                  .setDefault(true)
              )
          )
      );

    return interaction.showModal(modal);
  }

D.js v14.19.3

TypeError: (intermediate value).setTitle(...).setCustomId(...).addTextDisplayComponents is not a function
topaz bluff

update your djs

label builder was added in v14.23...youre on v14.19

solid mountain

Thank you so much

Strangely i'm getting the same exact error having upgraded to 14.23.2, but i'll keep troubleshooting

solid mountain

oh lord i see lol

cedar drift

Hi, does this still work?

bleak owl
cedar drift

I understand this, but it will not break anything if it suddenly stops working, just cosmetics. I've seen other bots like cloudy music bot able to use this and would like to test it as well.

bleak owl

we do not support undocumented features

stable sun

It’s prob faster if you test it out yourself than wait for a response from him tbh

stable sun
solid mountain

I just wish the error wasn't so vague

stable sun

I mean, it’s pretty straightforward

Ur sure the error points to the first addTextDisplayComponents?

stable sun
solid mountain

Yes,

 const modal = new Discord.ModalBuilder()
      .setTitle('Report Message')
      .setCustomId(`message.report-${interaction.targetId}`)
      .addTextDisplayComponents(  //errors here
        new Discord.TextDisplayBuilder()
          .setContent(`**${quotedAuthor}:** ${quotedContent}`)
      )
const Discord = require('discord.js');

if this wasn't clear

lavish oar

why doesnt v14.23.2 have the new component type enums? just getting back into js not up to speed with 14.14+

unique shoal

Which ones?

Im not aware of any its missing

stable sun
lavish oar
normal flare

what could be the reason of seeing duplicate commands?

sharp ginkgoBOT

tag suggestion for @normal flare:
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: [] })
normal flare

that was fast thanks 👍

does it make sense to have global commands when I intend to use the bot just in 1 server?

topaz bluff

doesnt really matter...but it can be nice to prevent commands from being used in dms

normal flare

or is the global commands meant for bots that are used in multiple servers?

stable sun

Yea

You can use either or both (ideally not for the same commands)

solid mountain

Chewinky, serious question. Could this be because my node v is out of date?

solid mountain

Ok

topaz bluff
stable sun

Missing methods that should be there is usually caused by outdated package version installed, not restarting bot, or editing files in node_modules

Did you try the test file yet?

normal flare

yeah I had this

if (guildId) {
  await rest.put(Routes.applicationGuildCommands(config.discord.clientId, guildId), {
    body: commandsData,
  });
} else {
  await rest.put(Routes.applicationCommands(config.discord.clientId), {
    body: commandsData,
  });
}```
`guildId` is coming from `env` which I added later, but now is required anyways
solid mountain

Both are on v14.23.2

stable sun
solid mountain
stable sun

Check the builders version on the VPS

solid mountain
rose tangle

have you tried nuking node_modules and reinstalling just in case

solid mountain

I will certainly try that now

safe gazelle

Which video did y'all watch to learn how to program a bot

stable sun

None tbh

topaz bluff

none...i used the djs guide

stable sun

I actually read an idiots guide one before I started reading the official one

That was back in v11.3 era tho

solid mountain

Thanks yall for the help!

stable sun
solid mountain

We're using PM2, i've pm2 restarted and pm2 stop/started several times now with no luck

frosty dagger

What will be best to use for making a Queue system . when a user click a button he being added to that button queue . BullMQ or any better ?

normal flare

queue for what?

cedar drift
solid mountain
cedar drift
solid mountain

It did!

cedar drift

Perfect!

gleaming badger

is it possible to make it so that you can only pick the options given to you by autoComplete and not just submit random things

clear garnet

No, the closest behavior to that which I can think of would be to validate the received option after the user sends the command to ensure it was one of the valid autocomplete options

gleaming badger

aw okay, thanks

steel trail

Or use choices, if those values you want to autocomplete are static

gleaming badger
bitter pivot

I've missed a bit of a trick here. What's the new deal with .setLabel not being a thing anymore on TextInputBuilder? Something about using a LabelBuilder. Do I need to create a modal, attach an action row that has a LabelBuilder that has some kind of String Input Builder?

sharp ginkgoBOT

class LabelBuilder discord.js@14.23.2
A builder that creates API-compatible JSON data for labels.

snow onyx

yes, you add a component to that label using one of the various setXComponent function

bitter pivot

So does that mean role/string select menus are now supported in modals too?

snow onyx

yes

steel trail

You replace the actionrow with a label. Not use both

bitter pivot

oh damnnn that's nice - thanks!

hasty comet

Guy's can we set the secondary button inside the embed msg?

rigid crest

If you mean the cancel&submit? Then you can’t change them

Oh I read wrong ignore me

spark ledge
hasty comet

i mean i want like this

i want the buttons to be under the msg

the buttons ( Support Server & Invite Rythm )

snow onyx

then you need to use components v2

aka a container

sharp ginkgoBOT

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

arctic oyster

Just a quick question, What does the "required" boolean do when getting an Interaciton Option?
Example here; interaction.options.getString("something", true); (the true here)

tardy sable
steel trail

Yup

arctic oyster

TakingNote Interesting to know

radiant epoch

When that could be useful?

steel trail

To make sure your code doesn't accidentally try to respond to another command than it's intended to

arctic oyster

Or something in my use case, a required input before another required input depending on the one before it (auto completions)

normal flare
snow onyx

v2 components work in both cases, if the flag is provided.

normal flare

not when deferring interaction responses.
what do we mean here?

// won't work
await interaction.deferReply({flags: MessageFlags.V2}) (the actual flag)

// will work?
await interaction.deferReply()
...
await interaction.editReply({flags: MessageFlags.v2})
silent mirage

Question i think i can answer for my self if i send a v2 i can not edit it to a embed

red coral

No

silent mirage

It will have to be another v2

silent mirage

Thanks for answering

steel trail
silent mirage

I kinda of figured as much

normal flare
swift jewel

I cant seem to find it but anyone know the character limit for custom activity type state ?

wary coral
red coral

Does a bot need manage messages to delete its own message?

snow onyx

no that would be weird

wary coral
normal flare

can we have a markdown table in an embed?
here I would like to display the browsers in a table if that's possible

wary coral
normal flare

I see, thanks

tardy sable

how does djs handle message channel send ratelimits, does it just add a timeout for next message so theres no ratelimit?

rigid crest

From my experience you can spam messages then the bot gets rate limited after a few minutes (one of my commands kept replying to its self a few years ago) it got so bad that discord reset the token at one point

balmy kraken

when i want to edit a response to a command interaction, must i call editReply() on the interaction or can i also edit the message by edit() as retrieved by response.resource.message?

steel trail
steel trail
swift jewel
steel trail

Suggestion for what?

This server, the library discord.js, the discord API or discord in general?

grave pond
sharp ginkgoBOT

We are not Discord, just some nerds who develop Discord bots!

grave pond
steel trail
tardy sable
polar karma

it sets a timeout based on the response from the api, then it tries the request again after the timeout is done

that's the default behavior at least, you can set different behavior in the client options

main axle

how to add those lines? those arent emoji

bleak owl

those are separators

main axle
bleak owl

the lines you see

main axle

how to write them?

sharp ginkgoBOT

guide Separator
A Separator is a layout component that adds vertical padding and optional visual division between components. You can select the amount of padding used for the Separator component (small or large) as well as whether a visual divider should be displayed (defaults to true). You can use the SeparatorBuilder class to easily create a Separator component. When a Separator component is used without any non-Separator components in the message payload, the message will not have any visible content.
read more

main axle

wow since when? you can add button and menu in embeds

bleak owl

containers, not embeds

topaz bluff

No

bleak owl

nope thats a container

main axle
bleak owl

no

its a container

main axle

in setAccentColor can I pass "Green" like embeds or no?

bleak owl

yes

sharp ginkgoBOT
bleak owl

well not really a string color

but you can set a color like embeds

sharp ginkgoBOT
tardy sable
sharp ginkgoBOT
main axle

ok tnx

spiral cargo

is it possible to update a voice channel status without using rest, yet?

bleak owl

its possible to set it, but it's not documented

main axle

containers are available in ^14.22.1 ?

spiral cargo

any ideas on how i would do that?

bleak owl

since its not documented, we do not support it

spiral cargo

alr

wary coral
main axle

tnx

bleak owl

but you should be using the most up to date version

main axle

Whats this error for?

ExpectedConstraintError > s.array(T).lengthGreaterThanOrEqual()
  Invalid Array length

  Expected: expected.length >= 1

  Received:
  | []

    at Object.run (/root/GardenBoi/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1045:79)
    at /root/GardenBoi/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:67
    at Array.reduce (<anonymous>)
    at _ArrayValidator.parse (/root/GardenBoi/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:29)
    at validateComponentArray (/root/GardenBoi/node_modules/@discordjs/builders/dist/index.js:1767:233)
    at SectionBuilder.toJSON (/root/GardenBoi/node_modules/@discordjs/builders/dist/index.js:2400:5)
    at /root/GardenBoi/node_modules/@discordjs/builders/dist/index.js:2105:64
    at Array.map (<anonymous>)
    at ContainerBuilder.toJSON (/root/GardenBoi/node_modules/@discordjs/builders/dist/index.js:2105:35)
    at /root/GardenBoi/node_modules/discord.js/src/structures/MessagePayload.js:151:46

I tried to add button to container and I got this error

stable sun
main axle
container.addSectionComponents((section) =>
    section.setButtonAccessory((button) =>
        button.setURL("https://www.fortnite.com/@sypherpk?lang=en-US").setLabel("PLAY NOW").setStyle(Discord.ButtonStyle.Link)
    )
);

stable sun

That’s an accessory, not a component

main axle

so I have to pass a text with it ?

sharp ginkgoBOT
stable sun

Yes

Why use a section if ur not gonna have text above it? That’s just a row

main axle

oh so I should use .addActionRowComponents((actionRow) =>... instead
I am new with containers srry XD

topaz bluff

If you want text only, add a TextDisplay to the container

If you want an accessory (a button or image on the right side), use a section

If you want several buttons, use an action row

stable sun

Yea

sharp ginkgoBOT

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

topaz bluff

You can see ALL the components here and how to use them

main axle

if you mention a role in container it will mention users in that role or it works like embed description?

clear garnet

It will mention them. Same behavior as message content

main axle

okay tnx

spiral cargo

im using something like:

container.addSectionComponents((section) =>
        section
          .addTextDisplayComponents(
            (td) => td.setContent([
              `# ${userData.global_name || userData.username} (${userData.discriminator !== '0' ? `\`${userData.username}#${userData.discriminator}\`` : `\`@${userData.username}\``})`
            ].join('\n'))
          )
          .setButtonAccessory((button) =>
            button.setStyle(ButtonStyle.Link).setEmoji(`:sparkle:`).setURL(`https://almightynan.cc`),
          ),
      );

and the .setEmoji() expects an object, but i'm not sure how i'm supposed to use that

this was the error:

ValidationError > s.object(T)
  Expected the value to be an object, but received string instead

  Received:
  | ':sparkle:'

    at _ObjectValidator.handle (/home/almightynan/Downloads/miku-rewrite/node_modules/@sapphire/shapeshift/src/validators/ObjectValidator.ts:147:102)
    at _ObjectValidator.parse (/home/almightynan/Downloads/miku-rewrite/node_modules/@sapphire/shapeshift/src/validators/BaseValidator.ts:126:2)
    at ButtonBuilder.setEmoji (/home/almightynan/Downloads/miku-rewrite/node_modules/@discordjs/builders/src/components/button/Button.ts:110:98)
    at <anonymous> (/home/almightynan/Downloads/miku-rewrite/src/commands/Profile/Profile.ts:351:47)
    at resolveBuilder (/home/almightynan/Downloads/miku-rewrite/node_modules/@discordjs/builders/src/components/Components.ts:186:10)
    at SectionBuilder.setButtonAccessory (/home/almightynan/Downloads/miku-rewrite/node_modules/@discordjs/builders/src/components/v2/Section.ts:80:59)
    at <anonymous> (/home/almightynan/Downloads/miku-rewrite/src/commands/Profile/Profile.ts:350:12)
    at resolveBuilder (/home/almightynan/Downloads/miku-rewrite/node_modules/@discordjs/builders/src/components/Components.ts:186:10)
    at <anonymous> (/home/almightynan/Downloads/miku-rewrite/node_modules/@discordjs/builders/src/components/v2/Container.ts:164:73)
    at Array.map (<anonymous>)
wary coral
spiral cargo

im using a discord emoji, not unicode

im using a different sparkle emoji

tardy sable

or object { name, id }

spiral cargo

thats what i was looking for, thank you both of you crySparkle

wary coral

np

versed current

hey guys, the status of my bot always resets after some time. Any idea why? I set it once in the clientReady event but it clears itself after some time (sometimes hours, sometimes days)

polar karma

your bot reconnects but the clientReady event doesn't emit on reconnect

topaz bluff

if you don't plan on changing it, you can set it on your client constructor

versed current

oh wow

polar karma

you should set the presence data in your ClientOptions, and it wil- damn you samtino

sharp ginkgoBOT
versed current

oh, neat. didnn't know I could do that. thx

versed current

OMEGAlul

radiant skiff

Hello!
I'm trying to find where this warning is triggered, but I've changed all ready events to clientReady on my code, except for shard events :

(node:18748) DeprecationWarning: The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
snow onyx

"(Use node --trace-deprecation ... to show where the warning was created)"

radiant skiff
gilded tendon

Is there a specific event to fetch context menu action commands?
It feels like my bot is not catching any command I run for it and it throws a "IntBot didn’t respond in time" / "The application did not respond"

clear garnet

The same one as with slash commands or any other interaction, interactionCreate

tepid crag

Hey, is it possible just to send a Container Component v2 with a separator?

const separatorContainer = new ContainerBuilder()
                    .addSeparatorComponents((separator) => separator.setSpacing(SeparatorSpacingSize.Large));```cuz this doesnt work :/
lyric bobcat

Is it not possible that my discord js bot stops an entitlement? I use my bot to offer various benefits on my server, but if they leave the server I want to stop the entitlement, because they cannot use the benefits.

modern void

how we can turn this section on in our bot?
no popular slash commands section in our bot page inside discord

gilded tendon
sharp ginkgoBOT
wary coral
lyric bobcat
modern void
topaz bluff

it's not a question of time, it's a question of usage

tepid crag
lyric bobcat
gilded tendon
topaz bluff

just console.log(interaction) and see if that is logging at all

gilded tendon
topaz bluff

is your event handler in a different file than your main index.js?

wary coral
gilded tendon
clear garnet

Sounds like you had an interactions endpoint set

topaz bluff

did you possibly have a space or something here?

wary coral
gilded tendon
topaz bluff

ya im curious

steel trail
tepid crag
tepid crag
wary coral

Why do you want a separator in a container with no content

steel trail
gilded tendon

How do I make my bot be usable in private-like environment? like DMs n such for context menu actions?

steel trail

Set integration type to include UserInstall and contexts to include PrivateChannel

tepid crag
steel trail

On the commands you want to be usable there

gilded tendon
steel trail
steel trail
gilded tendon
sharp ginkgoBOT
wary coral
tepid crag

separator is a top level component and can be added right to messages

steel trail
tepid crag

Yea, remove the container around the separator, put both containers and the separator between the containers on the same message

tepid crag

thanks

molten lake

How can I put the buttons inside the container / embed
Like discord add this inside

clear garnet

Refer to the bottom part of that container

sharp ginkgoBOT

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

gilded tendon

Is there a way for me to fetch a users nickname in a guild after I use a context action on them?
The bot is not in the same server and I want to fetch their nickname in the same server.

Interaction.guild is null.
same goes for Interaction.channel.

sharp ginkgoBOT
jagged rock

how to add buttons insdie container

topaz bluff
wintry laurel

anyone know of a way to tell when a user closes my bots activity? i want to have it send / update a message but i cant seem to find a way to detect if the activity is closed. i have tried the following things

  1. adding event listener for beforeunload
  • does not work
  1. subscribing to ACTIVITY_INSTANCE_PARTICIPANTS_UPDATE via the discord sdk
  • works presumably (event is emmitted when joining), but when leaving my code either has no time to run or gets terminated somehow (console logs of discord show that the event is sent)

anyone have any ideas? thanks

bleak owl

would be better to ask that in ddevs

wintry laurel

i did

figured i would ask here as well get more chance of someone answering

bleak owl

yeah, but we only handle discord.js, sorry

white escarp

The nickname of this member, if they have one

rose tangle

ah nvm, one of those spam bots

inner kernel

why Presense#clientStatus have desktop, mobile, web all seperate?
i thought discord status are shared between all devices

clear garnet

They're not in the API. You can be idle on desktop and online on mobile

inner kernel
clear garnet

It only makes the desktop presence idle, other platform presence statuses can "overwrite" it in the client GUI

inner kernel
clear garnet

Not exactly sure what you're trying to ask, but I'm going to steer clear of it since modded clients are against Discord's ToS

inner kernel
clear garnet

As far as I have seen, yes

inner kernel
rose tangle

tbf those are all api questions

we can only answer with as far as we've seen, we don't know how the api actually works

rose tangle

other than that, not much else, you might have better luck for better answers about specific api behavior in the ddevs server #useful-servers

feral spruce
radiant skiff
steel trail
snow onyx
steel trail
gilded tendon
steel trail

If the member is not in the guild they couldn't run the interaction in the first place

flint pier

Why i cant use messageUpdate?

bot will read edited message

steel trail
flint pier
steel trail

How do you load that event handler?

flint pier
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));

for (const file of eventFiles) {
    const filePath = path.join(eventsPath, file);
    const event = require(filePath);
    if (event.once) {
        client.once(event.name, (...args) => event.execute(...args, client));
    } else {
        client.on(event.name, (...args) => event.execute(...args, client));
    }
}```messageCreate and interactionCreate... etc all run but that one doesn't
steel trail

So it should be name: not data: in your event file

flint pier

Oh shit… thanks

flint pier
steel trail
flint pier newMessage console.log out 2 times?

What is that question supposed to tell me? The code you sent won't ever do that, so you probably changed your code and are you asking if that should happen while it doesn't. Or if it shouldn't but does. Or if you should write your code to do so or ...?

main axle

who is the message author of these type of messages that sent when someone joined to Server? and how can I check a message is in this type or not?

wary coral
sharp ginkgoBOT
main axle

ok tnx a lot

and also how can I add image and thumbnail in container?
setThumbnailAccessory and MediaGalleryBuilder??

wary coral
sharp ginkgoBOT

guide Section
Sections represent text (one to three Text Display components) with an accessory. The accessory can either be an image (thumbnail) or button. If you do not want to send an accessory, use a Text Display component instead. You can use the SectionBuilder class to easily create a Section component:...
read more

wary coral

What about it?

main axle

how can I use an image in container? not as a thumbnail as a big image like .setImage in embeds how can I do it?

wary coral

Oh, you need to use a media gallery for that

main axle

so I should create a media gallery using MediaGalleryBuilder() ?

wary coral

You can do it however you want but I would recommend using the builder

main axle

well after I create a mediagallery using the builder how can I put it in my container?

sharp ginkgoBOT
main axle

I mean media gallery is a component for it self tnx

container.addMediaGalleryComponents((mediaGallery) => mediaGallery.setComponents(mediaGallery)) 

is this correct?

wary coral

No,

sharp ginkgoBOT

guide Media Gallery
A Media Gallery is a display component that can display a grid of up to 10 media attachments. Each media item can have an optional alt text (description) and can be marked as spoiler. You can use the MediaGalleryBuilder and MediaGalleryItemBuilder classes to easily create a Media Gallery component and its items:...
read more

main axle

I have my mediaGallery

const mediaGallery = new Discord.MediaGalleryBuilder().addItems((mediaGalleryItem) => mediaGalleryItem.setURL(url));

now I want to put it in my container

container.addMediaGalleryComponents((mediaGallery) => mediaGallery.setComponents(mediaGallery)) 

oh I should use .addMediaGalleries instead of .setComponents got it

wary coral

Use addMediaGalleryComponents
Listen, I think you should read the full display components guide.

All the answers you want to the basic use of components V2 is in there

main axle

okay tnx

wary coral
dry star

hey i have a quick question can i use a discord invite url to check how many members are in the server?

sharp ginkgoBOT

documentation suggestion for @dry star:
class InviteGuild discord.js@14.23.2
Represents a guild received from an invite, includes welcome screen data if available.

wary coral

Here's what information is available from an invite

dry star

alr ty

scarlet nacelle

I doing everything according to the documentation... i want to use the select menu function in the modal but the problem is that it throws me an
code: 50035,
status: 400,
method: 'POST',
I dont know whats wrong anymore

steel trail

Show the full error

scarlet nacelle
    files: undefined,
    json: {
      type: 9,
      data: {
        title: 'title title title',
        custom_id: 'ticketModal',
        components: [
          { type: 1, components: [Array] },
          { type: 1, components: [Array] },
          { type: 1, components: [Array] },
          { type: 1, components: [Array] },
          { type: 1, components: [Array] }
        ]
      }
    }
  },
  rawError: {
    message: 'Invalid Form Body',
    code: 50035,
    errors: {
      data: {
        components: {
          '0': { components: [Object] },
          '1': { components: [Object] },
          '2': { components: [Object] }
        }
      }
    }
  },
  code: 50035,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/interactions/1431277083786608741/aW50ZXJhY3Rpb246MTQzMTI3NzA4Mzc4NjYwODc0MTozemVZd3Z3a05hSFdWbEpQQnFlbGxRc0JzYjRQV2x2VFJUMUVWWllDM1RWVGd6RjNXbkFrVW1IcXFtNGg3ZWlNVVhJWkVKNEtqVmw0WTh2eDFFdkhMYUJyQVlQQUR4TTVzZVdSNktWc3laVzRGeHhhT2RmY2JvaVExMzRZeU1aMg/callback?with_response=false'                                                                                                                                               
}```


i know theres something wrong with the body here but even when it works once i still cant read the data from that select menu in the modal 🙁
steel trail

And the code causing that?

tardy sable

@scarlet nacelle ^

wary coral
slate tartan

I wanna ask if I can update the continuer in the same message like
interaction.update

And also if I can change the continuer to embed in the same message ( I believe it's impossible)

tardy sable

if you mean componentv2, previous message must have been a componentv2 in order to edit it. cant change an embed to container

vice versa

slate tartan
wary coral
tardy sable
lofty topaz

File upload cv2
Guide ?

wary coral
lofty topaz
tardy sable

thats for modals

wary coral
lofty topaz
tardy sable

thanks for clarifying

lofty topaz

I want example code.

slate tartan
topaz bluff
slate tartan

The same is embed?
Interaction.update?

steel trail

you edit the message to include components and the flag, instead of embeds

tardy sable
lofty topaz
steel trail

cv2 and modals are two different things

topaz bluff
lofty topaz
wary coral

what do you not understand?

tardy sable

what am i doing wrong: FileUploadBuilder is not a constructor

modal.addLabelComponents(
  new LabelBuilder()
  .setLabel("File")
  .setFileUploadComponent(
       new FileUploadBuilder()
         .setCustomId("file")
   )
wary coral

are your getting an error?

tardy sable

yes FileUploadBuilder is not a constructor

wary coral

update your djs

tardy sable

oh yh bruh forgot that

lofty topaz

And add this for it?

tardy sable

? whats a normal modal

lofty topaz
topaz bluff

That was not the issue...

tardy sable

thats not the error. i already got my answer

south sigil
south sigil
topaz bluff

v14.23 added that

File upload was just released separate from select menus for the API

south sigil

yes

tardy sable

you cant set file size limit directly in the fileuploadbuilder right?

wary coral

correct it is not an option that Discord gives

steel trail

The max file size a user can upload is based on the user's upload limit in that channel.

lofty topaz
const {
  Client,
  GatewayIntentBits,
  ActionRowBuilder,
  ButtonBuilder,
  ButtonStyle,
  InteractionType,
  ModalBuilder,
  LabelBuilder,
  FileUploadBuilder
} = require("discord.js");



const client = new Client({
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages],
});

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

client.on("messageCreate", async (message) => {
 
  if (message.content === "!uploadtest") {
    const uploadButton = new ButtonBuilder()
      .setCustomId("open_upload_modal")
      .setLabel("📤 رفع ملف")
      .setStyle(ButtonStyle.Primary);

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

    await message.reply({
      content: "اضغط الزر لفتح نافذة رفع الملف 👇",
      components: [row],
    });
  }
});

client.on("interactionCreate", async (interaction) => {
 
  if (interaction.isButton() && interaction.customId === "open_upload_modal") {
    const modal = new ModalBuilder()
      .setCustomId("upload_modal")
      .setTitle("📁 Upload your file");

    
    modal.addLabelComponents(
      new LabelBuilder()
        .setLabel("Upload a file")
        .setFileUploadComponent(
          new FileUploadBuilder()
            .setCustomId("file")
        )
    );

    await interaction.showModal(modal);
  }

 
  if (interaction.type === InteractionType.ModalSubmit && interaction.customId === "upload_modal") {
    const uploaded = interaction.files;

    if (!uploaded || uploaded.size === 0) {
      return interaction.reply({ content: "❌ لم يتم رفع أي ملف!", ephemeral: true });
    }

    const file = uploaded.first();

    await interaction.reply({
      content: `✅ تم رفع الملف: **${file.name}** (${file.size} bytes)`,
    });
  }
});

client.login("");
north dagger

bro remove your token @lofty topaz

lofty topaz
steel trail

and reset it

radiant skiff
lofty topaz

i will reset it now sorry

lofty topaz
topaz bluff
wary coral
steel trail
lofty topaz
topaz bluff Are you getting an error?

yes
TypeError: FileUploadBuilder is not a constructor
at Client.<anonymous> (C:\Users\pc\OneDrive\Desktop\file uploader\index.js:52:11)
at Client.emit (node:events:524:28)
at InteractionCreateAction.handle (C:\Users\pc\OneDrive\Desktop\node_modules\discord.js\src\client\actions\InteractionCreate.js:101:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\pc\OneDrive\Desktop\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\pc\OneDrive\Desktop\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketManager.<anonymous> (C:\Users\pc\OneDrive\Desktop\node_modules\discord.js\src\client\websocket\WebSocketManager.js:236:12)
at WebSocketManager.emit (C:\Users\pc\OneDrive\Desktop\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:2504:31)
at WebSocketShard.<anonymous> (C:\Users\pc\OneDrive\Desktop\node_modules@discordjs\ws\dist\index.js:1190:51)
at WebSocketShard.emit (C:\Users\pc\OneDrive\Desktop\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:2504:31)
at WebSocketShard.onMessage (C:\Users\pc\OneDrive\Desktop\node_modules@discordjs\ws\dist\index.js:1007:14)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:407:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)