#djs-help-v14

78874 messages · Page 55 of 79

patent dune

it doesn't have guild capabilities, yet

steel trail

Then where do you check its offline status Thonk

patent dune

i have a dm with it

steel trail

You won't see presence of a user you don't share a guild with

patent dune

oh

mkay in that case i'll be right back

i set it to be possible to add it to servers but any time i add it to my server it just doesn't exist??

its fuckin with me

aha it works!
ty :3

tardy sable

You can use the resolveColor()

sharp ginkgoBOT
pallid flax

Anyone know what "You cannot remove this app's Entry Point command in a bulk update operation." means?

Adding a few new commands, never gotten this before

steel trail

Does your app actually use activities?

pallid flax

Oh I was working on one, I think the code might be split between branches

steel trail

How is that djs related?

pallid flax

Ah ok, just a command to call the activity?

steel trail

The command that already exists, yes

By you ticking the box in Dev portal it was created for you

sharp ginkgoBOT

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

deep ledge

ok, so i may leave

tardy sable

If you just use channel.messages.fetch() without specifying a limit or anything, what will it fetch?

steel trail

The default amount, which is 50 afaik

pallid flax
sharp ginkgoBOT

discord Messages Resource - Get Channel Messages GET channels/{channel.id}/messages
Retrieves the messages in a channel. Returns an array of message objects from newest to oldest on success. If operating on a guild channel, this endpoint requires the current user to have the VIEW_CHANNEL permission. If the channel is a voice channel, they must also have the CONNECT permission. If the current user is missing the READ_MESSAGE_HISTORY permission in the channel, then no messages will be returned.
read more

steel trail

Yup, default is 50

tardy sable

Thanks

silent plover

What can I do, that my bot react to timeouts? If I use guildMemberUpdate my bot doesn't react to a timeout.

stable sun

Enable the guild members intent in the code and the bot page

silent plover

It is.

stable sun

Ur talking abt editing timeouts, right?

silent plover

W8 I check th code
-edit yes it have the intent

silent plover

see

const discord = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.GuildMessageReactions,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildVoiceStates,
  ],
  partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});
inner kernel

how to convert Collection to Map?
can i just cast it?

hallow mesa
stable sun
stable sun

There’s no reason to cast

inner kernel

waitttttttttt
it is { [key: string]: ...} not Map

stable sun
inner kernel

my bad
can i convert to object too?

stable sun
stable sun

You can

inner kernel
sharp ginkgoBOT

mdn Object.fromEntries()
The Object.fromEntries() static method transforms a list of key-value pairs into an object.

loud quartz

Or just

stable sun

Why tho?

sharp ginkgoBOT

mdn Map.prototype.entries()
The entries() method of Map instances returns a new map iterator object that contains the [key, value] pairs for each element in this map in insertion order.

loud quartz

Or similar

Depends what you actually want

stable sun

That’s an Iterable of entries tho

loud quartz

Well, they didn't really say anything useful for us to go off of

So we can only throw random things

inner kernel

Object.fromEntries(myCollection.entries())?

loud quartz

What do you want to do

Don't make this an XY problem

stable sun

.entries() is a bit redundant, unless you want to be explicit

inner kernel

attachments: Object.fromEntries(m.attachments.mapValues(attachment => adaptDiscordMessageAttachment).entries())

attachments accepts {
[key: string]: MessageAttachment;
}, here the type is my own type
and i have m.attachments, which is discord.js' type

i need to convert discord.js' Collection<string, DiscordMessageAttachment> to my { [key: string]: MessageAttachment }

loud quartz

Is there a need for you to make such type?

Collection is perfectly fine for a lot of things, and it's almost exactly that type already, bearing the actual difference between object and Map

inner kernel
loud quartz

Ah

inner kernel

i think protobuf is absolutely better than using discord.js' toJSON to send requests/save data

steel trail

Are you using v14 now?

loud quartz

Except our toJSON makes sure that stuff is serializable (and what discord api wants)

stable sun

Wait a second, isn’t MessageAttachment v12?

inner kernel

wat

steel trail

You still didn't update, did you?

inner kernel

idk i just imported it to match my protobuf's name

stable sun

D.js doesn’t use MessageAttachment anymore

inner kernel
steel trail

you said you use v13 before. So unless you update we can't and won't support you in here

stable sun

Although if ur going for shared interface across langs, you prob shouldn’t be using d.js structures at this point anyways

inner kernel
stable sun

At least use the discord type from discord-api-types

inner kernel
steel trail

Or you use @discordjs/core or even /ws directly if you don't actually want the library structures

inner kernel

ok

junior ore

how to use file upload in modals?

sharp ginkgoBOT
light ibex

Hey everyone,

I’ve run into a strange issue while working with Discord.js Components v2, and I can’t seem to figure out what’s causing it.

I’d really appreciate any insights or suggestions from anyone who’s dealt with something similar.

and there's nothing that uses ButtonBuilder or something like that

wary coral
light ibex
wary coral

one or the other. else just uses the textdisplay on its own

light ibex

i'll try

radiant bough

I cant find any information about the labelbuilder, using v14.24.2

sharp ginkgoBOT
radiant bough

ahh thanks! How do i then use that label? Theres nothing in the djs guide about using it is there?

little pebble
radiant bough

ahh switching it up, i see alrighty!

radiant bough

ill dig in!

thanks

Oh this is actually an improvement once you get over the fact its different from what it used to be

radiant bough

Theres a typo, the text should be he maximum values that must be uploaded => he maximum values that can be uploaded

Idk where to report it tho

vagrant mortar

so I'm switching to /core and i've already run into some issues:

const rest = new REST({ version: '10' }).setToken(secret.token);
    const gateway = new WebSocketManager({
        token: secret.token,
        rest: rest,
        intents:
            GatewayIntentBits.Guilds |
            GatewayIntentBits.GuildMessages |
            GatewayIntentBits.MessageContent,
    });
    const client = new Client({ rest, gateway });
    //const eventsManager = new EventsManager(client, 'events');

    try {
        client.once(GatewayDispatchEvents.Ready, (payload) => {
            console.log('event: ready');
        });

        client.on(GatewayDispatchEvents.MessageCreate, (p) => {
            console.log('event: message_create');
        });

        //await eventsManager.loadEvents();
        await gateway.connect()
            .then(() => send({ type: 'ready', shardId: SHARD_ID }));

    } catch (err) {
        console.error(`Unable to connect to gateway`, err);
        process.exit(1);
    }

despite registering the events they aren't listened, to and I can't figure out why. what could be the reason?

tardy sable
pale flume

hi, I can’t find this permission in discord.js?

wary coral
pale flume

ah why?

stable sun

Blame Discord

pale flume

So to avoid having an error, I must use the manage channel permission instead?

tardy sable

you wont necessarily encounter an error its just undocumented. so in case you wont find how to find that permission i think you can use manage channel permissions for that

pale flume

I have a permission error, but yes I will have to use the manage channel permission

rose tangle

how did you get a permission error if editing the voice status isn't supported in djs?

if you're using the undocumented endpoint then not being able to find stuff in djs should be expected

loud quartz

lack of the permission is still bad on its own

because it means you can't meaningfully touch the permission on roles or overwrites

rose tangle

you add a label which has the file upload component

sharp ginkgoBOT

class FileUploadBuilder discord.js@14.24.1
A builder that creates API-compatible JSON data for file uploads.

loud quartz

on discord

rose tangle

the latter

well you get a full Attachment object

but usually you only want the url

which it holds

loud quartz

the Attachment also doesn't have the actual data

only metadata and a link for you to get the actual file

wary coral

They are ephemeral so they will be deleted but discord does not give a time on when

Ephemeral attachments will automatically be removed after a set period of time. Ephemeral attachments on messages are guaranteed to be available as long as the message itself exists.

pale flume
rose tangle how did you get a permission error if editing the voice status isn't supported i...
    public static async setVoiceStatus(client: Panais, channelId: string, message: string): Promise<void> {
        try {
            await client.rest.put(`/channels/${channelId}/voice-status`, {
                body: { status: message },
            });
        } catch (err) {
            console.warn(`setVoiceStatus failed for channel ${channelId}:`, err);
        }
    }
