#djs-help-v14

78874 messages · Page 69 of 79

sharp ginkgoBOT

documentation suggestion for @naive hull:
method TextChannel#createWebhook() discord.js@14.25.1
Creates a webhook for the channel.


// Create a webhook for the current channel
channel.createWebhook({
  name: 'Snek',
  avatar: 'https://i.imgur.com/mI8XcpG.jpg',
  reason: 'Needed a cool new Webhook'
})
  .then(console.log)
  .catch(console.error)

snow onyx

yes

if you want a bot to own a webhook, they will need to create it

sleek epoch

hey does InteractionCollector collect event doesnt fire when a selected option gets unselected?

snow onyx

the collect event fires when the bot receives a fitting interactioncreate event, so as soon as the select updates with the new values, it should

sleek epoch

mh

you see their is also no loading indicator or smth like when selecting an option

tardy sable
sleek epoch

when unselecting an option it doesnt actually unselect it. you gotta select another option or update the message again

sleek epoch

mh okay thats might be an needed feature? because only from ui-wise its looks like correct uk?

snow onyx

You will have to tell that discord then :D

sleek epoch

does discord have an feature request thing?

ah found it

jagged rock

how to get embed deleted message logs or is there anyway to tell them its an embed message

wary coral
worthy shale

hi what is the best lib for music bot rn?
sorry if this is wrong channel awkwardflushed

wary coral
worthy shale

alr thanks

jagged rock

i am able to get the embed title but nothing else

tardy sable
sharp ginkgoBOT
jagged rock
radiant bolt

guys does this look good? or is there a better way of doing it?

tardy sable
radiant bolt
stable sun
radiant bolt

I see but would be cool if can be a more general thing idk

sharp ginkgoBOT
stable sun

Usually, the caller should specify the type of reply they want

radiant bolt

alright thanks

sleek epoch

somebody have an idea how to handle a user has one running interaction process and dont be able to start an another interaction process before the first is finished
(like clicked button then needs so fill modals then needs to select stuff in v2 components message -> needs to press finish)

snow onyx

I guess you can somewhat misuse the cooldown system for that? have a collection with users that are blocked from the interaction and check on interactionCreate?

sharp ginkgoBOT

guide Cooldowns
Spam is something you generally want to avoid, especially if one of your commands require calls to other APIs or takes a bit of time to build/send. This section assumes you followed the Command Handling part of the guide. First, add a cooldown property to your command. This will determine how long the user would have to wait (in seconds) before using the command again. In your main file, initialize a Collection to store cooldowns of commands: 1. now: The current timestamp.

sleek epoch

thanks will look into this

sleek epoch
loud quartz

it's available for whatever you code it for

snow onyx

interactions, doesnt matter if slash or button

loud quartz

it's just storing and checking a value

sand minnow

Am I able to make a button copy a text to someone's clipboard when clicked?

tiny condor
sand minnow

Which is

Yh but in pc it has to be this

tiny condor

Yeah

sand minnow

So what's my solution here? Going with mobile I guess bc on pc there is a mouse, can select what to copy from the embed with the mouse

tiny condor

Yep, or you can just send both I guess depending on how you style it
What is the use case?

sand minnow

Copying a warn ID from an embed

tiny condor

Then just use ``

sand minnow

Alr, thanks

tiny condor

Also I suggest using components v2, you can style it to look much better

sand minnow
tiny condor

Worth imo

sand minnow

And wdym "style" it better. In what way? Css type style?

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.

pearl roost

Is this because rate limit? I try to log them, and it seems like```plain
switch-processing: 0.249ms
Akan rename: [CANCEL] Advert - Tiko → [RECEIVED] Advert - Tiko
Rename berhasil
rename-thread: 2:27.834 (m:ss.mmm)
send-content: 905.179ms
total-after-loading: 2:28.743 (m:ss.mmm)

stable sun
pearl roost

No there is no other bot renaming the thread

stable sun

Generally, all bots share a ratelimit of 2 edits / 10 minutes when renaming a channel or editing topic per channel

pearl roost

Likely limited to 2 edits per 10 minutes huh?

stable sun

It’s usually that

pearl roost

Got it, thanks!

vital marsh

Hi, does anyone know how to make an embed ephemeral?

bleak owl
vital marsh
tardy sable
sharp ginkgoBOT

The ephemeral option when replying to an interaction will be removed in v15

- {..., ephemeral: true}
+ {..., flags: MessageFlags.Ephemeral}
``` Read [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR) on how to specify multiple flags
tiny condor

If I want to give a lot of users roles, will Discord.js handle the ratelimit?

vital marsh
tardy sable
polar karma

A better option is to have a button or similar for a user to push to get a role

tiny condor

It's a backup system if a role gets deleted, for it to be re-applied to users that had it

I mean I'm ideally making sure to prevent that from happening but not much I can do if a single role gets deleted which majority of the members have 🥺

tardy sable
polar karma

-# discord does

turbid flame

