#djs-help-v14

78874 messages · Page 17 of 79

snow onyx

fetching all members is a single request

clear garnet

What...? You aren't going to be making 300 separate requests, you make a single one

leaden shuttle

ah okay. that makes sense. no need to be rude- i didn't know 🙂

sharp ginkgoBOT
leaden shuttle

yeah just assumed that function made separate requests for each member

loud quartz

it can be used this way

but if you don't pass anything to it, it fetches all members via a different way

leaden shuttle

(await client.guilds.fetch(guilds.main)).members.fetch(); this fixed my problem, thank you

loud quartz

there's no need to fetch a guild

leaden shuttle

oh are they cached on ready?

loud quartz

you have the Guilds intent which means the guild is already in cache

leaden shuttle

thanks

long ledge

im getting DNS_PROBE_FINISHED_NXDOMAIN when trying to access

wary coral
long ledge

weird

unique shoal

Most likely a DNS issue on your side

real notch
unique shoal

No

real notch
loud quartz

yes, you can put up to 5 action rows into a modal

each one containing single text input

real notch
loud quartz

whatever you're doing, the limit is the limit

real notch
loud quartz

you cannot chain modals

but you absolutely can have more than one button on a message, each triggering a different modal

real notch
loud quartz

if you wouldn't be able to tell when the user pressed the first button... how would you ever show a modal from it

you can tell when someone presses the button - you show the modal

you can tell when someoen submits the modal

what you cannot tell is when someone cancels the modal, or clicks out without submitting

real notch

Oh I see so it's not possible,
gotta use timeout in dms

loud quartz

mmmm

what is not possible

loud quartz
real notch

well anyways thanks

loud quartz

as i already said

real notch

yeah I got it what you are trying to say.

loud quartz

modal is not the same as button

dapper cave
const originalActionRow = interaction.message.components[0];
const originalSelectMenu = originalActionRow.components[0];
Property 'components' does not exist on type 'TopLevelComponent'.
  Property 'components' does not exist on type 'FileComponent'.```
erm why is it using components v2 type or whatever
const originalActionRow = interaction.message
        .components[0] as unknown as ActionRowBuilder<StringSelectMenuBuilder>;
const originalSelectMenu = originalActionRow.components[0];```ig this works but its still weird it type errors there
loud quartz

this is not a channel for sequelize support (message deleted)

dapper cave
loud quartz
dapper cave

worked fine before without needing as unknown as yada yada

loud quartz

because before there were no components v2

you're also casting as wrong type

loud quartz

you're casting as builders instead of received structures

dapper cave

oh yeah ur right

loud quartz

check the type of components[0]

dapper cave

toplevelcomponent[]

loud quartz

is it an action row, or is it <any other component v2>

the property

dapper cave

yaeh its an action row

loud quartz

then use that type check

instead of casting

dapper cave
const originalActionRow = interaction.message
        .components[0] as unknown as ActionRow<StringSelectMenuComponent>;```
silly me
loud quartz

drop the unknown

maybe then you'll know if you're casting wrongly

dapper cave

oh that works

maiden basalt

anyone experiencing TimeoutNegativeWarning?

full log :

(node:7384) TimeoutNegativeWarning: -17 is a negative number.
Timeout duration was set to 1.
    at new Timeout (node:internal/timers:195:17)
    at setTimeout (node:timers:163:19)
    at prepareNextAudioFrame (D:\project-development\rikai-discordbot\node_modules\@discordjs\voice\dist\index.js:130:28)
    at Immediate.<anonymous> (D:\project-development\rikai-discordbot\node_modules\@discordjs\voice\dist\index.js:135:22)
    at process.processImmediate (node:internal/timers:508:21)```
happen on voice related activities 

tried implementing padding frame and custom timeout but no luck
deft nimbus
velvet portal

where can I learn more about components v2 and its usage with discordjs specifically? resources/documentation would be helpful

sharp ginkgoBOT
loud quartz

they will have respective builders on d.js's end

velvet portal

thank you, appreciate it

polar karma

Same as deferReply and reply for command interactions, one gives you up to 15 minutes to respond, and one is a response

Except update edits the message the component interaction came from, not send a new message

worldly whale

can anyone help me? i been following the tutorial but it when came time for me to test the commands they arnt showing? the bot is online and working

halcyon bison

No but you can use both deferUpdate and followUp

rose tangle

which is entirely independent from running the bot itself

worldly whale
rose tangle

no, the deploy script

which is entirely unrelated to events

worldly whale

Where would that be in the docs

rose tangle

you need to finish the commands part

odd moon

Can this error be caused by just shards reconnecting too often? Or does this indicate a cluster (or like whole process I suppose) going down completely and needing to hard reconnect? I've been getting this error frequently as of recent on my relatively large bot (70k servers, 73 shards) and I'm not really sure how to resolve it. It's been causing me to need to regenerate the token often:

Error: Not enough sessions remaining to spawn 10 shards; only 4 remaining; resets at 2025-06-01T07:57:44.637Z
sharp ginkgoBOT

guide suggestion for @worldly whale:
guide Creating Your Bot: Registering slash commands
read more

worldly whale

Ah thanks

worldly whale
rose tangle

otherwise you should've known what it is

and once you read it you'll know what it does and how to run it

worldly whale

Oop 😭 dang how ya know

halcyon bison

You'd want to use editReply to edit the message after deferUpdate, but aside from that yes

worldly whale

I didnt do node fir the deployment

rose tangle

btw you can only acknowledge/reply to the interaction once, that means you can only deferUpdate, deferReply, reply OR update, then you can only editReply (whose behavior depends on which of the methods you use) and followUp which creates a new message

it edits the "target of" the acknowledgment you did

if you did update, then the "target" would be the message itself that was edited

if you reply()ed then it'll be that new message

basically the same respective thing for each defer

odd moon
rose tangle

why do you want it?

you can't edit the message through its Message object since it's ephemeral, it's not an actual message

you need to use editReply

if you're using followUp, editReply can also take the target message to edit

sharp ginkgoBOT
jaunty bronze

Probably not the right place, but I was wondering if it's possible if a bot can fetch what on-going activities are being played in a Voice Channel?

steel trail
lunar stream

is there something wrong with the api right now? completely unable to register command not even in test guild

crimson gale

what's the api response?

lunar stream
crimson gale

CNR

what do you mean "literally nothing"?
did you just spam deploy and now it's ratelimited?

lunar stream

I just wish I got my good old trusty erro 429 in return

crimson gale

how are you deploying?

tried passing the option so it rejects the promise on rate limit?

lunar stream

okay what the hell must've been one long rate limit, it does the job now

thanks for your time 👍

polar karma

Did you look on the docs?

sharp ginkgoBOT
dense jackal

looks like there is lol

polar karma

There is, that's why I asked them

dense jackal

yh message was meant for rem

sharp ginkgoBOT
analog oak

Is there a good way to add function to Interactions?

zenith violet

as in, custom implementations? No, it is not recommended to do so

You can have a helper function

sharp ginkgoBOT
dense jackal

I think you are referring to this?

well you actually use that and use update({ components: [stringSelectWithSetOptions] }) where stringSelectWithSetOptions is the string select component where you use the setOptions() method to set the options you want

you need to map over the list of selected values <StringSelectMenuInteraction>.values and use that to put them as options

sharp ginkgoBOT
dense jackal

and then you can set those options to default

steel trail

If you want them to be selected for everyone looking at that menu. If you just want them to stay as they were selected for that user simply don't update the menu at all

rich quarry

quicky: Is it possible to do live streaming with the library and if so could someone point me to the correct documentation page?

Just audio?

Oh thats a bummer, ty

scenic berry

is this valid? like i dont need to edit the message, just directly go for the collertor? im not sure what im doing. just asking for suggestion or recommendation by you guys.

polar karma

Sounds like you should just use the interactionCreate event instead

scenic berry
loud quartz

Like on any other interaction

sharp ginkgoBOT
scenic berry

ohh ok ok thank you @loud quartz

when im clicking the button for the first time its working, now when im clicking it again for some reason its not working.

nvm i fixed it, i just set the once to false.

fiery idol

Is there anyway to valid or know why api response when try to register slashComand . I am using SlashCommandBuilder from discord.js . I found that payload make error is below but don't know which party is wrong

rawError: {
    message: 'Invalid Form Body',
    code: 50035,
    errors: { '14': [Object] }
  },