setVoiceStatus failed for channel 1431208550327128165: DiscordAPIError[50001]: Missing Access
    at handleErrors (/home/pi/Canary/LucasB25/Canary/node_modules/@discordjs/rest/dist/index.js:762:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async SequentialHandler.runRequest (/home/pi/Canary/LucasB25/Canary/node_modules/@discordjs/rest/dist/index.js:1163:23)
    at async SequentialHandler.queueRequest (/home/pi/Canary/LucasB25/Canary/node_modules/@discordjs/rest/dist/index.js:994:14)
    at async _REST.request (/home/pi/MusicBot/LucasB25/Canary/node_modules/@discordjs/rest/dist/index.js:1307:22)
    at async Utils.setVoiceStatus (/home/pi/Canary/LucasB25/Canary/dist/Client.js:628:7)
    at async PlayerDestroy.run (/home/pi/Canary/LucasB25/Canary/dist/events/player/PlayerDestroy.js:413:9) {
  requestBody: { files: undefined, json: { status: '' } },
  rawError: { message: 'Missing Access', code: 50001 },
  code: 50001,
  status: 403,
  method: 'PUT',
  url: 'https://discord.com/api/v10/channels/1431208550327128165/voice-status'
}```
sharp ginkgoBOT

guide suggestion for @pale flume:
guide Implicit permissions
Some Discord permissions apply implicitly based on logical use, which can cause unwanted behavior if you are not aware of this fact. The prime example for implicit permissions is ViewChannel. If this flag is missing in the final permissions, you can't do anything on that channel. It makes sense, right? If you can't view the channel, you can't read or send messages in it, set the topic, or change its name. {/* prettier-ignore */} - Text Channels require ViewChannel as detailed above.
read more

crimson gale

prettier-ignore, nice

if i had to guess it's the connect permission being missing

pale flume

No, the error only concerns the update of the channel status, all other permissions are mandatory. Surely, the bot does not work

pale flume
crimson gale

well, missing access is an implicit resource check, don't know what to tell you

so for that route it'd be access to /channels/:id

be that through permissions, missing app user, or w/e else - see the article above for some more ideas on what could be missing re: impicit checks

versed current

guys how can I set the presence of my bot in the constructor?

sharp ginkgoBOT
red coral

presence: {
status: "dnd",
activities: [
{
type: ActivityType.Custom,
name: "custom",
state: ""
}
]
},
This is how I do mine

versed current

oooh nice

state is incorrect btw. status is is.

red coral

Didn’t realise there’s also an example of it in the client options there too

versed current

ooooh

versed current

oh mb

tardy sable

for message.mentions.members.first(). and i reply to someone but also mention someone in the message reply. is the first member the member i replied to or the member in my message mention?

hexed thicket

Heyo was wondering if there was a way to pull message id from a message being replied too so for example. User A types something in a foreign language, User B can then reply to the message with /translate and itd pull the message id of User A's message?

clear garnet

Sounds like you'd want to use a message context menu command for that

sharp ginkgoBOT

guide Context Menus
Context Menus are application commands which appear when right clicking or tapping a user or a message, in the Apps submenu. This page is a follow-up to the slash commands section. Please carefully read those pages first so that you can understand the methods used in this section.
read more

civic adder

Is there something wrong with the /guide command? Everything leads towards the same link called: "usernameOnClick"?

topaz bluff
civic adder

Yeah

But if I copy and paste it somewhere, then it's correct.

proud arrow
civic adder

I've cleared discord cache + data just to see if it's a bug and it is... wtf.

Every link was set as that

proud arrow
tribal birch

can I use just message ids array in bulkDelete

sharp ginkgoBOT

method TextChannel#bulkDelete() discord.js@14.24.2
Bulk deletes given messages that are newer than two weeks.


// Bulk delete messages
channel.bulkDelete(5)
  .then(messages => console.log(`Bulk deleted ${messages.size} messages`))
  .catch(console.error);

thin pagoda

Hi someone could guide me why this error?

Error in help command: 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 (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1965:23)
    at _UnionValidator.parse (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
    at SectionBuilder.toJSON (/home/container/node_modules/@discordjs/builders/dist/index.js:2525:37)
    at /home/container/node_modules/@discordjs/builders/dist/index.js:2226:64
    at Array.map (<anonymous>)
    at ContainerBuilder.toJSON (/home/container/node_modules/@discordjs/builders/dist/index.js:2226:35)
    at /home/container/node_modules/discord.js/src/structures/MessagePayload.js:151:46
    at Array.map (<anonymous>)
    at MessagePayload.resolveBody (/home/container/node_modules/discord.js/src/structures/MessagePayload.js:150:49)
    at ChatInputCommandInteraction.reply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:191:56)
stable sun
thin pagoda
stable sun

statsSection has no accessory

thin pagoda

sorry for it i didn't notice i thought it is an new TextDisplay

stable sun

It’s fine, happens

thin pagoda
edgy barn

ive got this snippet of code here

await bInteraction.showModal(roadNamer);
const mdInteraction = await bInteraction.awaitModalSubmit({time: 60_000});
await mdInteraction.update({ whatever });

ide is telling me that update() doesn't exist on a ModalSubmitInteraction, even though the guide says it should since it's from a button and it works as expected when compiled and run. not much of an issue, but i wanted to check if i'm doing something improperly or if this is a djs issue

pearl roost

Will this code work when someone boost the server?

snow onyx
sharp ginkgoBOT

The Discord API does not provide a dedicated event for guild boosts, but you can check for it in the guildMemberUpdate event:

client.on("guildMemberUpdate", (oldMember, newMember) => {
    // Check if the member wasn't boosting before, but is now.
    if (!oldMember.premiumSince && newMember.premiumSince) {
        // Member started boosting.
    }
});
pearl roost

Oh okay, thanks

steel trail
sharp ginkgoBOT
verbal vine
verbal vine
steel trail

Await the .reply call, else you won't be able to catch it there

verbal vine

wait

steel trail

the stacktrace is the relevant part. Copy instead of screenshot

verbal vine
PS D:\AF-BOTS\Almasa> bun run src/
DOMException {
  line: 0,
  column: 0,
  stack: "abort@[native code]",
  code: 20,
  name: "AbortError",
  message: "The operation was aborted.",
  INDEX_SIZE_ERR: 1,
  DOMSTRING_SIZE_ERR: 2,
  HIERARCHY_REQUEST_ERR: 3,
  WRONG_DOCUMENT_ERR: 4,
  INVALID_CHARACTER_ERR: 5,
  NO_DATA_ALLOWED_ERR: 6,
  NO_MODIFICATION_ALLOWED_ERR: 7,
  NOT_FOUND_ERR: 8,
  NOT_SUPPORTED_ERR: 9,
  INUSE_ATTRIBUTE_ERR: 10,
  INVALID_STATE_ERR: 11,
  SYNTAX_ERR: 12,
  INVALID_MODIFICATION_ERR: 13,
  NAMESPACE_ERR: 14,
  INVALID_ACCESS_ERR: 15,
  VALIDATION_ERR: 16,
  TYPE_MISMATCH_ERR: 17,
  SECURITY_ERR: 18,
  NETWORK_ERR: 19,
  ABORT_ERR: 20,
  URL_MISMATCH_ERR: 21,
  QUOTA_EXCEEDED_ERR: 22,
  TIMEOUT_ERR: 23,
  INVALID_NODE_TYPE_ERR: 24,
  DATA_CLONE_ERR: 25,
  toString: [Function: toString],
}

steel trail

So bun doesn't give you a stacktrace? One more reason for me not to use it

verbal vine

wait i 'll build it and run using nodejs

@steel trail

steel trail

Seems like something is blocking or slowing down your way to discord. Where are you hosting? Any VPN/proxy/firewall between you and Discord?

verbal vine

no

sharp ginkgoBOT

AbortError: The user aborted a request.
A request took longer than the specified timeout (15 seconds default), and was aborted to not lock up the request handler.

  • This can be caused by an internal server error on Discord's side, or just a slow connection.
  • In case of a slow connection, the timeout option in RESTOptions can be increased to prevent future AbortErrors.
steel trail

Or did you set the timeout to something very small by accident? Show your client constructor

verbal vine

im uploaded all images to my server

trail pasture

can the media element in the componentv2 work with videos?

steel trail

Yes

trail pasture
frosty epoch

with components v2 is not then possible anymore to have 2 columns in parallel with fields?

snow onyx

there are no fields in components v2, so correct

elfin shell

Is there a practical way to use discord.js with HTTP interactions, or even plans to implement support for them in the future?

lofty topaz

What's the problem with the package?

tardy sable
tardy sable

wait for a response from someone with knowledge about it

crimson gale
crimson gale
heady sundial

Hi – Does anyone know if there's some way to host the websocket instance on another HTTP server and have the Discord.JS client remotely use that websocket?

I want to be able to host the Discord.JS client on Hono on a serverless endpoint (Vercel), but I can't connect to a websocket on serverless.

proud arrow
normal flare

is there a downside from registering guild commands on bot startup (in main.ts via REST) instead of having it in a seperate script that I'd manually run?

heady sundial
polar karma

No need to send the same data every time

normal flare

okay that makes sense thanks

with HMR yeah that would send the call on each save

limpid mulch

Hey, I know it's possible to display a command using the format </command_name:command_id> and the user can click on it to try the command
but if a command has options, is it possible to fill these ?

novel mauve

you can only mention subcommands, not any other options

limpid mulch

okay, thank you

restive pebble

he wants to use the api itself not the discord.js lib.

bleak owl

they were already helped 3 days ago

crimson gale

message search is in public preview but not yet documented
discord.js will implement it once it's officially released and documented by discord
as per usual you can use Client#rest to do raw api calls, but we cannot guarantee you won't experience bugs in library internals when doing so and cannot help you with it/fixing any resulting issues

normal flare

once it's officially released and documented by discord
any clue when that would happen?

polar karma

Ask discord

tidal latch

How do I clear the text input value of a modal (discord caches it everytime the modal is opened until it gets submitted)

tardy sable
tidal latch

alright

elfin shell
peak egret

can "ephemeral" attachments be embedded in some way? i have attachments from a modal which i have to send over to a text channel, however sending the link doesn't seem to embed them (even though when i open them thru my browser they load just fine)

is reuploading them the only way? though i wouldn't want some stupid kid exploiting this to make the bot send 1gb of attachments (100mb per attachment)

wary coral
peak egret

alright, ty

coarse meteor

can i make a file upload in module and when the module is submitted the img is sent as an attachment in a embed or what
-# in the api

normal flare

I have a discord question, are spoiler hacks still a thing? I'm building a spam detection functionality, do I need to check for those or did discord handle that from their side? I was looking at nother bot and they're using this snippet

export function replaceSpoilerHack(messageContent: string | null, replacement = "[...]") {
  return (messageContent ?? "").replace(/(\|\|\u200b\|\|)+/g, replacement);
}

I don't even know how this could be used in a harmful way unless discord patched it because I tried sending the spoiler hack on my server but nothing really happened that shouldn't happen

tardy sable
coarse meteor

getUploadedFiles method in ModalSubmitFields class (Discord.js v14.21.0)

Hi Discord Developer Support Team,

I'm encountering an issue with the Discord.js library where the ModalSubmitFields class is missing the getUploadedFiles method that appears in the documentation.

Details:

Discord.js version: 14.21.0
Issue: When trying to use interaction.fields.getUploadedFiles('customId', false) in a modal submit handler, I get a TypeError: "getUploadedFiles is not a function"
Expected behavior: According to the docs at https://discord.js.org/docs/packages/discord.js/14.24.2/ModalSubmitFields:Class#getUploadedFiles, this method should return a ReadonlyCollection of uploaded files
Current workaround: Using fields.getField('customId', 19) and manually resolving attachments from interaction.data.resolved.attachments
The documentation for v14.24.2 shows this method exists, but it doesn't seem to be implemented in v14.21.0. Could you clarify:

When was this method added?
Is there an alternative way to access uploaded files in modals for v14.21.0?
Should the documentation be updated to reflect version availability?
Code example:

const fields = interaction.fields; // ModalSubmitFields instance
const uploadedFiles = fields.getUploadedFiles('file_upload_custom_id', false); // Throws error
TypeError: fields.getUploadedFiles is not a function```


This is blocking proper handling of file uploads in modal interactions. Any guidance would be greatly appreciated!

- Thanks
-# AI generated
tardy sable

if your question is if message content contains the spoiler symbols || then yes it contains it

tardy sable
sharp ginkgoBOT
coarse meteor
tardy sable
normal flare
tardy sable
normal flare

:)

