#djs-help-v14

78874 messages · Page 54 of 79

tardy sable

dont think any app has a reason to have more than 100 slash commands. there are subcommands for that

crimson gale

if your app reaches 100 slash commands you need to rethink how your commands work

red epoch

I haven't been developing a discord bot for about a year, and about a year ago, there were occasionally problems with discord. At the very least, it could even be slowness.

brittle current
tardy sable
tardy sable
brittle current
tardy sable

all probably unorganized and not a thought of grouping them into subcommands

i have prob every feature added to my private bot and im at 70 commands

topaz pawn

OK thanks

Ok 😁

rare verge
red epoch
tardy sable
burnt quartz

and they have the message intents so have no reason to remove them

fallow finch

It was there already and going from prefix to slash commands isn't a hard task imo

steel trail
rare verge

And now click on the other link. The one to the guide. The second one Mafia caused to be sent by docs bot

ruby river

they problem is solved, I was converting /cmds to !cmds with chatgpt, so all was good but in middle it convert the cmd to module.export = commandname

then logic of that, because of this module.export in middle it was not taking, Now its solved,
btw, thanks you helped me

rigid crest

i was going to ask about something forgot what it was now im annoyed i cannot remember

carmine sierra

yo

cunning hinge
carmine sierra

keep on getting this error whenever i did my setup command on my bot

wary coral

you're going to need to show your code and explain your goal

clear garnet

You’re trying to edit an interaction reply that doesn’t exist (anymore)

carmine sierra
carmine sierra
cunning hinge

use like pastebin for this pls

or the like

carmine sierra
sharp ginkgoBOT

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

clear garnet

Lot easier for those on mobile to see your code if it’s on one of those services rather than an attached file that would have to be downloaded

wary coral
carmine sierra

so hey @wary coral what should i do about this userside error though?

i'm sorry if i'm asking again and if it's rude, i'm just a new dev, sorry if i pinged you when i wasn't allowed to and all that

cunning hinge
tardy sable

thats not something user sided. check what youre doing after modal submit

carmine sierra
cunning hinge do you get an error from the bot?

content: 'Processing...',
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: undefined,
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: 'Unknown Message', code: 10008 },
code: 10008,
status: 404,
method: 'PATCH',
url: 'https://discord.com/api/v10/webhooks/1415662862310834318/aW50ZXJhY3Rpb246MTQzMjM4NDYyMzIwNzM4MzA2MDp4eHlPVnJQaUlxQUV0OWJ5RzRPUHdobFpPQ1lMN1Nzc0U4d3JlQ1dWQUw4Y0lIT3NVakZzdmtISll2V0ZFcGw5cmU3N25kbFR6cUhobm9KR1ZmYm8zOHJnc2g2T2tjbVBOcnhkTEJmUHF0YkRqbzU0N3dGUkYyVmUwNWhNU3g0Ug/messages/%40original'

tardy sable

show the code first in pastebin

cunning hinge
wary coral
carmine sierra

sorry for pinging you all, thanks for the help

ivory valve

Hey, we can now edit ephemeral message?

Like a counter for example

rose tangle

you always could

ivory valve

ah

sharp ginkgoBOT
rose tangle

usable for every repliable interaction, not just slash commands (chat inputs)

ivory valve

thanks

leaden shuttle

why does member.guild.members.cache.size sometimes return the incorrect member count?

before checking this, i call await guild.members.fetch(); if they haven't been fetched for that guild since the bot has restarted

tardy sable

are you modifying your cache somewhere?

leaden shuttle
leaden shuttle
wary coral

you can use the count on the guild

sharp ginkgoBOT
leaden shuttle
wary coral

it would be whatever the Discord API gives you. it would probably close enough

leaden shuttle

bet ty

leaden shuttle
wary coral

would that matter the apps are such a small number compared to total server size

leaden shuttle

i mean its just useful to know the bot count

tardy sable
leaden shuttle
tardy sable

is it a big difference?

leaden shuttle

yes, it's showing 6 compared to 300

tardy sable

try to fetch members on startup and then see cache

leaden shuttle

it fixes on bot restart but breaks after a few days

its not practical to fetch all guild's members anyways

rose tangle

I'm not sure what's the expected behavior

you want the cache to be accurate, but you don't want to fetch all members

there's no way for the cache to be accurate if you don't have all members

leaden shuttle

before checking the cache i call await guild.members.fetch(); if they haven't been fetched for that guild since the bot has restarted

tardy sable

i dont think that work cuz therell always be one or more members in the cache. so you will never fetch

rose tangle

if they haven't been fetched for that guild since the bot has restarted
how are you checking that?

leaden shuttle
import type { Guild } from "discord.js";

const fetchedGuilds: string[] = [];

export async function fetchMembers(guild: Guild) {
  if(fetchedGuilds.includes(guild.id)) return;

  await guild.members.fetch();
  fetchedGuilds.push(guild.id);
}
rose tangle

and where do you use that?

leaden shuttle
await fetchMembers(member.guild);

console.log(member.guild.members.cache.size);
rose tangle

should be fine, how big are the guilds you're working with? where is that last snippet?

leaden shuttle

the bot is in one guild with 40k members, 18k, 11k, 5k, 3k, 1k. but the ones we're getting reports of are only 100-400 members

leaden shuttle
rose tangle should be fine, how big are the guilds you're working with? where is that last s...

i simplified it

// Join Logs

await fetchMembers(member.guild);

logger.channel({
  guild: member.guild,
  moduleName: "serverGate",
  settingKey: "joinLogsChannel",
  title: "Member Joined",
  color: "green",
  thumbnail: member.user,
  customDescription: `${formatDescription([
    { name: "User", value: formatUser(member.user.id) },
    { name: "Bot Account", value: member.user.bot ? emojis.success : emojis.error },
    { name: "Account Created", value: time(Math.round(member.user.createdTimestamp / 1000), "R") }
  ])}`,
  footer: formatPlural(member.guild.members.cache.size, "member")
});

that's just one example where i use it. see another below

await fetchMembers(interaction.guild);

const totalCount = interaction.guild.memberCount;
const botCount = interaction.guild.members.cache.filter(m => m.user.bot).size;

interaction.reply({ embeds: [
  plainEmbed(`This server has **${formatNumber(totalCount)}** total members (${formatNumber(botCount)} are bots).`)
] });
rose tangle

can you show your client constructor?

leaden shuttle
export const client = new Client({
  partials: [Partials.Message, Partials.Channel, Partials.User, Partials.GuildMember, Partials.GuildScheduledEvent, Partials.ThreadMember],
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.DirectMessages, GatewayIntentBits.DirectMessageTyping, GatewayIntentBits.GuildModeration, GatewayIntentBits.GuildWebhooks, GatewayIntentBits.GuildExpressions, GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildScheduledEvents, GatewayIntentBits.GuildVoiceStates]
});
rose tangle

should be fine, the only thing I could think of is timeout errors since members go through the gateway

though if you only want the bot count I'd just fetch once on start, not cache and update the number on join/leaves

leaden shuttle
rose tangle

why not?

leaden shuttle
cunning hinge
rose tangle

so you mostly ask about the api spam, not when you're doing it (on start)

rose tangle

if you're asking whether fetching all members at once is fine

