#djs-help-v14

78874 messages · Page 77 of 79

torpid marsh

You mean link?with_components=true

loud quartz

Isn't it an option in the send options

It is indeed

sharp ginkgoBOT
torpid marsh

That is create option...

The webhook already exists.

vast nymph

that is actually "message create"

torpid marsh

Oh wait. I read it wrong.

Yes that worked.

orchid radish

Can I preset select menus to one of its own options eg how that menu looks when users select an option

proud arrow

Yes, for options you want to pre-select, pass default as true for that option

If it is autopopulating menu, then you need to pass default_values

sharp ginkgoBOT
proud arrow

How you would do with builders for example ^

cobalt valley

How can I disable role cache in discordjs 👀 also is it fair to disable or should I keep it?

velvet cipher

I think the question is rather why do you want to disable it?

cobalt valley
red coral

Depends if you need the roles cached ig, but bare in mind that a few of the helper functions rely on things that should be cached to be cached

You can also just see what’s using the most and disable/sweep those

shut musk

Yes I have it, it's just random when it doesn't show up

coral river

how do you use v2 components in .send again?

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.

stable sun
coral river

regular guild channel

stable sun

Then just the flag is necessary

flags: MessageFlags.IsComponentsV2 and use components to add components

The guide above covers the different types of components and where it can be used

coral river

alright thanks

red coral

With cv2, can you not put a mention in a heading?

… @red coral

For me it doesn’t work and just shows the string version

steel trail

Then that is not a valid mention. A mention has <@id> format

red coral

Ah Yh nvm

uncut mango

just says it has to be between 1 and 768 hours

loud quartz

sounds arbitrary then

just in a different range

uncut mango

maybe its so they don't have to update them on their end as frequently, i dunno

stray kraken

Hey their got a question regarding discord.js v14.25.1, just don't know where to ask because it might be a issue that i need to ask about privately

topaz bluff

... what type of question needs to be asked privately about an api wrapper?

stray kraken

not that just getting something about packages discord.js uses

i'm trying to find 2 different things at once as well so....

i've had about 5 dependabot security alerts opened on github with one of the packages on discord.js

snow onyx

if you are talking about undici, you can ignore that

stray kraken

okay wasn't sure because i had 5 of those come through

thank you gort for telling me because i got confused about it

subtle falcon

Is there a component for selecting a date ?

topaz bluff

not gonna say "planned" but highly requested and the interest is known

subtle falcon

Nice

lusty elk

has anyone else experienced type error with using a discord.js but, but the imported type just has { with: { "resolution-mode": "import" } }, which results in a type error? importing SlashCommandBuilder directly from node_modules instead of discord.js fixes it ..

unsure if its specifically a discord.js issue or some pnpm quirk

marble plover

but as it uses normal dependency and not peerdep, its highly likely to have version shift and conflicts

unique shoal
marble plover
lusty elk
fast shadow

Getting error "Module '"discord.js"' declares 'GatewayIntentBits' locally, but it is not exported." I'm on Discrd.js 14.24.0 and typescript 5.9.3. Attempted to reint my project still getting it, I also attempted to use the discord bot templates (bun - typescript) and still getting the same error. Any idea anyone?

EDIT: My import is: import { Client, GatewayIntentBits } from 'discord.js';

unique shoal
marble plover
unique shoal
unique shoal
fast shadow
steel trail
subtle falcon

Is it possible to have a description at the top of a modal ? (under the title)

wary coral
subtle falcon

Okay ty !

proper kraken

Hey.. Is there any repository which has a discord.js bot template? I’ll be starting out with bot development and the template will help me out with the basic structure.

Also which language is the best in use with discord.js? Javascript or Typescript

bleak owl

if you follow the guide, you can get yourself a pretty good starting template

shut sparrow
proper kraken
bleak owl

you'll definitely want to learn how to code first before making a bot

shut sparrow

yea then you should probably follow the guide

proper kraken

and about the coding language? JS or TS?

bleak owl

thats ultimately up to you

typescript is a bit more advanced than JS imo

proper kraken
bleak owl

avoiding that error from happening isn't possible. you need to make sure you're responding to the interaction properly

keen coral

could someone please link me components v2

fast shadow
rain forum

guys in modal
select menu and file
should be required ?
can i make it not required

sharp ginkgoBOT
topaz bluff

Yes. Just don't add setRequired on it

rain forum
keen coral

how do i do an embed without a side color?

tardy sable
sharp ginkgoBOT

guide suggestion for @keen coral:
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.

tardy sable
rain forum

what djs version are you on? be sure youre on latest

rain forum

latest

bleak owl

what is menu defined as?

tardy sable
rain forum

Ronaldo_3mk

how can i send all this

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.

rain forum

bro i didn't use required in anywhere

tardy sable

well then show your code so we can see

rain forum

I try to find where can i add setRequired

bleak owl

please show your code

your error stack will tell you where the problem lies

rain forum

id did it
menu default as required
i should to add setRequired

rain forum

i fix it
ty @bleak owl @tardy sable

keen coral
bleak owl

nope

rain forum

Guys how many the maximum button can I add in component v2

topaz bluff

there's no maximum for buttons... but there's a 40 total component limit for a Components V2 message

actions rows are still limited to 5

rain forum
topaz bluff

What do you mean "how"? That's the limit that not a technical limitation. It's an intentional one to discourage sending messages with large amounts of buttons.

If you need a user to have a lot of options to select, you should use a StringSelectMenu instead

rain forum

i mean how can 40 components make only 5 row

clear garnet

Because there's more components you can use at the top level than just action rows, e.g. separators or text displays

The 5 limit only applies to how many components you can put inside of an action row, if you so choose to use an action row in the first place

rain forum

If you want to add about 7 components, all for the Actions Row Builder, will they count as 7 only ?

rose tangle

action rows themselves are components

so they count

if you add an action row which has one button, that'd be two components

rain forum

ohhhhh

row with 5 button it 6 ?

rose tangle

yes

rose tangle

no, it depends on how many buttons each row has, it's different to have 7 rows with 1 button each, than having 2 rows one with 5 buttons and the other with 2

rain forum

yes i mean if all have 5

rose tangle

then you'd have 7 buttons + 2 rows = 9 components

rain forum

ty @rose tangle | @topaz bluff | @clear garnet

fervent bluff

Hey guys,
I keep running into an error that I’ve sent below, and I’m not really sure what’s going on. Is this an internet connection thing (I’m hosting the bot on a Google Cloud VM), or some other issue? They always come together at the same time in this order

fervent bluff

That’s interesting, cause I have several other bots on that same server, none of which are having an issue like this

tardy sable
lusty elk
steel trail
lusty elk
steel trail How was it typed in your interface? Where was it imported from there?

in my framework package it was typed as SlashCommandBuilder | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandsOnlyBuilder and then in my bot the interface is imported from my package, both my package and bot use the same version of discord.js and I've had this setup for months and only now had this specific issue

originally iirc I only had SlashCommandBuilder | SlashCommandOptionsOnlyBuilder

steel trail

Are both of them ESM or is one CJS?

lusty elk
gloomy flume

Guys
I gave a role the ban permission but users say that they can't ban anyone
even the users with roles way below theirs
am I missing something here?

Once a role has the ban permission and is above the others it should work
isn't that so?

stable sun
stable sun

Also can’t ban the guild owner

gloomy flume

Yep

stable sun

Not rly a discord.js issue tbh

Are you checking this code?

gloomy flume

Members can see that others haave the perms, but when checking yourself the perms don't appear
Overseer role has the ban and timeout perm

stable sun

Could ask in discord devs ig

It rly can’t be anything else

Except refresh Discord app ig