can i go from embed to cv2? (ik that u can't go from cv2 to embed)

velvet cipher

What do you mean by that?

topaz bluff

yes, you can

turbid flame

i have an embed.. then once i press a button or self-edit it turns it into an cv2.

topaz bluff

you have to set embed: null

turbid flame

k, thanks.

odd stirrup
polar karma It will queue up additional requests by waiting based on the info discord sends....

for my leveling bot, i wanna have a feature so that when an admin adjusts the leveling ranks in such a way that users should have different roles than before based on their xp, there could be a button to force update every user's leveling roles to match the newly updated settings

is this a bad idea in terms of rate limiting? without this feature it would just lazily wait for each user to send a message before updating roles

polar karma

Yes, it's a bad idea. You're not respecting the rate limits, and it scales incredibly poorly - imagine being on a server with 10k users that you need to update roles on

odd stirrup

ok so i should just stick to updating individual members on messageCreate

short totem
odd stirrup

that doesnt solve the bad scaling issue

i mean if i say 1 user updated per sec then thats 3600 an hour so it would take ~3 hours to update on the aforementioned 10k server

and if the server was considerably bigger than it gets considerably worse

and at a certain point id really have to consider what if the bot restarts in the middle of it and id have to keep track of who has and has not been updated to be able to resume that

short totem

o I see now maybe it could use a pre-existing role? wait nevermind

odd stirrup

the only bulk operation i can do to member roles without spamming the api is to delete and remake a role to remove it from everyone

btw tangentially related, is the 50 requests/sec iirc global rate limit per bot or per shard?

marble plover
odd stirrup

that was not a yes or no question

short totem

sorry it's 4am and I'm going crazy

marble plover

i believe everything modifying in discord is api request, so it doesn't know about your "shard"

short totem
odd stirrup

the idea is, for example, if an admin adds a new leveling role at a certain level, and then wants to update every user who has reached that level to have that role

tardy sable

i mean what you described, mee6 does that. if you respect the ratelimits which such thing and can properly implement you arent breaking any discord tos

short totem

It's not a constant change so I don't see a problem

odd stirrup

well its relatively simpler if i just queue it all up at once in djs, im just hoping thats not a bad idea to queue up like thousands of member things and just hope djs rate limiting keeps the api from getting mad

short totem
polar karma
polar karma
odd stirrup

so even not going past the rate limit can still make discord mad?

velvet cipher

Rate limits are implemented as a "last resort" to prevent spam, they're not to be seen as a guideline or a "maximum allowed". Even if you don't hit them, getting close can still be considered spam.

short totem
odd stirrup

ok so how should i check if a user is boosting the server? should i check member.premiumSince !== null or member.roles.cache.has(guild.roles.cache.premiumSubscriberRole.id)? or do these both do the exact same thing

grave trench

const { SlashCommandBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, StringSelectMenuBuilder, MessageFlags } = require('discord.js');
const db = require('../../utils/db');
const getTheme = require('../../utils/theme');
const { createMessage } = require('../../utils/messageHelper');

module.exports = {
data: new SlashCommandBuilder()
.setName('reply')
.setDescription('Reply to your pending appeal (DM only)')
.setContexts([2])
.setIntegrationTypes([1])
.addStringOption(option =>
option.setName('message')
.setDescription('Your reply message (leave empty to open modal)')
.setRequired(false)
),

i want to make this command to show only in dm's not in server, i'm doing it correctly?

because currently its not showing in dm's

odd stirrup

.setContexts is the important part of that for dms, but also do not just use numbers for that and .setIntegrationTypes

use the enums djs provides

ive seen ai likes to rely on "magic numbers" like that, and its terrible form that makes that part of your code unreadable without documentation, not to mention ai can easily get those numbers wrong

in this case, its using the one that makes it so that the command is visible in dms other than the dm directly between the bot and the user

sharp ginkgoBOT
odd stirrup

@grave trench

marble plover
odd stirrup
grave trench
odd stirrup <@1386689993094991972>

const { SlashCommandBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, StringSelectMenuBuilder, MessageFlags, InteractionContextType, ApplicationIntegrationType } = require('discord.js');
const db = require('../../utils/db');
const getTheme = require('../../utils/theme');
const { createMessage } = require('../../utils/messageHelper');

module.exports = {
data: new SlashCommandBuilder()
.setName('reply')
.setDescription('Reply to your pending appeal (DM only)')
.setContexts([InteractionContextType.PrivateChannel])
.setIntegrationTypes([ApplicationIntegrationType.UserInstall])
.addStringOption(option =>
option.setName('message')
.setDescription('Your reply message (leave empty to open modal)')
.setRequired(false)
),

odd stirrup

im assuming so because its typed as Date | null

marble plover

btw this is cursed, null for true and undefined for false

odd stirrup
odd stirrup

this does not spark joy

marble plover

ikr

i thought the null was wrong in the type part, until i read the description

stable sun

D.js won’t do that to you

marble plover

why not 😔

stable sun

You want this cursed "null" type?

odd stirrup

why tf would they design it like that, the fact that js has a weird separation between undefined and null is the only thing making that even possible to distinguish

grave trench

i was using privatechannel before

odd stirrup

well unless you do Object.keys and whatever but ew

stable sun

Dart uses Map for json objects

odd stirrup

idk

stable sun

Not sure about other langs

marble plover
odd stirrup
stable sun
marble plover

see im getting confused by null being true

odd stirrup

idk man this is still silly

marble plover
odd stirrup

like if i were using a proper hashmap for this

marble plover

the real question is why does json have null...

stable sun

They should’ve just used an array of strings

odd stirrup
marble plover

not sure how they would have the id's for bot/subscription tho

stable sun

Why wouldn’t they?

marble plover

clearly: tags: ["bot_id:123456789", "premuim"]

odd stirrup

hmm what do yall think, is the distinction between null and undefined in js overall a good feature or stupid

idk any other language that does this

stable sun

Oh right, null isn’t the only type

marble plover
stable sun

Make an object

marble plover

with null for truthy values right!!!

marble plover
ruby bane

i dont understand why they couldnt just use a boolean

stable sun

true dat

marble plover

no data to show unlike others with snowflake, so its just null

kinda makes sense

marble plover

i meant abc is an object

odd stirrup

wait im stupid

marble plover

as like why is const abc = {def: undefined} a thing, and like abc['def'] = undefined not the same as delete abc['def']

odd stirrup

oh the latter is so annoying

marble plover

lol

odd stirrup

as far as im concerned, the one usage for undefined is checking if an object key exists or not

marble plover

ya

odd stirrup

so the fact that an object key can exist and equal undefined is crazy

and its ofc not functionally identical to the key actually not being defined

marble plover

do you like an array with "empty" values

odd stirrup

maybe i should go back to learning rust with its lack of a typical null value

marble plover

oh and how you can empty/reduce an array by abusing .length

odd stirrup

?????

what compelled brendan eich to do this

in what world did this seem like a good idea instead of throwing an index out of bounds error

marble plover
odd stirrup

not especially, no

i cant say im a big fan of this sudden knowledge that arr.length is not a getter but is in fact mutable

marble plover

OH wait i forgot js loves converting things to strings

odd stirrup

⁉️

marble plover

wait, how do you have string key for array

i didnt even think of that

odd stirrup

because why are you assuming javascript data structures make any sense

recently in this server we were discussing why tf Maps are ordered

marble plover

yo

like why did js think its useful to have a term that can mean many things

odd stirrup

tbf most of this is just weird evil corners of the language that dont really matter for everyday usage

marble plover

i have to check .length if i wana know if key even should exist

odd stirrup
marble plover

btw does it make sense for programming languages to have 0 as first key of arr, or should it really be 1?

odd stirrup
marble plover

i like making yo yo's

odd stirrup
marble plover btw does it make sense for programming languages to have 0 as first key of arr, ...

well the reason for that is because the math works out more conveniently, especially for what arrays actually are in memory

this is more relevant in lower level languages like C, but you have a pointer to the start of an array, and then the array is just a contiguous series of elements of that array. The pointer doesnt point to some sort of header info or anything, it just points to the start of that list, so the first element

indexing into that array is then about offsetting that pointer a certain amount, which would be the index you want times the size of each array element in memory

the thing is, to get the first element of that array, you dont offset it at all because the pointer already points to that element, so the first element's index should be 0

marble plover

ohhhh ya that does kinda make sense

odd stirrup

there are other cases where the math of 0-based indexes is convenient but thats the main precedent set by lower level languages, and higher level languages follow because having a divide between 0-indexed and 1-indexed languages would just be confusing (*cough cough* R *cough*)

dang ok its more common than i thought (according to ai)

hmmm i havent heard anything about julia in a while, forgot about that language

marble plover
odd stirrup

or roblox kids

but outside of those more targeted languages, keeping everything indexed the same way means far fewer off-by-one mistakes

anyways i can forgive javascript for all its insanity because this is funny to me

marble plover

lol

crystal tiger

how do i use emojis from an app?
do i just upload them on the emojis developer application page

and why is there a "SERVER" tag how do i do that?

novel mauve

you use them like regular emojis by copying the markdown format from the dev portal
the server tag means the message has been cross posted from a news channel announcement <— this channel type icon

balmy kraken

can you have discord emojis in autocomplete responses?

frosty epoch

instead of fetching a member form a guild, can i fetch it from the client? does it return me all the servers in which both the bot and the user are in?

novel mauve

no a member is by definition part of a guild
you'd need to loop over the bot's guilds

signal pumice
crystal tiger

Go to Discord Developer Portal, and enter your app, go to Emojis Page, and upload your emoji, click "Copy Markdown", and use it

frosty epoch
rose tangle

to users yes

to members no

viral cave

what is the client.user function for that bubble?

loud quartz

That's an activity with the custom type

viral cave
sand minnow

I'm trying to make a guildBanAdd logs but I want to see the options inside it, is it possible to look for all of the client once events in docs?

sharp ginkgoBOT
loud quartz

All the events are right there

sand minnow
sand minnow
loud quartz

That's on the docs too

sharp ginkgoBOT
sand minnow
loud quartz

Yes, you get one parameter of the GuildBan type

You can name it almost whatever you want

sand minnow
sand minnow
grave trench

can we make modal fields to only accept specific type of input?

frosty epoch
rose tangle

client.users.fetch

frosty epoch
rose tangle

can fetch only 1 user id?
yes
will it return all the guilds the user is both with the bot?
no, a user is not a member

frosty epoch

so i cannot use a manager, it will just return basic user info?

rose tangle

well fetching a user will return as much data as you can get

whether that's "basic info" depends on what you need

frosty epoch

id need a member manager based on the guilds the bot share with such user

as in, editing roles for eample per guild

rose tangle

that's not a thing, like we said you need to iterate over your guilds and get the member

that's what such a manager would do anyways

polar karma
frosty epoch

so fetching the user with users.fetch wont gimme any utility to correlate with shared guilds

polar karma

If you want the shared guilds, the user needs to give it permission via oauth2

frosty epoch

ya no im just working thourgd user id

polar karma

Then it's not readily available

sand minnow

idk if it's a bug or not, but guildBanAdd and guildBanRemove do not trigger at all:
this is the code:

client.on("guildBanAdd", async (ban) => {
console.log(ban)
  const logData = await logSchema.findOne({ Guild: ban.guild.id });
  if (!logData) return;
  const logChannel = ban.guild.channels.cache.get(logData.Channel);
  if (!logChannel) return logData.delete();

  const embed = new EmbedBuilder()
    .setTitle("Member Banned")
    .setColor(colors.red)
    .addFields(
      { name: "Member", value: `${ban.user.tag} (${ban.user.id})` },
    )
    .setThumbnail(ban.user.displayAvatarURL({ dynamic: true }))
    .setTimestamp();

  logChannel.send({ embeds: [embed] });
});

client.on("guildBanRemove", async (ban) => {
  console.log(ban);
  const logData = await logSchema.findOne({ Guild: ban.guild.id });
  console.log(logData);
  if (!logData) return;
  const logChannel = ban.guild.channels.cache.get(logData.Channel);
  console.log(logChannel);
  if (!logChannel) return logData.delete();

  const embed = new EmbedBuilder()
    .setTitle("Member Unbanned")
    .setColor(colors.green)
    .addFields(
      { name: "Member", value: `${ban.user.tag} (${ban.user.id})` },
    )
    .setThumbnail(ban.user.displayAvatarURL({ dynamic: true }))
    .setTimestamp();

  logChannel.send({ embeds: [embed] });
});
``` not even the console.log before the ifs and even some other events like stickers
polar karma

What are your intents?

sand minnow
polar karma What are your intents?
intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMessageReactions,
    GatewayIntentBits.GuildVoiceStates,
    GatewayIntentBits.DirectMessages,
    GatewayIntentBits.DirectMessageReactions,
    GatewayIntentBits.GuildPresences,
    GatewayIntentBits.GuildWebhooks,
    GatewayIntentBits.GuildModeration,
    GatewayIntentBits.GuildExpressions,
    GatewayIntentBits.GuildIntegrations,
    GatewayIntentBits.GuildInvites
  ],```I added some, last 4
polar karma

I thought the events required a permission as well, but the API docs don't mention anything. Have you confirmed the listener is properly registered, such as by trying to manually emit it?

cobalt solstice

hello, is there any way to know if you are rate limited to discord with d.js?

snow onyx

You can listen to the rateLimited event
client.rest.on('rateLimited', ...);

cobalt solstice

thanks

midnight cape

So I'm using my interaction event handler file (called interactionCreate.js) to keep a string select menu constantly running without the usual slash command 15 minute interaction time limit. I have the string select response trigger a modal, the modal trigger a button, etc, all of which handled through that same interactionCreate file with the same method as the initial one, so now I'm wondering, do these all count as a singular interaction or separate ones? Specifically, the time limit. Like, does a 15 minute timer start the moment I use the stringselectmenu and I have those 15 minutes to fill out the modal and use the button, or does each of the different elements of this process have its own separate 15 minute timer?

wary coral
midnight cape

Yes I know that, what I'm asking is if the workflow I describe count as several different interactions, or if they are all part of the same interaction?

wary coral

They are all interaction the difference are the method of response and data included

midnight cape

Yes I know they are all interactions too... I'm asking if all of these different response methods (and included data) are multiple different interactions, or just one singular interaction

wary coral

each one will emit its own interaction create event. is that what your are looking for?

midnight cape

Yes correct

sand minnow
sand minnow
odd stirrup

outside of interactions (in a messageCreate event), how do i check if a guild has my premium subscription?

slow cipher

hm

marble plover

lol this inconsistent magic numbers are sending me....

fossil iris

What is the best storage package?

tardy sable
topaz bluff
fossil iris What is the best storage package?

There's rarely such thing as "best" in programming. It's highly contextual based on your use case

If you're talking about storage as in a database option? Many recommend starting with sqlite as it's a simple but powerful database that is run just in a file rather than on a DBMS server

fossil iris
topaz bluff

Prisma is not a storage tool, it's an ORM. It's used to simplify the process of interacting with a database, by using automatically generated types and by generation the SQL queries based on JS syntax

I think it's a powerful tool, but often overkill for Discord bots... I also typically prefer Drizzle as it's much more lightweight and I think simpler to set up

But even more lightweight than that is Sequelize

sharp ginkgoBOT
fossil iris
topaz bluff

there's no such thing as better

What are you using your DB for? What DB is it? Do you need a lot of concurrent connections? Are you performing complex queries? Do you use typescript and want generated types?

fossil iris
topaz bluff

Any can. Thousands is not that many for data solutions

You could even use a JSON file (you shouldn't but you could at that size)

odd stirrup
fossil iris I have a large bot on multiple servers and need a powerful storage tool. What do...

large bot, multiple servers, powerful storage tool, none of this is particularly useful

first of all, your first choice should be a relational database (sqlite, mysql, postresql, mariadb, etc) vs document database (mongodb being the main one)

relational databases are useful when you have a lot of relations, as in entries that are related to others in complex ways. for example, a discord message might be related to a channel, a guild, a guild member, then that guild member is related to a user, who is related to other users as friends etc

document databases are more similar to a file system, but i dont have any experience with them so i wont try to explain them any further, you absolutely should google relational vs document database if you arent familiar with this

if youve chosen a relational db, things like sequelize, prisma, etc are what are known as ORMs - Object Relational Mappers. You can absolutely use a relational database directly if you learn SQL (not too hard but there are a handful of footguns), but ORMs are designed to give you a more language specific, often type-safe API for your database. These can have some performance impact, but none of them is inherently best

topaz bluff
fossil iris
topaz bluff

... Typescript works on node...

You just compile the TS to JS...

wary coral
fossil iris

Which package did you use?

tiny condor
pine laurel
wary coral
pine laurel

what do you mean by suppress the push notification, i believe thats what im trying to do

sharp ginkgoBOT
snow onyx

this fits more than using silent

and is equivalent to turning off the reply mention

wary coral

IDK why I did not go tho that dead

pine laurel

I see, i will try it, because it is only for a specific message too

snow onyx

yes, you can provide that in the message options

pine laurel

Ahh, thank you

zealous knot

Is it possible to defer a command interaction, specifically a message context menu command interaction, then show a modal?

topaz bluff

No

Sending a modal has to be the initial response... You can't defer beforehand

zealous knot
tardy sable

a report message command shouldnt be that heavy that youre getting unknown interaction errors. use cache if youre fetching the message

zealous knot

I have a somewhat small app for large servers, and during those times I process roughly 15k interactions per hour, so there are a few that end up timing out

zealous knot

That query's p99 latency is just 6ms though, so it's really not the main problem to be honest

tardy sable

if youre doing some checks, move the checks after the modal submit, that can save some time

zealous knot
tardy sable
zealous knot
tardy sable
zealous knot

I'll try moving the query over to the modal handler and see if these stop. Right now it's really rare that it happens, at most 6 times within an hour. I just really hate that it has to create a sentry alert whenever it happens 💀

It also sends me an email every time it does... so it can get a bit annoying

zealous knot

Moved the query to the modal handler and it's still happening. Looks like an issue with my external network. I'll try moving the service closer to Discord since right now it's in Canada

odd stirrup
wheat gulch
      guildData.systems.moderation.loggedEvents = [
        "BAN", 
        "KICK",
        "TIMEOUT",
        "UNBAN",
        "WARN", // sonra eklicem
        "UNWARN", // .
      ];
     // guildData.markModified("systems.mod"); // eski bu
      guildData.markModified("systems.moderation");
      await guildData.save();
    }

logs:
TypeError: Cannot create property 'loggedEvents' on boolean 'true'
 at Object.execute (>src\commands\configuration\modlog.js:48:49)


why is it 



bleak owl
wheat gulch

uhh

zealous knot

It's no longer happening now that I handle that part in the modal since it's deferred

warm charm

can i set VoiceChannelStatus w/ djs v14?

ruby bane

since the feature is still an experiment/on rollout, no not yet

warm charm

ok tks

and how can i reset the stringselect menu after user used that

it stucked this option after i click the select

unique shoal

You have to update the message and pass the original component again to reset it

warm charm

thanks

stiff garden

is it possible to fetch messages in a group chat with a user install bot?

halcyon bison

no

trail osprey

anyone can help me to do that?

i want do custom emoji, ill use components v2 tho

bleak owl

i’m not sure what you want to do though

if you’re trying to add custom emojis to a select menu, just pass the emoji markdown in the emoji option of a select menu option

doesn’t necessarily matter if you use cv2 or not

trail osprey

I want to add it just as it is. I tried to insert my custom emoji and see how it looks. It says the name of the emoji, but it doesn't show up in the placeholder.

bleak owl

are you passing the emoji markdown in the emoji option of the select menu?

if so, please show your code

trail osprey
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.

pearl roost

why did it say something like this? nvm

ruby bane
unique shoal

^ that too, but its because 64 is Ephemeral and you cant pass that to editReply

pearl roost

well i use number because its just easier to type dogeHaHa

ruby bane

i mean you can also just do "E and press tab

warm charm

^ agreed

pearl roost

Oh well, I did not know that

Thank you very much

trail osprey

@bleak owli don't understand

marble plover

How do you do ephemeral components v2.. do you conpute the bit field value or do you still | them?

pearl roost
marble plover

Damn

topaz bluff

-# or you can bitwise or them with |

trail osprey
warm charm

💀

trail osprey

F

trail osprey
marble plover

Tbf I like using the most raw barebones option like @discordjs/core which doesnt have said helper anyway

candid quail

is there an npm package dealing with pagination? i found pagination.djs but it blocks any command after the pagination (until it has expired)

odd stirrup

maybe not the most helpful answer, but i code pagination myself

(assuming you mean paginating content you show to users, and not something api related)

the simple method being to have a function that renders a page given a specific page number (with an items per page constant, you just slice the array of page items based on that), and then you have page buttons that store the page to move to in their custom id, and when you get those button interactions you call that original function with the value from the custom id

so for example i might have a button with a custom id like "rank_page?5", where i can easily extract the page number by splitting at the special ? character

thing is, i design my bot so all interactions are handled and routed by a general interactionCreate handler, rather than using anything like a component collector, so my code never exactly pauses to wait for a pagination thing to happen or for anything to expire

obtuse laurel
normal lodge

Hello all, is there a limit to how many TextDisplays we can put into a Section regarding Components V2? I'm getting Error: Invalid Array length errors when I put in 4 or more TextDisplays along with a thumbnail; am I running into a limit here or is there another issue?

candid quail
wary coral
radiant bolt

Guys if I'm sending a quote block with >>> message how do I end up this block to write back normally?

blazing brook

hello i need help with automod system links.. i have been trying for all days idk why isnt working the bot in the server has admin perms.. i also created a command called >testautomod, to see if the bot gives any error but it says all good with green checkmark.. bot doenst auto elim the links, i have also separate files outisde automod system category, timeout.js for automute where bot gives to members after reaching 5 auto warns.
Models/Schemas.js
Models/timeout.js
in the ROOT:
messageCreate.js
main.js

code here:
Category: AutomodSystem
file name: auto-link.js

const { User } = require('../Models/Schemas.js');
const { checkAutomodThreshold } = require('../Models/timeout.js');

module.exports = {
    name: 'auto-link',
    description: 'Automod system for unauthorized links with media whitelist',
    category: 'Automod',
    aliases: ['autolinks'],
    usage: '',
    cooldown: 0,
    async handle(message) {
        if (message.author.bot || !message.guild || !message.member) return false;
        if (message.member.permissions.has('ManageMessages')) return false;

        const content = message.content.toLowerCase();
        const channelId = message.channel.id;

        const ADS_CHANNEL_ID = '1459674759616008346';
        const PHOTO_CHANNEL_ID = '1461861707805622304';
        
        // Regex per rilevare qualsiasi link
        const linkRegex = /(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+(com|it|net|org|gg|xyz|tk|info|biz|site|online|tv|me|io|social)/i;
        
        // Whitelist: Questi link sono SEMPRE permessi
        const mediaWhitelist = [
            'tenor.com', 
            'giphy.com', 
            'discordapp.com', 
            'discord.com', 
            'cdn.discordapp.com',
            'media.discordapp.net'
        ];
        if (!linkRegex.test(content)) return false;

        if (channelId === ADS_CHANNEL_ID) return false;

        const isMedia = mediaWhitelist.some(domain => content.includes(domain));```
        try {
            const pID = Math.random().toString(36).substring(2, 11).toUpperCase();
            
            let userData = await User.findOne({ userId: message.author.id }) || new User({ userId: message.author.id });
            userData.strikes += 1;
            userData.punishments.push({ 
                pID, 
                type: 'automod', 
                action: 'WARN', 
                reason: "[Automod] Unauthorized Link/Advertising", 
                date: new Date() 
            });
            await userData.save();

            await message.delete().catch(() => {})
            await checkAutomodThreshold(message, userData, pID);

            const warningEmbed = new EmbedBuilder()
                .setColor('#e55151')
                .setDescription(`**${message.author.username}**, you cannot send this type of link here. Only GIFs and Images are allowed.`)
                .setFooter({ text: `Auto-info: Total Strikes ${userData.strikes}` });

            const msg = await message.channel.send({ 
                content: `![alert](https://cdn.discordapp.com/emojis/1461652752169177215.webp?size=128 "alert") ${message.author} **Rule Violation**`, 
                embeds: [warningEmbed] 
            });

            setTimeout(() => msg.delete().catch(() => {}), 6000);
            return true;
        } catch (error) { 
            console.error("Error in auto-link.js:", error); 
        }
        return false;
    }
};```
loud quartz

Does the code run?

blazing brook

yes but it doesnt work..

in the terminal there's no errors.. actually i have also Render and i dont see errors it says correct with checkmark

maybe the proble in Events/messageCreate.js that i have that bot needs to listen the command..

loud quartz

If it doesn't work and doesn't error then it doesn't run

Check where it stops

normal lodge
blazing brook
loud quartz

Use some basic debugging

Put some console logs around

wary coral
blazing brook
blazing brook

wait

blazing brook
torpid marsh

What are the select menu max length of label and description?

topaz bluff
torpid marsh
topaz bluff
torpid marsh

Ah so 100 is the max. Alright.

subtle girder

why my client.application is undefined?
my client is ready

torpid marsh

Check client.interaction

halcyon bison

if client.application is undefined, it's likely that client isn't a Client instance
even when not present (before logging in) <Client>.application would be null

torpid marsh

Or that.

subtle girder
topaz bluff
torpid marsh
sand minnow

I have this in my clientReady event: js setTimeout(() => { client.user.setPresence({ activities: [ { name: `${client.guilds.cache.size} Servers!`, type: "WATCHING", }, ], status: "online", }); }, 6000) but it still doesn't show, it used to but not anymore for some reason

topaz bluff

Just put that in your Client Constructor...not your clientReady event

(oh nvm you want to update the cache size)

sand minnow
torpid marsh

I would suggest try this.client, but I am unsure if that would work.

topaz bluff

this.client is not a DJS thing

sand minnow

yeah

torpid marsh
topaz bluff

It's also not the problem. Because they're getting the client object fine. They want the application object

torpid marsh
sand minnow yeah

Well, if you run the code outside your script, it would not know what client is...
And maybe it is not client but Client

And if it is a slash command, it would be interaction.client

sand minnow

it does know what client is since I defined it in the eval command and tested it multiple times, it uses my actual client

sand minnow
torpid marsh

Just saying 😉

Try to do console.log(client) and see what it gives you

sand minnow
topaz bluff
topaz bluff
topaz bluff
sand minnow

wth is duck typing😭?

halcyon bison
sand minnow I have this in my clientReady event: ```js setTimeout(() => { client.user.se...
  1. activity types aren't strings in v14, you'll want to use the ActivityType enum
  2. not sure if you noticed you're using setTimeout rather than setInterval
  3. I'd suggest not updating your presence every 6 seconds
    as much as I have yet to see a strict rate limit or even discord sending the newer rate limit gateway event for presences, I tend to see more of this same issue for people who update their presence on an interval fewer than a few minutes
sand minnow
sand minnow
topaz bluff

Discord doesn't really like "realtime" stuff in general. Updating every 5 minutes or even longer isn't a big deal

topaz bluff

10 what? Minutes? I'd try it out and see. If it breaks again, move it up

sand minnow
sand minnow
halcyon bison

that's due to a change in discord's ui
not something that bots can control

sand minnow
halcyon bison

that's entirely up to you
personally, I started using more custom statuses in general which lack the activity type prefix altogether

sand minnow
sharp ginkgoBOT
sand minnow
topaz bluff

Click it

sand minnow
topaz bluff

Ya. It's a forum post (so a thread) so it just wasn't cached

sand minnow
rigid crest

im struggling to find the file attachment for V2 component not images or gifs/video like a txt file i thought it was under MediaGalleryBuilder unless its just media builder for txt file type?

rose tangle

it'd be a file component

sharp ginkgoBOT
rigid crest

ah

sharp ginkgoBOT
rigid crest

so id do it like this? or do i still need to call it into the files in the message builder part?
const exportedBansFile = new FileBuilder(tempPath); serverBanContainer.addFileComponents(exportedBansFile);

wary coral
rigid crest

👍 Cheers

sand minnow
        const emojiExt = getEmoji.animated ? ".gif" : ".png";
        const emojiURL = `https://cdn.discordapp.com/emojis/${getEmoji.id + emojiExt}`;
        console.log(emojiURL);
        message.guild.emojis
          .create(`${emojiURL}`, getEmoji.name)```

[Unhandled Rejection]
TypeError [ReqResourceType]: The resource must be a string, Buffer or a valid file stream.
at GuildEmojiManager.create (C:\Users\zeinf\Documents\Projects\tryhard\main\tryhard-main\node_modules\discord.js\src\managers\GuildEmojiManager.js:54:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)```

nvm, got it

tiny condor

Can I defer the reply and specify the components v2 flag

await interaction.deferReply({
      flags: [MessageFlags.Ephemeral, MessageFlags.IsComponentsV2],
    });

I am getting teh error;
DiscordAPIError[50035]: Invalid Form Body
components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).

tardy sable
tiny condor

That is perfect thanks

tiny condor

How come in a new message on a message update the message author is potentially null?

rugged lava

Guys who wants a host for discord bots

?

bleak owl
rugged lava
bleak owl

not really anywhere in this server, sorry

rugged lava

Ok

rugged lava

I need users

xD

tiny condor
stable sun

That’s old message

tiny condor

yeah nvm what am i talking about

sand minnow

how do I get a webhook?

stable sun

What’re you trying to do exactly?

sand minnow
sharp ginkgoBOT

method TextChannel#createWebhook() discord.js@14.25.1
Creates a webhook for the channel.


// Create a webhook for the current channel
channel.createWebhook({
  name: 'Snek',
  avatar: 'https://i.imgur.com/mI8XcpG.jpg',
  reason: 'Needed a cool new Webhook'
})
  .then(console.log)
  .catch(console.error)

sand minnow

I mean I already have it made and have the link

stable sun

Then make a WebhookClient and send to it

sharp ginkgoBOT
stable sun

const webhook = new WebhookClient({ url: "…" })

sand minnow
stable sun

Just make sure to handle errors from the send call in case the webhook gets deleted for whatever reason

jolly radish

what can cause this error?

bleak owl

your section is missing an accessory, which includes a button or a thumbnail. if you don't need either, don't use a section

jolly radish

oh so all sections must have at least one accessory

bleak owl

yes

jolly radish

okay! Thank you a lot!

jolly radish

I am new to this feature. How can I get an emoji I have uploaded to my application so the bot uses it?

sharp ginkgoBOT
jolly radish

I have created it. How I get it from the application so I can display it

sharp ginkgoBOT

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


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

tardy sable

you have to fetch them first and then you can use in cache if you want

halcyon bison

alternatively if you prefer to hardcode the markdown/ids you can access them from the dev portal

tardy sable

will v15 require to use the emoji object for setting emojis in options or will string just work fine?

jolly radish

Thank you!

halcyon bison
tardy sable

yh thats what i was referring to. i hope the easiness of just setting string will remain

rain forum

guys
in modal button
can i use

interaction.message
unique shoal

what?

Modals cant have additional buttons added to them, and don't always come from a message

stable sun

Thought they were asking abt a modal interaction shown from a button interaction

tardy sable

I think they mean when pressing a button that opens a modal

unique shoal

If the modal was opened from a button that was in a message, ModalSubmitInteraction#message will be defined

tiny condor

What was the method to check if the bot can send a message to a text channel?

Like permission wise

sharp ginkgoBOT
stable sun
tiny condor

That checks permission?

ruby bane

oh wait permission wise

tiny condor

So just the same old permissionsFor has

stable sun

Yea

tiny condor

Thanks guys

Property 'send' does not exist on type 'TextBasedChannel'. why_god_why

clear garnet

There are certain instances where apps will know about a text channel but not be able to send messages to it (group DM channels for user-installed apps)

tiny condor

i just imported the type as a guild text channel hahhahah

balmy kraken

is it possible to attach an audio file in a container so that its rendered and can be played?

topaz bluff

No

balmy kraken

and will it be playable when attached to a message as a regular file?

topaz bluff

Yes I believe so

cobalt valley

Is there any way to detect if someone is speaking for x% in a voice channel where a bot is connected through voice states??

steel trail

What do you mean by x%? With /voice you can listen to the SpeakingMap events to know when someone starts and stops speaking

zealous knot

What's the recommended way to interact with webhooks? I heard WebhookClient is getting removed in v15 and I use that for a few things right now

coarse remnant

Either @discordjs/core or @discordjs/rest

vale lantern

Guys help me

tardy sable
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.

vale lantern

Let me send mine file?

tardy sable
vale lantern

@tardy sable

tardy sable
vale lantern

Ok

tardy sable
vale lantern
topaz bluff

Well first off. You're using JSON as a database. This is highly not recommended. It's highly prone to read/write issues, possible data corruption, and is just extremely slow (you have to load the entire file every time you want to read from it)

You should instead, use something like sqlite which is significantly more performant and stable. There's a guide for using it. 1 sec

vale lantern

Oh bruh

topaz bluff
vale lantern
topaz bluff
vale lantern

Oh

Cant i fix it?

Bc iam trying like 3 months for this

topaz bluff

Because it likely failed to read or write the league to the file so when you went to search for it by id, none were found

vale lantern

Oh how do i fix it?

topaz bluff
tardy sable
topaz bluff
topaz bluff ^^^

By using an actual database. That's designed exactly for what you're doing

vale lantern

Ok

vale lantern
tardy sable not sure the file isnt organized so i cant tell easy. place console log interact...

up to date, audited 133 packages in 9s
35 packages are looking for funding
run npm fund for details
4 low severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run npm audit for details.
✅ Chaosity Official#0512 online
🔄 Registering slash commands...
(node:37) DeprecationWarning: The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead.
(Use node --trace-deprecation ... to show where the warning was created)
✅ Slash commands registered!

topaz bluff

That's just the startup logs. It doesn't show your leagues Map, or the props when you use a slash command (to see if they match an entry in your Map)

vale lantern

Where can I i find leagues map

topaz bluff

Line 31 of your pastebin

vale lantern

Okay

vale lantern
topaz bluff

Why are you showing me your files?

vale lantern
topaz bluff
vale lantern

Yea i do

topaz bluff

Ok. Because the issue with your code is that your leagues.get(leagueId) is returning undefined

So logging the leagues Map, and the leagueId being read from the command args and seeing if it exists in the map is how you debug this

vale lantern

Wdym

topaz bluff

What are you confused about?

vale lantern
topaz bluff

...

vale lantern

Ik iam just a stupid human

steel trail
steel trail

Then ask your friend to fix it

vale lantern
steel trail

Then start to learning and understanding what every part of that code does and JS fundamentals

vale lantern

Like 2 months ago

tardy sable

it looks very gpt coded

vale lantern
steel trail

Yeah. And to get that to work you'd need to understand what the code actually does and how to debug

It won't help nobody if we spoonfed you your fix

vale lantern

True but like i tryd like 2 months watch vids but i didnt fix it

steel trail

How does your code determine what league to join based on the button used?

steel trail

So you have no idea how your code does it. Until you do we won't be able to help you

tardy sable

start by organizing your file into different files. that will already help you understand the code better

vale lantern

Alr

steel trail
tardy sable

hm yh but to someone whos new to coding a file like this is very overwhelming imo since he got everything in one

steel trail

Your advice is good for someone that hasn't written anything, tried to rewrite from scratch or knows what the code they got given actually does. None of this seems to be the case

narrow orchid

What's the highest you can put FetchMembersOptions's 'limit' property? 100?

steel trail

Yes

narrow orchid

Gotcha thank u

shadow violet

Hey is there any way by which I can create linked role logs using discord js if any user updates any role and creates linked role or adds its connection then bot send message related to it

queen vale

Did discord make a breaking change around 8 hours ago or something? My bot is in a crash loop suddenly and I haven't touched it for weeks

steel trail

They did make a change, but shouldn't be breaking

drowsy pilot

msg.author.send and generally sending dms says cannot send msgs to this user, do u guys have any idea why?

steel trail
queen vale
drowsy pilot
queen vale
steel trail
queen vale

What was the change discord made?

steel trail

Nothing related to your issue I'd say

queen vale

its been basically fine till now - something caused something to break

queen vale

because this triggers

but any commands arent being recognised

steel trail

Does a log directly in interactionCreate listener log?

near siren

does d.js have something like an auditlog collector? Similar to a message collector but you would supply a action, target id, maybe time period and it would collect or get the first audit log event that meets that criteria?
im trying to detect whether a user was kicked or left the server and i believe the best way without fetching audit log each time is by re-creating the d.js collector to see if theres any audit log event that goes off within 5-10 seconds otherwise assume the member just left.

i know theres no guarantee whether or not the audit log event would run before or after the guild member remove event but its still significantly better than fetching audit logs everytime somebody leaves a server especially when the bot is in almost 30k servers

or is this something i would need to make myself?

halcyon bison

you'd need to make that yourself

crimson gale

i'd prob. just log based on audits instead of fetching on leave

near siren
crimson gale i'd prob. just log based on audits instead of fetching on leave

do you think i should add a delay to GuildMemberRemove to ensure GuildAuditLogEntryCreate runs first, then if the user was kicked, I'll temporarily store their ID so that the GuildMemberRemove event could check if they were kicked? I'm trying to avoid double logs and this seems like the best method that I could come up with (other than the collector idea)

crimson gale

that's what we do for #mod-log , but only because the system was developed before audits and i haven't had the motivation to switch
but since we split that from join/leave logs anyways, we want to "double" log, so not an issue

obtuse laurel
near siren

okay thats great. thank you!
also, when kicking a bot whilst listening to GuildAuditLogEntryCreate. i notice it also triggers an IntegrationDelete as well as MemberKick action. Does it trigger integration delete for EVERY bot or is this only certain bots which have created an integration (unless the bot is the integration?)

halcyon bison

the app as a whole is the integration, so that'll also emit for removing an app that only had the applications.commands scope
but yes that'd emit for every bot

zealous knot
zealous knot

I'll just use @discordjs/rest and make the requests through there

wispy nimbus

hello, is there an update to fix the vulnerable versions of undici from @discordjs/rest?

undici  <6.23.0
Undici has an unbounded decompression chain in HTTP responses on Node.js Fetch API via Content-Encoding leads to resource exhaustion - https://github.com/advisories/GHSA-g9mf-h72j-4rw9
fix available via `npm audit fix --force`
Will install discord.js@13.17.1, which is a breaking change
node_modules/undici
  @discordjs/rest  0.5.0-dev.1650197025-b94a876 - 3.0.0-dev.1744071169-d93a52c1d
  Depends on vulnerable versions of undici
  node_modules/@discordjs/rest
    @discordjs/ws  <=3.0.0-dev.1753316119-f2fec9177
    Depends on vulnerable versions of @discordjs/rest
    node_modules/@discordjs/ws
      discord.js  14.0.0-dev.1640779371.9cdc448 - 15.0.0-dev.1753316115-f2fec9177
      Depends on vulnerable versions of @discordjs/rest
      Depends on vulnerable versions of @discordjs/ws
      Depends on vulnerable versions of undici
      node_modules/discord.js

9 vulnerabilities (4 low, 5 high)

I'm on discord.js@14.25.1

bleak owl

please show the output or npm ls discord.js

wispy nimbus
user@lenovab:/opt/bot/src$ npm ls discord.js
bot@ /opt/bot
└── discord.js@14.25.1
bleak owl

i reported the issue internally, they’re gonna work on a fix

wispy nimbus

thanks 🙂

coarse remnant
grizzled ginkgo

how to clean selection on menu after use?

topaz bluff
wintry laurel

if someone clicks a button on a ephemeral message, will interaction.message be valid in the button interaction? if not, how would i get message info/data from the message the button was on

because i know interaction.message.edit()dosnt work so

wary coral
wintry laurel
topaz bluff

correct

wintry laurel

also does canceling a modal give any sort of event or response to my bot? does the modal code still run

wary coral

No

wintry laurel

dang so no way to know then?

wary coral
wintry laurel

ok

accually not to big of a deal i guess now that im thiunking about it

wintry laurel

how can i make a stringselectmenu's option reset after its clicked? so like they select it and it just goes back to normal instead of having that option selected so that they can choose the same option twice without having to navigate away

wintry laurel
loud quartz

hmm ok, any other way? i feel like if theres a lot of people using it it might cause issuies if theres a message edit request at the same time as someones clicking on it. also that would show the edited tag right?

loud quartz

updating components doesn't tend to show that

is it a select that's public for everyone?

wintry laurel

yes

loud quartz

cause only really the person who already used it will have the previous one selected

wintry laurel

also i would use .edit right\

loud quartz

no

just read after what i forwarded, please

since you were pretty much already told that

wintry laurel

well if i use .update i still need to respond to the interaction in a different way, and editreply you cant change the flags and i need a ephemeral message

oh wait i guess i can use followup right? that takes ephemeral tags

loud quartz

you can update and followup, or reply and editReply, passing the id of the original message in

wintry laurel

ok ill just use update and followup, thanks

sudden cedar

is role position 1 at the top or at bottom?

halcyon bison

the everyone role has a position of 0

stable sun

If you look at Discord’s UI, position 0 (everyone role) is at the bottom

crystal fable

Hello

I have a Code system but not Slashcommnad working Can Help me?

@loud quartz

@stable sun @halcyon bison

loud quartz

please don't ping everyone

we're not your answer slaves

crystal fable
jolly sun

How to make like this card

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.

crimson gale

the surrounding "card" is a "container"

this looks like a container with a media gallery, text display (for the heading) > separator > section with a text and a thumbnail accessory > separator > text display > separator > text display (subtext markdown) > action row > link button, link button

jolly sun
crimson gale

i linked you a guide and a code generator for discord.js - why would it not?

queen vale
sand minnow
client.on("messagePollVoteAdd", async (poll, user, option) => {
  const logData = await logSchema.findOne({ Guild: poll.guild.id });
  if (!logData) return;
  const logChannel = poll.guild.channels.cache.get(logData.Channel);
  if (!logChannel) return;

  const embed = new EmbedBuilder()
    .setTitle("Poll Vote Added")
    .setColor(colors.green)
    .addFields(
      { name: "User", value: user.tag },
      { name: "Option", value: option.label || option },
      { name: "Poll Message", value: poll.content || "No Content" },
    )
    .setTimestamp();

  logChannel.send({ embeds: [embed] });
});

client.on("messagePollVoteRemove", async (poll, user, option) => {
  const logData = await logSchema.findOne({ Guild: poll.guild.id });
  if (!logData) return;
  const logChannel = poll.guild.channels.cache.get(logData.Channel);
  if (!logChannel) return;

  const embed = new EmbedBuilder()
    .setTitle("Poll Vote Removed")
    .setColor(colors.red)
    .addFields(
      { name: "User", value: user.tag },
      { name: "Option", value: option.label || option },
      { name: "Poll Message", value: poll.content || "No Content" },
    )
    .setTimestamp();

  logChannel.send({ embeds: [embed] });
});

this doesn't seem to work even tho I have the intents for it in my client

sand minnow
queen vale

Nope - has something changed to the listener? Either that or it didnt deploy correcctly

sand minnow
sand minnow

that just might be your solution, changing Event.InteractionCreate to string and putting interactionCreate

@crimson gale does that happen to be an issue in djs? Where Events.InteractionCreate doesn't work with client.on?

I ran across the same problem once before

loud quartz

What does "doesn't work" mean here

queen vale
obtuse laurel
queen vale
obtuse laurel
warm charm

can i change voice channel region?

queen vale
jovial ivy
queen vale Yes

when u console log the client values are there any events presents in ur client it self ?

queen vale

Will have to check

sand minnow

@queen vale did u do what I told you?

queen vale
sand minnow
steel trail
queen vale

Did you by any chance set an interaction endpoint in dev portal causing interactions to be sent there and not as gateway events anymore? Do any other events (apart from ready) emit? Does the bot show as online in discord?

halcyon bison
sand minnow

well, we gotta wait for him to test and see

steel trail
smoky grail

I tried updating my commands on my discord bot and it gave me an error saying I'm not allowed to perform this action on this application and I don't know why considering it's my bot, can anyone help?

topaz bluff

Ensure that the client id and token match

And if you're updating guild commands, that your bot is in the server for the specific id

polar karma

providing the full error including stack can help

uneven plover

Is there a way, perhaps using a more raw/direct rest call to make use of the new create invite endpoint until djs is updated? I am not familliar with interacting more directly with rest.

queen vale
tardy sable

what version are you on?

polar karma
halcyon bison
queen vale

I'm on 14.21.0

uneven plover
sharp ginkgoBOT
uneven plover

Thank you!

polar karma

i meant if you had questions about forming the request

balmy kraken

is it possible to create the select menu so that its preset to some option at the start?

wary coral
short granite

I uploaded an image to the embed site, but it's not showing up. What could be causing this?
file size 7.2mb
and test in webhook work??

tardy sable

probably one of those embed builder sites through webhooks. you should ask to the support of the site

short granite
   const embed = new EmbedBuilder()
            .setImage('https://test.com/images/2026_01_23_00_02_20_753__Image_vmurguvmurguvmur.png')
            .setColor('#131416')
            .setFooter({ text: 'na', iconURL: interaction.guild.iconURL() || undefined })
            .setTimestamp();

        await interaction.reply({ embeds: [embed] });
balmy kraken
tardy sable
short granite
wary coral
tardy sable
sharp ginkgoBOT
tardy sable

doesnt embed either

smoky grail
short granite
tardy sable

if youre working with big image files its best to set them as attachement instead of link

sharp ginkgoBOT

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]
});
short granite