SlashCommandBuilder {
  options: [
    SlashCommandStringOption {
      autocomplete: undefined,
      type: 3,
      choices: [Array],
      name: 'action',
      name_localizations: undefined,
      description: 'Choose action (add/remove)',
      description_localizations: undefined,
      required: true,
      max_length: undefined,
      min_length: undefined
    },
    SlashCommandStringOption {
      autocomplete: undefined,
      type: 3,
      choices: [Array],
      name: 'type',
      name_localizations: undefined,
      description: 'Choose permission type (allow/deny)',
      description_localizations: undefined,
      required: true,
      max_length: undefined,
      min_length: undefined
    },
    SlashCommandStringOption {
      autocomplete: undefined,
      type: 3,
      choices: [Array],
      name: 'config_type',
      name_localizations: undefined,
      description: 'Choose configuration type (channels/roles/links)',
      description_localizations: undefined,
      required: true,
      max_length: undefined,
      min_length: undefined
    },
    SlashCommandBooleanOption {
      name: 'bypass',
      name_localizations: undefined,
      description: 'Set bypass option for links (true/false)',
      description_localizations: undefined,
      required: false,
      type: 5
    },
    SlashCommandStringOption {
      autocomplete: undefined,
      type: 3,
      choices: undefined,
      name: 'value',
      name_localizations: undefined,
      description: 'Channel, role, or link value',
      description_localizations: undefined,
      required: true,
      max_length: undefined,
      min_length: undefined
    }
  ],
  name: 'setlinkconfig',
  name_localizations: undefined,
  description: 'Configure server link and invite settings',
  description_localizations: undefined,
  contexts: undefined,
  default_permission: undefined,
  default_member_permissions: undefined,
  dm_permission: undefined,
  integration_types: undefined,
  nsfw: undefined
}
loud quartz

Is there anyway to valid or know why api response
yeah. in the errors

if you use node's util.inspect with a high depth setting, you can see the entire object

pliant forge

Can we do showModal() after interaction.deferReply() ?

loud quartz

no, you cannot suddenly appear a modal after up to 15 minutes

showing a modal has to be the first response to an interaction

pliant forge

tysm

abstract forge

im being extremely dumb or smthn but cant any commands to register, doesnt show in integrations or anything

module.exports = {
    name: 'ping',
    description: 'Pong! Returns ping.',
    // devOnly: Boolean,
    // testOnly: true,
    // options: Object[],
    // deleted: Boolean,
  
    callback: async (client, interaction) => {
      await interaction.deferReply();

      const reply = await interaction.fetchReply();
  
      const ping = reply.createdTimestamp - interaction.createdTimestamp;
  
      interaction.editReply(
        `Pong! | Client ${ping}ms | Websocket: ${client.ws.ping}ms`
      );
      console.log(`PING | Command ran by ${interaction.user.id}`)
    },
  };

this should work fine for the framework thing i use and it worked before on another bot

wary coral
abstract forge

already tried refreshing like multiple times

topaz bluff

Show us your deployment script. That's just a command file, that doesn't tell Discord your command exists

abstract forge

1 sec

oh woops i forgot it takes a while for global commands to register

zenith violet

Just a client refresh

abstract forge

wait wha

either way im gonna wait a bit and ill come back here if its still not registered

zenith violet

did you restart discord

rigid crest

so just peaked on this bot im working on for a gaming studio server ive not seen this error pop before was a interaction deleted before the collector timed out? is that what this means?
Error handling interaction: Error [InteractionCollectorError]: Collector received no interactions before ending with reason: time

zenith violet

and are you sure you're running your deploy script

abstract forge
zenith violet
steel trail

Or an awaitModalSubmit

trim basin

Hi there, when my bot is playing a from spotify song, it ends at 30 seconds, and i heard that its due to spotify gives the excerpt of the song, how to fix this? (ive installed yt-dlp from python pip)

const { DisTube } = require("distube");
const { SpotifyPlugin } = require("@distube/spotify"); const { SoundCloudPlugin } = require("@distube/soundcloud"); const { DeezerPlugin } = require('@distube/deezer'); const { BandlabPlugin } = require('@distube/bandlab'); const { YouTubePlugin } = require('@distube/youtube');
const { YtDlpPlugin } = require('@distube/yt-dlp');

const distube = new DisTube(bot, {
    emitNewSongOnly: true,
    plugins: [
        new SpotifyPlugin({
            api: {
                clientId: 'b39c35aeb118425ab2a50608d2b8f5f8',
                clientSecret: g7SaQ541dOnD,
            }
        }),
        new SoundCloudPlugin(),
        new YouTubePlugin(),
        new DeezerPlugin(),
        new BandlabPlugin(),
        new YtDlpPlugin()
    ],
});
distube.setMaxListeners(3);

distube
  .on("playSong", (queue, song) => {
    queue.voiceChannel.send(`▶️ Now playing: **${song.name}** \`[${song.formattedDuration}]\``)
  })
  .on("addSong", (queue, song) =>
    queue.textChannel.send(`➕ Added **${song.name} by ${song}** to the queue`)
  );
distube.on("error", (channel, error) => {
  console.error(`DisTube Error: ${JSON.stringify(error)}`);
  if (channel && typeof channel.send === "function") {
    channel.send(`❌ An error occurred: ${error}`);
  }
});
zenith violet

which distube is

Spotify does not allow playback. Distube uses youtube behind the hood

trim basin

really?! oh gosh, but its useful ...

zenith violet

Its against TOS

abstract forge

i know the commands are going to the discord api since if i mess smthn up about the command it returns an error

zenith violet

Show your deploy script

abstract forge
zenith violet

The thing thar registers commanda

rose tangle

deploying and registering are the same in this context

zenith violet

It should be a separate script

abstract forge
const { testServer } = require('../../../config.json');
const areCommandsDifferent = require('../../utils/areCommandsDifferent');
const getApplicationCommands = require('../../utils/getApplicationCommands');
const getLocalCommands = require('../../utils/getLocalCommands');

module.exports = async (client) => {
    try {
      const localCommands = getLocalCommands();
      const applicationCommands = await getApplicationCommands(
        client,
        testServer
      );
  
      for (const localCommand of localCommands) {
        const { name, description, options } = localCommand;
  
        const existingCommand = await applicationCommands.cache.find(
          (cmd) => cmd.name === name
        );
  
        if (existingCommand) {
          if (localCommand.deleted) {
            await applicationCommands.delete(existingCommand.id);
            console.log(`REGISTER | Deleted command "${name}".`);
            continue;
          }
  
          if (areCommandsDifferent(existingCommand, localCommand)) {
            await applicationCommands.edit(existingCommand.id, {
              description,
              options,
            });
  
            console.log(`REGISTER | Edited command "${name}".`);
          }
        } else {
          if (localCommand.deleted) {
            console.log(
              `REGISTER | Skipping registering command "${name}" as it's set to delete.`
            );
            continue;
          }
  
          await applicationCommands.create({
            name,
            description,
            options,
          });
  
          console.log(`REGISTER | Registered command "${name}."`);
        }
      }
    } catch (error) {
      console.log(`mess up: ${error}`);
    }
  };
rose tangle

you don't need to deploy your commands one by one

zenith violet

Yeah no

rose tangle

just a single .set and you're done

zenith violet

There's indeed your issue

You're likely ratelimites

abstract forge

how come that worked before for another bot?

zenith violet

You do not need to deploy on every start

sharp ginkgoBOT

guide Creating Your Bot: Registering slash commands
read more

zenith violet

It should be a separate script that you run when you add or edit commands

Not every time your bot starts

abstract forge

alright

rose tangle

send all your commands in the .set or .put if you use REST

abstract forge

this would work to make it a global command, right?

rose tangle

it works for both

if using the logged in client (not on a separate script but with a conditional so it only runs when you need it to):

  • client.application.commands for global
  • guild.commands for guilds
    if using the REST class (separate script)
  • Routes.applicationCommands for global
  • Routes.guildApplicationCommands for guilds, or something like that, it's in the guide

if you go for the first option I'd read from config or .env, some setting like "deployCommands" which you set to true when you need it and false afterwards

nova pond