gloomy flume
stable sun

Is this a new Discord app view?

gloomy flume

Right-click on the user
and click on View in Mod view or something

'Open in Mod View'

stable sun

I don’t use Discord on my computer enough ig

gloomy flume

poggies

stable sun

You have ban permissions on 1 acct that has overseer, but not the other?

golden plank

could be something overriding the perms on per channel basis maybe

gloomy flume
stable sun
gloomy flume

when you right click on the user the ban button doesn't appear

stable sun

Does the guild require 2FA?

gloomy flume

Oooh, is that a requirement for ban perm?

snow onyx

If configured, yes

stable sun

Only if required by the guild

gloomy flume

hmm thank you for pointing that out
lemme check

stable sun

That’s my actual last reason I can think of

gloomy flume

Ah yes, that was the reason
Thank you very much ❤️

kindred dragon

Is there a limit to the length a customId for a button can have?

kindred dragon

thanks!

latent shadow

How can I make such a selectmenu in a modal because I still have a problem with it

karmic hedge
latent shadow

When I run the bot on the desktop, everything works as it should, but when I upload the bot to the hosting, the bot doesn't run.

latent shadow
karmic hedge
latent shadow
karmic hedge
karmic hedge

You should contact them

latent shadow

okay

kindred dragon

Is there a message component that allows the user to enter custom text?
Im looking for something like a select menu, but one where the user can customize input completely
Cant use message collectors since i need to update an ephemeral message when the user inputs the text and I can't do that without storing the message ID somewhere which I wanna avoid

low spear

modal

proud arrow

No, but you can use modal with text input

kindred dragon

thanks!

cunning ember

how many characters can we write in title?

snow onyx

45

proven thunder

I have a question, in discord.js docs it says CLIENT ID but when I put client ID in my code (in the second picture), I got the following error:

DiscordAPIError[10002]: Unknown Application
    at handleErrors (C:\Users\techn\OneDrive\Desktop\things\node_modules\@discordjs\rest\dist\index.js:762:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async SequentialHandler.runRequest (C:\Users\techn\OneDrive\Desktop\things\node_modules\@discordjs\rest\dist\index.js:1163:23)
    at async SequentialHandler.queueRequest (C:\Users\techn\OneDrive\Desktop\things\node_modules\@discordjs\rest\dist\index.js:994:14)
    at async _REST.request (C:\Users\techn\OneDrive\Desktop\things\node_modules\@discordjs\rest\dist\index.js:1307:22)
    at async refreshCommands (file:///C:/Users/techn/OneDrive/Desktop/things/functions/refreshCommands.js:14:7)
    at async file:///C:/Users/techn/OneDrive/Desktop/things/index.js:13:1 {
  requestBody: { files: undefined, json: [ [SlashCommandBuilder] ] },
  rawError: { message: 'Unknown Application', code: 10002 },
  code: 10002,
  status: 404,
  method: 'PUT',
  url: 'https://discord.com/api/v10/applications/1175040737784643637/commands'
}

It should be Application ID right? then shouldnt it be Application ID on docs?

it works with Application id

wary coral

I believe the application ID and client ID are the same

proven thunder

hm

loud quartz

They are the same, unless your app is really ancient

Like 2017 or earlier ancient

marble plover
tiny condor
marble plover

hmm oh yeah maybe its only about deliverables apps then

at very least with this user they gotta be using someone elses bot or alt acc

loud quartz

there are regular bots that are just old that have separate app id from bot id

nadeko for example

proven thunder

thats crazy!!

tardy sable

whats the max time limit i can set on a collector? is it same as interactions, 15 min?

odd stirrup

is there a max time? buttons for example never expire on their own

an interaction ends after at most 15 minutes, but something like a message component collector collects new interactions which have no need to be constrained to the 15 minutes of the original interaction that may have sent those message components in the first place

personally i dont use collectors, i keep things stateless and run everything through my interactionCreate handler, so i dont actually know for sure if they do have some sort of limit, but i would assume no

tardy sable

i also prefer interactioncreate but sometimes a collector is better for certain functions

i guess theres no max time limit since its optional?

odd stirrup

perhaps, either way i dont think there should be a max time limit, unless djs is adding arbitrary limits itself

tardy sable

i hope so otherwise im gonna move it to interactioncreate

rose tangle

if you have a permanent collector you could just have an interactionCreate listener

but yeah there's no limit if you don't set one

subtle falcon

Anyone has an idea of why the GET request for /guilds/{guild.id}/scheduled-events/{guild_scheduled_event.id} is slow asf ? Sometimes, it's fast and when I redo it, it takes about 5 seconds to resolve

tardy sable
rigid crest

is there a alternative i can do for this? when i turned on the bot to test the enabler to turn the setting to be true, as it was false the function just died now its ture (bot still on) it came to XX:55 to send the message and.... nothing was sent as the loop is no longer functional is there a way... i can have this so it doesnt just die bit still checks the source in the time allocated i did? cuz this is stressing me out, i dont want to have to keep rebooting the bot everytime a settign gets updated

async function runEventPing(client) {
  const enabled = settingsDB.get("isAutoEventMessageEnabled") === "true";
  if (!enabled) return;

  for (const guild of client.guilds.cache.values()) {
    startEventPingLoop(client, guild.id);
  }
}

client.on("clientReady", () => {
  runEventPing(client);
});
tardy sable
subtle falcon
tardy sable

there also isnt a cache for it so you have to make your own cache

subtle falcon

Yepp

wary coral
sharp ginkgoBOT
wary coral

Cc @subtle falcon

subtle falcon
wary coral
lofty topaz

hello

how can i do this in my bot?

commands section...

bleak owl
marble plover

i think also needs to be global with no permission restrictions (and yeah alota usage)

jaunty urchin

i have question please i have bot it's working in host but when i turn to another host it's online but not reply any message it this problem from my side or the host

tardy sable
jaunty urchin
sharp ginkgoBOT

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

  • Once you do, log relevant values and if-conditions
  • More sophisticated debugging methods are breakpoints and runtime inspections: learn more
tardy sable
jaunty urchin
tardy sable
marble plover

that means nothing here

lofty topaz

How can I speed this up?

bleak owl

you can't.

lofty topaz

I want my bot commands to appear in profile 😒

So I will wait

bleak owl

you just need to wait. this is completely irrelevant to discord.js

pearl roost

Why did I sometimes just don't get the log```js
console.log([CLNT] Client is ready as ${client.user.tag}!);

velvet cipher

Where is this log in your code?

Or rather, how are you registering the event?

pearl roost

Here it is

pearl roost

That happened once few days ago

halcyon bison
pearl roost Here it is

just to be absolutely sure there's no race condition or anything like that, could you also share where this function is being called?

pearl roost
halcyon bison
pearl roost Here it is

on the assumption this is handler in your main file, looks like you aren't awaiting it resulting in a race condition between registering commands/events and logging in
we also recommend separating command registration (and not registering on startup) since it's unnecessary to do so unless you've changed the command data
it's unnecessary to re-register commands if you only changed the callback that handles the interaction

pearl roost

So it is better to use await for the handler and also just stop re-register all the commands when there's nothing I change?

torn orchid

for the modal components, is there a way to make it where you can only put a positive integer?

tardy sable

use a text input and validate for positive integer after submit

wispy nimbus

is there an event to see if a mod has timed out a user or just audit log

tardy sable
proven thunder

how can i fetch previous messages from other users in a channel? like i want to fetch previous messages in a chat, how can this be done with interactionCreate

sharp ginkgoBOT

documentation suggestion for @proven thunder:
method MessageManager#fetch() discord.js@14.25.1
Fetches message(s) from a channel. The returned Collection does not contain reaction users of the messages if they were not cached. Those need to be fetched separately in such a case.


// Fetch a message
channel.messages.fetch('99539446449315840')
  .then(message => console.log(message.content))
  .catch(console.error);

summer thunder

see the doc link for examples on fetching multiple messages ^^

proven thunder

alright thanks for your help

proven thunder
summer thunder see the doc link for examples on fetching multiple messages ^^

it returns empty stuff.

Code:

  const channelMessages = await interaction.channel.messages.fetch({
    limit: 10,
    cache: false,
  });

const formatted = channelMessages.map((msg) => ({
  id: msg.id,
  author: msg.author.username,
  content: msg.content,                          
  timestamp: msg.createdTimestamp,
  isReply: msg.reference !== null,
  attachments: msg.attachments.map((a) => a.url), 
  embeds: msg.embeds.map((e) => ({             
    title: e.title,
    description: e.description,
    url: e.url,
    image: e.image?.url,
  })),
  hasAnyContent: msg.content.length > 0 || msg.attachments.size > 0 || msg.embeds.length > 0,
}));

Why is this

marble plover
proven thunder

now it works thanks!

marble plover

party_blob

proven thunder
topaz bluff

100 per request iirc

proven thunder

ok

orchid radish

Can the role option in slash commands support more than one role selection

wary coral

no, but you can use a role select menu(in a message or modal) to have a user select up to 25

orchid radish

Thank you very much :)