thx brother

eternal moth

Okay, so I have a bit of an issue. I have a really old legacy bot running d.js 8.2.0. What do y'all suggest is the best way to update to v14? I was kind of thinking of recoding it anyways if that's easier.

wary coral
balmy kraken

what exactly do i put in .setEmoji() when using the ButtonBuilder? String emoji ID?

balmy kraken

can it be used with custom emojis? doing .setEmoji(":missing:1462959149741641738") doesnt work

the emoji is 100% valid

uncut mango

Also I believe you need angle brackets around that

Alternatively use an object with id: "1462959149741641"

balmy kraken

doesnt work, neither doing { id: ":missing:1462959149741641738" } or just ID

hallow mesa

Just the ID as a string is fine if using the builder

uncut mango
balmy kraken

tried that too

uncut mango
balmy kraken

.setEmoji({ id: "1462959149741641738" })

uncut mango
balmy kraken

maybe its something with discord caching the UI, because when i removed one button it still rendered it

unique shoal

Discord doesnt cache through edits

balmy kraken
uncut mango
balmy kraken

im probably missing something

uncut mango
balmy kraken

it still does not show the emoji and it does not hide the button i wanted to hide for testing, im assuming im overlooking something

uncut mango

Make sure that's set up properly or just restart manually whenever you make changes