not whether doing it on start is fine (but wouldn't in other times)

leaden shuttle

im asking if fetching all members from all guilds on startup is fine

clear garnet

How many guilds with how many members?

leaden shuttle

rn the bot is in 380 guilds. one server has 40k servers, 18k, 11k, 5k, 3k etc but i want to future-proof too

rose tangle

fetching all members is a single request by the way, not one per member

leaden shuttle

thats still 380 requests

rose tangle

and is fine for discord's ratelimit

leaden shuttle
rose tangle

with that many members you should expect much more requests anyways

that should always be fine

the ratelimit is 1 per guild every 30s

golden laurel

Why do you wanna fetch all guild members btw

rose tangle

so as long as you don't request more than once for that same guild, pretty sure it should work

leaden shuttle
rose tangle

you already do that, we're suggesting it to do on start

leaden shuttle
rose tangle

you'll eventually fetch every guild, you won't hit any ratelimit and you won't cache them, so it's fine

leaden shuttle
leaden shuttle

whats the fix for that

rose tangle

you increment the timeout, but for that you should know whether that's the issue in the first place

are you catching and logging errors somewhere?

leaden shuttle

yes to a logs channel

rose tangle

every single error?

leaden shuttle

i get this a lot too idk if its related

rose tangle

is that on start?

leaden shuttle

yeah

getting Members didn't arrive in time a lot too but i think thats when the bot is removed from a guild

rose tangle

sounds like unavailable guilds then, nothing to be worried about

rose tangle

so that confirms it's the issue

leaden shuttle

i dont understand why its only me having this issue tho

rose tangle

"only me" as in comparing with?

leaden shuttle

idk.. are other people having this issue and if so how r they fixing it

rose tangle

yeah, that can be a common issue when fetching members on big guilds

sharp ginkgoBOT

Fetching members can time out on large guilds, as they arrive in chunks through the WebSocket connections.

  • You can specify the time option in FetchMembersOptions to specify how long you want to wait.
  • Make sure you have the required GuildMembers gateway intent enabled
leaden shuttle

but this issue also happen in smaller servers too

rose tangle

I'd still recommend you fix it, just increase the time option to something you're reasonably comfortable to wait out

leaden shuttle

okay will do- what's the max and are there downsides to setting it to the highest possible amount?

rose tangle

you could end up with hanging promises, but other than that I'm not too sure, probably someone on the team knows

if there weren't that many downsides they probably wouldn't have added the option at all

(the error comes from djs, not the api)

spiral cargo

how would i check if a channel is marked as nsfw?

sharp ginkgoBOT
spiral cargo

thank you

gleaming badger

how would I do so in DJS? When I try to add a label component in witnout a input field it throws an error

crimson gale

you'd not use labels, if you don't want inputs

sharp ginkgoBOT
rose tangle

add the text display to the modal directly

gleaming badger

ah I see. Didnt know you could do that. Thanks a lot

sharp ginkgoBOT
rose tangle

@fiery epoch please use #app-commands or the hide option for personal docs usage

normal flare

when using component v2, is there way to output in a Container, what was previously known as fields?

loud quartz

no, containers aren't embeds

they don't have fields

normal flare

yeah I figured that out, is there no alternative way?

loud quartz

using embeds

can't say much more without knowing what you actually want to achieve

normal flare

1 sec

@loud quartz like this

loud quartz

so inline fields? not really

normal flare

I see

normal flare
white smelt

Do we use GuildMember.roles.cache.has() or has that changed?

loud quartz

what's your actual question?

white smelt
loud quartz

what makes you ask

white smelt

Nvm, i was checking if roles existed in the guild which it does, so fixed it now

tardy sable

i can check how many channels in category with channel.parent.children.cache.size right?

red coral

Hi, in the message update event the only difference is the content scan version. Can I use the oldMessage.equals(newMessage) to fight against this?

Well it would be oldMessage.equals(oldMessage, newMessage)?

Ah it looks to be used to not do that, ig I’ll have to write my own

tardy sable
clear garnet

Click on what it extends

tardy sable
clear garnet
tardy sable

thanks

hazy agate
Error [ShardingInProcess]: Shards are still being spawned.\n    at ShardingManager._performOnShards (/usr/src/app/node_modules/discord.js/src/sharding/ShardingManager.js:297:13)\n    at Shard._handleMessage (/usr/src/app/node_modules/discord.js/src/sharding/Shard.js:408:22)\n    at ChildProcess.emit (node:events:519:28)\n    at emit (node:internal/child_process:949:14)\n    at process.processTicksAndRejections (node:internal/process/task_queues:91:21)","name":"Error [ShardingInProcess]"

can someone tell me where this error could be coming from

dont think im doing anything while its starting up

hazy agate

well im setting presence

what operations can i do while its sharding and which ones cant i?

topaz bluff

You can set presence on the client constructor rather than on the clientReady event (which is recommended especially if you don't plan on changing it)

unique shoal

Very few operations you should do while its still sharding

sharp ginkgoBOT
hazy agate
weak ledge

hi
how can i "refresh" the attachment url that was submitted in modal?

hazy agate

is accessing client.guilds.cache.size a problem

unique shoal

no

The error is coming from shards handling a message - so something that is broadcast across them

Local cache access and even most API calls might be fine

hazy agate

its only on my first shard

i start an api server, but that doesnt immediately use the client

okay there might be requests coming in very soon

starting the api server only when all shards are ready is a good idea then probably right

that worked thanks :)

unique shoal

Yeah an API request that does a broadcast eval would absolutely cause that

gleaming badger
clear garnet

IRT_This

unique shoal

Cant showModal on a modal

gleaming badger
carmine sierra

yo https://pastebin.com/Juv6NeKg
idk why my code keeps on making channels in the root and not the categories when i setup my server
-# this pastebin is set to 10 minutes

unique shoal

looks like im too late lol

tardy sable

is there something like channelType enums but for modals?

unique shoal

There's only one type of modal - what is it youre looking for

tardy sable

to know if a modal is string select, user etc

unique shoal

Thats its field, not the modal itself

tardy sable

yh then that. is that there something to identify with in djs?

sharp ginkgoBOT
tardy sable

thanks

unique shoal

I think it uses that

tardy sable

yh it looks like it

noble crane

Hi — is there any way to get the total number of bots in a Discord server without enabling GatewayIntentBits.GuildMembers? Right now I only have interaction.guild.memberCount. Any suggestions?

unique shoal

Not that I know of

pearl roost

Is the bot can make post forum?

unique shoal

yes

sharp ginkgoBOT

method GuildForumThreadManager#create() discord.js@14.24.0
Creates a new thread in the channel.


// Create a new forum post
forum.threads
  .create({
    name: 'Food Talk',
    autoArchiveDuration: ThreadAutoArchiveDuration.OneHour,
    message: {
     content: 'Discuss your favorite food!',
    },
    reason: 'Needed a separate thread for food',
  })
  .then(threadChannel => console.log(threadChannel))
  .catch(console.error);

pearl roost

Alright thanks

pearl hazel

is there an event for GuildAuditLogEntryEdit ? for move member and disconnect

topaz bluff

Not that I'm aware of

Audit logs only emit an event on create...they're an unreliable source for detecting actions

lapis imp

Hello! Is it possible to see which options a user has selected in Channels & Roles via a bot?

unique shoal

no

lapis imp
unique shoal

correct

gleaming badger
unique shoal

received components are not builders, you cant modify them

gleaming badger
unique shoal

You can construct a new builder from them, or use the original builders from when you sent them

You have to edit the message to send the modified components either way

We might need some better guides on this, bit weird to explain

gleaming badger

So I basically have to create a copy of the original component and then edit it from there?

loud quartz

embed resend guide is a good starting point logic-wise

gleaming badger
sharp ginkgoBOT

guide Resending a received embed
To forward a received embed you retrieve it from the messages embed array (message.embeds) and pass it to the EmbedBuilder, then it can be edited before sending it again. We create a new Embed from EmbedBuilder here since embeds are immutable (their values cannot be changed directly).
read more

gleaming badger

I also tried .editReply

stable sun

You should be doing modalInteraction.editReply

Although, a bit skeptical on this usage since it’s not clear whether the awaitMessageComponent succeeded and the error occurred in the .then block

gleaming badger
stable sun

Then you didn’t save the code

Or the error occurred elsewhere

gleaming badger
TypeError: response.editReply is not a function
    at D:\Github Repos (Local)\TSA-Worklog-Discord-Bot\slashCommands\worklog\user.js:162:44
    at runNextTicks (node:internal/process/task_queues:60:5)
    at process.processTimers (node:internal/timers:511:9)
    at async D:\Github Repos (Local)\TSA-Worklog-Discord-Bot\slashCommands\worklog\user.js:117:21
gleaming badger

and I didn't do anything else besides letting the collector end on itself

clear garnet
gleaming badger
clear garnet

It sort of is, but that doesn't mean it has editReply() methods or similar. Following modalInteraction.reply(), you'd want to use modalInteraction.editReply() any time you want to edit that initial reply

sharp ginkgoBOT

method ModalSubmitInteraction#reply() discord.js@14.24.0
Creates a reply to this interaction. Use the withResponse option to get the interaction callback response.


// Reply to the interaction and fetch the response
interaction.reply({ content: 'Pong!', withResponse: true })
  .then((response) => console.log(`Reply sent with content ${response.resource.message.content}`))
  .catch(console.error);

clear garnet

Take a gander at the return type of reply()

gleaming badger

hm I'll try that

sorry it took so long, was fixing some other bugs that occurred. But it works now, thanks!

bright rivet

can i only enable caching for specific users, specific channel's messages, specific guilds etc?

clear garnet

Strictly enable/disable? No. You can however utilize sweepers to sweep caches and remove elements you deem unneeded to be cached

sharp ginkgoBOT

guide Sweeping caches
In addition to limiting caches, you can also periodically sweep and remove old items from caches. When creating a new Client, you can customize the sweepers option. Below is the default settings, which will occasionally sweep threads. Take a look at the documentation for which types of cache you can sweep. Also consider what exactly lifetime implies for invites, messages, and threads!
read more

molten lake

Has anyone already managed to create a model with file uploads?

bright rivet

can i assume every snowflake id is unique?
snowflake ids from other categories is unique too?
ex. message id and channel id

stable sun
bright rivet

wat

stable sun

Ancient guilds can have a channel id that matches the guild id

Also the everyone role has the id of the guild id

novel mauve

they’re only unique within the same type of entity they represent

scenic berry

hello i have been creating a slashcommand, for the command has a permission of .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild), and i need to add a userid on that command so i can use it. for example i will just add my userid so i can use that slashcommand.