tardy sable

the comments above the function explains whats it doing

but i dont think thats still a thing

normal flare

I just got a person to test it on, it's still a thing cat_despair

visual patrol

is there any possible way to see more detail about what is causing "Received one or more errors" on an embed builder

tardy sable
wary coral
tardy sable
visual patrol
normal flare
barren nacelle

What is required to make it so you're app can listen to slash commands being used in private text channels between friends on discord?

i've defined the data in my slash command data object

nevermind i solved it

heady sundial

Is it possible to host any part of Discord.JS on Vercel? I'm fine if the WS has to be hosted somewhere else.

bleak owl

discord.js is not meant for web development

heady sundial
stable sun

The WS is the only reason you’d use d.js tbh

I guess the correct question here is why?

jagged rock

how to stop a invalid webhook token i have added check but that doesnt seem to work

rose tangle

"stop" how?

you mean catch the error, or...?

you can't know beforehand if the token is invalid, if that's the question

maybe you could do some basic checks but that's about it, nothing definite

stable sun

Also please show code and the entire error (with stack trace)

swift jewel

does modal submit interactions include in interaction.isMessageComponent() this check ?

halcyon bison

no, modal submits aren't message components

sharp ginkgoBOT
swift jewel

alr thanks

red epoch

How many components with LabelBuilder can I put in the "labelComponents" array in the code ts .setLabelComponents(labelComponents); in a modal?

I couldn't find any sources about this.

snow onyx
wary coral
deft ermine

does anyone know how I can display the commands bar, as seen in the dank memer's bio?

wary coral
deft ermine
wary coral
deft ermine
wary coral

corrent, DDevs may be able to help more

deft ermine
wary coral

pretty much

loud hemlock

Why can't we assign strings to InteractionContextType? Using integers like 0, 1, 2 makes it confusing sometimes

deft ermine
golden laurel
loud hemlock
wary coral
red epoch
snow onyx

yes?

red epoch

There is a modal label component limit. Yes

My whole plan went to waste 😭

snow onyx
red epoch
      const modal = new ModalBuilder()
        .setCustomId(`anket_${optionCount}`)
        .setTitle("Anket Oluşturma");

      const questionLabel = new LabelBuilder()
        .setLabel("Anket Sorusu")
        .setDescription("Deneme")
        .setTextInputComponent(
          new TextInputBuilder()
            .setCustomId("question")
            .setStyle(TextInputStyle.Short)
            .setPlaceholder("Anket sorusunu girin")
            .setRequired(true)
            .setMaxLength(80)
        );
      const labelComponents = [questionLabel];
      for (let i = 1; i <= optionCount; i++) {
        const optionLabelComponent = new LabelBuilder()
          .setLabel(`${i}. Seçenek`)
          .setTextInputComponent(
            new TextInputBuilder()
              .setCustomId(`option_${i}`)
              .setStyle(TextInputStyle.Short)
              .setPlaceholder(`Anketin ${i}. seçeneğini girin`)
              .setRequired(true)
              .setMaxLength(80)
          );
        labelComponents.push(optionLabelComponent);
      }

      modal.setLabelComponents(labelComponents);
      interaction.showModal(modal);```

this code is inside the slash command

wary coral

what are you looking for modals can only have 5 top level components?

carmine basin

Hi, the modals guide mentions using modal.addComponents() but the reference docs don't include that method. Is the guide outdated? And if it is, is using label components the same as the previous use of action rows with respect to modals?

red epoch
carmine basin
untold mango
golden laurel
marble siren

Hey everyone, is this a common error with the newest d.js version?

...\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4
  client.actions.InteractionCreate.handle(packet.d);
                                   ^ 

TypeError: Cannot read properties of undefined (reading 'handle')```
golden laurel

No

marble siren
golden laurel No

So how i can fix this? Maybe my node.js version is to old, i use 22.2.0.

steel trail

I'll wager a guess and say you extend client and overwrite the .actions property

golden laurel

That would be my guess too

marble siren

I checked and you were right. I apologise for the inconvenience and thank you.

inner kernel

how to check that emoji is custom(uploaded) or not(unicode)?

steel trail

Where do you get that emoji you want to check?

inner kernel

reactions

sharp ginkgoBOT
steel trail

This?

inner kernel

yes

steel trail

If it has an id it's a guild/app emoji. If not then the name is the Unicode

inner kernel

so you mean if unicode name will have like 😄
if it has id it is like OMEGAlul ?

steel trail

The former will have .id === null, the latter a snowflake, yes

Assuming you did finally update to v14

inner kernel

so i have to make type guard?

btw is the emoji url must have that tokens like attachments do?

steel trail
steel trail
inner kernel
steel trail

You mean the expiration, no, emoji URLs don't expire

fair palm

How to get attachment from file upload?

sharp ginkgoBOT
fair palm
inner kernel

wait now we have file upload on modal??

tardy sable
silent mirage

question if i remove send messages permission from user and view channel permission can they not click on buttons

tardy sable

send message permisssions doesnt affect buttons

sand minnow

I have an issue with my reaction role system, if I turn the bot off then back on, if I had a reaction role set before it went offline when it goes back online it doesn't register it or count it when I react

sand minnow
fallow finch
sand minnow
sharp ginkgoBOT
fallow finch

don't think that's the correct one

sand minnow

I'll check, thanks

tardy sable

@sand minnow you have to enable partials for message reactions and if reaction partial fetch it

sharp ginkgoBOT

guide suggestion for @sand minnow:
guide Listening for reactions on old messages
Messages sent before your bot started are uncached unless you fetch them first. By default, the library does not emit client events if the data received and cached is not sufficient to build fully functional objects. Since version 12, you can change this behavior by activating partials. For a full explanation of partials see this page. If you use gateway intents but can't or don't want to use the privileged GuildPresences intent, you additionally need the User partial.
read more

sand minnow

Thank you guys

@tardy sable @fallow finch it works now, thanks a lot

turbid igloo

is it mandatory to disable button after duration of time?

sand minnow

I don't think so atleast

turbid igloo
fallow finch