Oh one more thing can bots sync channels to categories

sharp ginkgoBOT
orchid radish

Awesome :)

jagged rock

how to get accurate guild member count without it going Request with opcode 8 was rate

tardy sable
sharp ginkgoBOT
orchid radish

Can I put select menus in modals

tardy sable
sharp ginkgoBOT

guide Modals
Modals are pop-up forms that allow you to prompt users for additional input. This form-like interaction response blocks the user from interacting with Discord until the modal is submitted or dismissed. In this section, we will cover how to create, show, and receive modals using discord.js! This page is a follow-up to the interactions (slash commands) page. Reading that page first will help you understand the concepts introduced in this page.

river flint

Just confirming <guild>.<members>.cache.get() will fetch if it does not exist correct?

unique shoal

no, because its get and not fetch

Other way around, fetch will get from cache first

river flint

I have DJS running on an API route that rapidly requests a bunch of user IDs, Im only grabbing ID, username, avatar and if they are in the guild, Im getting ratelimited if i hit it more than twice,

How can I tell DJS to populate the cache with every member?

rose tangle

it does that already

unless you tweak the cache manually

with sweepers or limits

otherwise, it's already stored in cache

unique shoal

guild.members.fetch() once

river flint
async getDiscordUserDataFromId(userId: string) {
        const guild = await this.getNCFCGuild()
        if (!guild) return null;
        const user = await this.users.fetch(userId);
        if (!user) return null;
        const member = await guild.members.fetch(userId).catch(() => null)
        return {
            username: user.username,
            avatar: user.avatarURL() || "",
            isInServer: member !== null,
        };
    }```

This is my fetching function, I can safely just fallback to cache?
rose tangle
unique shoal

You get the user by fetching the member anyway, so that can eliminate one call

rose tangle

or well, not fallback, it's what is checked first

unique shoal

You can also simply populate the entire cache with guild.members.fetch() and then get from there without fetching

river flint

But if the member is not in the server, the member call will fail no?

unique shoal

if you need to know that, yes

river flint

Im using the state of if they are in the community to unlock actions on the API

unique shoal

there isnt really any way to not be ratelimited with a lot of calls though, djs will queue them accordingly

Well you could go the other way, fetch the member first, then only fetch the user if it fails

That flow will still save calls

river flint

Such as ```ts

async getDiscordUserDataFromId(userId: string) {
    const guild = await this.getNCFCGuild()
    if (!guild) return null;
    let user = this.users.cache.get(userId);
    if (!user) {
        user = await this.users.fetch(userId);
    }
    if (!user) return null;
    let member = await guild.members.cache.get(userId);
    if (!member) {
        let members = await guild.members.fetch().catch(() => null);
        if (members) {
            member = members.get(userId);
        }
    }
    return {
        username: user.username,
        avatar: user.avatarURL() || "",
        isInServer: member !== null,
    };
}```
unique shoal

no

rose tangle

no, like mentioned that's what fetch does

fetch works like return this.cache.get(id) ?? this.callAPI(id)

unique shoal

In fact this is the exact opposite of what I said

river flint

Sorry ;w;

unique shoal

I would suggest

  • get the guild
  • fetch the member, which will use the cache if its there
  • if that throws, fetch the user, which will use the cache if its there
  • return the object
river flint

I see

orchid radish

do modals support file uploads similar to the slash command option

sharp ginkgoBOT
solar thistle

Modals only support text input

I forgot lowkey forgot

clear garnet

You might want to take a look at the Discord developer docs changelog

solar thistle

Send link I needa take a look myself

rose tangle

their question was already answered above

solar thistle

Thanks

If only dropdowns could surpass 25

rose tangle

that'd be a pain to navigate

solar thistle

It’s only scrolling down

I mean I have a vault feature for users to store items in but when a user places item to bet the dropdown is limited to 25 which means the inventory is limited to 25

Double dropdown would help but it would be a bit weird

low spear

when updated modals

unique shoal

when code is done, reviewed, merged and released

keep this channel for support please

winter merlin

hey.

Has the <TextChannel>.stopTyping(); method been removed?

wary coral
winter merlin hey. Has the `<TextChannel>.stopTyping();` method been removed?

If that was a function. Yes it was removed. When using <BaseGuildTextChannel>#sendTyping() It will resolve on sending a message. Per Discord

Post a typing indicator for the specified channel, which expires after 10 seconds...

Generally bots should **not ** use this route. However, if a bot is responding to a command and expects the computation to take a few seconds, this endpoint may be called to let the user know that the bot is processing their message.

stable sun

D.js used to send typing in a loop until you sent a message or stoped typing

This was removed in v13 iirc

open belfry

Hi, on my server, I wan't to detect when the member accept the Discord natives rules to accord him a role, actually I'm trying to make this using the GuildMember Flags specially "CompletedOnboarding", I don't have the onboarding active, only the rules, do you have a workaround ?

My actual logic is that :

const completedOnboarding =
  !oldMember.flags.has(GuildMemberFlags.CompletedOnboarding) &&
  newMember.flags.has(GuildMemberFlags.CompletedOnboarding);

if (completedOnboarding && config.noVerifiedRoleId) {
  if (!newMember.roles.cache.has(config.noVerifiedRoleId)) {
    await newMember.roles.add(config.noVerifiedRoleId);
  }
}
sharp ginkgoBOT
sharp ginkgoBOT
tardy sable

yes click the edit options to see all

tardy sable

whats the difference member.timeout and disableCommunicationUntil?

wary coral
tardy sable
sharp ginkgoBOT
tardy sable

i guess only difference is that you can put date here?

vague ridge

Anyone knows why i got this error on
Error executing command info: TypeError: interaction.options.getSubcommand is not a function

const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");

module.exports = {
  category: "general",
  data: new SlashCommandBuilder()
    .setName("info")
    .setDescription("Show info")
    .addSubcommand(subcommand =>
      subcommand.setName("server")
        .setDescription("Show server info"))
    .addSubcommand(subcommand =>
      subcommand.setName("gebruiker")
        .setDescription("Show user innfo")),
  async execute(client, interaction) {
    const subCommand = interaction.options.getSubcommand();```
sharp ginkgoBOT

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