Hello, in the new update how to use the selectMenue classic because it mentions all the salons with it: js const channelSelectMenu = new ChannelSelectMenuBuilder() .setCustomId('select') .setPlaceholder('📁 Select Menue'); I've already tried it: StringSelectMenuBuilder but it doesn't work, why ? Error : js An error occurred in the command [TEST] DiscordAPIError[50035]: Invalid Form Body data.components[0].components[2].components[0].options[BASE_TYPE_BAD_LENGTH]: Must be between 1 and 25 in length. at handleErrors (C:\Users\Teck Génération\Desktop\Bad-Protect\node_modules\@discordjs\rest\dist\index.js:748:13) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async BurstHandler.runRequest (C:\Users\Teck Génération\Desktop\Bad-Protect\node_modules\@discordjs\rest\dist\index.js:852:23) at async _REST.request (C:\Users\Teck Génération\Desktop\Bad-Protect\node_modules\@discordjs\rest\dist\index.js:1293:22) at async ChatInputCommandInteraction.reply (C:\Users\Teck Génération\Desktop\Bad-Protect\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:194:22) at async Object.run (C:\Users\Teck Génération\Desktop\Bad-Protect\src\slashCommands\Security\settings.js:92:29) at async Object.run (C:\Users\Teck Génération\Desktop\Bad-Protect\src\events\Client\interactionCreate.js:60:9) { requestBody: { files: [], json: { type: 4, data: [Object] } }, rawError: { message: 'Invalid Form Body', code: 50035, errors: { data: [Object] } }, code: 50035, status: 400, method: 'POST', url: 'https://discord.com/api/v10/interactions/1378784688386343033/aW50ZXJhY3Rpb246MTM3ODc4NDY4ODM4NjM0MzAzMzpJZTNEVlc1MnV4UTRFdTl3VU5Ud2tyMDljVHZWdUZOWmJxWklkZmpMRXAxZkFJSDFsNXlpWUlGNUxGeU1JUWszS2M1eDkwRnZmVm5FWkljWkVlNDlPelpidEtBTFF4MXBpREt5MW1lRWtSYVRhaW9INWg1T2Z5WlpsS0FXTXI5Mw/callback?with_response=false' }

rose tangle

string select menus need from 1 to 25 options, inclusive

you're either not sending any option or sending more than 25

trim basin
nova pond
rose tangle
loud quartz

it's not about the amount of select menus in action row.
it's about amount of options the select has - which it has none.