balmy kraken

yeah nvm it was just a quirk with something in my code. It works, thanks

uncut mango
balmy kraken

just a way my code works, too long to explain. Nothing djs related

wintry laurel

hey, i have a public modal and i want to reset the users choice when they select one, and i was told to use .update() and thyen followup for any other code, however this produices this error: TypeError: Cannot use 'in' operator to search for 'fetchReply' in undefined (line for updating it)

attached is my code, how do i fix this?

clear garnet

You've failed to provide anything to update() based on your screenshot

tardy sable

you probably meant to use deferUpdate instead

wintry laurel

i guess so

tardy sable
wintry laurel
tardy sable
wintry laurel
clear garnet

If you update just the components, then I believe the (edited) label will not show

tardy sable

yes it edits the message. with suppressEmbeds it doesnt but yh doesnt work on ephemeral

tardy sable
wintry laurel
tardy sable

yes it just needs an edit to reset the menu

wintry laurel

ok thanks

tardy sable

kinda weird why discord doesnt natively reset the menu kinda bad ux

narrow geode

Is there any built-in way to filter all events to a specific guild?

wary coral

No, you would have to filter it yourself. But also bots only receive events from guilds they are members of

radiant bolt

Hi, can I reply a ModalSubmitInteraction with another modal?

my goal is to have a multi-page modal