function execute(client, interaction) { ... };
execute(interaction, client);
  • mismatch! you pass an interaction where the client is expected
  • mismatch! you pass the client where an interaction is expected
vague ridge
red coral Likely the above

So it's must be

const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");

module.exports = {
  category: "general",
  data: new SlashCommandBuilder()
    .setName("info")
    .setDescription("Show info")
    .addSubcommand(subcommand =>
      subcommand.setName("server")
        .setDescription("Show server info"))
    .addSubcommand(subcommand =>
      subcommand.setName("gebruiker")
        .setDescription("Show user innfo")),
  async execute(interaction, client) {
    const subCommand = interaction.options.getSubcommand();
red coral
vague ridge
wary coral
sharp ginkgoBOT
jagged rock

can you log if a message was forwarded

wary coral
jagged rock
wary coral

no, I dont belive so

jagged rock

y

wary coral

you can tell if a message is a forwared message tho

topaz bluff

what do you mean "y"

it's just not possible... when a message is forwarded is not emitted through the gateway as you don't control where the forwarded message went... the only way to tell is if a message is a forwarded message

odd stirrup

yea a forward is sort of like a screenshot of a message, you cant actually tell if someone else screenshotted something unless they send the screenshot and you see it

plus, similar to screenshots, iirc they take a frozen copy of the content and dont follow any edits made to the original

real python

Yo

Have anyone of you here build an instagram scraper?

red coral
real python

Bet

jagged rock
outer plume

hello. could member leave events ever be partial? and if yes, will Partials.GuildMember fix the issue of missing those events?

tiny condor

Frtch all your members when your bot starts then you will have more data

You will need the partial as well

outer plume

yes, that part is true. but also, does the member leave event not get emitted at all if that partial isn't present?

IF the "member" in the object is partial, that is

tiny condor

Uhh not sure I think it may not sometimes

outer plume

hmm. i'm also working with the same assumption currently. anyway, thanku

tardy sable

why i get twice the same event if a members get muted and shortly after a role added? it sends the role event twice then? even tho i have enforceNonce set to true

next wraith

error when i click on my modules v2

signal pumice
next wraith
signal pumice

yes

next wraith
signal pumice yes

but then ill get Error executing command help: DiscordAPIError[50035]: Invalid Form Body 4|rewrite | components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).

loud quartz

what is MessageFlags

wary coral

The message flag is the wrong value. The enum doesn't have underscores

loud quartz

nor isn't written in screaming case

sharp ginkgoBOT
halcyon bison
outer plume IF the "member" in the object is partial, that is

in general (not just for members), that is how partials work
if an event would emit a partial structure, and the associated partial isn't enabled, the event won't emit
as a general rule of thumb, delete/remove events tend to emit partial data unless the structure was previously cached
discord tends to only send the updated structure for update events, so the old structure would also be partial if not previously cached

loud quartz
} = require('discord.js');

so the answers you received are correct

it is not IS_COMPONENTS_V2

sharp ginkgoBOT
halcyon bison
tardy sable why i get twice the same event if a members get muted and shortly after a role a...

a mute and a role being added are separate changes that would each emit a guildMemberUpdate
they should emit as separate changes, but I suppose if they happened to be received at the same time, it's possible the oldMember could be cloned at the same time for both (showing neither change), then since the newMember is the actual cached object, it'd be patched with both changes
therefore your guildMemberUpdate handler would detect both changes both times
I can't imagine the window for this to happen is very big

even tho i have enforceNonce set to true
this is entirely unrelated unless your nonce is the same for both times you attempt to send the message
on the assumption this is some logging system and you're seeing both changes being logged twice, I suppose you could hash the changes and use that as a nonce or something

signal geyser

Good evening, I would like to know how to create buttons with different layouts. For example, buttons inside embeds, etc. I haven't found any documentation on this.

snow onyx

those arent embeds

signal geyser

I'd like to know how to make the buttons appear on the right side.

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.

snow onyx

those are sections

signal geyser
iron void

Hello

I have made a menu , when I chose any option the option still, i can’t chose same option

tardy sable
tardy sable
tardy sable
iron void
loud quartz

what about it

iron void
tardy sable
loud quartz

so are you guessing or are you making it do what was suggested

iron void

U knows

iron void
loud quartz

no, we don't do empty edits

loud quartz

all you need to do is just edit the message with the same components

loud quartz
iron void Guessing

then don't. if you think that line does what you were told to do, don't ask us if it does it, run it in your code and see

iron void

So that works?

loud quartz

you can check if it does

iron void
loud quartz

it will either do what you want, or error

we are not running your bot's code

iron void

Most likely, someone else was asked the same question, so what was your answer to him?

loud quartz

you asked how to reset selection, got the answer to edit the message to have the same components again

you came up with the code to do it (bearing one typo, but your IDE would hopefully catch it anyway)

try it out

iron void
iron void
iron void
loud quartz

honestly unsure, but it will not hurt to pass those too

i have foggy memories of content not changing when editing only embeds, but it was years ago and i might not remember it right

tardy sable

yh that still happens sometimes

wintry quartz

@empty spear hey could you add me? have something i wanted to ask you

topaz bluff
thin locust