I would say it's a good design so the user knows they can't click it anymore

tardy sable
turbid igloo

so buttons don't expire huh'

wary coral

Correct

tardy sable

if you dont use them in a collector theyre always active

turbid igloo

ooo
thx for info

bronze bronze

Anybody understand why my embed sends if I run another command first?

Whenever I run /info, it'll not respond. But if I do /ping, then it'll respond.

steel trail

Probably because your code does something weird... without seeing your code it's hard to say more

bronze bronze

I mean the commands are quite basic nothing crazy that's why I'm confused

drowsy vault

is it possible to make a browser extension that adds multiple context menu buttons

tardy sable
bronze bronze
steel trail

And are you sure your bot was online while doing the first command?

steel trail
bronze bronze
steel trail

You're basically adding a new listener every time a command is run. Your third command use should actually cause an error in console

bronze bronze

Yeah, it was a interaction error and looking at that I should've known. 😅 It works now tho!

untold mango

What would stop the bot actually playing a stream.mp3 link? It joins channel but no sound at all

steel trail
untold mango

I posted in there yesterday with as much info as possible

silent mirage

what does this error mean it happens when i submit a modal

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
mental idol

Hello d.js Support
I'd like to ask if the red line indicating an error in await is normal, or is the problem on my end?

I'm currently following the guide in order and would like to know if this is normal or not.

topaz bluff

async (interaction) => {

You forgot an async

Can't use await without async

mental idol
sharp ginkgoBOT

documentation suggestion for @mental idol:
mdn await
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async function or at the top level of a module.

rose tangle

you can search on mdn for usage of js operators and js syntax in general

it also mentions your solution

It can only be used inside an async function or at the top level of a module.

mental idol

Currently... I'm thinking of proceeding step by step with a guide.

topaz bluff

Strong recommendation. Do not use AI. It's the fastest solution to a problem but it frequently makes mistakes and even when it doesn't, you don't end up learning

Do it the "hard way" and search places MDN and StackOverflow and try and solve problems there first

mental idol
topaz bluff

Like AI chatbots, not editor tools like autocomplete and spell check...those are fine

mental idol
topaz bluff

But my recommendation is more general. AI is a great tool, I use it a lot. But I also know that by using it, mistakes (bugs or bad practices) could be introduced or that I just won't have as good of an understanding of how my own project will work

Use your own personal judgement on when to use it or not. Just don't rely on it or you can dig yourself into a hole

sand minnow
topaz bluff
mental idol
sand minnow
topaz bluff

It's really not. It's a common typo of a callback function. They're fairly unintuitive for people who haven't used JS

...ya

steel trail
sand minnow
verbal vine

Can i make a Button without label in ContainerBuilder?

sand minnow

A button needs to have a label otherwise you'd get an error

verbal vine

okay

steel trail

It needs a label or an emoji

sharp ginkgoBOT
sand minnow
steel trail

Since that is what djs constructs for data it receives, not meant for creating buttons, no

topaz bluff

The DJS docs don't show most requirements. That's where you want to go to the discord API docs to see

silent mirage

Can bots set vanity links

dense jackal

for obvious abusive reasons

mental idol

Hello Discord.js support,

I have a question regarding the difference between using:

const { SlashCommandBuilder } = require('discord.js');

const data = new SlashCommandBuilder()
    .setName('echo')
    .setDescription('Replies with your input!');

and using:

const { SlashCommandBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('ping')
        .setDescription('Replies with Pong!'),
    async execute(interaction) {
        await interaction.reply('Pong!');
    },
};

Because in the guide, it initially used module.exports, but when it entered the "echo" command example, it switched to using const data = new SlashCommandBuilder().

As I understand it, the code should contain both "data" and "execute". Therefore, the second example, const data = new SlashCommandBuilder(), will not work without execute.

Which is correct and better: using module.exports or const data = new SlashCommandBuilder()?

unique shoal

doesnt matter

The only difference is you still have to export const data later instead of doing it directly

jagged rock
DiscordAPIError[50027]: Invalid Webhook Token
    at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:762:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:1163:23)
    at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:994:14)
    at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1307:22)
    at async InteractionWebhook.editMessage (/home/container/node_modules/discord.js/src/structures/Webhook.js:351:15)
    at async ChatInputCommandInteraction.editReply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:247:17)
    at async Object.execute (/home/container/Events/Interaction/InteractionCreate.js:87:7) {
  requestBody: {
    files: [],
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      enforce_nonce: false,
      embeds: [Array],
      components: [],
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined,
      thread_name: undefined,
      applied_tags: undefined,
      poll: undefined
    }
  },
  rawError: { message: 'Invalid Webhook Token', code: 50027 },
  code: 50027,
  status: 401,
  method: 'PATCH',
  url: 'https://discord.com/api/v10/webhooks/'
}

How to fix this error and what's the cause

unique shoal

Did you attempt to edit after more than 15 minutes

Though that URL seems odd, where the rest of it

jagged rock
stable sun

Is the webhook id and token being omitted?

unique shoal

Yeah they invalidate after 15 minutes

stable sun

Did you omit it? Or you just copied pasted the error as is?

jagged rock

i jsut remove most of the url, everything else is how it is

mental idol
jagged rock

i also know what its coming from its a automated command where the gbot updates the progress oin an embed then sets up everything for you

jagged rock
unique shoal

Both define a variable named "data" and to use it in other files, it needs to be exported

jagged rock
DiscordAPIError[50027]: Invalid Webhook Token
    at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:762:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:1163:23)
    at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:994:14)
    at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1307:22)
    at async InteractionWebhook.editMessage (/home/container/node_modules/discord.js/src/structures/Webhook.js:351:15)
    at async ChatInputCommandInteraction.editReply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:247:17)
    at async Object.execute (/home/container/Events/Interaction/InteractionCreate.js:87:7) {
  requestBody: {
    files: [],
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      enforce_nonce: false,
      embeds: [Array],
      components: [],
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined,
      thread_name: undefined,
      applied_tags: undefined,
      poll: undefined
    }
  },
  rawError: { message: 'Invalid Webhook Token', code: 50027 },
  code: 50027,
  status: 401,
  method: 'PATCH',
  url: 'https://discord.com/api/v10/webhooks/1360006420619329727/aW50ZXJhY3Rpb246MTQzNDU4MDYzNDkyNzUwMTM5MzpnTDNhZUpZb2xqc0JBcm53dkpDb0pBRTNJTURVUjZraWhDeE5Db0piaUF4eUZiNU9sT3NFdkRtQkt3cWFsS2hzVmtldjBpTFNGOHBDT2VLQm5MTEdGWFlIejJIeU44MXFabUVkZm52QXZRRno5MEp2emt6OWxvT2p4QjNXNlFVTw/messages/%40original'
}
unique shoal
jagged rock

i know mate, i dont klnow how to get around it

unique shoal

You dont

You take less than 15 minutes

Or send new messages some other way

mental idol
stable sun
unique shoal

But yeah I already pointed out it still needs exporting

mental idol
jagged rock
unique shoal
const data = ...
const execute = ...
module.exports.data = data;
module.exports.execute = execute;

module.exports = {
  data: ...
  execute: ...
}

These are essentially identical for your needs, unless you for some reason needed to reuse the const references to this (which you probably dont)

unique shoal

Its not the relevant part of the code at all

unique shoal
jagged rock
unique shoal

Its possible the ephem was dismissed then

Nothing to update

jagged rock

howits ephemral

stable sun
jagged rock
stable sun

And the message is deleted and no longer exists

jagged rock

so what should i do make it not epehrmal

stable sun

Handle the rejection

It can still happen with non-ephemeral messages

unique shoal

What do you mean "make it not ephemeral", its your message isnt it? You chose for it to be ephem?

stable sun

Admin deletes message and now you can’t update it anymore

mental idol
stable sun

"Easier” is subjective

mental idol
stable sun "Easier” is subjective

Perhaps because I'm still learning, I might choose the easier method, but maybe later I'll switch to the other one.

But you've explained that they both serve the same purpose.

So thank you and monbrey.

stable sun

Some prefer less lines, some prefer less indents

I don’t see any benefit of factoring out data and execute besides indent

mental idol
stable sun I don’t see any benefit of factoring out data and execute besides indent

To confirm the information I have in mind:

const { SlashCommandBuilder } = require('discord.js');

const data = new SlashCommandBuilder()
    .setName('echo')
    .setDescription('Replies with your input!')
    .addStringOption((option) => option.setName('input').setDescription('The input to echo back'));
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('echo')
        .setDescription('Replies with your input!')
        .addStringOption((option) => option.setName('input').setDescription('The input to echo back')),
};

They are the same thing.

I apologize for the repetition.

topaz bluff

module.exports.data = data is needed for the first one

mental idol

like this:

const { SlashCommandBuilder } = require('discord.js');

const data = new SlashCommandBuilder()
    .setName('echo')
    .setDescription('Replies with your input!')
    .addStringOption((option) => option.setName('input').setDescription('The input to echo back'));