radiant bolt

so the only way is having multiple buttons is that correct?

proud arrow

Maybe, or a button in between modal that opens the second one or so on. Though not as efficient

subtle girder

what is the replacement of embed footer in components v2?

proud arrow

There are none, you can use subtext (-# ) to simulate that. But no footer image

subtle girder

okay, ty

warm charm

how much time the component will be invaild

signal pumice
warm charm
topaz bluff

Interactive Components do not expire. They're always valid, and send a new interaction to your application when they're interacted with (button clicked, select menu used, modal submitted, etc)

warm charm

alr tysm

topaz bluff

You can use a Collector to only listen to the component event for a limited time... But by using the InteractionCreate event, you can listen for them indefinitely

warm charm

ok thanks

brittle current

I made website with discord login and i want my bot to be able to send users dm but users are not in server with that bot. bc i want them receive dm if they succeeded or failed test

topaz bluff

Bots can't message people without sharing a server, regardless of OAuth state

proud arrow

In addition, user installed apps can too

rose kiln

Is it not possible to add fields to the component builder in the latest version of discordjs (except v15)?

wary coral
rose kiln

I'm talking about something like the fields in the embed builder.

sharp ginkgoBOT

documentation suggestion for @rose kiln:
method EmbedBuilder#addFields() builders@1.13.0
Appends fields to the embed.

// Using an array:
const fields: APIEmbedField[] = ...;
const embed = new EmbedBuilder()
	.addFields(fields);

wary coral

It is very much there in the latest version of the library

mighty saffron

Quick question: Can I pass multiple message flags?

tiny condor

Yes just put it in an array

mighty saffron

ok, thanks.

torpid marsh

Why can't add a button outside of the container?

await interaction.reply({
      components: [container, DeleteButton],
      flags: MessageFlags.IsComponentsV2,
    });
tardy sable
wary coral
wary coral
tardy sable
wheat gulch
const channelMenu = new ChannelSelectMenuBuilder()
      .setCustomId("ignore_channels")
      .setPlaceholder("Select channels to block...")
      .setChannelTypes(ChannelType.GuildText, ChannelType.GuildVoice)
      .setRequired(false) 
      .setMinValues(0)
      .setMaxValues(25);

    if (ignoredChannels.length > 0) {
      channelMenu.setDefaultValues(ignoredChannels);
    }

    const channelSelect = new LabelBuilder()
      .setLabel("🚫 Ignored Channels")
      .setDescription("Uncheck to unblock and check to block.")
      .setChannelSelectMenuComponent(channelMenu);

So I've been trying to make a command ignore sys with label builder on modal but keep getting:

[17:52:38] ERROR: TypeError: channelMenu.setDefaultValues is not a function

well, isnt setDefaultValues is a valid function? I am sure it was

tardy sable
wheat gulch

"discord.js": "^14.25.1",, latest

sharp ginkgoBOT
wheat gulch

ye i saw thanks

torpid marsh
topaz bluff

They have to be in an action row

Buttons are not a top level component, thus cannot be sent alone

torpid marsh

I understand...
But I can not do it like:

<Container>
<End of Container>
<button>

I want the button outside of the container... Not within.

const DeleteButton = new ButtonBuilder()
        .setLabel('Delete Message')
        .setStyle(ButtonStyle.Danger)
        .setCustomId('DeleteMessageButton');

      const row = new ActionRowBuilder().addComponents(DeleteButton);

    /* ------------------------------ Response -------------------------------- */

    await interaction.reply({
      components: [container, row],
      flags: MessageFlags.IsComponentsV2,
    });

Then I have this, and it still errors...

topaz bluff

What's the error?

torpid marsh
No overload matches this call.
  Overload 1 of 3, '(options: InteractionReplyOptions & { withResponse: true; }): Promise<InteractionCallbackResponse<boolean>>', gave the following error.
    Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIMessageTopLevelComponent | JSONEncodable<APIMessageTopLevelComponent> | TopLevelComponentData | ActionRowData<...>'.
      Property 'type' is missing in type 'ActionRowBuilder<AnyComponentBuilder>' but required in type 'ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>'.
  Overload 2 of 3, '(options: InteractionReplyOptions & { fetchReply: true; }): Promise<Message<boolean>>', gave the following error.
    Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIMessageTopLevelComponent | JSONEncodable<APIMessageTopLevelComponent> | TopLevelComponentData | ActionRowData<...>'.
      Property 'type' is missing in type 'ActionRowBuilder<AnyComponentBuilder>' but required in type 'ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>'.
  Overload 3 of 3, '(options: string | InteractionReplyOptions | MessagePayload): Promise<InteractionResponse<boolean>>', gave the following error.
    Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIMessageTopLevelComponent | JSONEncodable<APIMessageTopLevelComponent> | TopLevelComponentData | ActionRowData<...>'.
      Property 'type' is missing in type 'ActionRowBuilder<AnyComponentBuilder>' but required in type 'ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>'.
topaz bluff

That's looks like a TS error. You have to assign a generic to an ActionRow

ActionRowBuilder<ButtonBuilder>

sharp ginkgoBOT

In TypeScript the ActionRowBuilder class has a generic type parameter that specifies the type of component the action row holds:

const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
topaz bluff

Ya that

torpid marsh

Ah. Yes. That worked.

torpid marsh
stable sun

It’s basically just saying that only certain things that can go in the row is allowed for messages

Not everything that can go into a row is allowed

wary coral
stable sun

Might not even be an issue in v15 if TextInputBuilder is removed from rows (given nothing else gets added to rows and is exclusive to a specific context)

sleek epoch

somebody know why the webhook event entitlement_create doesnt fire when creating an test entitlement?

looks like it isnt implementent, but i need away to test it without subscriping to my application with discord client

i mean i can subscribe one time but i cant cancel it because of expire time

wheat gulch
 const file = modalInteraction.fields.getAttachment("suggestion_file");

ERROR: Suggestion Error: modalInteraction.fields.getAttachment is not a function

how do I fetch the attachment? djs v14.25.1

sharp ginkgoBOT
wheat gulch
tardy sable
stable sun
sharp ginkgoBOT

method Collection#at() discord.js@14.25.1
Identical to Array.at(). Returns the item at a given index, allowing for positive and negative integers. Negative integers count back from the last item in the collection.

stable sun

Although, it’s usually more common to either iterate or use the map/filter methods to handle multiple files

wheat gulch
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.

tardy sable
wheat gulch

yep

tardy sable

getStringSelectValues() returns also an array so use [0] for the first value

if you still receive the "one or more errors" place console logs and see where your code stops to debug

wheat gulch

but there is one more catch

when attachment wasnt selected, console logs that Cannot read properties of null (reading 'first')

tardy sable

can add safe chaining ?.first()

wheat gulch
tardy sable

same error message? that shouldnt happen if you added the safe chaining. be sure you saved your code

sharp ginkgoBOT

mdn Optional chaining (?.)
The optional chaining (?.) operator accesses an object's property or calls a function. If the object accessed or function called using this operator is undefined or null, the expression short circuits and evaluates to undefined instead of throwing an error.

wheat gulch

tried again didnt crash this time like bro just weird

torn orchid

TypeError: (intermediate value).setCustomId(...).setTitle(...).addLabelComponents is not a function

bleak owl

show code please

torn orchid

alright

        if (selected === "general") {
            const generalModal = new ModalBuilder()
                .setCustomId("ticket-modal")
                .setTitle("General Support")
                .addLabelComponents(
                    (label) => label.setLabel("Why are you opening this ticket?").setTextInputComponent((input) =>
                    input
                        .setCustomId("general-reason")
                        .setPlaceholder("Reasoning.")
                        .setStyle(TextInputStyle.Short)
                        .setMaxLength(4000)
                        .setRequired(true)
                    ),
                );

            await interaction.showModal(generalModal);
        }
topaz bluff

run npm ls discord.js

torn orchid

alr

figured it out, not the newest version

subtle girder
ExpectedConstraintError > s.array(T).lengthGreaterThanOrEqual()
  Invalid Array length

  Expected: expected.length >= 1

  Received:
  | []

    at Object.run (I:\VSCodefile\Discord\DogBot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1045:79)
    at I:\VSCodefile\Discord\DogBot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:67
    at Array.reduce (<anonymous>)
    at _ArrayValidator.parse (I:\VSCodefile\Discord\DogBot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:29)
    at validateComponentArray (I:\VSCodefile\Discord\DogBot\node_modules\@discordjs\builders\dist\index.js:1898:233)
    at SectionBuilder.toJSON (I:\VSCodefile\Discord\DogBot\node_modules\@discordjs\builders\dist\index.js:2532:5)
    at I:\VSCodefile\Discord\DogBot\node_modules\@discordjs\builders\dist\index.js:2237:64
    at Array.map (<anonymous>)
    at ContainerBuilder.toJSON (I:\VSCodefile\Discord\DogBot\node_modules\@discordjs\builders\dist\index.js:2237:35)
    at I:\VSCodefile\Discord\DogBot\node_modules\discord.js\src\structures\MessagePayload.js:151:46
    at Array.map (<anonymous>)
    at MessagePayload.resolveBody (I:\VSCodefile\Discord\DogBot\node_modules\discord.js\src\structures\MessagePayload.js:150:49)
    at InteractionWebhook.editMessage (I:\VSCodefile\Discord\DogBot\node_modules\discord.js\src\structures\Webhook.js:344:50)
    at ChatInputCommandInteraction.editReply (I:\VSCodefile\Discord\DogBot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:247:36)
    at Object.execute (I:\VSCodefile\Discord\DogBot\slashcmd\game\rpg\cook.js:168:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
        const item_input_string = item_needed
            .map(item => `${item.amount}${get_name_of_id(item.item)}`)
            .join("、") // 使用、作為分隔符
            .replace(/、 ([^、]*)$/, " 和 $1"); // 將最後一個、替換為 和

        const cookButton = new ButtonBuilder()
            .setCustomId(`cook|${userId}|${sessionId}`)
            .setEmoji(emoji_cooking)
            .setLabel("炒菜")
            .setStyle(ButtonStyle.Primary);

        const buttonSection = new SectionBuilder()
            .setButtonAccessory(cookButton);

        const container = new ContainerBuilder()
            .setAccentColor(container_default_color)
            .addTextDisplayComponents(
                new TextDisplayBuilder().setContent(`**${emoji_drumstick} | 成功放進平底鍋炒 ${item_input_string}**`),
                new TextDisplayBuilder().setContent(`快透過狂按按鈕來炒菜吧!`),
            )
            .addSeparatorComponents(new SeparatorBuilder().setDivider(true).setSpacing(SeparatorSpacingSize.Small))
            .addSectionComponents(buttonSection);

        await interaction.editReply({
            content: null,
            embeds: null,
            components: [container],
            flags: MessageFlags.IsComponentsV2,
        });

I just saw SectionBuilder in the error and no idea to solve

rose tangle

can't have a section with only an accessory

subtle girder

must with a text display component?

rose tangle

yes

if you only want a button, add an action row

sharp ginkgoBOT
rose tangle

a section accessory complements something else (only text displays for now), like its name implies

you can't have it by itself with nothing else

subtle girder

oh cool! thx

vale nest

.addSectionComponents(
new SectionBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder().setContent('Play automatically:\nBot rolls automatically')
)
.addButtonAccessory(
new ButtonBuilder()
.setCustomId(auto_${challengeId})
.setLabel('Death Roll')
.setStyle(ButtonStyle.Primary)
)
.addButtonAccessory(
new ButtonBuilder()
.setCustomId(decline_${challengeId})
.setLabel('Decline')
.setStyle(ButtonStyle.Danger)
)
);

I am trying to place two buttons with text display without accessory.

topaz bluff

sections cant take several accessories

you can either use a second accessory and an empty text display... or use an action row to house both buttons and not use a section at all

vale nest
sharp ginkgoBOT
subtle girder

the interaction is replied with a IsComponentsV2 flag, can I clear it when I click a button?
because I can't do await interaction.update({ content: "", embeds: [embed], components: []}) when IsComponentsV2 is enabled

marble plover

once a message is components v2, you can't undo that

you can only "upgrade" a msg to components v2

subtle girder

fine, thx:)