torn orchid
[2025-6-1 13:13:31] Error: [ Discord API : 400] Invalid Form Body
    at IncomingMessage.<anonymous> (C:\Users\nate\OneDrive\Desktop\Nate Assets\Discord Stuff\natebot1.0\Utils\RegisterCommands.js:86:19)
    at IncomingMessage.emit (node:events:530:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

const { MessageFlags } = require('discord.js');
const { SlashCommandBuilder, TextDisplayBuilder, ContainerBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
    .setName("testing")
    .setDescription("Testing component v2"),

    async execute(interaction) {

    const components = [
          new TextDisplayBuilder().setContent("They said I couldn't teleport, so I went to a parallel universe and became a time traveler."),
          new ContainerBuilder()
              .addTextDisplayComponents(
                  new TextDisplayBuilder().setContent("# testing"),
              ),
            ];

      await interaction.reply({
          flags: MessageFlags.IsComponentV2,
          components: [ContainerBuilder.toJSON()],
    });
  },
nova pond
rose tangle there isn't any option there

Code : ```js
const mediaGalleryComponent = new MediaGalleryBuilder().addItems(
{
media: { url: 'My_url' }
},
);

const SelectMenu = new StringSelectMenuBuilder()
.setCustomId('settings')
.setPlaceholder('📘 Commencer la configuration.');

const SelectMenuRow = new ActionRowBuilder().addComponents(SelectMenu );

const Opencontainer = new ContainerBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder().setContent(Text))
.addMediaGalleryComponents(mediaGalleryComponent)
.addActionRowComponents(SelectMenuRow)
.setAccentColor(Colors.White)
.setId(1);

const msgwait = await interaction.reply({
components: [Opencontainer],
flags: [MessageFlags.IsComponentsV2]
})```

rose tangle
torn orchid

oh i didnt even notice that

nova pond
sharp ginkgoBOT

guide suggestion for @nova pond:
guide Message Components: Select menus - Building string select menus
read more

torn orchid
rose tangle you're not sending your components, you're calling ComponentBuilder.toJSON() for...
const { MessageFlags } = require('discord.js');
const { SlashCommandBuilder, TextDisplayBuilder, ContainerBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
    .setName("testing")
    .setDescription("Testing component v2"),

    async execute(interaction) {

    const components = [
          new TextDisplayBuilder().setContent("They said I couldn't teleport, so I went to a parallel universe and became a time traveler."),
          new ContainerBuilder()
              .addTextDisplayComponents(
                  new TextDisplayBuilder().setContent("# testing"),
              ),
            ];

      await interaction.reply({
          flags: MessageFlags.IsComponentV2,
          components: [components],
    });
  },
};```
rose tangle

that guide article should probably help as well

rose tangle
torn orchid
steel trail
rose tangle
torn orchid
torn orchid
steel trail

Or use REST from discord.js to make the request to get more useful errors instead of your custom way

zenith violet

Whatever you're calling that on is undefined

steel yacht

Hi,
How to create at the highest possible position ?

steel trail

Find the highest current position and +1

steel yacht

How to find the highest current position ?

steel trail

Depends, what are we talking about? Roles, channels, ...?

steel yacht

Oh I'm sorry I meant to say "create a role", I don't know how I forgot to put those words 😅

sharp ginkgoBOT
steel yacht

And so higher in the list is a higher number value (as in opposite to the notion of array indexes) ?

red coral

Few questions related to emojis:

  1. guild.emojis.fetch and client.emojis.fetch would resolve the same thing? As in, if an emoji is in a guild, then client.emojis.fetch would be fine?
  2. if 1 is true, the difference would also be that client.emojis.fetch would also fetch from the ApplicationEmojis? or do you have to use client.application.emojis as a seperate request
torn orchid

I fixed the invalid form body now I am trying to send but what should I do now? ```javascript
const { MessageFlags } = require('discord.js');
const { SlashCommandBuilder, TextDisplayBuilder, ContainerBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("manage")
.setDescription("Testing component v2"),

async execute(interaction) {

const components = [
      new TextDisplayBuilder().setContent("They said I couldn't teleport, so I went to a parallel universe and became a time traveler."),
      new ContainerBuilder()
          .addTextDisplayComponents(
              new TextDisplayBuilder().setContent("# testing"),
          ),
        ];

  await interaction.reply({
    components,
      flags: MessageFlags.IsComponentV2,
});

},
};```

steel trail
steel trail
red coral
torn orchid
steel trail Does that not work? Do you get any issue?
Command: manage
Error: Invalid Form Body
data.components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
data.components[1][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
            ];

      await interaction.reply({
      ^^^
        components,
          flags: MessageFlags.IsComponentV2,
    });
  },```
steel trail

Did you overwrite the reply method of interaction in any way? Can you console.log(interaction) before that line?

torn orchid

this is my code: ```javascript
const { MessageFlags } = require('discord.js');
const { SlashCommandBuilder, TextDisplayBuilder, ContainerBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("manage")
.setDescription("Testing component v2"),

async execute(interaction) {

const components = [
      new TextDisplayBuilder().setContent("They said I couldn't teleport, so I went to a parallel universe and became a time traveler."),
      new ContainerBuilder()
          .addTextDisplayComponents(
              new TextDisplayBuilder().setContent("# testing"),
          ),
        ];

  await interaction.reply({
    components,
      flags: MessageFlags.IsComponentV2,
});

},
};```

steel trail

Can you console.log(interaction) before that line?

stable sun

You misspelled the flag

IsComponentsV2 "Components" is plural

steel trail

Oh, good catch

torn orchid
stable sun

I gave you the correct spelling

torn orchid

Oh alr

grizzled venture

Can someone please link me the link to the duplicating commands page? ON how to solve it?

I cannot seem to find it

steel yacht
torn orchid
stable sun I gave you the correct spelling
const { MessageFlags } = require('discord.js');
const { SlashCommandBuilder, TextDisplayBuilder, ContainerBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
    .setName("manage")
    .setDescription("Testing component v2"),

    async execute(interaction) {

    const components = [
          new TextDisplayBuilder().setContent("They said I couldn't teleport, so I went to a parallel universe and became a time traveler."),
          new ContainerBuilder()
              .addTextDisplayComponents(
                  new TextDisplayBuilder().setContent("# testing"),
              ),
            ];

      console.log(interaction);
      await interaction.reply({
        components,
          flags: MessageFlags.IsComponentsV2,
    });
  },
};```
torn orchid

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

red coral
loud quartz
torn orchid
loud quartz

app emotes are unrelated to guild emotes, therefore they don't exist under client.emojis

rose tangle
rose tangle
torn orchid
rose tangle

yes, that means you're not passing the IsComponentsV2 flag

which is why I asked if you're sure you saved the code

torn orchid

where should i put type at in my code?

red coral

ah, that was going to be my next question. I remember there was a guild emojis and stickers intent a while ago (might still exist), all emojis are sent over gateway then that intent keeps the cache up to date?

loud quartz

did you save the file?

if yes, check again

torn orchid

yes

loud quartz

did you restart the bot?

torn orchid

yes

loud quartz

or reload the command

rose tangle
red coral

cool thanks

loud quartz
red coral

and that's also a cache you can rely on unlike members for example?

loud quartz

but that intent is for emoteCreate, emoteDelete, etc. events

rose tangle
red coral

ill have it so ig i can rely on it

grizzled venture
loud quartz
grizzled venture
sharp ginkgoBOT

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

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

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

here

loud quartz

which immediately tells you to delete one of them

which you were linked to on how to do that

rose tangle

Thonk I don't think that link actually exists

red coral
rose tangle

yes

red coral

thanks 😭

rose tangle

yeah it's on the wrong page

loud quartz

where did you find that link

rose tangle

maybe it was there before and it's a cache issue

minor marten

I just copied it from that page

torn orchid
sharp ginkgoBOT

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

torn orchid
rose tangle

can you npm ls discord.js and npm ls discord-api-types

in console

(and show the output)

torn orchid

alr

npm ls discord.js = discord.js@14.14.1
npm ls discord-api-types = ├── discord-api-types@0.38.9
├─┬ discord.js@14.14.1
│ ├─┬ @discordjs/builders@1.11.2
│ │ ├─┬ @discordjs/formatters@0.6.1
│ │ │ └── discord-api-types@0.38.9 deduped
│ │ └── discord-api-types@0.38.9 deduped
│ ├─┬ @discordjs/formatters@0.3.3
│ │ └── discord-api-types@0.37.61 deduped
│ ├─┬ @discordjs/rest@2.5.0
│ │ └── discord-api-types@0.38.9 deduped
│ ├─┬ @discordjs/ws@1.2.2
│ │ └── discord-api-types@0.38.9 deduped
│ └── discord-api-types@0.37.61
└─┬ v2componentsbuilder@1.0.25
└── discord-api-types@0.38.9 deduped

torn orchid
rose tangle

yeah no idea what "v2componentsbuilder" is

steel trail
rose tangle

your discord.js version does not support v2 components

update to latest

torn orchid

i will do npm i discord.js@latest

rose tangle

and remove other packages

like v2componentsbuilder

and whatever other thing you may have

sharp ginkgoBOT

discord.js includes multiple sub-packages, installing these separately can mess with internal code:

npm uninstall discord-api-types @discordjs/rest @discordjs/builders
yarn remove discord-api-types @discordjs/rest @discordjs/builders
pnpm remove discord-api-types @discordjs/rest @discordjs/builders
torn orchid
rose tangle

npm uninstall <package>

torn orchid
loud quartz

the ones you're using

just uninstall that thing just mentioned, update d.js to latest and try again

rose tangle

for the discord part, you should only need discord.js and that's it

torn orchid
rose tangle for the discord part, you should only need discord.js and that's it

└─┬ discord.js@14.19.3
├─┬ @discordjs/builders@1.11.2
│ └── discord-api-types@0.38.9 deduped
├─┬ @discordjs/formatters@0.6.1
│ └── discord-api-types@0.38.9 deduped
├─┬ @discordjs/rest@2.5.0
│ └── discord-api-types@0.38.9 deduped
├─┬ @discordjs/ws@1.2.2
│ └── discord-api-types@0.38.9 deduped
└── discord-api-types@0.38.9

rose tangle

did you install builders separately?

because your builders version did not bump at all

and it's actually latest

I'll assume you did install it separately, because that old djs did not have that version

torn orchid

thats what i did there not going away

rose tangle

alright, should be fine then

rose tangle

yes, those are appropiate versions for your djs version

torn orchid

alr

what is like the npm to see if you are at the latest version for discord,js

rose tangle

you used to have an old djs but newer subpackages, hence why you could build the components (/builders) but not send them (discord.js)

you can just open discord.js on npm and see

but you're on latest

loud quartz
torn orchid
rose tangle

correct

loud quartz

there's no embeds

torn orchid

is there a identical way to have text go like this?

rose tangle

other than with spaces manually, which can break in mobile, no

torn orchid

oh alr

steel trail

Only by having the interaction webhook of the first interaction still stored somewhere

And it being less than 15 minutes since

sharp ginkgoBOT
rose tangle

can't you access the first interaction there?

have you tried collectors?

storing, retrieving and using the webhook directly isn't as straightforward as simply using the interaction object

hard gate

soo, i've trying to edit the component instead of creating a new one

            const message = await interaction.channel.messages.fetch(interaction.message.id);
            const existingContainer = message.components[0];
            const receivedContainer = new ContainerBuilder(existingContainer)
                .setAccentColor(1691997);

            const acceptedText = new TextDisplayBuilder()
                .setContent(`✅ Accepted by: ${interaction.user} (\`${interaction.user.username}\`)`);

            receivedContainer.addTextDisplayComponents(acceptedText);

but i'm getting this error

_ValidationError: Expected a string primitive
    at _StringValidator.handle (C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@sapphire+shapeshift@4.0.0\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2615:70)
    at _StringValidator.parse (C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@sapphire+shapeshift@4.0.0\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
    at TextDisplayBuilder.toJSON (C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@discordjs+builders@1.11.2\node_modules\@discordjs\builders\dist\index.js:1708:33)
    at C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@discordjs+builders@1.11.2\node_modules\@discordjs\builders\dist\index.js:2168:64
    at Array.map (<anonymous>)
    at SectionBuilder.toJSON (C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@discordjs+builders@1.11.2\node_modules\@discordjs\builders\dist\index.js:2168:35)
    at C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@discordjs+builders@1.11.2\node_modules\@discordjs\builders\dist\index.js:1870:64
    at Array.map (<anonymous>)
    at ContainerBuilder.toJSON (C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\@discordjs+builders@1.11.2\node_modules\@discordjs\builders\dist\index.js:1870:35)
    at C:\Users\Admin\Desktop\VN\VoidVacation\node_modules\.pnpm\discord.js@14.19.3\node_modules\discord.js\src\structures\MessagePayload.js:151:46 {validator: 's.string()', given: undefined, stack: 'Error: Expected a string primitive
    at _St…js\\src\\structures\\MessagePayload.js:151:46', message: 'Expected a string primitive'}
analog oak

so I'm building a ticket panel system using buttons and modals. After the user submits a modal (e.g. to add a question), I want delete the previous ephemeral message (the one with action buttons) to avoid clutter. However, since ModalSubmitInteraction doesn’t have .update() . How can I cleanly replace or remove the last ephemeral message after a modal submission?

loud quartz

do you have access to the ButtonInteraction that triggers the modal from where you handle the modal?

loud quartz

you're handling those modals separately, directly inside of the interactionCreate?

steel trail
hard gate
toxic moat

Can I see connections of user?

zenith violet

no

toxic moat

Is there any way

zenith violet

through oauth2

which djs does not support

analog oak
zenith violet

use .update, assuming the modal is shown from a component interaction

analog oak
zenith violet
sharp ginkgoBOT
lime moss

Im trying to have a discord bot that scans a server and grabs all user ids (utilizing user apps) but i cant figure it out since i am used to only using guild commands, this is the code i am using now: ```const { SlashCommandBuilder, MessageFlags } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('list-visible-users')
.setDescription('Lists visible user IDs in this channel'),

async execute(interaction) {
  const members = interaction.guild.members.fetch();
  const ids = [...members.values()].map(m => m.user.id);

  await interaction.reply({
    content: `Visible User IDs:\n\`\`\`\n${ids.join('\n')}\n\`\`\``,
    flags: MessageFlags.Ephemeral
  });
}

};

