#djs-help-v14

78874 messages · Page 22 of 79

prisma ruin

yes

zenith violet

Thats on you then. Make a handler formthem

Just like you did for your commands

but now for components

prisma ruin

but yeah u gave me an idea, ill just make a secondary event handler inside my interactioncreate and make files for every component

topaz bluff

you can set up your selectMenu handler just like the slash command handler...then make handler files just like slash command files

prisma ruin
zenith violet

An event handler isnt a command or component handler

sharp ginkgoBOT

guide suggestion for @prisma ruin:
guide Creating Your Bot: Command handling
read more

prisma ruin
zenith violet
prisma ruin

no issue in sight because im not talking about a command handler, im talking about an event handler

zenith violet

Use a handler similar to the command handler for your select menus

If you refuse to use one, yes, you're forced to put everything in your interactionCreate file, thats a you issue then

zenith violet

Thats not an event handler then

Event handker handles events

You are looking to make a handler to handle select menus

Those are not events

Those are message components

prisma ruin

im looking to make an event handler to handle all event in a way that i can clearly separate them, i just gave selectmenus as an example

topaz bluff

or dont handle them with interactionCreate at all and only use collectors and handle them in your command files

prisma ruin
zenith violet

Just edit it to use select menus

prisma ruin

but ok i already figured it out

pearl hazel

i use this to copy pictures from a message but it's look like this
user.send({files:msg.attachments.map(x=>x)})

happens to all attachments

molten holly
snow onyx
sharp ginkgoBOT
molten holly

thank you so much

wild thunder

Neich question, if the bot has the GuildVoiceStates intent, will it know of all users in a voice channel, or do I need to fetch members prior?

steel trail

All members in voicechannel will be sent to your bot on login. So unless you limit cache it will know

wild thunder
snow onyx

that intent gives you all relevant data, you dont need to fetch anything

wild thunder

Sweet, sounds good, thanks both

toxic moat

hello guys, is possible to check if user have a tag? (i mean the tag near to the username - in my case SCLB)

snow onyx

Its not documented by discord, thus not supported in discord.js
You can however fetch the user manually via the API which includes tag data.

worthy tiger

what would cause shardCreate to be called almost every minute? (same shard keeps recreating)

it worked before but started freaking out tonight, can‘t see any errors or vps issues

mental silo

getTextInputValue()
Returns an empty string for non-existing fields right?

snow onyx

No, it throws an error

mental silo

ah damn

actually not too bad i can just simply not call the function if I don't need it

If a field exists but is empty, that one will be an empty string tho, If I remember correctly

logically

wary coral
snow onyx

I'm basing my answer off the docs and the linked code, and it definitely should

mental silo
steel trail
steel trail
snow onyx
steel trail

That wasn't the question though

wary coral
snow onyx

we are talking about non existant fields

not empty fields

wary coral

Oh my bad

snow onyx

although I could have sworn there was the ability to provide a boolean to that function so it doesnt error in earlier versions

mental silo

This should work I guess