stable sun

Slash command permissions are ultimately controlled by guild admins and can only be restricted by roles and channels

flint pier

How to load button in interaction?

Chat is


const command = interaction.client.commands.get(interaction.commandName);```

what about button

flint pier

Does the button still work when the bot restarts?

unique shoal

The button will still send an event

If your bot is still listening after a restart it'll work

rigid crest

on ButtonStyle.value is one of them just black colour? im doing a roulette (basic just black/ red bet allowed)

i only ask as it doesnt say the colour

tardy sable
rigid crest

grey will subside

sand minnow
...
const container = new ContainerBuilder();

        container.addSectionComponents(
            this.createEligibilitySection(event),
        )

    private static createEligibilitySection(event: VoteEventConfigSchema): SectionBuilder {
        const section = new SectionBuilder().addTextDisplayComponents(
            (textDisplay) => textDisplay.setContent(this.buildEligibilityContent(event))
        );
        return section;
    }
// buildEligibilityContent return string
``` and then i sent the `container`, i received:
```yaml
2025-10-28 20:27:25 - ERROR - Encountered error on chat input subcommand "vote" at path "D:\...
\src\commands\subcommand\Vote.ts" CombinedError (2)
2025-10-28 20:27:25 - ERROR -   Received one or more errors
2025-10-28 20:27:25 - ERROR -
2025-10-28 20:27:25 - ERROR -   1 [ExpectedValidationError: s.instance(V)]
2025-10-28 20:27:25 - ERROR -
2025-10-28 20:27:25 - ERROR -   2 [ExpectedValidationError: s.instance(V)]
loud quartz

Section needs an accessory, either a thumbnail or a button

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

Use text display directly

sand minnow

Ahhh, tysm

frosty epoch

how many members can you fetch at once (of a guild)?
as in, one can do guild.members.fetch('id') or guild.members.fetch([array. of many ids?..])

tardy sable

api limit for that is 1 every 30s

frosty epoch

ok but what about those 2 scenarios I mentioned?

tardy sable
frosty epoch

theres no fetching by array of ids?

tardy sable

no

if you want to fetch a big array of ids, youd just fetch all members then and get what you want from cache

loud quartz

There is, actually

Look 5th example

sharp ginkgoBOT
loud quartz

cc @tardy sable

tardy sable

oh okay thanks didnt know

frosty epoch
{
 global: false,
 method: 'GET',
 url: 'https://discord.com/api/v10/guilds/GID/members/userID',
 route: '/guilds/:id/members/:id',
 majorParameter: 'GID',
 hash: 'e06f83c33559dfd4dc34f5666fdfa1d3',
 limit: 5,
 timeToReset: 250,
 retryAfter: 250,
 sublimitTimeout: 0,
 scope: 'user'
 }

coz I got this error, dunno what it means exactly, like a fetch users all the time

loud quartz

There's not an error

frosty epoch

ya rate limit im guessing

loud quartz

And if you're logging stuff in your code, would be a good idea to log what it is

frosty epoch

so what is that rate limit log, im fetching too many users per guild, or im fetching the same user multiple times? but fetch auto checks if user is in cache first? so how could I fetch it multiple times?

loud quartz

You're fetching too many times

Doesn't matter who

Api won't willingly let you spam it just became you're fetching the same user

frosty epoch

whats the limit on that?

delicate prairie

How do I get my bot to have the status like discohook's where they have their URL?

loud quartz
loud quartz

Also, dunno if you missed it

You can fetch with an array of ids

delicate prairie
frosty epoch
loud quartz Doesn't matter

would be useful to know how long id need to wait before fetchig the next id (im looping through user ids tasks)

loud quartz

You have that right there in your log

proud arrow
frosty epoch
loud quartz

Rate limits are dynamic anyway

And again - use an array

Although if you have to fetch this many individual ids, you could just fetch all members in one go

delicate prairie
frosty epoch

**if **this rate limit refers to specifically fetching a guild member, then im sure im barely fetching many for such guild. For other guilds I have much higher volume and never saw such rate limit message. Im very confused 😄

loud quartz

Making requests in a loop will get you ratelimited sooner or later

I have no idea what do you do in your code or why

How many you can fetch? All in one call
Can you fetch multiple ids in one go? Yes
Is there a ratelimit? There's ratelimit everywhere

frosty epoch

i mean surely is not 30 secs between each members fetch, coz otherwise my bot would have been blocked loooong ago. so must be 1-2 secs at the most per guild

loud quartz

It's once every 30s for fetching all

frosty epoch

i go 1 by 1

loud quartz

Then don't

What exactly do you expect me to say at this point

frosty epoch

fetch all is capped, at like 1k or 10k per fetch, if a guild is very large that'd be wasteful im assuming

loud quartz

It is in fact not capped

It's called all because it fetches all

Now, sure, you will receive all members which can take memory

frosty epoch

really? i remember for big server you could only fetch so much at the time

loud quartz

Yesn't

There's a REST way to fetch which is limited, and there's gateway way to fetch, which is not

The gw one is the one that fetches all in one go and is limited to 1 every 30s per guild

frosty epoch

but ye if id need to fetch say 5 per guild, calling all on a big server is not memory efficient

loud quartz

Then use an array

I'm saying this continuously

You can do that

frosty epoch

is there a max quantity on that in the array?

loud quartz

There's always a limit

You can check what's the limit in the dapi docs

frosty epoch

doesnt say the limit on the array (max values amount)

steel trail
low pumice

Hello, is it possible to obtain a list of users who have installed my application?

polar karma

no

low pumice
golden laurel

@rustic estuary @versed current both your issues are fixed in 14.24.1 (just released #announcements message), thank you for reporting!

versed current

yay :) Thanks!

topaz bluff

Actual 🐐

queen vale

I get this error when responding to an autocomplete - any idea what it is?

  if (interaction.isAutocomplete()) {
    const guild = await client.guilds.fetch(process.env.SERVER_ID || "");
    const interactionMember = await guild?.members.fetch(interaction.user.id);
    if (
      (interaction.commandName === "listing" && interaction.options.getSubcommand() === "edit") ||
      interaction.options.getSubcommand() === "bump"
    ) {
      const focusedValue = interaction.options.getFocused();
      const isAdmin = interactionMember.permissions.has(PermissionsBitField.Flags.ManageMessages);
      const listings = isAdmin
        ? await dbQuery("SELECT * FROM listings")
        : await dbQuery("SELECT * FROM listings WHERE userID=?", [interaction.user.id]);

      return interaction.respond(
        listings
          .filter(({ listingID }) =>
            focusedValue.length ? (listingID as number).toString().includes(focusedValue) : listingID
          )
          .map(({ listingID }) => ({ value: listingID, name: listingID }))
          .slice(0, 25)
      );
    }
sharp ginkgoBOT

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

queen vale

Would you like me to repost it using that?

rose tangle

yeah, mostly for convenience when on mobile

topaz bluff

Many of us are frequently on mobile

rose tangle

there's no preview so it'd need to be downloaded, which is an inconvenience

queen vale

the code or the error or both

rose tangle

the file, which I assume is the error

rose tangle

looks like you took too long to reply

queen vale

I replied instantly 😉

oh to reply to the user from the bot?

rose tangle

it isn't advised to do api/db calls before replying, usually you'd defer but you can't defer autocompletes

rose tangle
rose tangle
queen vale

I assume I cant respond to the user twice

rose tangle

yeah you can't, though I'm unsure what that'd fix

inland remnant

so i have a scenario like this

message w/ embed and ButtonBuilder -> button press (calls showModal()) -> modal submitted

can i get the message directly from the modal submit interaction? (aka .isModalSubmit() is true)

sharp ginkgoBOT
inland remnant

oh damn thank you sm

just thought it wouldn't be possible because i thought a modal is not really related to the message but rather the button interaction itself dogeHaHa

rose tangle

it counts as a component interaction since it comes from the button

inland remnant

ahhh got it now, thanks again

cosmic grotto

What was .setLable changed to:

and .addComponents too

steel trail

Hover over the strikethrough and your IDE should tell you

calm elm

I'm looking to create a command that can be used to ban someone from my server. Is it possible to also have this command remove the previous 7 days of messages by a user (like the behavior in Discord upon banning someone)?

sharp ginkgoBOT
topaz bluff

Oops wrong one. Ban seconds (as the docs say above)

inland remnant

i have a modal built w/ an image upload option, im fetching the image with interaction.fields.getUploadedFiles('proofImage').first();, question is, how do i send it spoilered?

loud quartz

prepend SPOILER_ to its name

hazy delta

does client.channels.cache always yield every channel in a server

steel trail

If you have Guilds intent it should for every guild you have a bot user in. Not all threads though

hazy delta

okay good, and I do

and also, channel.messages.fetch({limit: 100}); would this fetch every message or does the api sometimes skip some or something

proud arrow

Why would it skip some? It'll fetch last 100, not every msg tho

hazy delta

I was wondering if there was some sort of caching with that

polar karma

fetchMany requests will always be an API call and doesn't care about if any data was cached prior

late geyser

I've been noticing some issues with my bot lately about unknown interactions, and especially it being inconsistent. So I timed how long it takes for it to respond to an interaction slash command. The first image is completely fresh initialised discord.js bot handling (await interaction.reply('pong') while the latter image is responding directly using discord API (await interaction.client.rest.post(\/interactions/${interaction.id}/${interaction.token}/callback`, { body: Response });`), but is using discord.js to receive the interaction (same as the one using discord.js to respond)

How can the difference or well especially the variance be so big? Each ping command was executed with about 2-3 seconds in between them, and even if you wait 15 seconds between running the interaction it will still vary a ton.
Can anyone explain to me what is going on 😭 (I'm using djs v14.24.1)

quick wagon

The new components of the users modal and in this format that pulls them?

const users = interaction.fields.getUserSelectValue("user")
narrow orchid

how does interaction.channel.send() perform in comparison?

loud quartz

that does completely different things

narrow orchid

I'm aware

loud quartz

it is not comparable in behavior

narrow orchid

I meant in terms of latency, stable/still unstable

tardy sable

is checkAdmin removed?
interaction.member.permissions.has({ checkAdmin: true })

late geyser
narrow orchid

same results for me too. Strange indeed

tardy sable
loud quartz

how are you measuring it

tardy sable
late geyser
loud quartz how are you measuring it
const start = performance.now();
await command.execute({ interaction, client });
const duration = performance.now() - start;
console.log(`Command executed: ${command.data.name} - ${duration.toFixed(2)}ms`);```
loud quartz
tardy sable
coarse remnant
loud quartz