module.exports.data = data; // or module.exports = { data }
topaz bluff

Or
module.exports = { data }

mental idol
sharp ginkgoBOT

tag suggestion for @open musk:
Frequently Asked Questions: learn more

arctic badge

Hi, is anyone aware if the Discord API / DiscordJS has support for the apply to access for guilds? (i.e. approving / denying applicants)

stable sun
arctic badge

Gotcha, thanks :)

rigid knot

how to get image tag

sharp ginkgoBOT
rigid knot

@@bleak owl get me image tag

bleak owl

what image are you referring to? also, a "please" is helpful

rigid knot
unique shoal

Generating images has nothing to do with discord.js

barren nacelle

can select menus have autocomplete or no?

bleak owl

not at this time, no

barren nacelle

alright i felt like they did but i guess not

i just wanted to be sure before i wasted time thinking of an idea to do.

bleak owl

there are auto populating select menus like user, channel, role and mentionable, but not string menus unfortunately

carmine basin

Hi, does discordjs have any datetime pickers or similar interaction components?

clear garnet

We do not dictate what kinds of components exist on Discord, we can only implement support for existing ones

carmine basin

Ah okay so discord just doesn't support them at all. Thanks!

crisp roost

did discord break the bot statuses (i cannot see the “watching” part in my bots status, the rest is there)

bleak owl

well, it's hard to say since we are not discord

topaz bluff

But to save you a trip to DDevs, yes they're going away. It's an experiment

barren nacelle

Are you able to make it so you can just type what you want in a select menu without it being choices?

stable sun

Only slash commands support autocomplete on string options

barren nacelle

alright

can you still use text inputs on modals?

stable sun

Yes

barren nacelle

alright i'll do that thank you for replying to me

silent mirage
          name: `ticket-transcript-${Ticket.ticketId}.html`,
          description: `Transcript for ticket ID: ${Ticket.ticketId}`,
        });

sorry question is this how you send attachments

topaz bluff

This is the example from the guide of how to send an Embed with an attachment

const { AttachmentBuilder, EmbedBuilder } = require('discord.js');
// ...
const file = new AttachmentBuilder('../assets/discordjs.png');
const exampleEmbed = new EmbedBuilder().setTitle('Some title').setImage('attachment://discordjs.png');

channel.send({ embeds: [exampleEmbed], files: [file] });

Make sure to send the attachment in the files field

barren nacelle

Why would this type be never ?

stable sun
barren nacelle
rose tangle

that collector doesn't collect modal interactions

use awaitModalSubmit instead

barren nacelle

Can you use that if the modal is used more then once?

or it listens for 1 use of the modal

topaz bluff

How can a single interaction have 2 modal submits?

barren nacelle

How would i listen to my modal from inside the collector?

stable sun
barren nacelle

Ah okay so that won't work atleast but i moved on from trying that

stable sun

You can wait for a button press or select menu selection then show modal and wait for it

stable sun
barren nacelle

thanks

stable sun

I don’t think you need the response from showModal

barren nacelle

prob not

carmine basin

Do select menus support multiple selections? I had assumed they do, given the min and max values u can set, but when I try adding more than one choice, the dropdown seems to bug out and keeps instantly closing when trying to open it

rose tangle

they do assuming you passed valid min and max values (min <= amount of options < max)

the api will validate you're passing valid values anyways

that sounds more like a UI issue though

barren nacelle

why is this type never?

i'm trying to get the values from a select menu on a modal

i log it and this shows.

ruby bane

given the fact that its actual type is Extract<ModalData, { type: Type }> it might just be a TS interpreter issue, since its definitely mapping to SelectMenuModalData, but it thinks extract cant map to it?

you should be able to define loaderInput as SelectMenuModalData if you reallyyyyy want the properties

rose tangle

you should use the getter for string selects instead

sharp ginkgoBOT
rose tangle

you're not supposed to use the raw getField

carmine basin
rose tangle that sounds more like a UI issue though

yeah it does seem to be a ui issue. I was thinking i might have been missing some required values or something but I imagine it should error if that was the case:

const excludedUsersSelect = new UserSelectMenuBuilder()
        .setCustomId('excludedUsersSelect')
        .setRequired(false)
        .setPlaceholder('Select any members that should not be purged regardless of activity')
        .setMaxValues(25);

Would I be correct in thinking this may be more a discord ui issue rather than something related to discord.js? Also if it's relevant, I'm using the select inside a modal using a labelbuilder

rose tangle

that looks fine, also if shows the modal correctly then yeah it's a ui issue

make sure your client is up to date

carmine basin

yeah it is. I'll investigate further and/or pray it automagically fixes itself lmao

ruby bane
steel trail
normal flare

discord question, is there a Message limit in threads, as in, how many messages can a single thread have?

bright cradle
unique shoal
normal flare
normal flare
bright cradle

no errors

bright cradle
normal flare
bright cradle

it doesnt matter

normal flare

wdym, you're using the second arg in your code, client

bright cradle

yeah it doesnt matter if I use it or not, it wont affect the output

normal flare

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

change this to

if(!command) {
  await interaction.reply({content: "command not found"})
  return
}
bright cradle

yeah i've tried your way, still no result

it jsut says command not fouind

bright cradle

I did that, they way you've said

normal flare

send your updated code.

unique shoal
bright cradle
normal flare send your updated code.
module.exports = {
    name: "interactionCreate",
    async execute(interaction, client) {
        if (!interaction.isChatInputCommand()) return;
        
        const command = client.commands.get(interaction.commandName);
        // if(!command) return;
        if(!command) {
            await interaction.reply({content: "command not found", ephermeral: true})
            return
        }

        try {
            await command.execute(interaction, client)
        } catch(err) {
            console.error(err)
        }
    }
}```
const { SlashCommandBuilder } = require("discord.js");

module.exports = {
    data: new SlashCommandBuilder()
        .setName("ping")
        .setDescription("replies with ping, for now.."),
        // .ephermeral(true)
    execute (interaction) {

        interaction.reply("pong!")
        
    } 
}```

I've checked the path, its all good