Hello !
How's the deprecation of the "ready" event coming along ?
I've just today upgraded from v14.24.2 to v14.25.1 and I'm a bit confused since :

  • I no longer get the deprecation message for using the 'ready' event listener on the client
  • the 'clientReady' event never fires (I've been exclusively using the event for the past few weeks without a problem until today)
unique shoal

Sounds like a totally unrelated issue, nothing has changed about its deprecation

unique shoal
thin locust
unique shoal If I had to guess based on what you've said, the event isnt being registered, si...

Few things :

  • I haven't changed the way I register the event collector.
  • I am now at the moment exclusively registering 'ready' and getting no deprecation warning, and it fires correctly

Timeline of what happened for me:

  • upgrade to 14.25.1
  • 'clientReady' stops firing
  • I add back the client.on('ready', onReady) registering -> it fires, no deprecation warning
  • I comment-out the client.on('clientReady', onReady) registering -> nothing changes
unique shoal

Huh... are you sure you're on the version you think you are?

npm ls discord.js?

thin locust

that's a good question

Holy shit I'm stupid, the package-lock is somehow disregarded for an older version in the container it seems

unique shoal

All good, these things happen

thin locust

I must've broken my Dockerfile months ago 😭
-# edit : it was even more stupid
Thanks a lot

tulip torrent

Is it okay to put Japanese characters in setCustomId?

marble plover

i am not aware of discord having a strict regex there

wary ingot
grand scroll

hello how can I set VoiceChannel's Status in the bot?

shut musk

Considering discord usernames are unique, can we find a user directly by username?

steel trail

If you know what server you have in common with them: yes

sharp ginkgoBOT
marble plover

Filter members whose username or nickname start with this query
do be warned that it can return many results (inc from nicknames)

marble plover

i have wondered that

rotund slate

yo whaddup , im a bit fresh on this , so sorry if its a silly question , but is it possible to make a standard game invite like such ?

im sorta looking for a way to make source game invites in an integrated fashion since the steam protocol isn't supported

wary coral
rotund slate

i see i see

hazy agate

Hey i am sometimes getting „.permissionsFor is not a function“, im using it on a fetched discord channel

I wonder if this is a known issue, shouldnt that function exist on all channels?

bleak owl

can you show your code?

hazy agate
const discordChannel = await guild.channels.fetch(channel.id)
    .catch(async err => {
        if(err?.code === RESTJSONErrorCodes.UnknownChannel) await this.removeChatChannel(server, channel);
        return null;
    });
if(!discordChannel) return null;

const canManageWebhooks = discordChannel.permissionsFor(guild.members.me).has(PermissionFlagsBits.ManageWebhooks);
if(!canManageWebhooks) {
    await discordChannel.send({ embeds: [getEmbed(keys.api.plugin.errors.no_webhook_permission)] }).catch(() => {});
    return null;
}
red coral
steel trail

It doesn't exist on dm channels

What exactly is channel here? Because I'm confused why you need to fetch the channel in the first place here

hazy agate
hazy agate

And im very sure its not a dmchannel in any case

red coral

If you get the error, log the type or just the channel

Also, if channel doesn’t have an id, then that’ll return undefined which fetches all channels for that guild. Which ofc doesn’t have a permissionsFor method. Hence Qjuh asked what channel is

rose tangle

since it's not a Channel then it's fine

red coral

Oh well if not mb lol

rose tangle

I mean logging it is the best to figuring what it is tbh, my best guess is what you said, that channel.id is undefined

hazy agate

Okay i get it

cobalt valley

Can we make something like auto-resharding without a downtime in the built-in sharding in Discord.js?

brittle veldt

How did they send the container without the background ?

bleak owl

thats just muliple media galleries with separators

steel trail
polar bridge

I'm looking to do some unit testing for my bot and part of that is testing the messageCreate event. My initial thought was to capture a message from the raw event and then just replay it with emit('raw', ...) but it just seems to go to the void. My guess is that DJS just throws out the events since it is not logged in but I obviously can't do that during tests lol

Is there some way to override this behavior or am I forced to instead emit a messageCreate with a full Message instance? I took a look in the github but couldn't find any logic to throw out these events so take it with some salt

brittle veldt
steel trail
polar bridge
polar bridge
rose tangle

generally you want to test your methods, not the event itself

you can mock a Message instance or something like that and then just call your handler manually in your test

or make the handler accept the minimum amount of properties you need and then just mock that

the difference between that and an .emit test would be that one tests the event emitter (which you don't really need), at most whether the listener is appended but that'd be hard to miss

polar bridge
steel trail
polar bridge

👍

rose tangle
polar bridge

Yeah yeah I was just being lazy in the hopes that raw would somehow pass it around to messageCreate with the message instance lmao

rose tangle

it does that but then you'd need to mock a lot of data instead of just what your method accepts

so it'd be more work actually

polar bridge

Someone made the constructor private for some reason so TS complains that I can't create my own instance lmao```
TS2673: Constructor of class Message<InGuild> is private and only accessible within the class declaration.

rose tangle

oh, guess that makes sense, you're not really supposed to make a Message yourself

you can ts-ignore it ig if you really want a full Message

rose tangle

can even Pick it

polar bridge

I'll put in a quick pr to fix that, it's just one word. I'm not really sure why it's disallowed for cases like this lol

rose tangle

I've seen users make their own Message and Channel thinking that's how it works so it's understandable imo

polar bridge

Do people really do that? 😭

Well shit guess the private is staying then lmao

rose tangle

yeah quite a bit of guardrails are in place so newbies don't shoot themselves on the foot

as much as we don't want it, truth is a lot of people who don't know basic js or programming try to start making a full bot

polar bridge

God do many kitchen sink bots lmao

Anyways, thanks for the quick response, I'm not going to continue derailing this channel with random chatter lol

somber dome

❌ Panel Error: ValidationError > s.string()
Expected a string primitive

Received:
| undefined

at _StringValidator.handle (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2615:70)
at _StringValidator.parse (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
at TextDisplayBuilder.toJSON (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2074:33)
at C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2535:64
at Array.map (<anonymous>)
at SectionBuilder.toJSON (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2535:35)
at C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2237:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2237:35)
at C:\Users\Administrator\Desktop\Teams Bot\node_modules\discord.js\src\structures\MessagePayload.js:151:46
loud quartz

That's a cool error. Any more details?

somber dome
loud quartz That's a cool error. Any more details?

❌ Panel Error: CombinedError (2)
Received one or more errors

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

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

at _UnionValidator.handle (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1965:23)
at _UnionValidator.parse (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
at SectionBuilder.toJSON (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2536:37)
at C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2237:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (C:\Users\Administrator\Desktop\Teams Bot\node_modules\@discordjs\builders\dist\index.js:2237:35)
at C:\Users\Administrator\Desktop\Teams Bot\node_modules\discord.js\src\structures\MessagePayload.js:151:46
at Array.map (<anonymous>)
at MessagePayload.resolveBody (C:\Users\Administrator\Desktop\Teams Bot\node_modules\discord.js\src\structures\MessagePayload.js:150:49)
at TextChannel.send (C:\Users\Administrator\Desktop\Teams Bot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:191:61)

CODE :

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.

loud quartz

Sections need an accessory

Either a button or a thumbnail

If you don't need that, don't use sections

jagged rock

how to stop false posotvites in the memberupdate event shows roles added even tho i update my global avatar or is that just part of discord automation

topaz bluff
topaz bluff

Do you have the GuildMember partial? Is the old member state cached beforehand (aka, are you fetching all members on startup)?

jagged rock

yes i have the partial

topaz bluff

Then you'll need to check if the oldMember is a partial before comparing the roles as it could be null

jagged rock
topaz bluff

No. You do it once on startup and let the GuildMembers gateway event keep your cache updated

sharp ginkgoBOT
topaz bluff

It's a single API request. It returns the entire members list of the guild. It just takes time so do it as early as possible

jagged rock
topaz bluff

Then you can make it ignore all guildMemberUpdate events where oldMember.partial == true

coarse remnant
loud quartz

yes, but "gateway" and "http"/"rest" are still the overall discord's API

coarse remnant

i see, thank you for elaborating the terminology

marble plover
loud quartz

it doesn't hurt to open dapi docs

it's a single request, not pagination per se

coarse remnant
marble plover

lol

loud quartz

that's because you received 2500 events

marble plover
loud quartz

the api does yield all

just not at once

you don't get a gigabyte blob of 2.5m members

marble plover

or if the guild is over 75k members, it will only send members who are in voice, plus the member for you (the connecting user).

loud quartz

When initially connecting

please read entire paraghraph first

marble plover

ah, that blob of text is painful

loud quartz

last 2 sentences are of relevance here

marble plover

yeah i read it again fully now and feel dumb

im glad to not need member info, as idk how these bots deal with that spam

loud quartz

they receive it

marble plover

hahaha

imagine the cost of reconnecting to shard... well honestly that event is prob least of the conserns

loud quartz

the fact that one bot has "fried event loop", whatever that even means, does not mean that this request is a certified killer

loud quartz

reconnection is not reidentification

marble plover

like spawning new i meant, like when you need more as too many servers

loud quartz

there are ways to do it without downtime

marble plover

at least discord allows you to have many ws connections at same time :)

loud quartz

it involves some math and careful restarting, plus a way to stop one instance from responding

but tl;dr you spawn 2 bots at once, one with more shards

and then you stop the old one

marble plover

like many of same shard

loud quartz

it doesn't allow, it requires

marble plover

who needs over 2.5k servers

loud quartz
marble plover

seems like way better in scheme of ratelimiting haha

loud quartz

lack of gateway for starters

steel trail

If you have a gateway connection using it for fetching all members is the best option.

loud quartz

the second part is lack of the intent to receive the chunks (though the same intent also gates the rest request, so a moot point)

marble plover

time to make ws conn, just so i can request that

steel trail

None of this is djs related at this point though, so as tipakA already said: #general

marble plover

ye my bad

slim prairie

Hey how would i get the owner of a bot with or without discord.js is there anyway to see the bot owner without using discord.js?
Like is there an API to see information about a bot

steel trail

There is a way to get the owner of the bot you're running. But not of other bots

slim prairie
steel trail

Because it's not public information I'd say

warped badger

quick question: is there no way to get an interaction when a select menu is cleared (clicking the x on the right)? it seems to be just a client side change that unselects it but doesnt do anything. it's annoying me a little in a ui design sense that i have to also add explicit clear buttons when there's an x right there

unique shoal

Yeah the x doesnt send a new interaction, that selection is only in the client side cache

warped badger

aw :(

thanks

wary coral

I am having an issue with guildmember cache. I want to get all members of a role. It worked after the bot booted. but I think the members got sweeped. This is a single server bot. I want to double check my work here
I am going to add this to the client will it fix my problem

const client = new Client({
  intents: [
    Intents.Guilds,
    Intents.GuildMembers,
  ],
  sweepers: {
    ...Options.DefaultSweeperSettings,
    guildMembers: {
      interval: 86_400,
      filter: () => (member) => member.guild.id !== process.env.GUILD_ID,
    },
  },
});
unique shoal

Why do you have a sweeper at all for a single serrver bot?

therres no default sweeping behaivour on guild members

jagged rock

when is guild messages search getting added

red coral

bro is just got documented

jagged rock

it’ll be available in a couple days

red coral

whenever it’s ready djs doesn’t give eta’s

jagged rock

someone will push it on gh

red coral
wary coral
wary coral
red coral

Can you rephrase that? Idk what you mean

unique shoal

It will be added when the PR is reviewed, approved, merged, and released into the next stable version

unique shoal
wary coral
red coral Can you rephrase that? Idk what you mean

I have a command that is to return a CSV of the members with a role
The command was not working returning a incomplete list
I added Fetch to the ready event, it worked.
but then stopped seeming that the cache was cleared

red coral

Ig that is strange. Like mon I have no idea. Maybe you’re deleting members from the cache manually somewhere?

Does it just return no members?

wary coral

no it returned one or two

red coral

What happens if you refetch? I genuinely don’t know

wary coral

I am not sure. I will try and let you know

mental kite

i uploaded an emoji to my bot and tried doing

client.emojis.cache.get(this.EMOJI_ID)?.toString()
``` but i am getting undefined, is that a partial or something i need? (and yes it is the right emoji ID)
topaz bluff

client.emojis is for guild emojis

mental kite

thank you

marble plover
mental kite
marble plover

yeah that formatter i linked does it

mental kite
mental kite
sharp ginkgoBOT
marble plover
mental kite
loud quartz

Cause pretty sure during reconnects(?) or something like that we have to assume the cache is stale and redo it

I bumped into that myself a lot over the years, in a ~8k server iirc

You can probably find my and others' diggings if you search for memberCount from me in #internals

wary coral
steel trail
wary coral About 11K

On reconnect the member cache gets cleared. Should (re)fetch on shardReady instead of clientReady

wary coral

Is that on client or shard manager?

sharp ginkgoBOT
wary coral

Thanks

warm charm

Hi, webhook can send component v2 right? cause when i try to send it, it throw DiscordAPIError[50006]: Cannot send an empty message

proud arrow
warm charm

and i need to incl. flags: MessageFlags.IsComponentsV2, right

proud arrow

Yes

warm charm

thank you

marble plover

you also can "upgrade" a message from normal to cv2 with those 2 options, but not other way around

cobalt valley

Is it possible to read the 'about me' of some user through discordjs?

polar karma

Not through the API period

copper breach

How to get Upload File feature in Modals

sharp ginkgoBOT

guide suggestion for @copper breach:
guide File upload
File upload components allow you to prompt the user to upload a file from their system. Discord does not send the file data itself in the resulting interaction. You will have to download it from Discords CDN to process and validate it. Do not execute arbitrary code people upload via your app!

copper breach

Ok

wary coral

To clarify the linked guide section explains how to add the file upload component to a modal

tiny condor

shardReady fires no matter if you have sharding or not right?

marble plover

i mean you always at least one shard :)

i can't see any reason it wouldnt

tulip torrent

Is there a way to determine if a user icon is the default one?
Perhaps using a hash?

tardy sable
sharp ginkgoBOT
tulip torrent

Even with icons like this?

hazy agate

How is it that there can be DMChannels in guild.channels.cache

tardy sable
tardy sable
tulip torrent
hazy agate
tardy sable
marble plover

i remember hearing there was 25 pfps made, but idk if all are usable

(all i know is in mobile app apparently on user creation it suggests some)

marble plover
marble plover

oh so it really is just those 8

good to know

tulip torrent

👍

loud quartz
hazy agate
hazy agate
rose tangle

that'd be a cache.set()

you aren't using that anywhere?

loud quartz

or an accidental = instead of == / ===

brave moth

Is this the proper way to retrieve the values of a modal string select menu interaction.fields.fields.get('eat').values; confusedcat

stable sun

No

interaction.fields.getStringSelectValues("customId")

brave moth

Thank you so much!

sand minnow

am I able to change the bot's avatar and username only in one server?

sharp ginkgoBOT
sand minnow

thanks!

I'm curious why does setting like banner: null, and banner: "" not remove it?

trying to remove the banner and bio

marble plover
sand minnow
marble plover

Ah i dont think thats possible without also resetting ur bots main

sharp ginkgoBOT
wary coral

here is the Discord doc for the end point it is not imidately clear to me how to remove the banner

marble plover
wary coral

I guess I am just miss understanding what "default discord style" means

rigid ridgeBOT
rose tangle
hazy agate
rose tangle

check tipaka's comment

hazy agate

no

i wouldnt do .channels.cache === 'to idk what this would be'

rose tangle

not that, assigning a channel instead of comparing

just double check all your comparisons are with == or ===

otherwise, show how you are fetching the dmchannel initially, not getting it from cache

hazy agate
hazy agate
rose tangle

can you show that file?

hazy agate

when i refetch all channels theres no DMChannel but it stays in the cache

hazy agate
rose tangle can you show that file?

its on entitlement create im just doing

        const user = await entitlement.fetchUser();
        logger.info(`Entitlement created by user ${user.displayName} (${user.id})`);
        const dm = await user.createDM();
        await dm.send(getReplyOptions(keys.custom_bot.success.subscribed, await ph.commandName('customize', true)));

on another note im getting this error when simply doing guild.members.fetch sometimes

loud quartz

We know our code, we don't know yours

hazy agate

dude im just doing guild.members.fetch

loud quartz

Like for example that "fetchMembersIfCacheDiffers" cathes attention

hazy agate

well im not making guild.shard undefined

loud quartz
hazy agate
    if(guild.memberCount !== guild.members.cache.size) await guild.members.fetch();
``` this is the entire fetchMembersIfCacheDiffers
tribal birch

and just use cache

hazy agate

bruh goodbye memory

tribal birch

arent u killing memory this way same way

hazy agate

no its only limited guilds

loud quartz

If it's undefined it would most likely mean it's not a guild in the first place

tribal birch
loud quartz

Reconnects clear cache anyway so that fetch is still useful

hazy agate

well discordjs keeps track of members afaik by gateway events or fetches or whatever

so most guilds will have valid members

tribal birch
hazy agate

i only need to fetch members in specific cases

loud quartz

That's why they are fetching them

tribal birch

they will by events but not all of them

loud quartz

If they don't have them

And need them

hazy agate

it doesnt even matter, theres an error and its unrelated to what we are discussing

tribal birch

right, my bad

hazy agate

np

im fetching members so that i can check whether a member has specific roles

tribal birch

one question do u use typescript

hazy agate

apparently fetching a single member isnt enough for that (not sure but thats probably why i wrote the code like that)?

hazy agate
tribal birch
hazy agate

jsut look at the stack trace not sure it could be anything else

tribal birch
loud quartz

guild.shard is a getter

tribal birch

and that COULD give that error idk never seen it

loud quartz

What's guild.shardId on that guild

loud quartz
hazy agate
loud quartz

and guild.client.ws.shards?

sharp ginkgoBOT
hazy agate

collection of one shard

loud quartz

With id of

hazy agate

0 actually but im evalling this from a different shard than the code is running it from

wait actually idk

well its 0

loud quartz

Are you fetching guilds

hazy agate

and the guild.shardId is 7 but doesnt that just mean what shard the guild is "assigned" to

hazy agate
loud quartz

don't

hazy agate

instead? and why?

loud quartz

You have fetched a guild on a shard it doesn't belong to

loud quartz

Ask the shard that has it to give you the data

hazy agate

what thats a thing, that breaks stuff?

loud quartz

Instead of fetching the guild locally

hazy agate

so is this only for guilds or for other data too?

loud quartz

All

But some stuff breaks more than other

hazy agate

so basically never do fetch but always like shrad.getClientData or broadCastEval on that specific guild.shardId

loud quartz

You can broadcastEval too, but don't try to pull entire Guild if all you need is it's name

Or don't try to pull all thousand members from other shard just to count how many you got

The shard that already has that data is already capable of counting it and returning you the number

hazy agate

well i often need a guild object to do operations on it, i could just pass the id and then broadcastEval whenever i need to operate on it

loud quartz

Yeah

Do that. Tell relevant shard to do work on guild it has

hazy agate

this is new to me, didnt think that could make issues moderately annoying

loud quartz

Because a guild can only ever be on one shard

You fetch a guild that will then no longer anyhow update, and it might have less data than the guild received on login

hazy agate

so could this also be responsible for the permissionsFor issue ive had previously

loud quartz

Dunno

Sounds unrelated, but i guess you could revise your code now with this knowledge

hazy agate

okay time for refactoring, gtg good night thansk for helping

loud quartz

And maybe you'll find something similar

tribal birch

if i put id of a category id

const ignoredChannelIds = ['1461151996550582446'];

if (ignoredChannelIds.includes(message.channel.id))

would this work (its a category not a channel)

wispy pumice

....day, uh... whatever it is until new modal components are integrated within d.js

tardy sable
rose tangle

categories are channels, it's just not possible for message.channel to be one

tribal birch

so what do i do

tardy sable

category is message.channel.parent

rose tangle

do you want to check the channel's category or where is your category?

rose tangle
wispy pumice

using the indev wouldn't be a good idea for me
and from my experience of using hybrid raw API and d.js... they aren't well.

tardy sable
wispy pumice
rose tangle

it'll be announced in #announcements with an everyone ping so there shouldn't be a need to remind specifically someone

wispy pumice

alright then, appreciated meow_thumbsup

torn orchid

when i deploy my deploy-commands.js script

DiscordAPIError[50035]: Invalid Form Body
9.options[2][APPLICATION_COMMAND_OPTIONS_TYPE_INVALID]: Sub-command and sub-command group option types are mutually exclusive to all other types
wary coral
sharp ginkgoBOT

To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.

rose tangle

specifically the 10th command you're deploying has both subcommands/groups and regular options

torn orchid
rose tangle

we know what it means so it's not really helpful, you're going to need to log your commands before deploying

torn orchid

all of them?

rose tangle

I don't know if the order of your commands is constant and they're deployed in bulk so yeah ideally

you can also just log the names in the same order

torn orchid

in deploy-commands.js?

rose tangle

yeah

torn orchid

oh yeah, it does go in the same order

like after the last one it says
Started refreshing 27 application (/) commands.
then errors

rose tangle

"after the last one"?

can you show your code?

torn orchid

yup

rose tangle

okay and does it still specifically say 9.options[2]... ?

torn orchid
rose tangle

then the issue would be the 10th command you logged

torn orchid

alright

unique quest

Hi! Veteran here (im very lost with v14)
when I have
await interaction.reply({content: `${emoji} ${result.message}`, ephemeral: true})
it says its deprecated but
await interaction.reply({content: `${emoji} ${result.message}`, flags: MessageFlags.Ephemeral})
doesnt work either
would appreciate some help!

This is the error message
ReferenceError: MessageFlags is not defined

rose tangle

you need to actually import MessageFlags

that's just how js works, nothing is imported by default

unique quest

Okay thanks! My bad, thought I was missing somethng else

true dew

it's fine to see 4 vulnerabilities (3 moderate, 1 high on discord.js 14.25.1?

unique shoal

Yes, they're related to undici and dont impact discord.js usage

lusty elk
proven thunder

can threads be created with it being never archived or smth?

vague tendon

Error: Expected the value to be an object, but received string instead

when using an unicode emoji in a button inside a section

in a normal button it works, it errors only if the button is an accessory

summer dune

Can you put emojis into a modal?

marble plover

otherwise you can make a bot that auto-unarchives them

wary coral
wary coral
empty hazel

Hiii

wary coral
wary coral
ivory spruce
sharp ginkgoBOT

guide suggestion for @ivory spruce:
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.

ivory spruce

and they added the button by components v2 right

signal pumice
vestal sun
wary coral
summer dune
wary coral

oh no, users can not submit custom emojis

marble plover

but if they are smart, they can manually construct the <:name:id>

(ie if you're going to just directly use the content for a message)

vague tendon

setButtonAccessory gives me a button builder as parameter

signal pumice

then you need to use ButtonBuilder
like setButtonAccessory(new ButtonBuilder().setEmoji(emoji))

vague tendon
wary coral could you show your code?

im following the guide basically

const exampleSection = new SectionBuilder()
    .addTextDisplayComponents(
        (textDisplay) =>
            textDisplay.setContent(
                'test',
            )
    )
    .setButtonAccessory((button) =>
        button.setEmoji("👍").setCustomId('exampleButton')
      .setLabel('Button inside a Section').setStyle(ButtonStyle.Primary),
    );

interaction.reply({
  components: [exampleSection],
  flags:[
    MessageFlags.IsComponentsV2
  ]
})
vague tendon
wary coral
wary coral
vague tendon

discord.js

import {SectionBuilder} from "discord.js"

wary coral

ok, just checking

one sec I am going to try and relipicat the issue

ivory spruce
wary coral
wary coral
ivory spruce
sharp ginkgoBOT

guide suggestion for @ivory spruce:
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.

wary coral

Your going to need the read the guide no one here is going to do it for you

ivory spruce

ty

copper breach

Ok

wary coral
vague tendon

so basically it's a bug and the workaround is to pass the correct builder?

loud quartz

it's not a bug, it's by design

the callback passes in a /builders class, not the discord.js class

vague tendon

so this is not going to be changed?

loud quartz

doubt because instead of using callback you can just make a new discord.js class and pass that

vague tendon

well yeah but i don't see the point of passing a builder to a callback if i still need to create my own instance

loud quartz

i wasn't part of the design

vague tendon

fair point

wary coral
loud quartz

can't tell you if it was more of a idealistic reason, or more of a technical because builders aren't actually part of d.js

making them return discord.js classes would mean you couldn't use them without discord.js, which ruins entire point of it being a separate package

queen vale

Hey - is the auto role assignment in stable djs yet?

loud quartz
vague tendon

i see

queen vale
loud quartz

correct

queen vale

Is there a list of what's needed until next version releases?

winter mason

I've been facing this error and I know of no clear source/origin that's causing this.

 DiscordAPIError[10062]:Unknown interaction
File "/opt/magpie-khxyro-yt/app/node_modules/@discordjs/rest/dist/index.js" , line 762 , col 17 , in handleErrors
     throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
File "/opt/magpie-khyro-yt/app/node_modules/@discordjs/rest/dist/index.js" , line 866 , col 29 , in runRequest
     const handled = await handleErrors(this.manager, res, method, url, requestData, retries);
File "native" , line 7 , col 39 , in processTicksAndRejections 
loud quartz
sharp ginkgoBOT

tag suggestion for @winter mason:
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
winter mason
hoary rock

Does anyone have the link to docs/guide for when they added channel, roles and users select menu inside of modals

sharp ginkgoBOT

guide suggestion for @hoary rock:
guide Modals
Modals are pop-up forms that allow you to prompt users for additional input. This form-like interaction response blocks the user from interacting with Discord until the modal is submitted or dismissed. In this section, we will cover how to create, show, and receive modals using discord.js! This page is a follow-up to the interactions (slash commands) page. Reading that page first will help you understand the concepts introduced in this page.

Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.

client
    .on("debug", console.log)
    .on("warn", console.log)
  • Note: if you initialize your Client as bot or other identifiers you need to use these instead of client
  • If the output is too long to post consider using a bin instead: gist | sourceb.in | hastebin
brave wagon

Can I use warn button?

.setStyle(ButtonStyle.Warn)

is it wrong?

wary coral
winter mason
wary coral
loud quartz

Warn style doesn't exist. if it did it would be listed

winter mason
brave wagon

I thought it was real

loud quartz

or feedback

loud quartz
brave wagon
wary coral
loud quartz
winter mason
loud quartz

catch your promises

winter mason
loud quartz

and see what throws?

you have an error of unknown source, that has only so many possible reasons

winter mason
sharp ginkgoBOT

Common causes of DiscordAPIError[10062]: Unknown interaction:

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

It is one of those three things

loud quartz

the Promise rejects with that error

you gotta find which one

to have a chance on figuring out why

proven thunder

can i .editReply interaction multiple times?

proud arrow

Yes, as long as it is within 15 min of interactions acknowledgement

proven thunder

alright

pearl roost
loud quartz

it says exactly why and what you need to do

sick rover

Hey so curious question, with interactions v2, say if you wanted to edit a specific field to replace buttons with a select menu, as easy as embeds, would you have to replace the ENTIRE container, or can you js edit that one field of the container where the interactions are

tardy sable
sick rover

that's so lame

tardy sable

you have only spliceComponents that might be useful for you

sharp ginkgoBOT
wary coral

you can recreate the builder from the message component data. then edit

shell girder

Is there a way to set permissions for threads created in channels?

wary coral
shell girder

I understand, thank you.

pearl roost

What is the different between this two? Is it only for the developer or the user can see it too?

sharp ginkgoBOT
pearl roost
hybrid fable

The latter is a group of the former
Sub commands have a limit, i think its not particularly generous.
Lets assume it would be only 10 sub commands you can have (which is probably wrong)
With sub command groups, you could have 10 groups instead of 10 subcommands.
Those 10 groups can then themselves result in a lot more sub commands than you would have otherwise.

But in short, the latter is a group for the former

I did not find groups particularly fun to use from a user perspective, and since I dont really need 100 sub commands, I tend to not use them

steel trail

It's 25, so 625 sub commands

But grouping has more uses than just "I need more than 25 subcommands". /settings add user vs. /settings adduser makes more sense semantically

marble plover

sadly they arent as much independent as people want. mainly as they still only have same perms as top level and in code the subcommands are just "options"

smoky grail

I updated to discord.js version 14.25.1 and it says there's a high vulnerability and a moderate vulnerability what do i do, how do i fix it

snow onyx

if its undici you can ignore it

smoky grail

Okay yeah it's undici

reef rover

I need help disabling the discord server embed of the message, I've tried putting the discord gg link in < > but that didn't work
Is there a way to send a message with disabled embeds?

tardy sable

set in a container or embed instead

reef rover

Does my bot need the EmbedLinks permission to send embeds to a channel?

Reason I'm avoiding containers or embeds is because of this, I want the bot to send this message on invite to a channel he has access to sending messages to, and I want to avoid looking for a channel with embedlinks permission

marble plover
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.

reef rover

appreciated

marble plover
reef rover

Alright got it, many thanks

jagged rock

how come my command name change isnt deploying or changing via / my bot is sharded also any reason for this ?

topaz bluff
  1. Are you registering your changed command names with Discord? Updating your code alone doesn't update the commands
  2. Have you restarted your Discord Client (the app itself, not your bot) with Ctrl+R?
jagged rock

using rest to register commands usualy it updates straight away now i changed a commands name due to inccorect spelling and its failing everytime i run the command

topaz bluff

Define "it's failing"

brave moth

Is there a way to convert a JSON modal like this (made with https://modal.builders/) to an actual modal with discord.js?

  "title": "Modal",
  "custom_id": "modal",
  "components": [
    {
      "type": 18,
      "label": "Text Input",
      "component": {
        "type": 4,
        "custom_id": "46fa1bad6b864cfca3603b70794bcb0e",
        "style": 1
      }
    }
  ]
}```
jagged rock
halcyon bison
brave moth
marble plover

yeah

brave moth

Wow this is truly a dream coming true 🥹🥹

dry star
brave moth
dry star
brave moth

I thought I had to build a manual parser for my bot to understand this JSON modal, but discord.js is just perfect froggiggles

odd stirrup

ModalBuilders have that toJSON() method so they work fine, you can add that method to any other object, or you can use json directly

brave moth

JDA doesn't seem to have this PikaThink

velvet cipher

It's just the raw JSON that discord's API accepts, nothing magical about it. Any library that can send a request to discord can also do this

javascript just happens to have very nice syntax for JSON, hence the "JS" part of JSON

naive mango

There is a function for get the list of joins request

tardy sable
naive mango
tardy sable more context?

I have a server that is in ‘ask to join’ mode, and I would like to create a bot that gives me the list of people who have submitted a request with discord.js v14

tardy sable
velvet cipher

How does someone submit a join request?

reef rover

should my bot fetch it's member self in a server before like checking for it's member permissions in a server? Or are those always in cache by default on guild join or boot up? I have the Guilds & GuildsMembers intents.

tardy sable
tardy sable
reef rover
tardy sable
marble plover

like you can customise how cache works

like making agressive sweepers or just disabling it

halcyon bison

aside from that however, it should be cached on ready with the Guilds intent

reef rover

alright thanks all

marble plover
soft lance

Is fetching the audit logs the only way to figure out who deleted a message? I have a problem where sometimes the message deletion doesnt get logged in audit logs and thus i cannot find who deleted it

marble plover

user self deletes & bot deletes (not bulk) dont get saved to audit log

soft lance

ah

coral river
RangeError: Value is too large to be represented as a JavaScript number: 1424408311582953628
    at Object.find (file:///C:/Projects/Shockwave/db/db_handler.js:44:30)
    at log (file:///C:/Projects/Shockwave/src/log.js:6:33)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  code: 'ERR_OUT_OF_RANGE'
}
```I understand what this error means but I keep getting it when using interaction.guild.id and I am not sure what to do to fix it?
topaz bluff

Are you casting the ID to a number at any point?

coral river

the chain of me using the id is a bit confusing since it goes from a command to a function to my db handler

erroring at every step of the way

Ah, I have guildId set to a strict interger in the db handler, could that be the issue?

topaz bluff

Yes that is where I assumed the issue probably was. It's not necessarily an issue to do that, you just need to ensure that the JavaScript side of that logic always handles the id as a string and the DB itself does the conversion to and from int to str