then it works just fine

given how you're not even really giving it any permission whatsoever to check for

late geyser
tardy sable
loud quartz

no, it takes a permission you want to check

tardy sable

oh okay thanks

loud quartz

not an object telling it to ignore checking all perms if it happens to have admin

late geyser
coarse remnant
loud quartz

even the part about manual REST.post not being this much around?

late geyser
coarse remnant

the POST /interactions/*/*/callback has had intermittent increased latency from the start of october 13-14

loud quartz

so what about their second screenshot

late geyser

Sorry correction to my earlier deleted message, the problem goes away if I comment out auth: false under InteractionResponses.js in the discord.js node module.

I'm not quite sure what auth: false does exactly though-

stable sun
unique shoal

Why would you have put it there in the first place...

loud quartz

it's relevant for webhooks mostly

late geyser

I didn't put it there. that's the source code

loud quartz

which is like, what interactions are

unique shoal

Ahh

late geyser

but why would commenting out auth: false fix the latency issues?

narrow orchid

That fixed it for me too, wild

howd u know where to look lol

sharp ginkgoBOT

tag suggestion for @drifting tartan:
You can control which entities receive notifications via the allowedMentions option. You can:

{ ..., allowedMentions: { parse: ["users", "roles"] } }
late geyser
narrow orchid howd u know where to look lol

searched through the discord.js library until I found something that had to do something with reply. But I don't think this is really a fix, but I don't have enough knowledge of the discord API to know why this is causing this

tardy sable

im trying to figure out why it wont set sendmessages to enabled for interaction user, what am i doing wrong?

await interaction.channel.permissionOverwrites.edit(interaction.user.id, { SendMessages: true });

sendMessages is currently on false

unique shoal

Thats not the format that permissionOverwrites.edit takes

oh wait im looking at the wrong thing

loud quartz
late geyser searched through the discord.js library until I found something that had to do s...

From what i know about that option, it's used for passing (or not) the usual auth header to the request, which is normally required, obviously.
But there are things that don't require your app's token to perform, for example executing webhooks. In fact, without that setting, if you would be to try and execute a deleted webhook and get a 401, discord.js would happily assume that it's your bot token that's expired and pretty much log you out, as it would prevent you from using an invalid token.

unique shoal

You might need to also pass { type: OverwriteType.Member } as the third parameter

loud quartz

since interactions are pretty much just webhooks with a fancy magic for how they display to the user, i'd assume that this is the reason the auth: false is there. so that if you reply after the interaction token expires discord.js doesn't "confuse" it with your bot token expiring

narrow orchid

I've had this issue for ages, maybe since v13, i cant rember tbh. but recently got worse

golden laurel
narrow orchid

just weird i dont see many others besides you with the same thing

late geyser
loud quartz

i have no idea or any input as to why this is happening as it is, but yeah. there is a potential that d.js will unset your app token if you hit 401 on any webhook stuff

bleak owl

you can use the most recent d.js version to access it

you can use the most recent d.js version to access it

sharp ginkgoBOT
stable sun

Or ur just asking what the file upload is?

burnt quartz

why would message.member on a message from a guild be null? in the messageCreate event

unique shoal

guild member cache settings

burnt quartz

so the cache is full for that guild?

unique shoal

no

red coral

Webhooks? Do they have a member

burnt quartz

i havent changed the guild member cache settings, its default

tardy sable
unique shoal You might need to also pass `{ type: OverwriteType.Member }` as the third parame...

that didnt change anything so i tried to console log to see what it was doing and console logging this it just keeps console logging duplicates with no end.

for (const overwrite of interaction.channel.permissionOverwrites.cache.values()) {
    if (overwrite.id !== interaction.guild.id) {
        await overwrite.edit(overwrite.id, { SendMessages: null, type: overwrite.type });
        console.log(`Set overwrite for ${overwrite.id} to SendMessages null`)
    }
}
burnt quartz

its a real message from a user, not a webhook

loud quartz
unique shoal

Not sure what you mean by logging duplicates

tardy sable

the same ids

like the channel has 4 permissions overwrites. and doing that it just keeps logging the same id over and over

ill try passing as third parameter to see if it fixes

same issue

burnt quartz
unique shoal guild member cache settings

looking into this further, it seems i am receiving the message from a guild, it has a valid author and is not a webhook, but i cannot fetch that member manually, its as if they are not in the server

unique shoal

Can you share your code for doing that? Are you getting Unknown Member?

Is your bot actually in the guild and not just as app commands?

steel trail
burnt quartz
steel trail
burnt quartz
const message = client.channels.cache.get("1405902117117497456").messages.cache.get("1432833080565043291")
const guild = message.guild
return guild.members.fetch(message.author.id)

this returns a collection of 0

unique shoal

uhhh

burnt quartz

there is a chance of course that they left the server now, but message.member was null and erroring for multiple messages in a row

unique shoal

It should never return a collection of 0, unless youre fetching something undefined, and theres somehow nothing in the cache

Its a fetch, it should be throwing an API error if the value passed is invalid

That just shouldnt be happening at all

burnt quartz
unique shoal

yeah no, thats not what fetch returns

waitWhat

burnt quartz