normal flare
module.exports = {
    name: "interactionCreate",
-   async execute(interaction, client) {
+   async execute(interaction) {
        if (!interaction.isChatInputCommand()) return;
        
-       const command = client.commands.get(interaction.commandName);
+       const command = interaction.client.commands.get(interaction.commandName);
bright cradle

same error "command not found"

normal flare

also in the same file

- await command.execute(interaction, client)
+ await command.execute(interaction)
bright cradle

yeah I did that already

low spear

is it normal for a typescript bot to use 150mb+ of memory when deployed to heroku

bright cradle

@normal flare any idea why its happening?

low spear
bright cradle

could you explain it better?

low spear

you are registering them right

what is your "client.commands"

bright cradle
topaz bluff

So your issue is loading the commands, not deploying them

client.commands is not something added by DiscordJS. Where are you making it and how are you filling it with data?

This is the example of how to do that from the guide

client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);
for (const folder of commandFolders) {
    const commandsPath = path.join(foldersPath, folder);
    const commandFiles = fs.readdirSync(commandsPath).filter((file) => file.endsWith('.js'));
    for (const file of commandFiles) {
        const filePath = path.join(commandsPath, file);
        const command = require(filePath);
        if ('data' in command && 'execute' in command) {
            client.commands.set(command.data.name, command);
        } else {
            console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
        }
    }
}
bright cradle

yeah its there in index.js

topaz bluff

But...specifically how are you filling that collection

That there looks like an empty Collection just called commands which would explain why it's not finding a command by any name in your interactionCreate event

bright cradle

wait

bright cradle
topaz bluff

```diff

  • green
    - red
    ```
bright cradle
- client.commands.set(command.data.name)
+ client.commands.set(command.data.name, command)
``` in line 11 I made this change if that would make any difference
topaz bluff

Yes it would. collection.set(key, value) means that now you can search for an Object value using the String key of the name of the command

sharp ginkgoBOT

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

topaz bluff

Not adding a Value meant that getting a value was returning undefined

bright cradle

Still no results..

bright cradle

thanks so much

topaz bluff

Are you deploying command every time you start your bot?

That's a different issue and can cause rate limiting. But happy it's working for now.

Try and separate command loading and command deployment (actually sending to Discord) to avoid the rate limit

bright cradle

how can I make messages ephermeral?

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

module.exports = {
    data: new SlashCommandBuilder()
        .setName("ping")
        .setDescription("replies with ping, for now.."),
    flags: MessageFlags.Ephemeral,
    execute (interaction) {

        interaction.reply("pong!")
    } 
}```  I tried this but its not working
little pebble
sharp ginkgoBOT

guide Ephemeral responses
You may not always want everyone who has access to the channel to see a slash command's response. Previously, you would have had to DM the user to achieve this, potentially encountering the high rate limits associated with DM messages, or simply being unable to do so, if the user's DMs were disabled. Ephemeral responses are only available for interaction responses; another great reason to use the new and improved slash command user interface.
read more

west pier

is it just me or client.on messageCreate dont return .content anymore?

rose tangle

it does

if it's an empty string then you probably don't have the MessageContent intent

west pier

it is an empty string, but i also do have the messagecontent intent on the discord developer apps

this one right?

rose tangle

that allows you to request it without getting an error

you'll still need to actually request it on your Client constructor

west pier

oh, one sec let me try it

ohh it worked now, i dont know why it doesnt work now though, i changed nothing for the intent bits. it was 32767. i currently have another active bot thats using this intent bit and still worked, i guess its a new change in the update?

sharp ginkgoBOT

tag suggestion for @west pier:
We highly recommend only specifying the intents you actually need.

  • Note, that 98303, 32767 or whatever other magic number you read that represents "all intents", gets outdated as soon as new intents are introduced.
  • The number will always represent the same set of intents, and will not include new ones. There is no magic "all intents" bit.
west pier

i just found out im illiterate, thank you though 😺

rose tangle

an actual intents list would also let you easily know what you do and don't have

west pier

yeah i shouldve used that instead of these funky numbers, hate to admit i was too lazy to care about the intents i needed... 💔

glad oxide

Hey everyone, wondering if there's a "proper" way to write the following code:

async function main() {
  const client = new Client({intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers]});
  client.login(config.token).catch(console.error);

  const channel = await client.channels.fetch('get ID from some persisted data');
  if (channel) {
    if (channel.isTextBased()) {
      // TS error: Property 'send' does not exist on type 'Channel'.
      channel.send({content: 'Hello world!'});

      // Just hack around it
      const ch = channel as TextChannel;
      ch.send({content: 'Hello world!'});
    }
  }
}

during regular interactions replying has no problems since the interaction has a strictly typed channel, but when fetching it like this it could be anything and the isTextBased() doesnt seem sufficient for TS
I'm not the most proficient with TS itself so I don't know what the feasability of a typeguard like that is mind you

sharp ginkgoBOT
glad oxide

ah perfect, that did the trick 👍

are there text based channel types that lack a send method then?

little pebble
glad oxide

hm 🤔

ruby bane
little pebble
ruby bane

oh wait nevermind its specifically worded as "between 2 members"

spark bough

hey is it possible to unemphemeral a message via interaction.editreply?

spark bough

oh alr

spiral wyvern

I get a warning that TextIunputBuilder.setLabel is deprecated and I should use a LabelBuilder but how do I add the LabelBuilder to the TextInput?

steel trail

You do the opposite, you add the TextInput to the labelbuilder

spiral wyvern

oooh

thanks

sharp ginkgoBOT
ivory wasp

Is there a section in the guide that covers monetization/skus?

vestal sun

is there a way for me to defer an interaction and then send an modal* ? i need to make 1-2 web calls before i can answer and i could potentially run into the window of not beeing able to answer in time

specificly talking about AnySelectMenuInteraction and the <interaction>.showModal() function (or any other way if thats even possible)

Example: https://pastebin.com/B8HPwF6Z

wary coral
vestal sun

oh sorry i misstyped that it was ment to say Modal*

wary coral

ah well than no. showModal must be a first respose to an interaction

ivory wasp

What's the most efficient way to check if a guild has a particular Entitlement?

tardy sable

i think thats called guild features

sharp ginkgoBOT
ivory wasp

Don't think so

wary coral
wary coral

Ah. Give me a sec

sharp ginkgoBOT
wary coral

you then need to check the entitlement for the guild

ivory wasp

And subsequently I have to manage the caching myself then?

wary coral

not necessary ClientApplication#entitlements is a EntitlementManager which has a cache

it works similarly to UserManager or GuildManager

sharp ginkgoBOT
ivory wasp

Ok so in theory if I call eg fetch() on entitlements on every message send, it's fine since the internal cache will manage it? My bot handles every message sent so I want to make sure I'm not looking up entitlements repeatedly on every message

wary coral

correct

ivory wasp

Ok thank you

wary coral
ivory wasp Ok thank you

I am not happy with my solution so I am looking at FetchEntitlementOptions and FetchEntitlementsOptions on how to make it better (ie limit to target guild)
got it in FetchEntitlementsOptions give me a sec to write it down

fleet patio

hi! I haven't worked with Discord bots in a long time and I was just wondering how I could add horizontal breaks and embedded buttons like these

sharp ginkgoBOT

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

wary coral
noble pendant

can someone help me? im trying to build a bot im using replit and keep getting errors, i can invite u to my replit project

unique shoal

Just ask about the problem you're having, we don't want to go to replit

bleak owl
noble pendant
bleak owl

nope, please send the error here

noble pendant
bleak owl

you do not, please send the error here

noble pendant
bleak owl

no one here can help you if you don't explain the problem by showing your code and error

noble pendant

[dotenv@17.2.3] injecting env (10) from config.env -- tip: 🔐 prevent committing .env to code: https://dotenvx.com/precommit
Successfully registered application commands.
Connected as 10#2798
node:events:502
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'EPHEMERAL')
at Client.<anonymous> (/home/runner/workspace/index.js:315:34)
at Client.emit (node:events:524:28)
at InteractionCreateAction.handle (/home/runner/workspace/node_modules/discord.js/src/client/actions/InteractionCreate.js:101:12)
at module.exports [as INTERACTION_CREATE] (/home/runner/workspace/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/runner/workspace/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31)
at WebSocketManager.<anonymous> (/home/runner/workspace/node_modules/discord.js/src/client/websocket/WebSocketManager.js:236:12)
at WebSocketManager.emit (/home/runner/workspace/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)
at WebSocketShard.<anonymous> (/home/runner/workspace/node_modules/@discordjs/ws/dist/index.js:1190:51)
at WebSocketShard.emit (/home/runner/workspace/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)
at WebSocketShard.onMessage (/home/runner/workspace/node_modules/@discordjs/ws/dist/index.js:1007:14)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:407:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v20.19.3

when i fix one line then it goes to another line

bleak owl

to fix the error, you need to use MessageFlags.Ephemeral

noble pendant
noble pendant
bleak owl

thats not quite what i suggested

noble pendant
bleak owl

no,

MessageFlags.Ephemeral
noble pendant

do i need to change everywhere its that? to that?

bleak owl

correct

noble pendant
bleak owl

no

MessageFlags.Ephemeral

noble pendant

ok let me try that now

noble pendant
bleak owl `MessageFlags.Ephemeral`

/home/runner/workspace/index.js:73
MessageFlags.Ephemeral,
^

SyntaxError: Unexpected token '.'
at wrapSafe (node:internal/modules/cjs/loader:1472:18)
at Module._compile (node:internal/modules/cjs/loader:1501:20)
at Module._extensions..js (node:internal/modules/cjs/loader:1613:10)
at Module.load (node:internal/modules/cjs/loader:1275:32)
at Module._load (node:internal/modules/cjs/loader:1096:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
at node:internal/main/run_main_module:28:49

Node.js v20.19.3

bleak owl

please show your code, you have a syntax error

noble pendant

its manyy lines shall i send one line?

normal flare

Hello, I want to add a feature where the user manually adds a role to himself, role is pre-determined (1 role), should I do this with reactions or with a button?

noble pendant

MessageFlags.Ephemeral,
line 73

sharp ginkgoBOT

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

noble pendant
bleak owl

please send a picture of your code, showing the error

normal flare

How are you importing MessageFlags

noble pendant
bleak owl

did you make that code yourself?

you're using an outdated api version

normal flare
polar karma

can't, you'd just check if they have it and return if they do

noble pendant
tardy sable
bleak owl

did you make that code yourself? what version of discord.js are you using?

normal flare
oak fossil

can someone explain what a PrimaryEntryPoint is?

noble pendant
bleak owl
bleak owl
noble pendant
bleak owl

who made it then?

oak fossil
bleak owl

it invokes a discord activity

noble pendant
oak fossil
bleak owl
bleak owl
oak fossil

ty

bleak owl
noble pendant bro

it's hard to help someone that didn't make their own code and has no idea how to fix it, especially with code that is outdated and incorrect

bleak owl

i did already

but it would seem like parts of your code still do not work

so i suggest looking at the discord.js guide to start over

noble pendant
topaz bluff
normal flare

how does this work exactly,
bot sends a button component in some channel that users click to get a role
bot gets restarted for any reason (re-deployment)

what happens now, is the old button component that was already sent still working?
Do I need to delete it and send it again?

polar karma

no

any new button pushes will send a new interaction for your bot to respond to irrespective of the message's age or cached status

normal flare
polar karma

yes

normal flare

got it, thanks again

safe wigeon

To get the display name of the member who sent a message, would it be message.author.displayName or message.member.displayName? I'm a bit unsure

clear garnet

author is their User, member is their GuildMember

sharp ginkgoBOT

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

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

anyone know why this might be incorrect

stable sun

Can’t use reply after deferReply

Either remove deferReply (recommended), or use editReply instead of reply

oak fossil

sorry I forgot to change it back to editReply, that's when it breaks

I can do a reply on its own, but when I do editReply after deferring, I get Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.

stable sun

Show the entire error w/ stack trace

Could be bc the deferReply wasn’t awaited tbh

oak fossil

it's a synchronous function tho

stable sun

Change it to async

It’s returning void anyways

But yea, the deferred state is only updated after the deferReply finishes

oak fossil
node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:253
    if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied);
                                               ^

Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
    at UserContextMenuCommandInteraction.editReply (node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:253:48)
    at UserInfo.run (user/src/actions/user/UserInfo.ts:11:21)
    at Bot.dispatchUserAction (src/core/Bot.ts:197:16)
    at Bot.dispatchInteraction (src/core/Bot.ts:181:18)
    at InteractionCreate.run (/Users/joey/Documents/Code/bot-lib/user/src/events/InteractionCreate.ts:7:11)
    at Client.<anonymous> (src/core/Bot.ts:307:23)
    at Client.emit (node:events:508:28)
    at InteractionCreateAction.handle (node_modules/discord.js/src/client/actions/InteractionCreate.js:101:12)
    at module.exports [as INTERACTION_CREATE] (node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31) {
  code: 'InteractionNotReplied'
}
oak fossil
normal flare