thin pagoda

Hi some body tell me how discord's embed timestamp is working???

wait huh??

ruby bane

scam bot, ignore it

thin pagoda

nice try buddy

Hi some body tell me how discord's embed timestamp is working???

ruby bane

are you just asking what they are or how to generate them?

thin pagoda
narrow geode

Well, that's far simpler. It sets a timestamp field in the embed and displays that timestamp to the user.

topaz bluff

oh nevermind i was mistaken... youre talking about the footer timestamp on an embed

clear garnet

setTimestamp() just converts it to a format that is eventually sent to Discord in the ISO8601 format

narrow geode
thin pagoda oh but it is updating

The client displays the timestamp in a format it sees fit. If the timestamp is the same day as when the message is viewed, it might just show the hh:ss part. Etc.

clear garnet

You pass a date representing a point in time, and Discord displays it, that's it

Same as most other date-related things on Discord I'd say

thin pagoda
ruby bane

using discord's existing timestamp feature

clear garnet

Yea, the Gist that Jeremy sent above

<t:1769234481:f> It'll give you something like this

thin pagoda
clear garnet

Depending on which style you use, sure

ruby bane

depends on the formatting style, but in most cases, yes (🐌)

thin pagoda
thin pagoda
ruby bane

if you use relative time, it would (which is R)