//...
   async createCommonPost(interaction, category, fields, baseData) {
    const { client } = interaction;
    const isForHire = category === Categories.ForHire;
    const workExamples = isForHire ? fields.getTextInputValue('workExamplesInput') : null; // <-- Avoid erroring if modal doesen't contain work example (non-for-hire) 
    const imageRegex = //...;

    const postData = {
      ...baseData,
      title: fields.getTextInputValue('titleInput'),
      description: fields.getTextInputValue('descriptionInput'),
      payment: fields.getTextInputValue('paymentInput'),
      other: fields.getTextInputValue('otherInput') || null, // <-- Empty optional fields are empty strings afaik
      ...{ work_examples: workExamples },
    };
//...

That condition makes it kinda messy
But probably bad practice to call a function if we literally don't need it anyway

worthy tiger
mental silo

Idk if Discord does that logic on the client or server, if someone could just send fields which the modal doesent initially contain

steel trail
worthy tiger

Wait sorry, it's not shardCreate that is being called every minute, it's shardReady

steel trail
worthy tiger

14.18.0

steel trail

Update to 14.20.1

worthy tiger

I only have 14.20.0 and 15.0.0-dev versions to pick from

snow onyx
steel trail

Oh, mb, 14.20.0 then kek

worthy tiger

There are no breaking changes from .18.0 to .20.0 I suppose?

snow onyx

breaking changes would change the 14 to a 15 :P

worthy tiger

Awesome, thanks I'll try that

vital cliff

is it possible for my discord.js bot to relay a voice message from one channel to another?

steel trail

Yes, but only by using raw API, since sending voice messages isn't documented by discord

hollow oriole

why doesn't this work?

polar karma

You tell us - do you get an error?

hollow oriole

no, i do not get an error but the image is the same

polar karma

There's a whole lot of context missing then

steel trail

Better question would be: why do you mix builder and JSON like that?

royal atlas

what do i use to control the discord bot though a rest api without using the full discord.js? i forgot what you call it, where the bot status is not shown

molten storm

How can I check what guild tag a user has? Can I check what guild it is?

sharp ginkgoBOT

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

fathom sand

One of my friend want to start a new project with bun and I was wondering if discordjs run well under it?

sharp ginkgoBOT

tag suggestion for @royal atlas:
HTTP-only applications receive interactions through HTTP webhooks instead of the Discord Gateway. Bots that are not connected to the Gateway, but use HTTP interactions appear as online without a status. Discord.js does not support HTTP interactions. Use discord-interactions instead.

open vale

hey is it possible to get the tag server of a user with djs or not again ?

snow onyx

Its not a documented feature by discord, thus not available in djs.
You can fetch the user from the api directly tho, there its included.

open vale
snow onyx

Its available in the API but not documented by discord, yes.

vital cliff

uhhh does anyone know what error gets thrown if the server emoji limit is reached and the bot tries to create a new emoji?

hollow oriole

is there any way to decrease the size of the img?

scenic berry

hello how can i able to make this command option to be multiple roles?

ex:
/security whitelist:@role1 @role2

wary coral
sharp ginkgoBOT

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

open vale
snow onyx

like I said, its not supported in djs, thus the event wont work

scenic berry
topaz bluff
open vale

im trying this sir, userUpdate doesn't list the tag, im trying with guildMemberUpdate
edit : good with guildMemberUpdate

bleak owl

i’m not sure why you’re not quite understanding that the user guild tag isn’t documented nor available in d.js

you need to request it on your own through a rest request

we can’t keep repeating the same thing

topaz bluff

Also I don't think servers tags would be part of guildMemberUpdate, even after it's documented, as you can't set your tag on a per-server basis

bleak owl

it wouldn’t yeah since again, it’s not documented nor available in d.js

open vale
bleak owl

that’s what we were trying to say from the beginning

open vale

all is good sir

keep going

w move, thanks for the help

steel trail
open vale

discord logic

maybe because it's tag from server

topaz bluff
steel trail
topaz bluff

Oh ok. That's what I was talking about in particular. The DJS event, not the raw one

cedar ember

anyone knows how I can do a raw api call to get back the user data so I can check if they have a guild tag or not?

last part I don't really care, just on how to do a raw api call, I can figure the rest out >.<

steel trail

client.rest.get(...)

cedar ember
minor marten

Hello, does reaction.emoji get converted to an actual emoji when concatenated inside a string

rose tangle

the api sends it as an object

djs doesn't do that conversion

but if you have an emoji string and you want the api object you can use resolvePartialEmoji()

it's used by builders

minor marten

Ah Ic, thank you

toxic moat
steel trail

Yes, that is correct. You can't edit the ephemeral status of a reply

You'd have to deferReply ephemerally already

Or deleteReply and then followUp ephemerally

toxic moat

ok thanks

crystal cargo

user can be a userId?

sharp ginkgoBOT

typealias UserResolvable discord.js@14.19.3
Data that resolves to give a User object. This can be:* A User object* A Snowflake* A Message object (resolves to the message author)* A GuildMember object* A ThreadMember object

steel trail

So: yes

crystal cargo

UserResolvable can always be a userId ?

crimson gale

i'm not sure what you mean, if you looked at the sentence 2 above yours

nova pond

Hello, I took the liberty of contacting you to find out if with djs we could manage who took the guild tag?

topaz bluff
nova pond
steel yacht

Hi,
I suddenly can't figure out how to reply to a modal after a deferral without it saying "something went wrong", I tried reply, editReply, update, followUp... What's wrong ? Thanks

zenith violet

you cant

you cannot defer and show a modal

steel yacht

No, after the user submits the modal

zenith violet

then you defer and editReply as usual

if you get the 'something went wrong' message, you arent even reaching that defer

steel yacht

Oh I just forgot () inside Promise.allSettled 🤦
Thanks

ocean portal

why am I seeing too many errors using djs functions?

zenith violet

you tell us

we dont know what your code does

slate ginkgo

hey everyone, is there api support for bots to toggle or apply the new gradient/holographic styles?

slate ginkgo
ocean portal
dense jackal

but is ctx an actual message object

zenith violet

we cant just guess

steel trail

Let me guess: you don't actually code in js but a weird wrapper language built on top of it

ocean portal

it just say everything isn't defined OMEGAlul

steel trail

Without code you won't be able to get help here

dense jackal

well you haven’t shared any of your code to us either shrug

ocean portal
zenith violet

showing vague screenshots is not gonna help

ocean portal

not everything is "defined" 😔

zenith violet

if you want help, show your code

and it also looks like you did not actually code this at all

because thats just basic js

ocean portal
zenith violet

okay

and what code is djseval

it wont magically do something

ancient horizon

I think that is aoi.js

ocean portal

no

steel trail

No. That's not JS code. That's you using some weird non-djs stuff

ocean portal
ancient horizon
zenith violet

if you write good code for it, sure

steel trail

If you actually wrote djs code it might

ocean portal
ocean portal
ancient horizon

It does not seem to be djs related

toxic moat

hi guys, there is anyway to put an image in a container like as author of embed?

zenith violet

no

toxic moat

thx

snow pike

yo

can someone help me please with my discord

i can stream but there is no sound

sharp ginkgoBOT

tag suggestion for @snow pike:
We are not Discord, just some nerds who develop Discord bots!

bleak owl

you are in the wrong server for discord issues

distant bramble

Can we disable buttons when the collector ends inside a container?

rose tangle

sure, editReply with the button being disabled

rigid furnace

I am hoping this is a Quick oversight on my part but for some reason I have not been able to get the "Ban Reason" to show up in our logs. All of the other details are correct it just appear that the reason keeps coming back with undefined

The guildBanAdd event looks like the following

//...
async run(guildBan) {
    try{
        // ---------------------- Send Log Message ------------------------------
        const embed = new EmbedBuilder()
            .setColor(this.ee.color.leave)
            .setTitle('New Ban Added')
            .addFields(
                { name: 'User', value: `${guildBan.user} (${guildBan.user.id})`, inline: true },
                { name: 'Ban Reason', value: `${guildBan.reason}`, inline: true },
            )
            .setTimestamp();

        await this.sendBotLogMessageEmbed(this.name, null, guildBan.guild, embed);
    }
    catch(err) {
        this.client.errorHandler(err);
    }
}
//...

Any help is much appreciated.

polar karma

What's the value of guildBan? Did you log it? Do you pass client as an arg in your event handler?

rigid furnace

Ill have to re-fire an event to get the values console logged, one moment but yes the client is passed in as an arg so the event handler has access to it.

rose tangle

make sure it's not the first argument

otherwise guildBan will be a Client

rich terrace

Is there a way to do a small text like this:
-# Hey

in discord.js ?

(You do this using -# at start of sentence)

rose tangle

you answered yourself

if you want a method:

sharp ginkgoBOT

function subtext discord.js@14.19.3
Formats the content into a subtext.

rose tangle

but it simply appends -# at the start

rigid furnace

the ...args broken out and assigned in my Event Class so the client is not the first argument, The guildBan appears to output 2 values guild and user for some reason the other properties don't seem to exist in the console output.

polar karma
rigid furnace

`-- discord.js@14.19.3

So one version behind current

polar karma

That doesn't agree with the docs

sharp ginkgoBOT
polar karma

What are the values you get in the event

red coral

^

polar karma

So something isn't lining up

red coral

Regardless, it’s not sent

rigid furnace
polar karma What are the values you get in the event

If i have this in the event

console.log(guildBan)

Then i get the following

GuildBan {
  guild: <ref *1> Guild {
    id: '634896097612922890',
    name: 'PrivateTestBotServer',
    icon: '790a1195596694209d3273e46369d3da',
    features: [
      'GUESTS_ENABLED',
      'WELCOME_SCREEN_ENABLED',
      'MEMBER_VERIFICATION_GATE_ENABLED',
      'COMMUNITY',
      'NEWS',
      'PREVIEW_ENABLED',
      'THREADS_ENABLED'
    ],
    commands: GuildApplicationCommandManager {
      permissions: [ApplicationCommandPermissionsManager],
      guild: [Circular *1]
    },
    members: GuildMemberManager { guild: [Circular *1] },
    channels: GuildChannelManager { guild: [Circular *1] },
    bans: GuildBanManager { guild: [Circular *1] },
    roles: RoleManager { guild: [Circular *1] },
    presences: PresenceManager {},
    voiceStates: VoiceStateManager { guild: [Circular *1] },
    stageInstances: StageInstanceManager { guild: [Circular *1] },
    invites: GuildInviteManager { guild: [Circular *1] },
    scheduledEvents: GuildScheduledEventManager { guild: [Circular *1] },
    autoModerationRules: AutoModerationRuleManager { guild: [Circular *1] },
    soundboardSounds: GuildSoundboardSoundManager { guild: [Circular *1] },
    available: true,
    shardId: 0,
    splash: null,
   {REDACTEDED EXTRA}......
  },
  user: User {
    id: '308378500140892162',
    bot: false,
    {Redacted Extra}......
  }
}
polar karma

It's still wrong

rigid furnace
polar karma

It's nullable, so it's not always present

But then it should be null if not sent

viral hinge

hi so for some reason my user install broke did i do something wrong?

rose tangle

yeah doesn't look like it's set as null if not present

rose tangle

should be fixed ig

polar karma

Ah bless, it's the library

viral hinge

when i try doing it on dm it does not show

red coral

You do .type but you need to deploy the contexts and integration_types

rigid furnace
polar karma Ah bless, it's the library

So if i understand, there are a couple of things wrong. 1) The documentation isn't 100% in line with the actions of the library, and 2) I still need to figure out why if i do provide a reason its not being passed back to the event.

rose tangle

you were told about it

rose tangle

call #fetch(), if you have the appropiate permission

and technically it is 100% in line, it says it's nullable or missing

rigid furnace

Ok ill accept that answer, I don't understand fully so will have to read some more about it.

rose tangle

it's missing an explanation as to which case is which though, since missing fields aren't that common in the lib

rich terrace
hallow mesa

Space after the -#

rich terrace

1m

rich terrace
hallow mesa

Np

prisma ruin
LoadEmojis(): void {
    const emojiDirectory = `${process.cwd()}/assets/emojis/*`
    glob(path.join(emojiDirectory), (err, files) => {
      files.forEach(file => {
        const emojiName = path.parse(file).name;
        if (!this.application?.emojis.cache.find(emoji => emoji.name === emojiName)) {
          this.application?.emojis.create({ attachment: file, name: emojiName })
        }
      });
      console.log(`Loaded ${files.length} emojis`);
    });
  }```
any1 knows why my bot isnt creating the emojis?
rose tangle
sharp ginkgoBOT

tag suggestion for @prisma ruin:
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
rose tangle

up to what point though? that's what the tag tries to suggest

you put logs or breakpoints to see where it doesn't execute anymore

the only issue I'm seeing is that .create() isn't being awaited, all promises will be sent in "parallel", but that shouldn't be an issue, not that you can await a forEach either way

prisma ruin

its not that, just tested

rose tangle

also it'll still run them in "parallel" since forEach doesn't await the callback

you'd have to use a for of

sharp ginkgoBOT

mdn for...of
The for...of statement executes a loop that operates on a sequence of values sourced from an iterable object. Iterable objects include instances of built-ins such as Array, String, TypedArray, Map, Set, NodeList (and other DOM collections), as well as the arguments object, generators produced by generator functions, and user-defined iterables.

prisma ruin

same stuff, changed to a for

rose tangle

share your code

prisma ruin
async LoadEmojis(): Promise<void> {
    const emojiDirectory = `${process.cwd()}/assets/emojis/*`
    glob(path.join(emojiDirectory), async (err, files) => {
      for(const file of files) {
        const emojiName = path.parse(file).name;
        if (!this.application?.emojis.cache.find(emoji => emoji.name === emojiName)) {
          await this.application?.emojis.create({ attachment: file, name: emojiName })
        }
      }
      console.log(`Loaded ${files.length} emojis`);
    });
  }```
rose tangle

and which checkpoints did you test?

prisma ruin
rose tangle

even with the await? can you place them back, share what is being logged?

rose tangle

isn't there a way for glob to return the files?

prisma ruin

am i doing it wrong or something? i just pass in the file like that

i think i need to make it a buffer, just searched it

unique shoal

why glob

prisma ruin
tough folio

hey so i'm trying to get autocorrect for discord.js to work and it is not sort of working

topaz bluff

autocorrect is a type of interaction, you need to route your interaction events to the autocomplete field of your command file

can you share your command file and your interactionCreate listener?

topaz bluff
rose tangle

can you specify what you mean by "autocorrect"

a photo, an example, something

topaz bluff

youre talking about this?

tough folio
rose tangle

specifically... (why not exactly that)?

topaz bluff

that is called IntelliSense...JavaScript doesn't support it natively, you have to either use TypeScript or use JSDocs which simulates it (without error messages...just autocomplete)

tough folio

i want something that can autocomplete code

rose tangle

do you want it to write code (like entire lines), or do you want it to suggest methods and fields

topaz bluff

so CoPilot?

unique shoal

Intellisense is probably what youre after, and works best with Typescript

rose tangle
unique shoal

You otherwise have to write JSdoc for all your custom functions so that VSC knows what classes are being passed in

tough folio
unique shoal
topaz bluff

ok, ya that's IntelliSense...which again doesn't really work in JavaScript

prisma ruin
topaz bluff
tough folio like this

you can do this (which is JSDocs) which adds autocomplete by setting the type of params or variables

rose tangle

that's not what they're suggesting

tough folio

idk which one to take:

rose tangle

they're suggesting that you get the emojis' paths with fs

unique shoal
unique shoal
rose tangle
unique shoal

readdir to get file paths, supports recursivity, readFile to get files into Buffers (if needed)

XY?

tough folio
rose tangle

given djs accepts filepaths, explicitly getting the buffer should not be needed

rose tangle
unique shoal
unique shoal

fs.readFile

If you dont specify a text encoding, it reads into a Buffer

prisma ruin
unique shoal

Can we go back to your code

Are you just rate limited or something

prisma ruin

yes

prisma ruin
rose tangle

he meant whether your bot is rate limited

can check with client.rest.on('rateLimited', console.log)

and see if anything logs

prisma ruin

not rate limited

rose tangle

where did you place it specifically?

and also does, "Loaded X emojis" log?

unique shoal

Or Loading for that matter

prisma ruin
rose tangle

and "Loading emoji:"?

ah

can you console.log(this.application) just in case

unique shoal

Yeah thats what I was looking for

Not a good spot for optional chaining

prisma ruin

mightve found it

rose tangle

yeah you need to use that after your client is logged in, not before

it's not erroring because of the optional chaining, like monbrey said

prisma ruin

did a .then after logging in, now im finally getting an error

just duplicate emoji name, will do a check for that, thx for the help m8s

btw, is there a way to download all the emojis that my bot has to its cache? @rose tangle

rose tangle

do you want to download the buffers, or just fill the cache with the data (name, id, etc)?

sharp ginkgoBOT

method ApplicationEmojiManager#fetch() discord.js@14.19.3
Obtains one or more emojis from Discord, or the emoji cache if they're already available.


// Fetch all emojis from the application
application.emojis.fetch()
  .then(emojis => console.log(`There are ${emojis.size} emojis.`))
  .catch(console.error);

prisma ruin

appreciate it

finite leaf

just curious, when you do member.displayName, if they have no displayname, does it resort to the username or null?

snow onyx

"The nickname of this member, or their user display name if they don't have one"

sharp ginkgoBOT
sharp ginkgoBOT
snow onyx

@finite leaf please use #app-commands for private use (or use the hide option)

finite leaf

shi didnt see the channel mb gng

scenic berry

im having with unregistering the commands. when i start the bot all the comamnd has been registered and when the blacklist is applied the commands is still registered.

zenith violet

If you have blacklisted guilds, make the bot leave them

Or just check the id when receiving the interaction

scenic berry
unique shoal

Our guide just suggests having the code in a separate script

No reason to tie it to your main process at all

fast scaffold

Hi, is it possible to know which "server tag" is activated by a member with discordjs ?

snow onyx

Its not a documented feature by discord, thus not available in djs.
You can fetch the user from the api directly tho, there its included.

fast scaffold
snow onyx

Thats something you have to ask discord xD

fast scaffold
hushed condor

I need to fetch systemChannelId when added a guild

sharp ginkgoBOT
shrewd wraith

Are server tags still undocumented?

snow onyx

yes

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

I need to do like mobile icon on status. it's possible?

snow onyx

djs does not support setting mobile icon, bots are not supposed to do it.

uncut mango

I know gradient roles aren't supported in discord.js because they're not documented but I don't want to wait a long time to support them.

Does anyone know what routes to use and how to set gradient roles with the API?

wary coral
uncut mango
uncut mango
uncut fable

Hello, i'm trying to do an autorole tag for my private server, anyone know why the guildmember event or userupdate is not triggered when tag is updated?

client.once(Events.ClientReady, async () => {
    console.log(`Logged in as ${client.user.tag}`);
    await client.guilds.cache.get(Config.GuildID).members.fetch();
});

client.on(Events.UserUpdate, async (oldUser, newUser) => {
    console.log(`[UU] User Updated : ${newUser.tag}`);
});

client.on(Events.GuildMemberUpdate, async (oldUser, newUser) => {
    console.log(`[GMU] User Update : ${newUser.user.tag}`);
});

client.on(Events.Raw, async (raw) => {
    if (raw.t === "GUILD_MEMBER_UPDATE") console.log(raw);
});

Only the raw event seem to be working, but it can have some latency if it's a large server no? and also do i need to fetch all guild members before ?

polar karma

Because tags aren't documented by discord, so the library doesn't support them until they are

uncut fable

yeah i know that, but for now i need to use the raw event?

polar karma

Or a raw GET request, yes

shrewd wraith

Does anyone know why the /guilds/GUILD_ID/members request returns an array with only one user?

Nvm, I supposed to set a limit parameter

novel mauve

what version of djs added customization of how much stuff is cached?

polar karma

iirc it was available in older major versions, but it's been available in all of the 14.x versions

novel mauve

do you mean v12 or v13 when you say older

polar karma

no idea tbh but it's irrelevant as neither is supported

if you want to look through the repo, it should still be there, just look in the ClientOptions

verbal vine

how i can use addField on componentsv2

loud quartz

You don't

Containers are not embeds

languid fiber

how can i make a full width button wit the new containers with the action row

indigo storm

V20 Its woww

loud quartz

containers also dont' really have much to do here

languid fiber
loud quartz

the components v2 you can put into a message can be put into a container, that's pretty much it

languid fiber

lemme see if i can find the image again

languid fiber

ty anyways

loud quartz

you can just look through your browser history then

languid fiber
cobalt solstice

hello, is there any way to fetch all the threads of a forum channel to check the title?

languid fiber

@loud quartz did it!

loud quartz

it's still undocumented so only with raw requests

loud quartz

fetching the user directly via rest, as discord.js doesn't know about those properties

sharp ginkgoBOT

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

cobalt solstice
rose tangle

it sounds like you need some kind of db for storing the id

instead of fetch all and search by title

loud quartz

no, there isn't

karmic hedge
rose tangle
languid fiber

yeah there's nothing in the api for that, that was definitely done manually and probably breaks in mobile

loud quartz
karmic hedge

oh just whitespace, nvm lmao

loud quartz
rose tangle

ah, thought they meant they found the example, my bad

karmic hedge

yh same

languid fiber
loud quartz

ooooor, don't do that at all

languid fiber
loud quartz

if you already know that some users will have it look like crap

languid fiber
loud quartz

and any attempts at styling stuff makes it worse

languid fiber

discord pls fix

loud quartz

nothing to fix

languid fiber

Embed backgrounds and buttons ect don't even look the same

loud quartz

because there's less screen space

and it's you who broke the captcha button here

not discord

anyway, this is getting offtopic

languid fiber
loud quartz

which is a bad ux

because everyone sees it

and mobile users have to press it first to even get something usable, every time

but you do you

if you want control over display, make that dashboard into a website and send people the link

languid fiber

so thought it would be cool that even the setup was all done on an in app dashboard

back to the drawing board i guess

loud quartz

not if you're fighting the platform over it

shrug

languid fiber

aaano typical discord

modest surge

whats the function again isguildfetched or something likethat

loud quartz

wha

what are you trying to do?

modest surge

just checking if its fetched from guild

loud quartz

"it" being?

rose tangle

whether an interaction comes from a cached guild?

loud quartz

so there's nothing fetched

sharp ginkgoBOT
rose tangle

yeah it's the way around, since it's cached, it's not being fetched

modest surge

o yeah cached notfetched

foggy mortar

Did they fuck something with the markdown again? Links showing as text.

steel trail

Does that end with the correct ) and is a valid URL?

foggy mortar

Yeah, I only snipped a bit since the url is loooooooooooooooooooooong

It was fine before for months. Now since 2 days it broke.

rose tangle

where is that?

foggy mortar

My bot. inside a Discord embed it sends. I checked discord api gh since last time it was them doing an oopsie but I don't see anything now.

rose tangle

I mean, where exactly

in what part of the embed

grizzled bison

any1 can help me? how to make that line not exist does the thumbnail in componentV2 count the line?

rose tangle

you mean you want something like this?

grizzled bison

I want to delete the line from the name server to the server information. How do I close it even though I've used small separate?

grizzled bison
foggy mortar
steel trail
rose tangle
sharp ginkgoBOT

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

grizzled bison
foggy mortar
naive obsidian

Hii, is it possible to “monitor” whether someone puts or removes the tag from the server? The idea would be to assign a role to the person wearing the server tag.

rose tangle

tags are undocumented by discord, any functionality with it is not supported by djs

you could get around via raw requests/listeners but you're on your own for that

sharp ginkgoBOT

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

modest surge

hey guys !cmd @user why message.mentions.user.first wont work

rose tangle

do you have the MessageContent intent?

if yes, share your code

modest surge

it only works when reply

steel trail

Then you're indeed missing MessageContent intent

Why not use slashcommands instead?

modest surge

oh right

modest surge
loud quartz

and you are doing it with..?

indeed, profile is not accessibel to bots

but it's also not where the tag is

i didn't tell you to fetch user's profile, but the user

eh?

sharp ginkgoBOT

documentation suggestion for @lyric bobcat:
discord Users Resource - Get User
read more

grizzled bison
steel trail Then you're indeed missing MessageContent intent

then how to add bot or server logo next to name server or username?
``1
const botAvatarURL = client.user.displayAvatarURL({ dynamic: true, size: 64 });
const sectionHeader = new SectionBuilder()
.addImageDisplayComponents(img => img.setURL(botAvatarURL).setDescription('Bot Avatar').setWidth(64).setHeight(64))
.addTextDisplayComponents(text =>
text.setContent(**${guild.name}**\n__Server Information__)
);

i use this but not function
rose tangle

a section doesn't have "image display components"

it has a thumbnail accessory, and only one

sharp ginkgoBOT
rose tangle

you can check the docs to see what methods each class has

grizzled bison
rose tangle

if you want to show it in an independent line you need to add it outside the section

given you're in a container:

sharp ginkgoBOT
steel trail

components v2 is not a 1:1 replacement of embeds. There is no author or footer icon

modest surge

yo why theres no message content intent in v13 how do i use mention

sharp ginkgoBOT

Version 14 has released! Please update at your earliest convenience.

  • Update: npm rm discord.js npm i discord.js
  • Update guide (use CTRL + F to search for the old method or property)
modest surge

im exploring v13

loud quartz

exploring?

modest surge

just testing it

steel trail

Then you're in the wrong place. v13 is unsupported

loud quartz

but what for

everything v13 can do you can do on v14

and then v14 has more things

grizzled bison
modest surge

i just prefer to code in v13 bro

steel trail

Thumbnail always is on the right

steel trail
modest surge

what channel

grizzled bison

alr

loud quartz

none

we dont' support v13

modest surge

just help on the mentions i tried putting args it works but i want to know if theres other method

steel trail

There is no reason at all to use v13. As tipaka said v14 can do all v13 could and more

grizzled bison

I've only been trying componentv2 for about 5 hours and I don't understand the structure yet, it's complicated. mvcry

rose tangle

what exactly are you trying to do?

steel trail

What part confuses you?

rose tangle

even embed thumbnails have always been in the left corner

I don't think you're looking for a thumbnail?

steel trail

*right

loud quartz

author icon is top left

footer icon is bottom left

rose tangle
loud quartz

thumbnail is top right

image is entire bottom part

containers don't have any of those, for what it's worth.
there's a section component that can have a thumbnail, and you just so happen to be able to put a section into a container

same with image(s)

if you want to replicate author or footer icons, bots split an image into 4 emotes and use that

for an example

grizzled bison
loud quartz

you can click on it

or hover over it

pallid ridge

how long do i have to reply to a deffered command? and is that time reset if the message is edited

I'd like to have some long running commands (like probably around an hour)

not sure if i can do that within the normal reply window or if i should just send a message and edit it or something

grizzled bison
loud quartz

uhh, do what

grizzled bison

that emoji of mine is so small it's like following the text

rose tangle

all emojis are of the same size

loud quartz
rose tangle

you just need to split your image in 4 and make an emoji for each part

pallid ridge

okay so ill probably need to just send a message and edit it after responding immediately

do you know if discord.js stops like whatever thread spawns to handle that command (or however it works im not too sure) after the 15 min time window too?

grizzled bison

need more effort mvcry

steel trail

There's no threads being spawned, you decide how your code handles the emission of interactionCreate events

signal pumice

How do i know if there a new updates in the ComponentsV2?

loud quartz

what do you mean by "new updates"

shrewd wraith

can i add one role to multiple users with one api call?

signal pumice
zenith violet

but no, nothing has been added since it released

signal pumice

hmm, ok thank you

hot marten

Hello y'all 👋
Do these codes do the same thing?

  1. interaction.fields.fields.find(i => i.value === key)
  2. interaction.fields.getTextInputValue(key)
zenith violet

yes

hot marten

thanks ^^

vernal mortar

I have a bot that users can ask and answer questions anonymously (for a secret santa type thing)

User A asks a question; question goes into a db ->
Pings User B. User B uses a slash command to list their questions.
Questions are listed in an embed menu (next previous buttons to navigate through) ... when they have a question that needs an answer, an "Answer this" button shows.
Click button which starts the new interaction from the button ...

My question is, once that button interaction is made, how do I wait for the user to send the message (which is the answer)? or is that even possible?

zenith violet

why not use modals?

wary coral

A modal is the way to go

vernal mortar

wasnt even aware of that .... yeah thats exactly what I need

charred lion

Im getting this
components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,) error when trying to add a mediagallerybuilder to my webhook

            const webhookOptions: WebhookMessageCreateOptions = {
                username: originalMessage.author.displayName || originalMessage.author.username,
                avatarURL: originalMessage.author.displayAvatarURL(),
                allowedMentions: {
                    parse: ['users', 'roles'],
                    repliedUser: false
                },
                components: [
                    new MediaGalleryBuilder()
                        .addItems(
                            new MediaGalleryItemBuilder()
                                .setURL(newContent)
                        )
                ]
            };
zenith violet

needs the IsComponentsV2 flag set

charred lion

ok, thx

wary coral

also the parameter withComponents: true

vital vortex

can someone point me in the right direction in the docs for uploading emotes directly to the bots 2000 emote reserve?

sharp ginkgoBOT

method ApplicationEmojiManager#create() discord.js@14.19.3
Creates a new custom emoji of the application.


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

vital vortex

thank you!!

unreal stone

Hey, I have a strange issue with the last version, all my interaction.options throw an TS error :

async execute(interaction: Djs.CommandInteraction, client: EClient) {
        const options = interaction.options as Djs.CommandInteractionOptionResolver;
}

error TS2339: Property 'options' does not exist on type 'CommandInteraction<CacheType>'.

Did i miss something?

zenith violet

type as ChatInputCommandInteraction

unreal stone

Even for slashCommand ?

zenith violet

that is what a slash command is

unreal stone

oh. Thanks then

zenith violet

CommandInteraction includes context menu commands

unreal stone

Oh, that's why. Thanks ;)

lethal badge

how can i check how many people have my tag on discord using api

clear garnet

I doubt anyone knows since tags aren't documented by Discord thus far
-# Also, let's avoid ghost-pinging people just because they start typing in chat

ocean portal

is there a way to restart the command folder instead of a single command

zenith violet

just restart your bot

ocean portal

ig.. but why doesnt my slash command appear in /? literally no errors

unique shoal

Its not deployed or you need to refresh your Discord app

ocean portal
proud arrow

You need to register your commands with discord. It won't magically appear

sharp ginkgoBOT

guide Creating Your Bot: Registering slash commands - Global commands
To deploy global commands, you can use the same script from the guild commands section and simply adjust the route in the script to .applicationCommands(clientId)
read more

ocean portal

ty

steel yacht

Hi,
Is followUp not usable after deferReply ?

unique shoal

it is

steel yacht

Why would I be getting InteractionNotReplied ?

unique shoal

Not awaiting?

zenith violet
ocean portal

why does it say client isnt defined in client.ws.ping?? im pretty confused with these kind of errors

steel yacht

I wish there was something that would automatically choose

sharp ginkgoBOT

tag suggestion for @ocean portal:

  • ReferenceError: "x" is not defined: learn more
  • TypeError: Cannot read properties of undefined/null (reading "x"): learn more
steel yacht

Is there a diagram of what can be used in which order ?

proud arrow

For interaction responses?

steel yacht

Yes

proud arrow
steel yacht Yes

It's pretty straight forward really. You use deferReply so you need to follow to that, with editReply. And you cant use editReply/followUp without really acknowledging the interaction first either by reply or deferReply

steel yacht

Yes but then there's also what to use after reply and editReply and update, and also I sometimes noticed having to use the latter but without really knowing why.

proud arrow

It depends on what you want to do, if you want the edit the original message, you use editReply, or if you want create another response, you use followUp. And update is only for component interaction, which falls more or less in the same category on how to respond to it

steel yacht

I always want to edit the original message when there is one.

rose tangle

then update

or editReply if you replied already to that interaction (defer, update, reply)

ocean portal
bleak owl

client isn't defined, not undefined

this is basic javascript

rose tangle

you don't define any variable called "client"

the error is self descriptive

bleak owl

and you can access the client from message.client.ws.ping. no need to define it as a separate variable

bleak owl

please look at the docs on your spare time

ocean portal

will do

rose tangle

basically every djs object has a client property

steel yacht

Is this it ?

rose tangle

and commands can show modals

and buttons can also reply

every interaction can reply basically lol (obviously excluding autocompletes)

not just commands

I'm not sure what's the issue tbh, it's pretty straightforward

you want to update? update or deferUpdate
you want to reply? reply or deferReply
want to edit your reply (or defer)? editReply
you want to show a modal? showModal, can't defer or reply in any other way

clear garnet

You cannot do this (image), as update() is a form of acknowledgement. Interaction acknowledgements can only happen once and must happen within 3 seconds of the interaction being created and received. You'd want to use editReply() in this case after using update(). reply(), deferReply(), deferUpdate(), update(), and showModal() are all forms of an acknowledgement. followUp() and editReply() can happen anytime up to 15 minutes after the initial acknowledgement and can be used multiple times

steel yacht

modals can also reply
buttons can also reply
Yeah but I always want to only have 1 message per command (create once, edit forever).
commands can show modals
Okay

ocean portal

is there a guide for cv2? i cant find that in docs

bleak owl

its there in the guide

rose tangle

just in case you don't check it for another unrelated project and think that is how the api behaves

steel yacht

Yeah, no worries, I won't forget how I'm trying to figure out how to accomodate the extravagant requests of this client

ocean portal
bleak owl

it’s in the guide

feel free to use the search bar in there

ocean portal

do i have to make another file for using rest or put it on indexjs

bleak owl

what are you using rest for? your question is a bit vague

ocean portal

global slash command

sharp ginkgoBOT

guide Creating Your Bot: Registering slash commands
read more

bleak owl

please look at our guide

ocean portal

i did and i understand what should i do but
what file should i place this in

bleak owl

that section says exactly how to do this

it’s a file named “deploy-commands.js”

this is its own separate file

which is listed on that page

Create a deploy-commands.js file in your project directory. This file will be used to register and update the slash commands for your bot application.

ocean portal

thank you.. one last question why doesnt the bot say in the console when its ready, errors, slash command register, and stuff?

its completely white on startup

bleak owl

you're supposed to run that file separately

it's not supposed to be ran when your bot starts

ocean portal

i have ready event though

bleak owl

where in the guide does it say to do that? we don't suggest this method at all as you can get rate limited by registering every single time your bot starts

ocean portal
bleak owl

no. did you read the guide fully? i think you're just guessing here

Once you fill in these values, run node deploy-commands.js in your project directory to register your commands to the guild specified. (or globally)

ocean portal

project directory? file manager right??

tribal kiln

It's me again with the problem

Hi! I'm trying to create a dropdown menu (StringSelectMenu) in a regular message command (not a slash command) using discord.js v14.

I want to send a select menu in response to a classic prefix command like !help. The menu works, it sends correctly, but when I select an option, I keep getting "interaction failed" in Discord. Nothing happens.

I'm using the messageCreate event to handle the command. I also listen to interactionCreate, and I tried handling select menu interactions with interaction.isStringSelectMenu() but still no success.

Here's my structure:

  • Commands are handled through prefix (!help)
  • The dropdown appears in the message
  • Selecting the option triggers an interaction error

How can I fix this and properly respond to dropdown interactions coming from prefix commands?

Thanks in advance!

bleak owl
bleak owl

specifically your interactionCreate event. you probably don't respond to the interaction

sharp ginkgoBOT

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

bleak owl

please delete that

you just spammed the chat

tribal kiln

sorry..

you say send code

bleak owl

yeah, but not where it fills the entire chat window

tribal kiln
bleak owl

okay

tribal kiln
bleak owl

please send your code again, from one of the links i sent

it was not small from what i saw, it took up the whole page

tribal kiln
bleak owl

that's not your interactionCreate event.

i see a collector

what is your discord.js version?

tribal kiln
bleak owl

i mean, your code looks fine, but have you checked to see if the collector is being emitted?

tribal kiln

Yeah I added a console.log inside the collector.on('collect') but it never shows up, so it seems like the collector isn't triggered at all.

bleak owl

place a console.log above the collector and see if that returns anything

tribal kiln

okay wait

bleak owl

i dont really see why it wouldn't be firing

tribal kiln

I added console.log("Collector created") and it shows, so the collector is created.
But when I click the select menu, I still get “interaction failed” and nothing happens — the collect event doesn’t trigger.
Do you know why this is happening?

tribal kiln
bleak owl

why are you using every possible partial and intent

tribal kiln
bleak owl

remove the Message partial

that's probably why its not working

enabling partials doesn't mean it will make your code work

sharp ginkgoBOT

guide Popular Topics: Partial Structures
read more

tribal kiln

I removed all partials, but it didn't change anything. The interaction still fails.

bleak owl

i didn't say to remove all of them

tribal kiln

ok remove the message part wait

bleak owl

i would suggest trying to handle this inside the interactionCreate event to see if this still happens while also attempting to use slash commands

im not sure what else to suggest

tribal kiln
tacit acorn

this chat help ? @bleak owl @tribal kiln

bleak owl

please do not ping people without context

tacit acorn
bleak owl

is your bot written with discord.js?

tacit acorn
bleak owl
hybrid trail

to change the role style mode and change the gradient role color, is it supported in the latest version of DiscordJS? If it helps, I will provide the method, because I have not found it in the DJS documentation.

bleak owl

it's not

feel free to make a PR if there is not one open for this already on GitHub

tribal kiln
bleak owl

no

sorry

tribal kiln

ok

ocean portal

why does this error staring at me when i use client.ws.ping?

bleak owl

you need to learn javascript

that is not how .then works

ocean portal
bleak owl

and?

what about it?

ocean portal

i cant solve that thing

bleak owl

because it's not valid javascript

you've been told before about the code you have sent previously that it's not valid, which is why you need to take a step back and learn proper javascript fundamentals, which can be done by looking at #resources

and also falls under #rules 3

you can either look at the guide link i sent for checking a bot's ping, or look into learning a bit more js

i cannot help you anymore passed this point

neither can anyone else if you don't look at the resources we send

ocean portal

how to return option value? i cant find that on docs to

rose tangle

return option value?

like, the selected values from a string select menu?

ocean portal

string slash option

rose tangle

or the inputted autocomplete value?

from an autocomplete interaction? or from a chat input interaction

ocean portal

chat input, no autocomplete

sharp ginkgoBOT
ocean portal

ty

short magnet

Hi all, I used the sample example code in the docs to start with and then switched to guild slash commands for quicker updates and now I can't get rid of the global commands. Any ideas?

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: [] })
short magnet

Thank you

rose tangle

guild commands aren't quicker to update though

you might need to restart your client

but it should be the same thing

the choice between global and guild should be a matter of where you want your commands to be executed, not how fast they refresh

short magnet

applicationCommands can take up to an hour to update to the server where guild commands are relatively instant to an extent.

rose tangle

no, global commands are instant as well

rose tangle
carmine dew

Hello anyone interested in gambling ?

stable sun

Prob bj or bingo. This isn’t rly a d.js question tho

carmine dew
stable sun
pearl hazel

how much embed description length limit ?

unique shoal

2000 iirc

visual tusk

So I have emoji attached to these dropdowns (application emoji) and some of them suddenly broke...anyone have this happen before? Using latest discord.js, and these aren't components v2

They were working earlier sus

nevermind, turns out i'm just an idiot Kek

odd stirrup

how do i check whether a specific member has permissions to use a slash command, including all command permission overrides and whatever?

im tryna limit buttons and stuff related to my command to only be able to be pressed by users who have access to the command itself, and id prefer for this to be able to take into account permission overrides for that command in a guild but idk how to do that

stable sun

Easiest way is to just make them use the command and make the button show up in an ephemeral message tbh

odd stirrup

this command opens up a menu that id prefer not be ephemeral, thats annoying

stable sun

You would have to be in the guild to fetch the command permission and check the user/role permissions

odd stirrup

but my bot is in the guild

like i know i can fetch all the permission overrides myself and probably put together some sort of check but that sounds slow and tedious and id hope that theres an easier option

ocean portal

Why does the bot shutdown when there's a single error? how do i make it stop this

unique shoal

I suggest you look into the well defined programming concept of "error handling"

In JavaScript, this is try/catch

hushed condor

I need to edit a specific embed field using message id

dense jackal
sharp ginkgoBOT
zenith violet

Or that to edit a specific field

solid summit

Is embed .setTimestamp function showing time relative to every user for their timezone?

crimson gale

yes

solid summit

discord doesn't gives timezone of any user?

crimson gale

do you know how timestamps work?

solid summit
crimson gale

then you should understand how it's possible for a local client to derive the time from that

your phone/pc/other device is aware of your timezone

the client locally calculates the time in your time zone based on the timestamp (amount of milliseconds since epoch)

solid summit
crimson gale

it doesn't?

the viewing client (read: discord app) sees the amount of milliseconds in the embed structure and decides how to display it - based on your local timezone

discord.js doesn't do anything

solid summit

hmmm, quite interesting

crimson gale
grave willow

Hello. I just updated to 14.20.0 and I'm seeing that CommandInteraction no longer has a CommandInteractionOptionsResolver typed .options property. Can anyone help me understand the change?

Oh I see, nevermind.

young oxide

im struggling to get an even listener for bans working....

const { Events, AuditLogEvent } = require('discord.js');
const sendWebhookLog = require('../utils/sendWebhookLog');

module.exports = {
  name: Events.GuildBanAdd,
  async execute(ban) {
    const { guild, user } = ban;
    const client = guild.client;

    const config = client.config.guilds.find(g => g.id === guild.id);
    if (!config?.modules?.logger) return;

    const logFeature = config.features?.logger;
    if (!logFeature?.events?.member_ban || !logFeature.channel) return;

    try {
      const audit = await guild.fetchAuditLogs({ type: AuditLogEvent.MemberBanAdd, limit: 5 });
      const entry = audit.entries.find(e =>
        e.target?.id === user.id &&
        Date.now() - e.createdTimestamp < 5000
      );

      const mod = entry?.executor;
      const reason = entry?.reason || 'No reason provided';
      const logLine = `🚫 **${user.tag}** (\`${user.id}\`) was banned by <@${mod?.id}> (**${mod?.tag}**)\nReason: ${reason}`;
      await sendWebhookLog(client, guild, logFeature.channel, logLine);
    } catch (err) {
      console.warn('[Logger] Failed to fetch ban audit log:', err.message);
    }
  }
};```

The ban event isnt even caught or logged at all, any advice? (I can sharer the event handler that triggers this, but literally every other discord intent works in this format except bans, unbans, and kicks 😭
molten storm

is there a way to listen to guild tag changes? I want to check automatically if one of my guild members changed their tag so I can remove them a role, and vice versa

unique shoal

No

molten storm
young oxide
molten storm
young oxide
molten storm does your event handler work?

yes, i have a ton of other event listeners registered through it (examples: detect nickname change, member update (roles), VC state update, etc). They all work except this one

young oxide

init:

            intents: [
                GatewayIntentBits.Guilds,
                GatewayIntentBits.GuildVoiceStates,
                GatewayIntentBits.GuildMembers,
                GatewayIntentBits.GuildMessages,
                GatewayIntentBits.GuildMessageReactions,
                GatewayIntentBits.MessageContent,
                GatewayIntentBits.GuildPresences,
                GatewayIntentBits.GuildMessageTyping,
                GatewayIntentBits.GuildModeration,
                GatewayIntentBits.GuildWebhooks,
                GatewayIntentBits.GuildInvites,
                GatewayIntentBits.GuildBans,//Listed here tho i know its deprecated and now GuildModeration
                GatewayIntentBits.MessageContent
            ],
            partials: [
                Partials.Message,
                Partials.Channel,
                Partials.GuildMember,
                Partials.Reaction
            ]
        });```

handler:
```JS
const fs = require('fs');
const path = require('path');
const logger = require('../utils/logger');

async function loadEvents(client) {
  const eventsPath = path.join(__dirname, '..', 'events');

  if (!fs.existsSync(eventsPath)) {
    logger.warn(`No events folder found at: ${eventsPath}`);
    return;
  }

  const files = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));

  if (files.length === 0) {
    logger.warn('No event files found in the events folder.');
    return;
  }

  for (const file of files) {
    const filePath = path.join(eventsPath, file);
    try {
      const event = require(filePath);

      if (!event?.name || typeof event.execute !== 'function') {
        logger.warn(`Skipped invalid event file "${file}" (missing name or execute)`);
        continue;
      }

      if (event.once) {
        client.once(event.name, (...args) => event.execute(...args, client));
      } else {
        client.on(event.name, (...args) => event.execute(...args, client));
      }

      logger.info(`Loaded event: ${event.name}`);
    } catch (error) {
      logger.error(`Failed to load event file "${file}":`, error);
    }
  }
}

module.exports = { loadEvents };

Is it maybe the way in which the event handler is registering the event? I cant imagine this intent is emitted differently than all the other ones that work already

unique shoal

But I don't know for sure

molten storm
vestal sun
young oxide

not sure why or how that solved the issue, but putting GuildModeration events in their own file with the same js name as the emitter solves the problem

versed current

Sorry for interrupting, but I only got a small question
What's the correct type for "any top-level message component" ? I tried out so many types and it won't work...

young oxide

looks like you're trying to construct a class, id start by making it a class with a constructor instead of a returned object, see if you get the same result

young oxide

also, your message will error because youre not calling components properly, you reply with

            const message = await interaction.reply({
                flags: MessageFlags.IsComponentsV2,
                components: [container],
                allowedMentions: {users: []}, // Prevents the ping
                //fetchReply: true```
versed current

that's not what I asked...

and it's not what the issue is

young oxide
versed current
young oxide

when you say top-level did you mean the ### header?

snow onyx

the problem is that TopLevelComponent consists of components, not builders

versed current

top-level-components !== headings

versed current
young oxide

i think you can just toJSON the builders to get the components data

versed current

I could. But I don't want to unless there's no other option.

young oxide

whats the class construction look like

snow onyx
versed current

that's the JSON-ified version I think

yep

snow onyx

does it throw an error if you use it though

versed current

yes, if I don't toJSON() it.

tbh types have not been very unplesant to work with when it comes to djs-Builders since they released 😅

I've now made my own type but djs isn't allowing me to use that in the .reply() method (directly passing the builders)

I have to toJSON() the array of builders to make that work.

snow onyx

using JSONEncodable<APIMessageTopLevelComponent> should work as the type

versed current

oooooh yeah that works

snow onyx

if not I'm going home and continue hating ts

versed current

😂 yeah

when guide-update tho >.>

tough folio

Does anyone know whether or not it is better to disable inline comments for eslint, (looking for opinions)

young oxide

the reaosn i asked about doing a class constructor is for the purposes of overriding the class super instead of changing constants

snow onyx

If you set contexts you can control where the command will be available

sharp ginkgoBOT
young oxide

i personally prefer to register commands locally / per instance

verbal mica

when is this discord.js update for role style?

snow onyx

whenever discord documents it

verbal mica

feelsTenseMan

snow onyx

its an undocumented features not rolled out everywhere

verbal mica

if it is published in the documentation, it would be great to change it from the role style

rain forum
    if (interaction.customId === "call_user") {
          await interaction.message.delete();
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.

note : message is ephemeral

How can I fix it

polar karma

that error is not from that code

sharp ginkgoBOT
polar karma

but for deleting ephemeral messages, use that method

steel trail

After a deferUpdate() in case you want to delete the message the button is on

rain forum
steel trail

Seems like you didn't do what I said or didn't await it

rain forum

i try to edit it

steel trail

But also find the place in your code that error comes from (look at the stacktrace)

Considering you had that error before and it was unrelated to the code you sent

rain forum
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.

this error

steel trail

That's not the full error. Where's the stacktrace? If you log errors make sure to log the full error, not just the error message or stringifying the error

rain forum
steel trail That's not the full error. Where's the stacktrace? If you log errors make sure t...

now i try deferReply

Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
    at StringSelectMenuInteraction.editReply (C:\Users\pc alkazaz\OneDrive\Desktop\ALL\developer\system\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:247:48)
    at Client.<anonymous> (C:\Users\pc alkazaz\OneDrive\Desktop\ALL\developer\system\bots\test1.js:376:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
    at emitUnhandledRejectionOrErr (node:events:402:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
  code: 'InteractionNotReplied'
}
steel trail

And what is test1.js line 376? Or rather what is before that line

You call editReply on a SelectMenuInteraction without any reply before

rain forum

this deferReply

steel trail

But those are two completely disjoint if conditions. That first editReply will never be called on the same interaction that the deferReply there is called on

rain forum
steel trail

What owners? And that code is still not the one causing that error

rain forum

now i want to edit or delete the message

  • deferReply not work
  • interaction.message.edit not work
rose tangle

for editing it depends on whether you replied to it already

for delete it's deleteReply, but you need to have replied already

defers are completely unrelated to editing and deleting

tags are undocumented, hence not supported by djs

sharp ginkgoBOT

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

rose tangle

update if you haven't, editReply if you have

ivory sable
await interaction.followUp({
  content: `\`\`\`${meta.status} ${meta.msg}\n${errors.title}: ${errors.detail}\`\`\``,
  components: [row],
  ephemeral: true
                });```
This returns a normal message, rather than emphemeral, am I smissing something?
snow onyx

is it an actual follow up or the first "reply" after deferring

ivory sable

it's the first reply after deferring

snow onyx

Then yes, this is intended behaviour.
using followUp() after deferring results in the deferred reply being edited.

In that case the ephemeral state of the deferReply() will be used.

ivory sable

I see, is there a way to change it depending on if conditions are met, I will I have to handle that in different replies?

snow onyx

You need to check it before deferring then.

ivory sable

alright, thank you o7

snow onyx

fetch them via the API and not djs

scenic berry
snow onyx

you can just use client.rest

sharp ginkgoBOT
rose tangle
sharp ginkgoBOT
rose tangle
scenic berry
sharp ginkgoBOT
rose tangle

interactions have their own ratelimits

you can't be ratelimited from an interaction you didn't respond

sharp ginkgoBOT
rose tangle
rain forum
rain forum
rose tangle
scenic berry

how can i add cooldown on slashcommand?

rain forum

i have last update

rose tangle
rose tangle
sharp ginkgoBOT

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


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

rose tangle

for example

rain forum

oh

so i should do deferReply and after that update right ?

toxic moat
const targetUser = await args.pick('user').catch(() => message.author);
await targetUser.fetch();

I do this to make sure user's banner is fetched and it works, but should I fetch user in avatar command too or it's not needed

rain forum
rose tangle
sharp ginkgoBOT

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

rose tangle

I think the api doesn't include them in update events

toxic moat
rose tangle

pretty sure the avatar is always sent

toxic moat

alright

tribal kiln

Hello, I’m having an issue with select menus in my prefix command help. The menu appears correctly, but when I select an option, it says "interaction failed" every time.

Here's what I’ve already tested:

The interactionCreate event is properly loaded.

The customId of the select menu matches correctly.

The bot has full permissions and intents are all enabled.

I'm using interaction.reply() within 3 seconds.

I’ve confirmed the interaction type with isStringSelectMenu().

Logging inside the interaction event shows that the code does not run at all when I interact with the menu.

However, in another bot using the same menu logic (Snoway), it works perfectly. So I think it might be an issue with how my interactionCreate is handled or registered.

Can you help me figure out why interactions from the select menu are failing?

novel pendant

so i have a command where it checks for permissions then show a modal, but permissions dont take less than 3 seconds to check any solutions?

sharp ginkgoBOT
novel pendant

modals dont show up after defer reply..

topaz bluff

Oh .. Yes you did say modal

hushed condor

I need to do like who added the bot to guild. Send a message to added user..

short mulch

How could I make my bot use sub commands (on slash)?

sharp ginkgoBOT
scenic berry

and when getting the subcommand you need interaction.options.getSubcommand()

hallow mesa
steel yacht

Hi,
How to check whether the message linked to an interaction has been deleted ?
Thanks

hardy kite

Fastest and safe way to extract audit logs information? sleep 1000?

Developing an anti nuke system and I need to extract information fast to preserve most.

hallow mesa
topaz bluff
hallow mesa
hardy kite
topaz bluff

Events don't have a ratelimit as it's data discord is sending TO you, not being requested

It just slows down your bot having many listeners open

hardy kite

I was thinking abou thaving a priprity but it would prompt out all information upon severe bot instances

hardy kite

Thank you for your time!

toxic moat

In interactionCreate if I use: if (!interaction.isButton()) return; and I want to say add an emote or respond to a button, it keeps stating TypeError: interaction.isButton is not a function. I can do slash commands just fine, but if theres a reaction or button press, it freaks out. I am not sure whats going on. I've checked im on djs (latest) already.

Current interactionCreate.js

const {
  Events,
  EmbedBuilder,
  PermissionFlagsBits,
  ChannelType,
} = require('discord.js');
module.exports = {
  name: 'interactionCreate', // Use string here
  async execute(interaction) {
    if (!interaction.isButton()) return;
    if (interaction.customId === "ban_user") {
        handleBanUserButton(interaction);
    }
  },
};
proud arrow

I suspect interaction there is not an interaction. Log it and see. Depends on how you are passing parameter to execute callback in your handler

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
toxic moat
proud arrow

Show what the it logged

toxic moat

its like 300+ lines though

Heres a pastebin: https://pastebin.com/KPMnmud7

steel trail

Yup, that's a Client, not an interaction

toxic moat

but why is it passing the client and not the interaction when im passing the interaction?

const {
  Events,
  EmbedBuilder,
  PermissionFlagsBits,
  ChannelType,
} = require('discord.js');

module.exports = {
  name: 'interactionCreate',
  async execute(interaction, client) {
    console.log(interaction);
    if (!interaction.isButton()) return;
    if (interaction.customId === "open_ticket") {
        handleSupportTicketButton(interaction);
    }
  },
};

this is all that was re-done to the module, besides passing client in the index.js

hallow mesa

You don't need to pass client at all since you can get it from the interaction... But could you show where you call execute in your handler?

toxic moat

Oh, the index.js execute:

client.on('interactionCreate', async interaction => {
    if (!interaction.isChatInputCommand()) return;

    const command = client.commands.get(interaction.commandName);
    if (!command) return;

    try {
        await command.execute(interaction);
    } catch (error) {
        console.error('Command execution error:', error);
        await interaction.reply({
            content: `There was an error while executing this command! ${error}`
        });
    }
});
steel trail

That looks like you have two interactionCreate event handlers... why?

And implemented in two completely different ways

I assume your event loader passes client as first parameter to the event's execute()

odd stirrup

do builders mutate

like

const bruh = new TextDisplayComponent();
bruh.setContent("hello")

// do something with `bruh`
``` will this actually set the content of `bruh` or no
toxic moat

hello guys, is this the best way to get a channel and message or there is some better ways? (im getting many times error on getting)

            let channel = await client.channels.cache.get('123');
            let message = await channel_interaction.messages.fetch('456');

also there is any rate limit?

odd stirrup
toxic moat

ok nice, and about the fetchingfor the message?

odd stirrup

channels are most of the time cached so accessing the cache generally works (i forget if there are any normal circumstances in which a channel wouldnt be cached by default), but with messages you do have to actually fetch them, idk the rate limit

toxic moat

ok thx for help

proud arrow
odd stirrup
proud arrow

Well no. It doesn't return new modified instance but modifies the current one and returns it

odd stirrup

ok cool

shut musk

Will djs support this?

Seems like it only shows install count

buoyant thorn

hello, is there a way to customize this msg circled in red? the use case is for commands that have an option string, I would like this message to include what the user's input was, instead of just repeating it back in the response.

shut musk

No, you cannot customise that. you can click the "leave" thing and it will show the input

wary coral
buoyant thorn

gotcha, thank you!

toxic moat

i have seen now new SlashCommandBuilder().setDMPermission(false), is deprecated, with what i can replace it?

sharp ginkgoBOT
proud arrow
rigid ridgeBOT
shut musk

ty

toxic moat
clear garnet

Ideally you'd use the InteractionContextType enum and not just 0 to make it more readable, but otherwise, yes

toxic moat

ok ty

dim estuary

Hey yall, quick question:
Will using guild.members.fetch() cache the members returned by the function? Passing {cache: false} throws type error as shown on the picture bellow

crimson gale

cache:false is just available on the overload with user resolvable(s)
if you use it without, it sends a gateway command and will accumulate received GUILD_MEMBERS_CHUNK events the gateway sends
it cannot not cache those

dim estuary
crimson gale

i sometimes think we shouldn't even let you do that as an overload and fully require it to be its own thing with a big warning

it's okay on small server, but it really scales horribly on very large ones

unique shoal
weary cypress

Moved it to there now

pine quarry
const {
    SlashCommandBuilder,
    EmbedBuilder,
    TextDisplayBuilder,
    MessageFlags,
    SeparatorBuilder,
    SeparatorSpacingSize,
    SectionBuilder,
    ThumbnailBuilder,
    ButtonBuilder,
    ButtonStyle,
    MediaGalleryBuilder,
    ContainerBuilder,
    AttachmentBuilder,
    FileBuilder
} = require('discord.js');```
Hi, Can you send me all the functions of this ComponentsV2?
steel trail
wraith seal

How can you use .update() from components v2 to content?

Here's my code.

From components v2:

        if (interaction.values) {
            await interaction.followUp({
                components: [container],
                flags: MessageFlags.IsComponentsV2
            })
        } else {
            console.log('LOC185:', fromOrder)
            await interaction.update({
                content: null,
                components: [container],
                flags: MessageFlags.IsComponentsV2
            })
        }```

To content:
```js
    await interaction.update({
        content: `✅ Picked <@${creatorId}>!\n\nYou can pick more or wait for Creators to claim your order.`,
        components: [],
        flags: MessageFlags.Ephemeral
    })```

I'd use this to update a message with components v2 to make it without components v2 and only text (`content`)

I don't know if this is discord.js-related tho

unique shoal

cant

wraith seal

Interesting, it worked the other way around

unique shoal

Yep

topaz bluff

the MessageFlags.IsComponentsV2 flag is irreversible, similar to ``MessageFlags.Ephemeral`...once it's assigned, you can't remove it

So the content and embeds fields are remove permanently for that message

frigid lynx

why does the components v2 setAccentColor(color?: RGBTuple | number): this; not use ColorResolvable for typescript?

unique shoal

Because that would include more types than it supports?

frigid lynx

isn't colorresolvable a class to resolve a bunch of formats to what discord supports?

unique shoal

no

frigid lynx

ah that makes more sense then, cheers

hallow mesa
tough folio

hey does anyone know how to get a database going?