@noble pendant Please do not send me DMs, I do not know you

Question about ids, what's the scope of defining an ID, is it the whole client? the channel where the component is sent to, or the message containing the component

cobalt plover

would it be possible for all djs errors to return a non-zero exit code? I'm currently struggling with a github pipeline because it doesnt halt, even though there is a command deploy error

polar karma
golden laurel
normal flare

like a button, where I give it an id, then I send that button via, channel.send

noble pendant
unique shoal

Yes, as per the Server Guide

ivory wasp

Is it possible to set a custom profile picture for a bot for a specific guild like i can with discord nitro?

sharp ginkgoBOT
tardy sable
stable sun
radiant bolt

why my bot can't ban even if it has admin perms

DiscordAPIError[50013]: Missing Permissions
    at handleErrors (/home/container/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:148:10)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:417:20)
    at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:169:11)
    at async _REST.request (/home/container/node_modules/@discordjs/rest/src/lib/REST.ts:210:20)
    at async GuildBanManager.create (/home/container/node_modules/discord.js/src/managers/GuildBanManager.js:169:5)
    at async BanCommand.run (/home/container/modules/Utility/ban.js:42:13)
    at async InteractionCommandHandler.interactionCreate (/home/container/modules/InteractionCommandHandler.js:49:13)
    at async BotClient.<anonymous> (/home/container/structures/ModuleManager.js:80:33) {
  requestBody: { files: undefined, json: { delete_message_seconds: 0 } },
  rawError: { message: 'Missing Permissions', code: 50013 },
  code: 50013,
  status: 403,
  method: 'PUT',
  url: 'https://discord.com/api/v10/guilds/607686647307304970/bans/1429421261984895039'
}
bleak owl

are you trying to ban the server owner?

sharp ginkgoBOT
  • Bots cannot moderate (kick/ban/nickname/...) a target with a higher or equally high highest role or the guild owner.
  • Bots cannot modify (edit/add/remove) roles that are higher or equally high compared to the bot's highest role.
  • The Administrator permission does not skip these checks.
radiant bolt

i forgot i did some role reworking those days and yea i put the bot role under the members one so that's why 🥲

Thank you!

ashen quartz

Not a super complex question, but I've been trying to figure out how to use these little rich presence icons to the left of the activity (the little green tv, here)

bleak owl

are you streaming in a voice channel at that time?

bot's can't stream video

ashen quartz