ruby bane

<t:1769234619:R>

thin pagoda

<t:timestamp:R> right

ruby bane

okay i was mistaken there is no Today at x format, i thought relative would eventually become that but i dont think it will

If you still want to use it though, that is the correct formatting for using relative

thin pagoda

7_pinkskull i just used Date.now and got that

clear garnet

Yea, and Date.now() provides the unix timestamp in milliseconds

Discord's formatting takes seconds

thin pagoda
clear garnet

If the date in question is not from within today or yesterday, embeds seem to use the same format as the "Short Date, Short Time" timestamp style

thin pagoda
marble plover
thin pagoda

damn, so its not just me that has invites not centered... why is discord like that 😭

narrow geode

(bumping my question since I think it got lost)
Is it possible to get two messageDelete events for the same message id? Alternatively is it possible to get messageDelete for a message that is also included in a messageDeleteBulk event?

loud quartz

Former shouldn't happen, but discord is a huge platform, and they explicitly state that as a possibility your app should handle (receiving duplicate events or receiving them out of order)

Latter shouldn't happen

orchid radish

can embeds handle svg files as images

stable sun
sharp ginkgoBOT
orchid radish
cursive hollow

Hey all. It's been a long time since I made a bot. Anyway does D.js support creating a discord bot/app that only responds to interactions from a REST api? The discord api says there's support for that but I can't find anythign in D.js guide