i did just ```js
const guild = await client.guilds.fetch("911223311135047680")
const member = await guild.members.fetch("1234567891234556")
console.log(member)

in my ready event and it still returns an empty collection with a completely made up member id
unique shoal

Can you show your client constructor please?

loud quartz

if you're passing an id like that, and it still returns a Collection, something is quite wrong somewhere

unique shoal

ya

burnt quartz
loud quartz

globalThis

unique shoal

Can you try logging client.users.resolveId("id you were trying to fetch");

burnt quartz
unique shoal

Im looking at the fetch logic and trying to work out how it could be returning a 0 collection here, and the only spot I can think is that somehow you've stored an empty collection against people's IDs in the guild member cache

Or its not resolving and trying to do a fetch that somehow doesnt return any results

djs version?

burnt quartz

i tried in blank bot and yes it errors when trying to fetch unknown user, ima debug whats causing that

unique shoal

The way you map your intents seems kinda odd too since the strings are already accepted there anyway

burnt quartz

i assumed they werent when i read the update to discord.js v14 guide which i did that

steel trail

If I had to guess I'd say tipaka was on the right track: why do you use globalThis?

burnt quartz

to access the client across every file without needing to manually pass it across

unique shoal

You already dont since its attached to most structures, e.g., message.client

steel trail

You're replacing node's native fetch with that from node-fetch library

If I was node I'd get confused too

burnt quartz

native fetch was not a thing when i started this bot, and caused issues when it was first added, so i kept node-fetch, i probably dont need that anymore, i can try removing it

loud quartz

global pollution, prototype pollution

as you can see it never ends up working well

tardy sable
burnt quartz

i know its bad to extend prototypes, but does this mean that somewhere in discord.js its just checking for a limit function to exist rather than checking the type?

loud quartz

LimitedCollection exists

and it's incredibly popular way in typescript to make type guards - check for existence of a property, for example

steel trail
loud quartz

ah, so even simpler than that lol

steel trail

And by that your string then gets spread into an object (and the id is gone, but limit is now set to a function and that gets sent over the websocket... quite interested to see the actual request that gets made by that kek

burnt quartz

i am removing the prototype now. meant to clean up stuff like this for a while but put it off, better late than never

i guess i will just have to wait and see if the issue I came here with still occurs

unique shoal

Fascinating

dim needle

Getting white screen with CSP violation error when launching activity:

Refused to frame 'http://localhost:5173/' because it violates CSP directive
Setup:

URL Mapping is done
Discord SDK configured
What am I missing?

polar karma

You should ask in ddevs, the d.js library doesn't have support for this

dim needle
polar karma
burnt quartz
unique shoal

Interesting

And we couldnt arrive at an "Unknown Member" error because of the other stuff

silent mirage

        if (q.type === "file_upload") {
          return new ActionRowBuilder<FileUploadBuilder>().addComponents(
            new FileUploadBuilder()
              .setCustomId(`q_${i}`)
              .s(q.question)
              .setRequired(q.required ?? false)
          );
        }

how can i pass label to options

unique shoal

The ActionRowBuilder approach is deprecated, switch to LabelBuilder and you wont have this problem

sharp ginkgoBOT
silent mirage

oh do i need to switch all my code cause i used action row builder everwhere

unique shoal

Not until v15

But you might as well start writing new code this way

stable sun

The new components must use label though iirc

cunning hinge
silent mirage

question how can i get the answers to the modals

silent mirage
rose tangle

you're meant to move your older code to labels, and use them for new components

rose tangle

or well, from which component type

silent mirage

the answers to the modals that the user does when submit

rose tangle

there's no component named "answers"

but I'll assume you mean a text input component

sharp ginkgoBOT
rose tangle

you get that via <ModalSubmitInteraction>#fields

sharp ginkgoBOT
silent mirage

what is the limit in modals

loud quartz

limit of?

silent mirage

nvm i found it it can be a limit of 5 questions

loud quartz

5 elements, yes

pliant forum

do unfurled media items under media gallery items have a file size limit when it comes to external URLs?

ive given videos like 100mb large a shot and they seem to work out fine

rose tangle

that's pretty much just an embedded video so I wouldn't think so

that's more of an api question though, ddevs would be a better place to ask

pliant forum

ahh. gotcha

fading girder

how do I add file uploads component in my modals?

stable sun
sharp ginkgoBOT
left cloud

is there a function or something that i can call that triggers discord to open an image in the modal / overlay view? context is i'm building an embed and it has an attached img that's taller than it is wide, so if using setImage() it makes the embeds very tall while setThumbnail() makes the img a bit too small. i know on desktop you can click the thumbnail to pull up the picture in the overlay/modal view i'm talking about but that behavior isnt reflected on mobile.

my idea is to use a button on the embed to call whatever makes discord pull up the larger preview, but want to know if that's even possible? my fallback is to make the button temporarily remake the embed as setImage for 10s or so before reverting to the setThumbnail version (unless someone has a better idea/implementation)

stable sun

Discord doesn’t have support for images in modals at this time

Have you tried the media gallery component?

Or you don’t want to use components v2?

sharp ginkgoBOT

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

left cloud

The original thing I was talking about is this view when you click an image

Not sure if that's called a modal or how that's officially named

stable sun

You mean clicking on an image to get the full view?

Doesn’t it to that already if you just send an image normally?

Not a modal btw, just client-side stuff

left cloud

Yeah, it does however if the image in an embed is the thumbnail, mobile users cant click the thumbnail to see the full view

stable sun

Components v2 is its own animal. Takes over the entire message

You have more freedom over placement to a point

left cloud

I see, and I assume there's no way to trigger or call client-side stuff through discordjs

stable sun

That’s correct

Blame Discord for that

left cloud

🙃 ok thanks for the guidance! i'll take a look more at components to see if there's something there that can work

is there a place to see more examples of componentsv2 in action and what's possible?

stable sun

The guide I sent earlier has all of that

red epoch
const targetMember = interaction.options.getMember("member");```
Is there a way I can force this code to get the GuildMember data directly?
little pebble
red epoch

I don't want to use APIInteractionGuildMember.

sharp ginkgoBOT
little pebble

Use this typeguard, handle the case when the interaction is not in a cached guild

cedar kindle

Guys are there good example of what v2 components can do?

unique shoal

The announcement of the version that released them

cedar kindle

Thanks

red epoch
dusky harbor
left cloud

With components v2, is it possible to place a mediagallery component inline with text component(s)? or is a mediagallery always on its own line and only thumbnail works?

steel trail

A media gallery always is its own line. There is no concept of "inline" in cv2, only accessory of a button or thumbnail belonging to a section

And even those can be below on mobile, you define context, not layout

You control the content, discord takes care of layout

left cloud

Gotcha, thanks

pearl roost

Why when I execute a cmd to make a thread it appear a notification, but when I make a thread based on message create event, it don't appear any notification? I had the same exact code:```js
// CMD:
const msg = await interaction.channel.messages.fetch(messageId);

if (msg) {
await msg.startThread({
name: ${threadName},
autoArchiveDuration: "10080",
reason: Thread created by ${interaction.user.tag},
});

return interaction.editReply({
    content: "Successfully created the thread!",
});

}

// messageCreate:
if (
message.channel.id == weekListChannelId &&
!message.channel.isThread()
) {
await message.startThread({
name: ${message.content},
autoArchiveDuration: "10080",
reason: "Auto-thread for week report",
});
}

stable sun

An inline reply

The bot replied to your message, then started a thread on its own message

pearl roost
stable sun

Just without the ping

To clarify, the ping is from using message.reply on your message, nothing to do with the thread

steel yacht

Hi,
Is there any way to get the actual HTML that Discord will render for a message's content ?
Thanks

stable sun

No

Best you can do is generate the html based on the markdown

Pretty sure there’s packages that convert entire messages to html for you alr

pearl roost
crimson gale

remark-html and showdowns are two of the more popular ones

you'd def. have to handle mentions and custom embeds yourself, though

nimble tundra

hey all, just wondering what the main difference is between interaction.channelId and interaction.channel.id

unique shoal

Nothing

interaction.channel is a getter that does client.channels.cache.get(interaction.channelId)

stable sun

channelId is guaranteed to exist, channel isn’t