(i know it sucks) it gives this err: at Object.execute (C:\Users\X\Downloads\TheChangeMakers\commands\Utility\pred.js:9:41)
at Object.execute (C:\Users\X\Downloads\TheChangeMakers\events\interactionCreate.js:46:25)
at Client.<anonymous> (C:\Users\X\Downloads\TheChangeMakers\index.js:19:50)
at Client.emit (node:events:518:28)
at InteractionCreateAction.handle (C:\Users\X\Downloads\TheChangeMakers\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\X\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\X\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31)
at WebSocketManager.<anonymous> (C:\Users\X\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\WebSocketManager.js:235:12)
at WebSocketManager.emit (C:\Users\X\Downloads\TheChangeMakers\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
at WebSocketShard.<anonymous> (C:\Users\X\Downloads\TheChangeMakers\node_modules@discordjs\ws\dist\index.js:1190:51)

loud quartz

that's not the full error

also this sounds really scummy

and i believe should be impossible for that exact reason

lime moss

its so i dont have predators joining my server

    at Object.execute (C:\Users\cgmcc\Downloads\TheChangeMakers\commands\Utility\pred.js:9:41)
    at Object.execute (C:\Users\cgmcc\Downloads\TheChangeMakers\events\interactionCreate.js:46:25)
    at Client.<anonymous> (C:\Users\cgmcc\Downloads\TheChangeMakers\index.js:19:50)
    at Client.emit (node:events:518:28)
    at InteractionCreateAction.handle (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12) 
    at module.exports [as INTERACTION_CREATE] (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31)
    at WebSocketManager.<anonymous> (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\discord.js\src\client\websocket\WebSocketManager.js:235:12) 
    at WebSocketManager.emit (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
    at WebSocketShard.<anonymous> (C:\Users\cgmcc\Downloads\TheChangeMakers\node_modules\@discordjs\ws\dist\index.js:1190:51)
loud quartz

and to do that you go to all servers and grab all users that happen to be in those servers? seems really unrelated.

lime moss

i grab them put them in a database and then ban them from joining the server

loud quartz

i don't really understand how would you determine someone is a "predator" from their id

anyway

this is genuine invasion of privacy

and therefore is not possible

lime moss

except its been done before (for different servers)

loud quartz

does not mean you should do it too

zenith violet

user apps dont have access to the members regardless

crimson gale

you cannot retrieve server members with a user app. if you need access to members, you have to install the app to the server in question

so whatever it is you are trying to filter for - you will need server staff to opt into it by installing your app (and giving it the required permissions)

topaz bluff
analog oak
zenith violet

no

use deferUpdate and editReply

analog oak

editReply in this case will update the original message that contains the button?

zenith violet

yes

torn orchid

how do you put a acccentcolor on a embed in discord.builders

bleak owl

we are not the creators of that website so we cannot help you

this server is only for the discord.js library

visual stag

Are there any planned or anticipated breaking changes in v15? I was wanting to make a bot but I heard it was planned to be releasing soon and I didn't want to have to rewrite if that's the case

rose tangle

major version bumps are synonym of breaking changes

otherwise it wouldn't be a major version

there's no particular plans to release it soon

and no guide to update yet, since changes are still being done

visual stag

Yeah I know, it's just there's "ctrl+f replace all" breaking changes and then there's rewrite entire sections breaking changes, and I was wondering if there were any of the latter
I guess I heard wrong about v15 being impending, my apologies

rose tangle

there are behavior changes, yes

mostly with currently deprecated fields/methods being removed

wicked rampart

my bot keeps telling me it's getting removed from the same server over and over but the number of servers it's in doesn't go down. all the info about the server is just "undefined" and the server ID is always the same. Any ideas?

rose tangle

do you have the Guilds intent?

wicked rampart

yes

loud quartz

what code logs this

wicked rampart

added this for troubleshooting

wicked rampart

I do also get legitimate guildDelete events

but a bunch of these random "undefined" events firing for some reason

rose tangle

ah, yeah that's an unavailable guild

no properties are available on those

probably only the id is the only actually reliable one

filter out unavailable guilds in your log and you're good

or maybe only log the id if you want

wicked rampart

what are these unavailable guilds? and why do so many fire at the same time

rose tangle

I think they happen due to outages, ddevs can probably give more info #useful-servers

wicked rampart

and I also tend to see a bunch of them show up in the log any time I restart the bot

rose tangle

well the bot is still in that guild then

it's just unavailable

wicked rampart
rose tangle

well discord is quite a big platform

wicked rampart

look how many fired all at once at this time.. I don't get it..

unique shoal

I'd recommend including the id, since you will get that at least

Then you can see if its the same, or one guild firing a lot

wicked rampart
unique shoal

Yeah, so that would explain it

One guild is flagging a lot

wicked rampart

why does this happen?

I understand moving forward just filter them out but now I'm curious what causes this

rose tangle

ddevs = discord developers (server)

wicked rampart

thanks everyone. I guess this will have to do.

rose tangle

should add a ; so it doesn't execute the next line by mistake

wicked rampart

👍

hybrid olive

is there a way to make context menu commands show up in DMs like esmbot?

sharp ginkgoBOT
hybrid olive

thanks!

like this?
it's still not showing

new ContextMenuCommandBuilder()
        .setName("meow")
        .setType(ApplicationCommandType.Message)
        .setContexts(["Guild", "BotDM", "PrivateChannel"])
        .setIntegrationTypes([0, 1]),

ah nevermind it just did
guess there was a delay

lunar stream
crimson gale tried passing the option so it rejects the promise on rate limit?

I did some more testing regarding this and there's 2 interesting finds, sorry for ping by the way.
if I deploy the exact same code and settings but change token to another bot it works flawlessly, so it shouldn't be the code. However if I with very minimal just set a single command this also work? so something tells me it's not ratelimit if some things work and some things won't

torn orchid
module.exports = {
    roles: ["1375655275670798357", "1375658621458845797", "1375658664161181766", "1375661716976832532"],
    name: "say",
    aliases: ["repeat"],
    description: "Sends a message",
    usage: "say <message>",

    async execute(message, client, args) {
        if (!message.member.roles.cache.some(role => this.roles.includes(role.id))) return;

        const sayMessage = args.join(" ");
        
        message.channel.send(sayMessage);
        await message.delete().catch((err) => {
      });
    }
}```
i want to have -say hello and -repeat to also say hello so another alias of say
bleak owl

did you make that code?

calm maple

i thought discord bots could use emojis from other servers they're in in any guild?

stable sun

You could make a Map that maps each alias to the corresponding command and check that in the message create event

calm maple

with slash cmds too?

torn orchid
stable sun
stable sun

Given the bot or everyone role has the use external emojis perm

calm maple
stable sun Yea

confused

let me make sure the external emoji perms is enabled 1 sec

stable sun
calm maple
stable sun

It varies by server setup

calm maple

yeah the bot and everyone has external emojis but its still like that, is it because its a user installed app rather than a guild command?

wait nvm its a guild command

stable sun

Could also be an invalid emoji id

calm maple

server with the emojis vs server without; both servers have external emoji permissions enabled for both the bot and everyone

the emojis are in the first server

stable sun

And ur sure the perm enabled in the channel?

uneven crater

And you're sure it's not a user installed app?

calm maple

i'll try removing it from my user install

it's the same, i think bots are unable to access emojis from other servers now? maybe due to them adding the app specific emojis? the external emojis permission is enabled and everything

rose tangle

that's definitely not the issue

but you should prefer app emojis if possible

calm maple

💀

im trying to make a pokedex bot but i have more emojis than i can in the app emojis since i have 4 per pokemon 🥲

stable sun

App emojis do bypass the permission

calm maple

maybe i just need to rethink this

unique shoal

use a media gallery?

rose tangle

I mean, using emojis was the approach they did in the official stage

calm maple

yeah thats what i was copying basically

rose tangle

it'd suck if you couldn't replicate yourself

calm maple

i don't think theres any way to have both a button and image in a section?

rose tangle

correct, there isn't a way

calm maple

like these are emojis on the left

rose tangle

yeah that's only possible with emojis, like they did in the stage

calm maple

but limited to 500 pokemon (4 emojis per; 2000 max emoji in app)

unique shoal

how does that alignment work

unique shoal
calm maple
rose tangle

yeah imo it would've been better if they had chosen an example that wasn't limited by design

calm maple

i mean i could have a single emoji per pokemon, but it wouldnt' display very well

rose tangle

yeah

calm maple

like this is a bit ugly

uneven crater

I dunno, I like it.

bleak owl

i think it looks fine

rose tangle

even then can't have all pokemons kek

calm maple

1025 pokemon (excluding other forms); 2000 max bot emojis?

rose tangle

ah, thought there was more

it does feel a lot more

unique shoal
unique shoal

I had no idea, well done

calm maple

it was copied from the discord thingy they had for components v2 lol

torn orchid

what are prefered prefixes to use with custom bots?

uneven crater

Slash commands.

calm maple

^

slender scarab

ik the consensus is usually to use slash commands, but alot of people liked using 'jarvis' on my server, so i used jarvis,

unique shoal

The / character

Since its built directly into Discord and offers significantly better functionality than literally any other prefix

uneven crater

Self-documenting, if you do it right.

unique shoal
slender scarab
calm maple
uneven crater

I don't think that works with arbitrary strings like a Discord message?

slender scarab

thats not exactly enough for discord commands tho,

yeh

calm maple

yeah thats fair

torn orchid
stable sun You could make a Map that maps each alias to the corresponding command and check...
module.exports = {
    roles: ["1375655275670798357", "1375658621458845797", "1375658664161181766", "1375661716976832532"],
    name: "say",
    aliases: ["repeat"],
    description: "Sends a message",
    usage: "say <message>",

    async execute(message, client, args) {
        if (!message.member.roles.cache.some(role => this.roles.includes(role.id))) return;

        const sayMessage = args.join(" ");
        
        message.channel.send(sayMessage);
        await message.delete().catch((err) => {
      });
    }
}```
how do i do that
bleak owl

do you know how to make a map?

torn orchid

nope

bleak owl

do you know javascript?

torn orchid

yes

bleak owl

how much

slender scarab
torn orchid ```javascript module.exports = { roles: ["1375655275670798357", "13756586214...

you could try use my command-loader lib i made for this purpose, but there's not much documentation as its literally just me using it, you'd have to clone the lib as its neither on npm (basically your on your own for the most part) -- its what im using with my discord bot atm

https://github.com/Syth-1/command-loader

its pretty stable tho, i have the same lib running in a game chat, where users are hitting about 30-40k messages with the bot a month

sharp ginkgoBOT

mdn Map
The Map object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and primitive values) may be used as either a key or a value.

torn orchid
slender scarab
bleak owl

we don't even recommend using prefixes as it results in really bad UX

bleak owl
visual tusk

With the new components, is it possible to do something similar that EmbedBuilder.from() does and build a container from an existing message to modify things within it?

I'm assuming interaction.message.components[0] will always be a container (so it's a ContainerComponent when inspecting debug)

clear garnet

new XBuilder(component.toJSON())

visual tusk

Oh, so obvious...thanks!

sudden estuary

is it possible to mimic the search function in discord using djs?

other than fetching every single message that has been sent and sorting through it?

unique shoal

No

Apps don't have access to the search endpoint

mellow tartan

tags: { guildConnections: true }
What are considered as guildConnections ???
All I know is Linked Roles, is there anything else ???

vital raven
mellow tartan
vital raven

No, only that

mellow tartan
vital raven

Check for integrationId

mellow tartan
vital raven

If the role belongs to a bot, there will be botId

sharp ginkgoBOT
vital raven

All tags are here

mellow tartan

Like what comes under integrations in roles

vital raven

Integrations can manage roles, like YouTube or Twitch. You get the role if you're subscribed. Integrations can be found in server settings > integrations tab

stable sun

No to both

I mean neither is accepted

I believe you can use an empty string

vital raven

There would be an API error

stable sun

Just use an if statement

Well, ig that requires you to extract it as a local variable

Why don’t these methods accept undefined like required does?

steel trail
stable sun

Right, default values

trim elm

any particular reason why components v2 doesnt allow the content field anymore? unless its still wip for that part

stable sun
trim elm

mentioning users, mentions in containers dont ping

golden laurel

They do

crimson gale

you may be confusing that with embeds

stable sun

Ddocs does say that components v2 will not work with content

trim elm
stable sun

To use components, messages must be sent with the IS_COMPONENTS_V2 flag (1<<15). Note that using this flag disables traditional content and embeds - all content must be sent as components instead.

golden laurel

It sounds like you're making use of allowed mentions and forgot?

trim elm
stable sun

It doesn’t sound like enabling content will be a thing

knotty wind

Hello, probably might be a weird question, but I kinda want to know.

Supposed the bot doesn't have any permission flags (including view channel), and all of @everyone permission flags is also disabled. Then there's a private channel only for member/role with Administrator permission.

The bot doesn't show up on the member list, but when I'm using one of the slash command, they're still able to send non-ephemeral messages and image with non V2 Components even though it theory they should get permission denied / no access error. Is this intended or is there any reason behind it?

trim elm

if its a reply perms dont matter

stiff fulcrum

Price Style
20 Blue

unique shoal

No, but you can just like... do exactly what you just did

stiff fulcrum

That would do weird line breaks I think If on a smaller device for example

rugged coyote

anyone know about this error

Error [ShardingReadyTimeout]: Shard 43's Client took too long to become ready.
    at Timeout.onTimeout (/home/container/node_modules/discord.js/src/sharding/Shard.js:190:16)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7) {
  code: 'ShardingReadyTimeout'
}
errant tendon
pearl roost

how do i make the embed doesn't have a color like this?

steel trail
stiff fulcrum
pearl roost
stiff fulcrum

Isnt that an embed ?

steel trail

A container is not an embed

steel trail
stiff fulcrum
pearl roost

container and embed is different?

steel trail
steel trail
amber bronze

Hi all, can anyone explain why code that worked before is stable and no errors. In the last 2 days there is just some horror going on. 2 gbps is happening at moments. And DiscordAPIError[10062]: Unknown interaction error like this. I understand that it is an error if the command is not answered in 3 seconds, but how can it be that the code worked all the time and now this happens? And it is the bot process that takes 2 gbps

polar karma

Gentle reminder this is a volunteer service and people help as they are able and have time. There is no guarantee of a quick response (or one at all)

agile nest

what is a partial

sharp ginkgoBOT

guide suggestion for @agile nest:
guide Popular Topics: Partial Structures
read more

pearl hazel

if i use channel.permissionOverwrites.set(overwrites_role1_role2)
and there is already same overwrites for role1 and role2 does this request change it ? like remove it and readd it or it's just edit if the overwrites not the same ?

kindred moon
pearl hazel

so i should check if it's the same to skip useless request

agile nest

is this possible???

(those small images inside cv2)

kindred moon
agile nest

so they are just text display?

kindred moon

correct

agile nest

thats so sad ngl

rose tangle

ask in ddevs

and yes

amber bronze
keen widget

What are the ratelimits for messages?

  • Knowing that the global is 50/s
  • Do shards affect it in any way
  • Is it per server or per channel or global

I know they aren't public, but someone might have figured them out

sharp ginkgoBOT

tag suggestion for @keen widget:
Ratelimits are dynamically assigned by the API based on current load and may change at any point.

  • The scale from okay to API-spam is sliding and depends heavily on the action you are taking
  • Rainbow roles, clock and counter channels, and DM'ing advertisements to all members are all examples of things that are not okay
keen widget

So it's not as dynamic as you think it is

rose tangle

that info is all the help djs can give

not that it's a djs issue in the first place either way

keen widget

cuz djs has a built-in rate limit handler, doesn't it?

rose tangle

yes

keen widget

so does it force every request to the same endpoint every time and looks up the retry-after or is it more customized towards the discord api rate limits in order not to hit 429(lmk if I gave the wrong status code)

or is it a queue and if one request got rate limited, the rest needs to wait

rose tangle

though if it's the global ratelimit then yeah

it'd need to wait entirely

keen widget
keen widget
visual tusk

It knows the ratelimit buckets and abides by them, you'll see it in action if you intentionally hit them

analog oak

Can i change the permission of a list of users of a channel at the same time?

rose tangle
visual tusk

By "knows", Discord sends the ratelimit data in response headers, it's not safe to hard-code these values and most of the time you don't need to do your own ratelimiting.

keen widget
visual tusk

Which is why you listen for the rateLimited event and handle it yourself if needed...I'm not sure which endpoints you're referring to, though. Most endpoints are pretty narrowly scoped, although yes multiple buckets can be part of a single request

keen widget
visual tusk

For example, /guild/id/member/id GET has both a ratelimit on the user and overall guild requests

But in reality, in normal operations you usually won't see it.

rose tangle
keen widget
sharp ginkgoBOT
rose tangle
keen widget

I don't mind the global rate limit since in my case it's just a setInterval() setted up correctly

rose tangle

then it shouldn't be something you need to handle separately

if you're consistently hitting ratelimits and you want to handle it by yourself then either:

  • you don't need djs but a thinner wrapper like /core
  • you're doing what's considered to discord as api spam
  • you could qualify to higher limits

or you need another approach entirely since there are endpoints with really high limits

copper trail

anybody know why i am getting this error/what this error is
Code is: ```js
const Discord = require("discord.js");
// // Fetch a message
channel.messages.fetch('930492253439418460/1197905693676687410')
.then(message => console.log(message.content))
.catch(console.error);

> error is: `node:internal/modules/cjs/loader:1404
>   throw err;
>   ^
> 
> Error: Cannot find module '/Users/redacted/discordbot2/collector.js'
>     at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
>     at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
>     at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
>     at Function._load (node:internal/modules/cjs/loader:1211:37)
>     at TracingChannel.traceSync (node:diagnostics_channel:322:14)
>     at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
>     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
>     at node:internal/main/run_main_module:36:49 {
>   code: 'MODULE_NOT_FOUND',
>   requireStack: []
> }`
rose tangle

there isn't an easy way, I'd re-think the workflow either way since it doesn't look like good UX to have that many consequent messages

rose tangle

also that isn't a valid message id

copper trail
rose tangle

but you already have the channel object?

using channel.messages.fetch will only fetch messages from that channel

wouldn't make much sense for it to also get from other channels

not that it can either way

copper trail
rose tangle

wdym?

copper trail

like a module export or import

rose tangle

I don't really understand

the error says youre requiring 'module.js'

and there isn't such a module

in case you wanted to require a local file you probably meant './module.js'

but that isn't djs related at all either way

copper trail

because what i have in my current file is just

rose tangle

you're supossed to know what your code does

copper trail

i do

just not know where to end or if its if enough

rose tangle

then how do you not know whether you need more code Thonk

if you know what it does, you'll know if it's lacking something

copper trail
rose tangle

and what are you having trouble with in the first place

steel trail
hot marten

Hey, user.banner returns undefined even tho the user has a banner, v14.19.3

steel trail

And what's filetitle.js? Rather weird name for your main file to run

sharp ginkgoBOT
rose tangle

@hot marten ^^

copper trail
steel trail

It definitely does not. Because you're making it impossible to help you when you do that. So good luck on your own

rose tangle

it's not sensible data in case you were concerned about that

and it should be main.js or index.js either way

copper trail

im just gonna try to figure it out on my own. sorry for bugging, just kinda feeling lost.

need to learn more

polar karma
rose tangle

it actually just looks like you were running node collector.js while having no file called "collector.js"

so yeah you need to brush up on your js/node essentials ^^

hot marten
steel trail

No

That fetches members

hot marten

with the user id

steel trail

<User>.fetch() would

steel trail
sharp ginkgoBOT

Despite sounding similar there is a distinct difference between users and members in Discord:

  • User: global Discord user data (global avatar, username, tag, id)
  • GuildMember: user data associated to a guild (guild, nickname, roles, voice, guild avatar, etc.)
  • Conversion: User ➞ GuildMember | GuildMember ➞ User
    * Note: Events received in cached guilds will often have both the member and user available, eg. interaction.user and interaction.member
hot marten
steel trail

You have the user already. Call .fetch() with no parameters on it

uneven plover

When using interaction.followup() is it possible to prevent it from being a reply? My issue is that I send an ephemal saying operation complete, and then folowup with a public message of the result, but that public message being a reply to the ephermal shows the operation complete text

rose tangle

to other users it won't show the text since they can't see the message

uneven plover

Oh, ok, perfect!

fickle trenchBOT

foo

rose tangle

it'll show like this

I'd show the confirmation in the same message as the question being edited

tired kindle

How to add buttons to activities? As the new Discord Social SDK has it but couldn’t find any example of it in the guide

red coral

You can’t reply to a modal with a modal. You can reply with a button or something asking the user to answer another modal

zenith violet

its a different sdk

which djs does not support

rugged coyote

*+9+

heady zodiac

where is the guide for component v2 on djs ?

i mean documentation

red coral
rugged coyote
hearty rain

For UserSelectMenuBuilder, is there a way I can limit the users that can be selected? I'd like for the user to pick only the users in a room, for example

finite brook

what the tag crwl mean?

i need to know, everybody is asking me this

fleet ridge

its me

rose tangle
calm maple

are builders or functions preferred? or just preference? ie:

const container = new ContainerBuilder().addSectionComponents((sb) =>
  sb
    .setThumbnailAccessory((thumbnail) =>
      thumbnail.setURL(
        pokemon.value.sprites.other["official-artwork"].front_default,
      ),
    )
    .addTextDisplayComponents((t) =>
      t.setContent(`**${name}**\n${description}`),
    ),
);

vs ```ts
const container = new ContainerBuilder().addSectionComponents(
new SectionBuilder()
.setThumbnailAccessory(
new ThumbnailBuilder({
media: {
url: pokemon.value.sprites.other["official-artwork"].front_default,
},
}),
)
.addTextDisplayComponents(
new TextDisplayBuilder({
content: ## ${name}\n${description},
}),
),
);

rose tangle

preference

calm maple

hm alright

rose tangle

pretty much the only actual difference is that the former lets you pass current data directly

but there's no difference if you're not doing that

calm maple

is there any way to just pass the objects directly? without using a builder or something since its kinda verbose
(although i guess you'd need to pass the other stuff the api needs?)

stable sun
calm maple

hm; this like isn’t a big deal at all i was just curious on if i could clean my code up a bit lol

rose tangle

and Chewinky said you can

calm maple

ty :D

swift heath

How do perms for userinstalled bots work like are they based of the person who runs the command perms or do they have a strict set of perms?

red coral

There's an enum somewhere with the error codes from discord, anyone know what that is and what the error code is for max amount of emojis in a server?

sharp ginkgoBOT

documentation suggestion for @red coral:
dtypes v10: RESTJSONErrorCodes - MaximumNumberOfEmojisReached
read more

red coral

Ah, that one, thanks

red coral

<Guild>.emojis.create returns a GuildEmoji, it also seems as if most of the properties can be null, why would it be the case if .name or .animated are null?

red coral
rigid ridgeBOT
rose tangle

@red coral ^^

red coral

oh sick thanks a lot

rose tangle

though it needs to be implemented for v14

stable sun

Yea

swift heath

How do perms for userinstalled bots work like are they based of the person who runs the command perms or do they have a strict set of perms?

loud quartz

user installed apps do not come with a bot that could have any permissions in the server

they are however interactions, so fall under usual set of permissions regarding interaction responses, some taken from the @everyone role

and the apps being able to respond non-ephemerally is controlled by the "Use External Apps" permission

swift heath

oh okay thanks

oblique talon

Does anyone have the part of the code that allows you to put files inside the Container?

sharp ginkgoBOT
raven hearth
{
                    name: "hours",
                    description: "the amount of hours to be applied",
                    type: 4,
                    required: true,
                    maxLength: 3,
                    minLength: 1,
                }

14.19.2 Thonk

rose tangle

minValue and maxValue, not maxLength and minLength

length is for strings

builders exist to avoid these specific things

or you can type the option

raven hearth
raven hearth
rose tangle

could check at the regexes escapeMarkdown uses, but it's not 100% reliable

sharp ginkgoBOT

function escapeMarkdown discord.js@14.19.3
Escapes any Discord-flavored markdown in a string.

modest surge

hi just a simple question is a tsx watch a ts-node thing or it can be use on something like

rimraf dist && npx tsc && tsx watch src/main.ts
topaz bluff

tsx and ts-node are 2 separate things but both accomplish the same goal. To run TypeScript code in real time

So, that script has redundant actions in it. There's no reason to compile your TS to JS (with tsc) before running tsx

modest surge

so whats better tsc tsx ts-node

or people preferred

topaz bluff

Depends. All TS code needs to be turned into JS at some point to run, and many just like to use it all the time...but if you want to use them:

tsc for production
tsx or ts-node for development...I think tsx is supposed to be better but it shouldn't make a huge difference

modest surge

so tsx on making the bot then tsc when is it done or ready to be published

unique shoal

I just use tsc --watch and the run the JS

modest surge

im really confused in typescript i only know the interfaces

its like coding in java

unique shoal

A little, yeah

modest surge
topaz bluff

you can use as much or as little of typescript as you want. at the end of the day, it's just type control for JS...it has a lot of power when it's fully utilized but you don't need to do any more than just controlling types

modest surge

tsx works too in production

topaz bluff
modest surge

oh just a memory

shell owl

Hello, are message edits rate limited by any chance?

topaz bluff

yes

pretty much everything is rate limited...but to what extent, depends on the action

modest surge

10 per hour i think

3*

shell owl

yea makes sense

thank you !

modest surge

why interaction.client.commands does not exist in ts

topaz bluff

interaction.client.application.commands

commands are stored in the application not the client

modest surge

so

interaction.client.application.commands = new Collection()

clear garnet
topaz bluff

no...you should not override the existing application.commands

clear garnet

It's a property you're adding onto the d.js Client

modest surge

i am making command handler

modest surge
sharp ginkgoBOT

We highly recommend you extend the Client structure properly instead of just attaching custom properties like .commands to the regular discord.js Client instance.

modest surge

so i am not using the discordjs one im making my own collection thingy

unique shoal

You always were

There is no discord.js one

modest surge

but its in discord js docs

sharp ginkgoBOT

guide Creating Your Bot: Command handling
read more

modest surge

client.commands

unique shoal

Yes, making your own is in the guide

modest surge
unique shoal

Because youre using TS

And the property doesn't exist

modest surge

so how

unique shoal

Which is not an issue in JS, but is an issue in a strict-typed language like TS

unique shoal

Or just dont attach it. Very little benefit honestly

The guide is kinda old and isn't written for TS projects

modest surge

ima use array instead

unique shoal

lol

yeah thats the problem meguFace

I dont mean to be rude but why are you using TS?

modest surge

or just variable = new Collection() then export it

unique shoal
topaz bluff

using an array instead of a collection will make no difference. a collection is objectively better since it's a map

unique shoal

From a command loader file utility or something

modest surge
unique shoal

Fair enough

modest surge

i only understand typescript in a react app

const commands: command[] = []
commands.push(command)

lol

unique shoal

no

topaz bluff

thats a good reason. typescript is designed to prevent you performing actions on a type that it doesnt recognize. the built in Client doesn't have a commands property, so you can either override the Client class to add a commands type, or you can store your commands somewhere else

unique shoal

Have you built a bot in JS before?

topaz bluff

no...do not store them in an array...just use a collection. a collection is a Map so it has helper functions that are extremely benefitial such as find and filter

modest surge
unique shoal

(I mean those are array functions too)

(The helpful Map ones are get)

modest surge

what do you use new Map or new Collection

unique shoal

Collection (or map)

modest surge

is it samething

unique shoal

no

sharp ginkgoBOT

guide Additional Information: Collections
read more

modest surge

this typescript thing keep me stressing

I dont see difference in Map and Collection i build same one before

unique shoal

I mean we're literally telling you that there are differences

Collection extends Map with additional functionality

topaz bluff

you dont have to use it...but it's objectively better for something like commands

modest surge

thanks got a new knowledge bout that

modest surge

how do u register a command in ts bro

zenith violet

same way as in js

Using the deploy script

sharp ginkgoBOT

guide Creating Your Bot: Registering slash commands
read more

modest surge

ok but i got one more question when exporting a command should i use module.exprots or export default or interfaces

modest surge
rose tangle
modest surge
rose tangle well what's the error

well first i make a js file not ts file inside a src folder now in the register command code i switch the file ends with js to .ts now i runned the code it give me a error that says : expression thing error so i remove the : in the async execute function so its likr async execute(interaction, client) and i runned again it give me a error of data not found but it was there

zenith violet

Probably because you export default but didnt adapt your imports

raven hearth

do i need to use a shard manager? previously i just used the client options but apparently v14 has changed stuff 🤔

zenith violet

If you set shards to auto djs should handle it for you

raven hearth

from what i recall it's 2,500 per shard

client.shard -> null

stable sun
stable sun
raven hearth
stable sun

Are you sure ur using v14?

raven hearth

yes

lemme get you the exact version

14.19.2

stable sun

Mb, had the main docs

client.ws.shards.size

raven hearth

alright nice! it works thank you

elfin basin

does channel.messages.fetch get all, or does it have a limit and you have to offset?

i imagine there is of course, but is there no way to filter it for say a given day

snow onyx

by default the limit is 50, you can change that to 100

You can, of course, work with filters as well, like before, after, around

elfin basin

is there an offset?

snow onyx

What exactly do you mean with offset

You can provide message ids to before/after/around, if thats what you mean

elfin basin

interesting

i guess i can use that as a stepping offset, like get 100, then get the last id of the 100 and get before of that and so on

clear garnet
elfin basin

yup thats what im looking for thanks thanks

latent hawk
abstract forge

in slash command options is there a way to like provide like suggestions?

sharp ginkgoBOT

guide suggestion for @abstract forge:
guide Slash Commands: Autocomplete
read more

abstract forge

cheers

latent hawk

What licenses does discordjs use? Is it possible to fork it create a own branch?

Legally speaking I mean the license regulates that

snow onyx

Apache License 2.0, means you can fork whatever you want, but you need to add a license and copyright notice and also list your changes.

latent hawk

Good because there is an important thing I want to change: Remove any kind of "Rainbow" in it

snow onyx

k

unique shoal

Do you hate the prismatic spectrum of light?

chrome cloak

how do i send an attachment from a buffer?

unique shoal

The AttachmentBuilder supports buffers

chrome cloak
sharp ginkgoBOT
potent burrow
steel yacht

Hi,
How to allow selecting only specific users in a user select menu ?
Thanks

snow onyx

you can't

steel yacht

Any alternatives ?

potent burrow

you can list out the users and give a button for selecting each one

steel yacht

That would limit the list to 25

snow onyx

autocomplete

thats all your options

steel yacht
sharp ginkgoBOT

documentation suggestion for @potent burrow:
dtypes v10: RESTPostAPIApplicationCommandsJSONBody
read more

unique shoal

Its a union of types but you can navigate from there

potent burrow

intellisense was not cooperating

hybrid olive

are context menu commands not allowed to have components?

potent burrow

what

that question doesn't make sense
no command can have components
messages have components
and u can send messages as responses to commands

unique shoal

Responses to them can, yes

hybrid olive

that's odd
is something wrong here then?

const {
  ContainerBuilder,
  SeparatorBuilder,
  TextDisplayBuilder,
  MessageFlags,
} = require("discord.js");

module.exports = {
  info: {
    name: "Meow",
    perms: [],
    dev: true,
  },
  run: async (client, i) => {
    if (!i.inGuild()) {
      const text = new TextDisplayBuilder().setContent("bwaaaaa :3");
      const sep = new SeparatorBuilder();
      const container = new ContainerBuilder()
        .addTextDisplayComponents(text)
        .addSeparatorComponents(sep)
        .addTextDisplayComponents(text);
      return i.reply({
        flags: MessageFlags.IsComponentsV2,
        components: [container],
      });
    }
  },
};

oh wait it's probably the dev flag
i'll try turning it off real quick

steel yacht
hybrid olive
snow onyx
steel yacht

Yeah I understood that

I guess that would be commandInteraction.awaitSomething then

snow onyx

not sure what you want to await here

steel yacht

Just like there are awaitMessageComponent and awaitModalSubmit functions to avoid requiring globally listening to events, is there one for autocompletion ?

unique shoal

no because autocompletes dont happen after interactions

steel yacht

Then there's also no way to verify who is querying the autocompletion ?

And no way to respond if they don't have the rights to access the autocompletion data ?

unique shoal

Of course there is

Listen to the autocomplete interaction via an interactionCreate listener

sharp ginkgoBOT
steel yacht

Okay
So, can the list show up before the user starts typing the first character, and is the list limited in number of values ?

Also, about responding to the user that they don't have the right to access the autocompletion data, I can only use the channel property for that, and therefore cannot use ephemeral ?

unique shoal

Yes (e.g, our /tag command, and yes)

No, it just fails

Theres no response until they execute a slash command

Why wouldnt they have rights to the data?

But still have rights to use the command?

steel yacht

No, they wouldn't have the right to use the command at all.

unique shoal

Then they wont be able to

You dont need to check yourself if you just use the permissions properly

steel yacht

Oh, you mean there's a role-based system to allow access to commands ?
That's interesting, although not applicable either in my case, because access control is not role-based

unique shoal

Ahh

Well yes there is, but I guess that doesnt help you then

I guess you could respond with a single choice that tells them access denied

steel yacht

Why not, lol
So what's the maximum number of items allowed ?

unique shoal

20 or 25, I dont recall

I think 25

Really anything more than 10 is bad autocompletion imo

steel yacht

Well, only one must be selected, but the option list might be bigger than 25

unique shoal

Thats why you filter based on what theyre typing

steel yacht

So they could only have a partial list before typing the first character

unique shoal

yes

Thats the whole point

Too many to choose from, so they type

steel yacht

Well, the thing is, the user doesn't necessarily know the content of the list

unique shoal

k i have no idea wft youre building lmao

steel yacht

An overly complex "security" bot

pearl roost

can i do something like this?

minor marten

It's an array also, I guess you could do flags: [flag1, flag2]

verbal vine

why buttons not working i copy this component code from ddev

unique shoal

wtf are those flags lmao

This looks like really badly AI generated trash

verbal vine

u talk with me?

unique shoal

yes

steel yacht
unique shoal

what about it doesnt work?

"not working" tells us nothing

verbal vine

lol

zenith violet

first of all there is no event named componentsv2

verbal vine
client.on("messageCreate", async(message) => client.emit("componentsv2", message))
unique shoal

why tho

still havent told us what isnt working

verbal vine

i want to make like this

this is my code's result

sharp bramble

Discord caches the slash commands locally and if I deploy new commands to the bot... the only way for them to appear is, I need to refresh/restart my discord.
My question being, where exactly are these commands cached locally?

dense jackal
verbal vine

thats a section component with a text display component and a button component accessory

sharp bramble

Where exactly should my question be asked?

unique shoal

Not specifically, no

There are builders

dense jackal
unique shoal

You still havent said whats not working

sharp bramble

Oh crazy, thanks.

dense jackal

but what they did wasn’t making use of a section, just text display with an action row

unique shoal

Finally. We got there from "why buttons not working"

verbal vine
dense jackal

they work, you can click on them lol

unique shoal

They work

Use your words, we cant help you if you dont explain what it is you need help with