sharp ginkgoBOT

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.

cursive hollow

oh, cool

steel yacht

Hi,
Is it possible to edit a message to add a component without redeclaring the existing ones ?
Thanks

topaz bluff

You can use the createComponentBuilder helper function (#1370478227872551032 message) to turn the raw component data from a message back into Builders so you can modify them easier

But no. You HAVE TO redeclare the entire components array to modify them

steel yacht

Okay, can the existing components be fetched from Discord ?

topaz bluff

Yes. The interaction message contain the components array. That forum post shows how to do so

subtle girder

if I create my custom Client object withclass MyClient extends Client {...}
Is [the client property of some object has that property like interaction] my custom client object?

steel yacht

How to fix this TypeScript error ?

somber dome

what i can reslove my error

data.components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
    at handleErrors (C:\Users\shong\kick-bot\node_modules\@discordjs\rest\dist\index.js:762:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async BurstHandler.runRequest (C:\Users\shong\kick-bot\node_modules\@discordjs\rest\dist\index.js:866:23)
    at async _REST.request (C:\Users\shong\kick-bot\node_modules\@discordjs\rest\dist\index.js:1307:22)
    at async ButtonInteraction.reply (C:\Users\shong\kick-bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:193:22)
    at async Client.<anonymous> (file:///C:/Users/shong/kick-bot/dist/client.js:86:58) {
  requestBody: { files: [], json: { type: 4, data: [Object] } },
  rawError: {
    message: 'Invalid Form Body',
    code: 50035,
    errors: { data: [Object] }
  },
  code: 50035,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/interactions/1464630506665541673/aW50ZXJhY3Rpb246MTQ2NDYzMDUwNjY2NTU0MTY3Mzp0RXBpUVhUdkxLMGtxUWUwVnRBWTZ3eEJsUjR2VWM3NFFpZjc1bzBpR045UENDUUZyemNON0R6ZEs5UTYxcmdqbkhOemh4dmZIMlVtOXp1VVVXT2luYnpLTERBcVE2NG9teDdUcVlSZ2Nwbm1kUDlxaHhqUGlCdWxTRGZwYlJaWg/callback?with_response=false'
}

My Code:

  if (i.customId === "kick_moderator_add_reply") {

    const container = new ContainerBuilder()
      .setAccentColor([24, 167, 138])
      .addTextDisplayComponents(text =>
        text.setContent(
          "**نظام الردود التلقائية**\n\n" +
          "اختر العملية التي تريد تنفيذها من القائمة بالأسفل 👇"
        )
      )
      .setSpoiler(true)
      .addSeparatorComponents(separator => separator)
      .addActionRowComponents(row =>
        row.setComponents(
          new StringSelectMenuBuilder()
          
            .setCustomId("kick_reply_select")
            .setPlaceholder("اختر العملية المطلوبة")
            .addOptions(
              new StringSelectMenuOptionBuilder()
              .setLabel("إضافة رد")
              .setEmoji(":add:")
              .setValue("add_reply")
              .setDescription("إنشاء رد آلي جديد للرد تلقائياً على كلمات/عبارات محددة"),
              new StringSelectMenuOptionBuilder()
              .setLabel("تعديل رد")
              .setEmoji(":edit:")
              .setValue("edit_reply")
              .setDescription("تعديل رد تلقائي موجود وتحديث إعداداته"),
               new StringSelectMenuOptionBuilder()
              .setLabel("حذف رد")
              .setEmoji(":remove:")
              .setValue("remove_reply")
              .setDescription("حذف رد تلقائي موجود بشكل نهائي")
           )
        )
      )
      .addSeparatorComponents(separator => separator)
    return i.reply({
      content: `<@${i.user.id}>`,
      components: [container],
      flags: MessageFlags.Ephemeral
    });
  }
warm charm
topaz bluff

2 issues

  1. You don't have the IsComponentsV2 flag in your i.reply so you can't use the new Components
  2. If you choose to add that flag. You can't define anything in the content field

You don't need to ping the user outside of the container. CV2 Text Display Components will ping users mentioned in them

somber dome
warm charm
hollow plover

Hello ! Is there a way, to automaticly pin a post in a forum, et automaticly change to view to gallery ?

sharp ginkgoBOT

documentation suggestion for @hollow plover:
method ForumChannel#edit() discord.js@14.25.1
Edits the channel.


// Edit a channel
channel.edit({ name: 'new-channel' })
  .then(console.log)
  .catch(console.error);

meager meadow

Does anyone know how to find out how a user logged into a server, like an invitation link or something?

sharp ginkgoBOT

tag suggestion for @meager meadow:

Discord does not provide the invite that a member used to join through the bot API.

  • Tracking the uses of invites through the inviteCreate and guildMemberAdd events is unreliable and we recommend against it.
  • Discord has not shared any plans to make the members tab available for bots.
meager meadow

I know there is a bot called InviteLogger. How does he implement this?

shell wagon
neat nimbus
case 'Add': {
  i.showModal(
    new b.djs.ModalBuilder()
      .setCustomId('Logs-Add')
      .setTitle('Select Log Type and Channel')
      .addComponents(
        new b.djs.ActionRowBuilder().addComponents(
          new b.djs.StringSelectMenuBuilder()
            .setCustomId('Type')
            .setPlaceholder('Select the log type...')
            .addOptions([
              { label: 'Message Updates', value: 'MessageUpdate', description: 'Log when messages are edited' },
              { label: 'Message Deletions', value: 'MessageDelete', description: 'Log when messages are deleted' },
              { label: 'Channel Creation', value: 'ChannelCreate', description: 'Log when channels are created' },
              { label: 'Channel Deletion', value: 'ChannelDelete', description: 'Log when channels are deleted' },
              { label: 'Channel Updates', value: 'ChannelUpdate', description: 'Log when channels are modified' },
              { label: 'Role Creation', value: 'RoleCreate', description: 'Log when roles are created' },
              { label: 'Role Deletion', value: 'RoleDelete', description: 'Log when roles are deleted' },
              { label: 'Role Updates', value: 'RoleUpdate', description: 'Log when roles are modified' },
              { label: 'Invite Creation', value: 'InviteCreate', description: 'Log when invites are created' },
              { label: 'Invite Deletion', value: 'InviteDelete', description: 'Log when invites are deleted' }
            ])
        ),
        new b.djs.ActionRowBuilder().addComponents(
          new b.djs.ChannelSelectMenuBuilder()
            .setCustomId('Channel')
            .setPlaceholder('Select a channel for the logs')
            .setChannelTypes([b.djs.ChannelType.GuildText])
        )
      )
  );
  return;
}

how can i make use of the channel select menu builder

stable sun

Put the channel select inside of a LabelBuilder

And make sure to setLabel on the LabelBuilder

neat nimbus
new b.djs.ActionRowBuilder().addComponents(
  new b.djs.LabelBuilder()
    .setLabel('Select a channel for the logs')
    .addComponents(
      new b.djs.ChannelSelectMenuBuilder()
        .setCustomId('Channel')
        .setPlaceholder('Select a channel')
        .setChannelTypes([b.djs.ChannelType.GuildText])
    )
)
```?
stable sun

No ActionRowBuilder

ActionRowBuilder in Modals is deprecated in favor of LabelBuilder. New components (any select menus in modal) aren’t allowed to be put in rows

neat nimbus
new b.djs.ModalBuilder()
  .setCustomId('YourModalId')
  .setTitle('Select a Channel')
  .addComponents(
    new b.djs.LabelBuilder()
      .setLabel('Select a channel for the logs')
      .addComponents(
        new b.djs.ChannelSelectMenuBuilder()
          .setCustomId('Channel')
          .setPlaceholder('Select a channel')
          .setChannelTypes([b.djs.ChannelType.GuildText])
      )
  );
stable sun

Yea

neat nimbus
case 'Add': {
  i.showModal(
    new b.djs.ModalBuilder()
      .setCustomId('Logs-Add')
      .setTitle('Select Log Type and Channel')
      .addComponents(
        new b.djs.ActionRowBuilder().addComponents(
          new b.djs.StringSelectMenuBuilder()
            .setCustomId('Type')
            .setPlaceholder('Select the log type...')
            .addOptions([
              { label: 'Message Updates', value: 'MessageUpdate', description: 'Log when messages are edited' }
            ])
        ),
        new b.djs.ActionRowBuilder().addComponents(
          new b.djs.ModalBuilder()
            .setCustomId('Channel')
            .setTitle('Select a Channel')
            .addComponents(
              new b.djs.LabelBuilder()
                .setLabel('Select a channel for the logs')
                .addComponents(
                  new b.djs.ChannelSelectMenuBuilder()
                    .setCustomId('Channel')
                    .setPlaceholder('Select a channel')
                    .setChannelTypes([b.djs.ChannelType.GuildText])
                )
            )
        )
      )
  )
  return;
}

TypeError: (intermediate value).setLabel(...).addComponents is not a function

bleak owl

you reverted your code

bleak owl
neat nimbus

for both of them?

stable sun