Not really, I'm using an app that displays what I'm watching on Plex as an activity (similar to Spotify's status)

But if bots just can't show that kind of status that's that lol

bleak owl

oh, well, bot's don't have rich presence, sorry

ashen quartz

At least it's an easy solution lmao

tardy sable

do i need attachfiles perms to attach files in ephemeral messages?

tardy sable

thanks

ruby bane

np

mental idol
topaz bluff

SoonTM

mental idol

Or two weeks

topaz bluff

When it's ready. It's in the finishing touches phase

There's a preview link if you want to use the WIP version

mental idol

But what do you mean by "It's in the finishing touches phase"

topaz bluff

Read the PR. The content is finished, it's just grammar and formatting changes right now

mental idol

ok thx agine

rose tangle

this is for support with the discord.js library

west tide

nvm i figured it out mb

rose tangle

no worries, next time for api-related questions or something about the panel, you can ask in ddevs instead #useful-servers

brazen zinc

I am taking emoji input as a string option in a slash command and need to get the id.

I have to have the id because I am storing the emoji in mongodb until a later date and it would seem that a good number of the discord default emoji are not a part of the unicode library so they get borked when I store them.

Unfortunately, from what I cant find in the documentation, there seems to be no way to get the id if you don't already know the name.

I really feel like I must be missing some foundational knowledge here so if I am just an idiot who can't read, feel free to say as much but do please still tell me what I failed to read.

proud arrow

How do you expect to get the emoji without anything to identify it? Be it their name or id. Also do note that emoji name is not unique across servers

brazen zinc

I wasn't sure if I had just misinterpreted the documentation. From what I read, what I need seems impossible. Unfortunately, I don't really see any other way to do what I am trying to do in the bigger picture. Take emoji as text, store it, repost it later. Because the client converts it to the image before sending off the command, I was pretty sure this is a dead end, I just wanted to be 100% sure before I gave up on it and moved onto working out another feature.

proud arrow
rose tangle

but you get both the name and id when you get the command interaction

with the <:a?:name:id> format

brazen zinc
rose tangle

well in any string you get from the api, emojis are either in unicode or with the mentioned format

you can then send that same string and it'll show the emoji

basically

const content = message.content; // or any other user input with emojis
await channel.send(content);

should show the original content, including the emojis, without issues, though it must have the use external emojis permission

though if you're sending the content on another guild, then (in addition to the permission), the bot must be on the guild from where the emoji comes from

brazen zinc

I am not sure how to get that out of the interaction. getting interaction.options gives me this: CommandInteractionOptionResolver { _group: null, _subcommand: null, _hoistedOptions: [ { name: 'role_name', type: 3, value: 'testing' }, { name: 'role_emote', type: 3, value: '📝' }, { name: 'role_month', type: 3, value: '1' } ] }

stable sun

Best to rely on the guide and docs

const value = interaction.options.getString(optionName);

sharp ginkgoBOT

guide Advanced Command Creation
The examples we've covered so far have all been fairly simple commands, such as ping, server, and user which all have standard static responses. However, there's much more you can do with the full suite of slash command tools!
read more

stable sun

Apparently it’s covered in this part

Then it links to parsing options at the bottom

brazen zinc

This is where I think I am missing some foundation. Any time I try to get that data, JS interprets it as a unicode emoji and then breaks the non standard emoji. I understand getting the data out of the command but I need the id. I will continue to play with it for a bit and then revisit this tomorrow if i cant figure it out tonight

stable sun

Not sure what you mean

Unicode emojis and custom emojis are completely different formats

Custom emojis are always in the form <:name:id> (or <a:name:id> for animated ones)

brazen zinc

My issue is that some discord emojis are not in the standard unicode library. 🪨 🪶 and 🫄 are among a few that break in the flow that I have set up

stable sun

\🪨

tired kindle

Why does the discord bot die after some time of it being online without being used? (Not sending heartbeats or?)

stable sun

Ah, ur trying to validate Unicode emojis

rose tangle
rose tangle
brazen zinc
tired kindle
rose tangle

I'd look into how to make mongo not break with those values, haven't used it

rose tangle
stable sun

Should just store it as buffer/bytes?

brazen zinc
stable sun

Could just be ur console that can’t display them

rose tangle

yeah but you can still send them back to discord and it'll work fine, it's just not a standard emoji so it can't show it

tired kindle
stable sun
brazen zinc
stable sun

Are you putting the Unicode emoji in the name property?

rose tangle
brazen zinc
topaz bluff
rose tangle
rose tangle

pretty much as in yes, or...? since that's a built-in discord error

topaz bluff

No errors of any kind from your console?

tired kindle
brazen zinc
tired kindle
topaz bluff

Then that means you're losing your gateway connection...or your application is hanging

tired kindle
topaz bluff

Can't. Without diagnosing what it is...and where it's happening

Both of which can be done with logging

sharp ginkgoBOT
brazen zinc

Ladybugs and Gentleworms, I am an idiot. The array that I had stored in mongodb and was mapping data from was formatted incorrectly!!!

This is your friendly reminder to not write code 4 hours after dinner. You are too tired. Go to bed.

rose tangle

glad you worked it out though

toxic latch

Hello, what would be the correct way to check user's roles from ButtonInteraction? I'm trying to check if user has one of the required roles when clicking the button. It's a bit confusing with these 3 typings

crimson gale
proud arrow

I guess when member is APIGuildMember

stable sun

Or just type the interaction as such and pass the responsibility onto the caller

sharp ginkgoBOT
stable sun

You need this type guard either way

toxic latch
stable sun

Yea

toxic latch

Great. And if user is not cached, it'll auto-fetch his roles?

stable sun

Interactions come with the user and member

toxic latch

Perfect, thank you!

fair palm

Is it secure using user uploaded files?
I want to create something like ToS system. I want to give the ability to server owners update their ToS/Privacy Policy by uploading files.

export async function execute({ interaction, options }: CommandOptions<ModalSubmitInteraction>) {
    const [tosFile] = options;
    const attachment = tosFile.values().next().value
    const response = await fetch(attachment.url)
    const text = await response.text()
    console.log("File contents:", text);

}

Is it secure trusting user submitted files? I think file size is handled by discord as well as the content is displayed only as text. It's stored in discord cdn.
So my bot is going to store the url, fetch and send the file whenever its needed. Is there any security issue in that?

stable sun

Also, that url only lasts as long as the interaction does

Files sent via slash commands and modals aren’t stored/accessible forever

distant inlet
stable sun

I remember that there used to be certain characters that would crash iOS devices when rendered

obtuse laurel
verbal vine

how to check if bot working

stable sun

Make sure it responds as you programmed it to

If it’s supposed to reply to a specific slash commands, try executing the slash command

Stuff like that

verbal vine
stable sun

Check Discord

verbal vine

no in the code

stable sun

See if the bot still responds

Oh, you get an error

Well, most likely will get an error if you try to use an invalid token

If ur bot hasn’t alr shutdown due to being disconnected from Discord

verbal vine

there is event like on shutdown

sharp ginkgoBOT
stable sun

There’s prob a node event on process

verbal vine

thaanks

sharp ginkgoBOT

node 'beforeExit'
The 'beforeExit' event is emitted when Node.js empties its event loop and has no additional work to schedule.

stable sun

As that description mentions, there’s also a process exit event, depending on ur intentions

The process stuff only fires if you don’t have other stuff running in the code tho

Usually db connections

normal flare
export const autoRoleAssignment = createEvent(
  {
    name: Events.GuildMemberUpdate,
  },
  async (member) => {
    await member.fetch(); // with and without, log below shows roles before they changed
    console.log(
      `member ${member.user.tag} roles: ${member.roles.cache.map((r) => r.name).join(', ')}`
    );
  }
);

I have this code, createEvent is just a wrapper to create an event object

if the user has no role and I add role A -> log: @eveyone
if I then add role B -> log: @everyone, Role A

how do I get the updated roles list instead of the old list?

stable sun
sharp ginkgoBOT
stable sun

Notice that you get the old and new member in that order

normal flare

thanks 👍

fleet patio

Is it possible to show some commands only to users that have a specific role?

tardy sable
fleet patio
distant inlet
tardy sable

instead of hard coding it for every server

distant inlet

Do I really need to post more things google is showing me?

tardy sable

the first link is an outdated page. the second link only shows the command permissions. not how to hide a command for a specific role

distant inlet

Also Ctrl+F will probably tell you a lot more about the same question being asked here

tardy sable

those are not the same question

u can better link to a discord js doc instead of showing things that dont exist

obtuse laurel
fleet patio
tardy sable
distant inlet
tardy sable
bleak owl
fleet patio
tardy sable
fleet patio
bleak owl

the only way, without oauth, would be to configure it in the server settings > integrations, itself

fleet patio
tardy sable
bleak owl
distant inlet

they want to do it with a role, please read the conversation

distant inlet

Just check the kick permission and you are done, only staff that can kick have the command

tardy sable

?

distant inlet
bleak owl

a role, not permissions

distant inlet
bleak owl

you cannot hide a command based on a role in code without oauth

fleet patio
distant inlet

Thats why Im saying he can with perms

bleak owl

they don't want to do that though, that is the whole point

distant inlet
bleak owl

dont be rude, you're not being helpful on what they want

distant inlet

I'm out

tardy sable
fleet patio
distant inlet
tardy sable
fleet patio
late apex

Hi guys

wary coral

Hi how can we help?

late apex

When I use :
(àwait interaction.guild.members.fetchMe()).user

All the Bot info are returned but the banner is undefined but my bot as a banner

  id: '1332251376968794182',
  bot: true,
  system: false,
  flags: UserFlagsBitField { bitfield: 65536 },
  username: 'MultiBrawlBot',
  globalName: null,
  discriminator: '4977',
  avatar: 'e105da50ba02593c33164c44ae126aa3',
  banner: undefined,
  accentColor: undefined,
  avatarDecoration: null,
  avatarDecorationData: null,
  collectibles: null,
  primaryGuild: null,
  verified: true,
  mfaEnabled: true
}```

```Caught exception: TypeError: AppInfo.displayBannerURL is not a function```
wary coral

Where did you set the banner?

late apex

in discord dev

rose tangle

try force fetching, pass { force: true }

late apex

okok i will try

@rose tangle now i have the banner but the same error is not a function

fallow finch

It should be bannerURL()

sharp ginkgoBOT
late apex
sharp ginkgoBOT
rose tangle

ideally you should use that if you want your banner in a server

just in case you set a custom one for that server

late apex
rose tangle

then yeah, use displayBannerURL, but on the member, not the user

late apex

@rose tangle thanks a lot u saved me a lot of time

topaz bluff

Amgelo is big smort

dire valve

so im trying to add select menu + 3 text input text field in modal form, it is only showing select menu and not the text input field:

                const GameServerMenu = new LabelBuilder()
            .setLabel("Creator Verification")
            .setTextInputComponent(gameIdInput)
            .setTextInputComponent(channelProfileLinkInput)
            .setTextInputComponent(contentPlatformInput)
            .setStringSelectMenuComponent(inGameSrInput1);
            

                
                verificationModal.setLabelComponents(GameServerMenu);```

so what am i suppose to do? how do i make the 3 rows come?
proud arrow

Use separate label for each

dire valve
proud arrow

You can, but action row in modal is deprecated. So better you use label

wary coral
dire valve

worked thanks guys!

empty leaf

hi how to create embed like this?

clear garnet

That’s not an embed, that’s a container

sharp ginkgoBOT

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

empty leaf
clear garnet

Refer to the link above your message

empty leaf

can you help me?

wary coral
cerulean lichen

Anyone run into this issue before? I tried playing around with DNS servers (as logs indicate), but no luck. tracert gateway.discord.gg says it doesn't exist as well.

[2025-11-04T19:05:04.160Z] INFO: Registered messageCreate listener for tag proxying.
[2025-11-04T19:05:04.160Z] INFO: Attempting to login to Discord...
[2025-11-04T19:05:04.440Z] ERROR: Failed to login to Discord: - getaddrinfo ENOENT gateway.discord.gg
[2025-11-04T19:05:04.442Z] ERROR: Unhandled error during startup: - getaddrinfo ENOENT gateway.discord.gg
[2025-11-04T19:05:04.442Z] ERROR: Error stack: - Error: getaddrinfo ENOENT gateway.discord.gg
    at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26)
 ELIFECYCLECommand failed with exit code 1.

Curl is not happy with it as well:

Fen> curl -v https://gateway.discord.gg

VERBOSE: GET with 0-byte payload
curl : The remote name could not be resolved: 'gateway.discord.gg'
At line:1 char:1
+ curl -v https://gateway.discord.gg
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
stable sun

I mean, it’s a ws url

cerulean lichen

yeah, it is just weird since I did get a handshake with this in the past

main axle

fetching last 100 messages in 1 channel in guildMemberLeave event will spam the API?

tardy sable
main axle
tardy sable
main axle wdym by one by one?

i assume you will fetch like this await channel.messages.fetch({ limit: 100 }); ? and not message by message. then youre good

main axle

yes but each time for each member leave doesn't spam the API?

tardy sable

it does. but i think djs handles that and will check cache first

main axle

okay tnx so I will set it as premium feature to don't do it a lot

tardy sable
rose tangle

bulk requests don't check cache

only individual ones do

rose tangle
tardy sable

good to know

it doesnt without specifying limit right?

rose tangle

and yeah it can be spammy if you're on a guild with frequent leaves/joins, would be better to know the use case to know a workaround

if you don't specify a limit then it'd be an individual fetch, and that does check cache

main axle
tardy sable if i can ask, why are you fetching messages on guild member leave? there is prob...

You know some guys just join to a server and left immediately and then if you seted up Discord Welcome message it could be annoying specially when you set it up in chat channel and your members will say welcome to them but they are not in the server!

So I want to create a feature which remove those messages if user left immediately so I need to fetch the last 100 messages and check if their welcome message is there then delete it

rose tangle

I'd do a LimitedCollection of reasonable size where you store the welcome message ids of each member

then on leave you delete the message (you can pass the id directly to the manager)

tardy sable
main axle

okay tnx so in message create event how can I check those type of messages? I mean what is those messages type

sharp ginkgoBOT
rose tangle

the author is the user who joined