nimble tundra
database.findOne({ channel: interaction.channelId }, (err, thread) => {
        if (!thread) return interaction.editReply('**CHANNEL NOT FOUND**');
};```
hm okay, well i have an odd issue that could be unrelated but thought id ask here

i have this running via a button and i have to spam it to work

its confirmed in the db so not sure why its bugging

stable sun

What type is it stored as in the db?

nimble tundra

a seperate model i removed for simplicity here

stable sun

Should also be checking for errors

There’s won’t be thread if err isn’t undefined/null

Or at least log it

nimble tundra

right

unreal stone

Hi, I have a question about file upload in modals.
Where are the file stored after upload? I noticed they are url.

unreal stone

So they is the same problem if an user upload the image in the server and want to access it days later?

Idéa is to just to store it in an embed but I'm not sure how much time the image will stay

steel trail

you'd need to reupload it, not use the ephemeral attachment URL you get in modal submission

unreal stone

And embed doesn't allow upload in thumbnail, only URL…

Does it works if I upload the image the bot is in ? Or I will face the same problem (as now image/file are not uploaded forever)

autumn idol

Does Guild#edit options support Url for Icons ?

sharp ginkgoBOT

tag suggestion for @unreal stone:
Files in embeds should be attached via the message option object and referenced in the embed:

const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
  .setTitle('Attachments')
  .setImage(`attachment://${attachment.name}`);

channel.send({
  embeds: [embed],
  files: [attachment]
});
stable sun
sharp ginkgoBOT

method Guild#edit() discord.js@14.24.0
Updates the guild with new information - e.g. a new name.


// Set the guild name
guild.edit({
  name: 'Discord Guild',
})
  .then(updated => console.log(`New guild name ${updated}`))
  .catch(console.error);

stable sun

await guild.edit({ icon: … })

autumn idol
stable sun

It’s a union of types

BufferResolvable is either a Buffer or url as string

Base64Resolvable is a Buffer or base64 string as a string

Or null to remove the icon

You just click on it to see what it is

rose tangle

what?

yes, but if you want to change the token you can't do that in the middle of your execution

you'll 100% need to restart

then yeah that's usually fine

you shouldn't be running two bots from the same process, ideally both should be in different ones

polar karma

depending on how you obtained those tokens

rose tangle

it is, it's just a matter of good practices and maintainability

oh, if you're talking about getting tokens then yeah you can't ask users for them

polar karma

you should still run each bot/app in its own process, so they're independent from each other

steel trail

That won't reload anything. It just reconnects the websocket running the same code as before

steel trail
unreal stone
steel trail

Way too complicated when a simple restart is easier

And you made all those 1000 bot tokens yourself?

round linden
const modal = new ModalBuilder()
     .setCustomId('limit_users_vocals_modal')
     .addLabelComponents(
         new LabelBuilder()
             .setLabel('Limit users')
             .setDescription('Use 0 to reset.')
             .setTextInputComponent(
                 new TextInputBuilder()
                     .setCustomId('limit_users_vocals_text')
                     .setStyle(TextInputStyle.Short)
                     .setRequired(true)
                     .setMinLength(0)
                     .setMaxLength(99)
              )
    )

return interaction.showModal(modal);

any idea of why is it giving ValidationError: Expected a string primitive?

steel trail

From an account created two weeks before today?

fading girder

is there a docs page or example code for using the new modal builder with label and text display builders

steel trail

Then you won't have any issues running your two bots as seperate processes

fading girder
round linden
round linden
proud arrow

Next time share the full error

round linden

oh ok

fading girder
            .setCustomId('setupadvertise' + interaction.id)
            .setTitle(t('descAndReq.modal_title'))
            .addComponents([
                new ActionRowBuilder<TextInputBuilder>().addComponents([
                    new TextInputBuilder()
                        .setCustomId('description')
                        .setValue(existingData?.description || '')
                        .setLabel(t('descAndReq.description_label', { type, targetAudience }))
                        .setStyle(TextInputStyle.Paragraph)
                        .setMaxLength(1000)
                        .setRequired(type === 'Clan' ? false : true)
                        .setPlaceholder(
                            type === 'Clan'
                                ? t('descAndReq.description_placeholder_clan')
                                : t('descAndReq.description_placeholder_alliance')
                        ),
                ]),
                new ActionRowBuilder<TextInputBuilder>().addComponents([
                    new TextInputBuilder()
                        .setCustomId('requirements')
                        .setLabel(t('descAndReq.requirements_label', { type, targetAudience }))
                        .setValue(existingData?.requirements || '')
                        .setStyle(TextInputStyle.Paragraph)
                        .setMaxLength(1000)
                        .setRequired(true)
                        .setPlaceholder(t('descAndReq.requirements_placeholder')),
                ]),
            ]);```

this is the code I have rn but I am trying to change it and remove the deprecated components
round linden

sorry for the inconveniece

proud arrow
wary coral
fading girder

thank you guys

what is text display component?

sharp ginkgoBOT

guide suggestion for @fading girder:
guide Text Display
Text Display components let you add markdown-formatted text to your message and directly replace the content field when opting to use display components. You can use the TextDisplayBuilder class to easily create a Text Display component. Sending user and role mentions in text display components will notify users and roles! You can and should control mentions with the allowedMentions message option. The example below shows how you can send a Text Display component in a channel.
read more

fading girder

wait so I can add role select, string select, etc too inside modals?!

topaz bluff

All select menus can go in a modal

fading girder

yo awesome, I just found it out now 😭

inland remnant

need advice; so i am making a bot that sort of logs actions in a channel. i can easily get who banned who and why just by getting GuildBan from the guildBanAdd event, however this is not the same case with kicks, as there's not a seperate event for that - only guildMemberRemove. question - is querying the audit log really the most efficient way to find out if its a kick and who performed it? or is there something im missing

tardy sable

guild ban event also emits the executor?

tardy sable
bleak owl
fading girder

how many label builders can I add in a modal

proud arrow

Max 5 top-level components

The limits haven't changed

tardy sable
topaz bluff

Should be under the Client class iirc

sharp ginkgoBOT
steel yacht
steel trail
steel yacht
swift jewel

Why adding addTextDisplayComponents before setLabelComponents not working ( as in that wont display at all ) in a modal but works when i use addLabelComponents instead ? is this intentional ?

loud quartz

because set overwrites

like = would

use add* instead of set*

swift jewel
steel trail

setLabelComponents shouldn't exist anymore now that you can add things that aren't labels to modals. But removing it would be a breaking change so 🤷‍♂️

swift jewel
steel trail

You should only use setX if you want to completely overwrite what you have in it, yes. Not if you want to ... add to it

swift jewel
urban nimbus

Odd question but is it known if discord gonna be deprecating the old components at all and making v2 default?

loud quartz

old components?

urban nimbus
loud quartz

embeds are not components

and v2 isn't "replacing", it's adding more

buttons and selects are not going away, and yet aren't under v2

and embeds are not going away either

you can use them just fine, and links will continue embedding

coarse meteor

hi
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

sharp ginkgoBOT
topaz bluff

That returns a collection of attachments. You can then use that attachment however

coarse meteor
orchid radish

Is there any method to collect the results of a poll and if so what’s the event for that called?

meager meadow

I encountered the error DiscordAPIError[50240]: You cannot remove this app's Entry Point command in a bulk update operation. Please include the Entry Point command in your update request or delete it separately.
Can I make it so that it doesn't cause an error but without breaking it?

            this.application.commands.set([
                ...this.commands.map(command => command.data),
                ...this.userContextMenuCommands.map(menu => menu.data),
                {
                    type: 4,
                    name: 'launch',
                    description: 'Launch an activity',
                }
            ]);
unique shoal

I think that should work, yeah, but do you actually have an activity to launch?

unique shoal
orchid radish
unique shoal

Bots can, yeah

I think you just get a messageUpdate when the poll finishes, Im not sure

orchid radish

Ok cool does a poll require having more than one answer? I was thinking of using one for a giveaway thing to negate having to handle times for ends of giveaways or stuff like that

unique shoal

no idea

orchid radish

But that would only really work if I could collect who all added to the poll but I guess I could just use the event for that and store them temporarily

unique shoal

You can

sharp ginkgoBOT
orchid radish

Huge thanks

unique shoal
thin pagoda

Hello in new StringSelectMenu how i can set a value? old one have setValue but now i cant see that option

topaz bluff

from a select menu interaction or a modal?

wary coral

String select menus to my knowledge have not had set value. To set the default value of a string select menu, the string select menu option must have default set to true

thin pagoda
pearl roost

What event to know if someone boost the server?

topaz bluff

theres no event for boosts...the only ways to check is the system message for when they boost or the role being assigned

pearl roost

Hmm... Okay

frosty epoch

in the same action row, can there be both dropdown and a button?

unique shoal

no

frosty epoch

If I update to latest d.js version, can I still use older embeds v1 class? new EmbedBuilder()

steel trail

Embeds are still embeds; components are what got a v2 and those are merely an addition, not a replacement

frosty epoch

so new EmbedBuilder() (which is v1) would still work, embeds v2 would just have a separate class

kindred moon
rigid crest

but you cannot use a embed & v2 in the same message youll get a incompatible error

steel trail

Yes, components v2 don't allow any other content, be it plain content, embeds, sticker_items, poll (or attachments not used in any component). Apart from that and they can look similar there is no connection between embeds and components v2

cv2 is a way to make a message from components alone, instead of having five separate parts you can't arrange the way you want

sharp ginkgoBOT
frosty epoch

are there any breaking changes from @14.16.3 to @14.24?

wary coral
frosty epoch
wary coral

Then you should experience no problems

frosty epoch

i dont like that 'should' dogeHaHa

wary coral

I am not making a guaranty but there are not library breaking changes

proud arrow
coarse meteor

how can i make my bot have no status like this (it's not online, invisible, dnd or idle)

sharp ginkgoBOT

tag suggestion for @coarse meteor:
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.

coarse meteor

interesting

bleak tiger

Hello, I'm trying to create a /backup command (with subcommands), but the problem is that when creating roles, the order isn't respected, and the roles of the bots present on the old server are created (which I don't want). Furthermore, only the categories are created, but not the channels. Here are my files:

sharp ginkgoBOT

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

frosty epoch

are there example methods for the new modals? the docs are not really example friendly

frosty epoch
quaint mantle

Hey, why exactly were the docs moved? Like the guide ones

topaz bluff

My guess is a combined reason of it being migrated to the monorepo as well as just to update it

rose tangle

plus it looks much nicer

quaint mantle

Well, this doesn't KEKW

loud quartz

path is a bit different

golden laurel

It doesn't look like linking a discord.js guide there is appropriate either way

You might wanna updated some strings there too, like the copy id ones, they're outdated

uncut sorrel

Can you create an Attachment using a Discord cdn url? Or would you have to download the attachment and reupload it?

rose tangle

that's what the attachment builder does

fetches the url and sends the buffer

but there's no guarantee that by the time you try to download it, the url still works

loud quartz

so does just putting the link into the send

sharp ginkgoBOT

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

sonic lichen

oh ok

bleak tiger

np

open musk

on giveaway boat, in the raffles pagination there's an option to show the user's username instead of the mention. i know the bot can't fetch users on demand, does anyone know how they do that without hitting the api rate limits? the only thing i can think of is caching users when the bot logs in. also, is there any other solution?

loud quartz

i know the bot can't fetch users on demand,
but it can

sonic lichen
bleak tiger
sonic lichen

weird

maybe another one can help you because i see nothing

bleak tiger
topaz bluff

Well I know that channel positions are extremely weird to work with and the one that DiscordJS uses is not the one the API uses directly

You could instead store your channels inside of each other rather than independently
(Store categories, put text/voice channels inside category, etc) and iterate over it yourself

Or iterate by channel.type creating categories first

ivory wasp

Does Event.MessageDelete not fire if the message is not cached?

tardy sable

that would be a partial message and they do get emitted

ivory wasp

And I'm seeing a behavior where "old" messages being deleted are not getting the MessageDelete event fired at all

halcyon bison

to clarify, you would need to enable the Message partial in order to receive events with partial messages

sharp ginkgoBOT

guide Partials
One example leveraging partials is the handling of reactions on uncached messages, which is explained on this page. Prior you had to either handle the undocumented raw event or fetch the respective messages on startup. The first approach was prone to errors and unexpected internal behavior. The second was not fully fail-proof either, as the messages could still be uncached if cache size was exceeded in busy channels.
read more

ivory wasp

Oh

Had no idea about Partials, ok thanks that would be it

dry minnow

Hey guys

What kind of language is this, DJs?

rose tangle

djs isn't a language, it's a javascript library

the language would be javascript

dry minnow

I understand. Can I ask about regular JavaScript?

halcyon bison
brittle current

so when i tested it in vs code it works but when its on hosting it returns: YouTube API: Request failed with status code 403

polar karma

that is unrelated to d.js

brittle current

srry

boreal olive

can bot set a server only avatar?

sharp ginkgoBOT
upbeat girder

any idea when will we can be able to set VC channel status via djs? i think currently its not possible

discord py can do it i heared

halcyon bison
loud quartz

Which might be never

torn orchid

how do i make a message not ephemeral bc right now I have
flags: MessageFlags.Ephemeral

dire rose

just remove that

snow onyx

just... dont set the flag? thin

polar karma

you can't change the ephemeral state of a message, if that's what you're asking

bright cradle

anyone know why i keep getting this js at Object..js (node:internal/modules/cjs/loader:1893:10) at Module.load (node:internal/modules/cjs/loader:1480:32) at Module._load (node:internal/modules/cjs/loader:1299:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:244:24) at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5) { code: 'TokenInvalid' }

it keeps saying token invalid even while the token is valid

polar karma

having the full stack trace would be useful

bright cradle
[dotenv@17.2.3] injecting env (0) from .env -- tip: ✅ audit secrets and track compliance: https://dotenvx.com/ops
Started registering slash commands.
Error: Expected token to be set for this request, but none was present
    at _REST.resolveRequest (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1381:15)
    at _REST.queueRequest (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1341:46)
    at _REST.request (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1307:33)
    at _REST.put (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1290:17)
    at C:\Users\Crew\Desktop\maharaja\src\Functions\handleCommands.js:23:28
    at client.handleCommands (C:\Users\Crew\Desktop\maharaja\src\Functions\handleCommands.js:33:11)
    at C:\Users\Crew\Desktop\maharaja\src\index.js:25:12
    at Object.<anonymous> (C:\Users\Crew\Desktop\maharaja\src\index.js:27:3)
    at Module._compile (node:internal/modules/cjs/loader:1760:14)
    at Object..js (node:internal/modules/cjs/loader:1893:10)
C:\Users\Crew\Desktop\maharaja\node_modules\discord.js\src\client\Client.js:217
    if (!token || typeof token !== 'string') throw new DiscordjsError(ErrorCodes.TokenInvalid);

}```
polar karma

what's in handleCommands.js

bright cradle

should I send the code

sharp ginkgoBOT

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

bright cradle
polar karma

log process.env.token and check its value, it seems to be something besides a string (i would guess it's undefined)

bright cradle

the thing is

when I ran this same code last week, it worked without any issue, when I opened it today it shows this

polar karma

ok and? did you log the value of the variable?

tardy sable

a normal user or member fetch first checks if in cache right?

I dont have to add this fallback?
interaction.guild.members.cache.get(user.id) || await interaction.guild.members.fetch(user.id).catch(() => null)

clear garnet

Correct

topaz bluff

unless you set { force: true } to force a fetch

tardy sable

also deleted users wont throw errors?

clear garnet

If a user is deleted, they'll be removed from the cache and if you attempt to fetch them with their former ID, you'll get an Unknown User API error

tardy sable

ok thanks

warped crown

Hi all, wanted to get some help on this quickly.
Struggling on getting a response sent to a Modal using the promisified method...
I haven't done ts in a while so please be gentle haha

        const filter = (i) => {
            return i.user.id === interaction.user.id;
        };

        interaction
            .awaitModalSubmit({ time: 60_000, filter })
            .then((interaction) => interaction.editReply('Thank you for your submission!'))
            /**Keep getting No modal submit interaction found... */
            .catch((err) => console.log('No modal submit interaction was collected'));

I copied this straight from the website (as my previous implementation wasn't working either...); it prompts up the Modal correctly, but after I click Submit the bot gets stuck on "Bot is thinking..."

I am aware that I have not done <ChatInputCommandInteraction>#deferUpdate() in the filter (apologies if I have put the wrong class name here but you get what I mean I hope), as the framework I am (unconsensually) using automatically does this. The frameowrk is robojs if that is of any relevance.

Djs version 14.21
(the "website" is https://discordjs.guide/legacy/popular-topics/collectors#await-modal-submit)

Please ping in replies, TY for any assisstance

clear garnet

In your then() callback, I think it'd be wise to use a different name for the parameter than interaction again, otherwise you get confused between which interaction you're working with. Your issue here is that you aren't responding to or acknowledging the ModalSubmitInteraction after receiving it

warped crown
molten lake

can I send an container with mention but make it to not send a notify?

unique shoal

yes, same way you would any messages

sharp ginkgoBOT
molten lake
clear garnet
warped crown
clear garnet

You wouldn't be able to use deferUpdate() in that case, since there's no message to be updated

What is your end goal after you receive the ModalSubmitInteraction? Send a basic message in chat?

clear garnet

You'd want to use reply() then

warped crown

Ahhh, let me give that a try

That worked! Thank you

tardy sable
fallow finch
fallow finch
vital raven
tardy sable
vital raven

Yes

tardy sable

thanks

silent plover

If I timeout a user, do I have to input the duration in ms or can I use like days?

clear garnet

numOfDays * 86_400_000

unique shoal

It must be in ms, so yeah, do the math

silent plover

fine xd

pearl roost

Can we arrange the order of the cmd names (for example, depending on how we arrange the subcommands), or is this arranged directly by Discord? I'm pretty sure I put the subcommand accept first, I don't know why it became the fifth one

proud arrow

Discord does that. You have no control over that

The app launcher, at least on mobile allows you to sort commands though

pearl roost

Ohh, that is right actually

glad stone

is there any way to remove a modal from a users screen?

i have some code that shows a user a modal and upon the modal being submitted some information gets logged and then an embed updates. everything else works as mentioned however the modal doesnt disappear from the users screen only says "something went wrong, try again" is there any way to remove a modal from a users screen upon the modal being submitted manually because it seems like it doesnt want to do it automatically

crimson gale

is there any way to remove a modal from a users screen?
no

"something went wrong" implies you didn't respond to the modal submit interaction

if the modal is popped from the interaction on a button/select menu, you can respond to the submit interaction with an update which will update the message the button/select menu is on that prompted the modal

if the updated embed is not the origin of the modal, consider responding to the modal with just a simple acknowledgement that the data was successfully updated (ephemeral channel message with source)

glad stone
wary coral
glad stone

ok thanks

distant inlet
glad stone
bright cradle
DiscordAPIError[0]: 405: Method Not Allowed
    at handleErrors (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:762:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async SequentialHandler.runRequest (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1163:23)
    at async SequentialHandler.queueRequest (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:994:14)
    at async _REST.request (C:\Users\Crew\Desktop\maharaja\node_modules\@discordjs\rest\dist\index.js:1307:22)
    at async C:\Users\Crew\Desktop\maharaja\src\Functions\handleCommands.js:23:17 {
  requestBody: { files: undefined, json: [] },
  rawError: { message: '405: Method Not Allowed', code: 0 },
  code: 0,
  status: 405,
  method: 'PUT',
  url: 'https://discord.com/api/v10/applications/1409253135754596412/commands/undefined'
}``` can I know why im getting this
distant inlet

Looks to be an undefined command

bright cradle
steel trail
bright cradle
distant inlet
bright cradle
distant inlet

And show the file of the command

distant inlet
bright cradle

theres nothing there

distant inlet
bright cradle

give me a minute

@distant inlet I've added a command it still shows it

nor is it creating the command in the server

distant inlet

I have the idea that you have no idea what you are doing

why you have prefix while you try to create a slashcommand

bright cradle

the bot has both slash commands and prefix commands how is it that hard

distant inlet
steel trail
bright cradle

@distant inlet itd be more helpful if you actually "help" someone

distant inlet

You mean spoon feeding you the correct code? And me sniffing in empty air to find your errorin first sight? You are better of interacting with GPT then with humans.

steel trail
distant inlet
fiery epoch
bright cradle
steel trail

You can drop it too

snow onyx

no, please just drop the conversation

fiery epoch

giving someone code isn’t helping them. It is being a human version of their GPT slave.

steel trail

Nobody asked for giving them code. Now drop it

bright cradle
bright cradle
fiery epoch

Helping would be providing guides, explaining what code goes where and why it works, or something else doesn’t.

distant inlet

My first act of helping them out was to** spoon feed** them** on how to ask for help**, by providing the code and file tree. Without that act of help nobody could have sniffed in empty air what the fault would be. But it's okay, I'll never try to help someone again over here with that absurd time out. Because yeah.. they are so right.

bitter leaf

Error: Webhook send timeout
at Timeout._onTimeout (/home/container/commands/slash/Admin/panel.js:156:54)
at listOnTimeout (node:internal/timers:581:17)
at processTimers (node:internal/timers:519:7)
Error: Webhook send timeout
at Timeout._onTimeout (/home/container/commands/slash/Admin/panel.js:156:54)
at listOnTimeout (node:internal/timers:581:17)
at processTimers (node:internal/timers:519:7)

why webhooks getting timedout
my own bot can send but webhook cannot sended
issue from my server or discord provider?

trim elm

Seems like the type for "content" is missing, or im doing something wrong here

It is typed as a TextDisplayBuilder too

i mean i can cast the type, but question still stands

wary coral
trim elm

containerbuilder

wary coral

then it is a union type

sharp ginkgoBOT
wary coral

Id and type is the only propertes that they all share

trim elm

gotcha

wary coral

you could type guard it but using instanceof

sharp ginkgoBOT

mdn instanceof
The instanceof operator tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object. The return value is a boolean value. Its behavior can be customized with Symbol.hasInstance.

inner kernel

how author can be null in partialmessage?

fallow finch

partial message only shows message id, and a few minimal other stuff but I forgot

little pebble

Only ids are guaranteed for partial structures

steel trail
inner kernel

but why new message can be partial message?

fallow finch
inner kernel

what about message delete event

tight dagger

how i can make embed like this any docs? I am using yt dlp and i want my video to be inside this embed

fallow finch
inner kernel

can i fetch oldMessage too?

fallow finch
tight dagger
inner kernel

will i just get newMessage then?
can i assume that only content, editedAt/Timestamp is changed between newMessage and oldMessage?

fallow finch
inner kernel
fallow finch

You would usually have a fetching logic using Message#partial to check if it's partial and you would try to fetch

steel trail
steel trail
steel trail
fallow finch

I think it shows up as Message | PartialMessage in the event then or I'm mistaken I haven't looked at MessageUpdate event in a few months

tight dagger
inner kernel
wary coral
inner kernel

Client<boolean>.on<"messageUpdate">(event: "messageUpdate", listener: (oldMessage: DiscordMessage<boolean> | DiscordPartialMessage, newMessage: DiscordMessage<boolean> | DiscordPartialMessage) => Awaitable<void>): Client<boolean>

i think this is called method signatures

wary coral

what version of djs are you on?

tame eagle
const modal = new ModalBuilder()
  .setCustomId(`rankImage_${interaction.id}`)
  .setTitle(`123`)
  .setLabelComponents([
      new LabelBuilder()
          .setLabel(`1`)
          .setTextInputComponent(
              new TextInputBuilder()
                  .setCustomId("link")
                  .setRequired(false)
                  .setStyle(TextInputStyle.Paragraph)
          ),
      new LabelBuilder()
          .setLabel(`2`)
          .setTextInputComponent(
              new TextInputBuilder()
                  .setCustomId("brightness")
                  .setRequired(true)
                  .setStyle(TextInputStyle.Short)
          ),
      new LabelBuilder()
          .setLabel(`3`)
          .setTextInputComponent(
              new TextInputBuilder()
                  .setRequired(true)
                  .setStyle(TextInputStyle.Short)
          )
  ])
await interaction.showModal(modal)
Error: Expected a string primitive
    at _StringValidator.handle (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2615:70)
    at _StringValidator.parse (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
    at validateRequiredParameters (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:906:21)
    at TextInputBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:1528:5)
    at LabelBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:1757:29)
    at C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:2857:64
    at Array.map (<anonymous>)
    at ModalBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:2857:35)
    at ButtonInteraction.showModal (c:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:402:46)
    at Object.run (C:\Users\AnthonyVault\Documents\GitHub\wetbot\slash-commands\rank-set.js:76:35) {validator: 's.string()', given: undefined, stack: 'Error: Expected a string primitive
    at _St…b\\wetbot\\slash-commands\\rank-set.js:76:35)', message: 'Expected a string primitive'}
wary coral
glad stone
inner kernel

i think it isnt

wary coral
inner kernel

so i can assert it?

cinder osprey

Question about the .setAccentColor() of ContainerBuilder, how to use a #123456 hexa color ?

wary coral
inner kernel

is there type guard checking message is partial or not?

wary coral

message#partial is a Boolean you can use that

steel trail

npm ls discord.js

Because we can't really help you without knowing that

inner kernel

im on 13 because that one made really hacky patch that forces me to in 13

wait this is v14 channel..? if you guys cant help thats ok ill find my way

steel trail

v13 is deprecated and unsupported for a long time; you really should update

patent dune

realistically, this should set the status right?
nothing i've done has made the bot appear online

const client = new Client({
    intents: [GatewayIntentBits.Guilds],
    presence: {
        status: 'online',
        activities: [{
            name: 'everyone get petted!',
            type: ActivityType.Watching
        }],
    },
});
inner kernel
inner kernel
steel trail

You don't even know why you're using a deprecated version?

Update then

inner kernel

ok ill try

patent dune
steel trail

What exactly is showing/not showing when doing the stuff in constructor?

patent dune

I only did one at a time, the one not in use was commented out.

the bot remains in the offline appearance, and I haven't managed to get it out of that.

I can't see anything in the linked thread that I haven't done.

steel trail

Is the bot actually logging in, if it doesn't show as online it probably isn't

patent dune

well the bot responds to commands

steel trail

Does it show as an actual user in members list?

Or is it just added as an app and not a full bot user