#djs-help-v14
78874 messages · Page 52 of 79
It is
Do you want source code?
If it was, then you wouldn’t get an error after calling it
If I had to guess before looking at the code, I’d say that you are using an event handler and forgot to export the run/execute function in one of the event files
Let me get a zip
Just send the event handler file
ok
Or pastebin exists
const path = require("path")
const getAllFiles = require("../utils/getAllFiles")
module.exports = (client) => {
try {
const eventsFolders = getAllFiles(path.join(__dirname, "..", "events"), true)
for (const eventfolder of eventsFolders) {
const eventFiles = getAllFiles(eventfolder)
eventFiles.sort((a, b) => a > b);
const eventName = eventfolder.replace(/\\/g, "/").split("/").pop()
client.on(eventName, async (arg) => {
for (const eventFile of eventFiles) {
const eventFunction = require(eventFile)
await eventFunction(client, arg)
}
})
}
}catch (error) {
console.log(`Error loading event handlers: ${error}`)
}}
Crazy part is that there’s no event firing being shown in the stack trace
?
eventFunction is only executed when a client event fires. Thus, that event should be part of the stack trace
this is my index.js:
const { Client, IntentsBitField, ActivityType } = require('discord.js');
const mongoose = require("mongoose");
const eventHandler = require('./handlers/eventHandler');
require('dotenv').config();
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
IntentsBitField.Flags.GuildPresences,
IntentsBitField.Flags.DirectMessages,
]
});
(async () => {
try {
mongoose.set('strictQuery', false);
await mongoose.connect(process.env.mongodb_uri, {});
console.log("MongoDB connected");
// Event handler
eventHandler(client);
client.login(process.env.BOT_TOKEN);
} catch (error) {
console.log(`Er was een error: ${error}`);
}
})();
Log the eventName and eventFile before you call eventFunction
with console.log()?
Yea
Missing an await before client.login btw, not related to the issue tho
Guys when I receive a string select menu interaction from an ephemeral message and try to .update(...) it, it ways "Unknown Message" - is this supposed to happen?
Did you specify the message property?
Show code
interaction.update(...)
... is not very descriptive
there is nothing more to show really. 😅
There's always more to show until you have sent ur entire gh repo
interaction.update({
flags: EphemeralV2Flags, // MessageFlags.IsComponentsV2 | MessageFlags.Ephemeral
components: [new ContainerBuilder().addTextDisplayComponents((t) => t.setContent(`${LoadingEmoji()}`))],
})
I don't know why this wouldn't work
Did you dismiss the ephemeral message?
nope, I ccan send you a recording. one sec
Show the full error
Error message and stack trace
something else broke. I will get back to you asap, sorry
ah wait, it's not even reaching the point where it updates. I think the issue is somewhere else.
ah I found it
Was gonna say, Unknown Message doesn't come from interaction.update
yeah I'm editing ctx.message message before but this was guarded with an if-statement. However, I forgot, I only had the string select as a condition - because before I didn't have a second string select.
-# I'm resetting the first select menu this way
That's not an embed. It's a container
Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.
read more
I wouldn't say that
People wanted more rich customization, hence Discord came up with components v2
lol
Is it just me?
no, its half the internet 
wdym
other sites don't work either?
correct, so I assume its related
((
then can you help me with inviteCreate event 🙂
what do you need help with?
i need to find log channel
import { EmbedBuilder, Events, Guild, GuildBan, GuildMember, Invite, Role, RoleManager, TextChannel, User } from "discord.js";
import bot from "../../core/classes/Bot";
import Event from "../../core/classes/Event";
import GuildConfig from "../../core/schemas/GuildConfig";
import { useI18n } from "../../core/classes/Interaction";
export default class inviteCreate extends Event {
constructor(bot: bot) {
super(bot, {
name: Events.InviteCreate,
description: 'sadasdawd event',
once: false
})
}
async exec(invite: Invite) {
const i18n = useI18n();
const lang = await GuildConfig.findOne({ guildId: invite.guild?.id });
const guild = await this.bot.guilds.fetch();
try {
const embed = new EmbedBuilder()
.setColor('Green')
.setTimestamp() // Добавляет временную метку
.setTitle(`:True: ${i18n.twl(lang?.lang ?? "en", "logs.title")}\n**${i18n.twl(lang?.lang ?? "en", "guildrolecreate.title")}**`)
.setDescription(``)
.setThumbnail(`${invite.guild?.iconURL({ size: 1024, extension: 'jpg' })}`)
if (lang?.lang && lang?.logs?.enabled && lang?.logs?.channelId)
(await invite.guild?.channel.fetch(lang?.logs.channelId) as TextChannel)?.send({
embeds: [embed]
})
} catch (error) {
console.log(error)
}
}
}```
wdym with log channel
you mihgt wanna use channels and not channel
id in db
same
It's there in the error. An invite guild is not the same as a guild object. You'll need to get the guild from cache or fetch it
yes you need to make sure you have the full guild object, not just an InviteGuild
I'm sure there is a typeguard for it, but without docs I have no idea 
how if inviteguild isnt guild
I whipped this out
if (!invite.guild || invite.guild instanceof InviteGuild) return;``` because I'm a monster
I legit couldn't find a type guard
<InviteGuild>#fetch() this should return a promise for a full guild object
InviteGuild#fetch() discord.js@14.23.2
Fetches this guild.
it doesn't work and doesn't log anything
import { EmbedBuilder, Events, Guild, GuildBan, GuildMember, Invite, InviteGuild, Role, RoleManager, TextChannel, User } from "discord.js";
import bot from "../../core/classes/Bot";
import Event from "../../core/classes/Event";
import GuildConfig from "../../core/schemas/GuildConfig";
import { useI18n } from "../../core/classes/Interaction";
export default class inviteCreate extends Event {
constructor(bot: bot) {
super(bot, {
name: Events.InviteCreate,
description: 'sadasdawd event',
once: false
})
}
async exec(invite: Invite) {
console.log(invite)
const i18n = useI18n();
const lang = await GuildConfig.findOne({ guildId: invite.guild?.id });
if (!invite.guild || invite.guild instanceof InviteGuild) return;
try {
const embed = new EmbedBuilder()
.setColor('Green')
.setTimestamp() // Добавляет временную метку
.setTitle(`:True: ${i18n.twl(lang?.lang ?? "en", "logs.title")}\n**${i18n.twl(lang?.lang ?? "en", "inviteCreate")}**`)
.setDescription(`aa`)
.setThumbnail(`${invite.guild?.iconURL({ size: 1024, extension: 'jpg' })}`)
if (lang?.lang && lang?.logs?.enabled && lang?.logs?.channelId)
(await invite.guild?.channels.fetch(lang?.logs.channelId) as TextChannel)?.send({
embeds: [embed]
})
} catch (error) {
console.log(error)
}
}
}```
You need GuildInvites intent
TYSM
guys, i have old laptop and my pc, if i host my bot on pc, it works normally, but if i host it on laptop, bot crashes by Unknown Interaction / Missing Access
hii
Can someone help me with Railway hosting?
Probably not, no
this support is for djs, not railway
I have always used it to host bots
It gets stuck at the npm ci command, I don't understand why... I've just started programming again recently
Or do you know any other free hosting?
fake new, it's started
tag suggestion for @robust flame:
Common causes of DiscordAPIError[10062]: Unknown interaction:
- Initial response took more than 3 seconds ➞ defer the response *.
- Wrong interaction object inside a collector.
- Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance)
* Note: you cannot defer modal or autocomplete value responses
LTS (V22.20.0)
use 22.19.0 then I guess
you can also use the latest I assume
who said anything about embeds?
that wasnt a reply to you
the message they replied to was deleted
ah, ok
Hey ya'll. So, having some issues with my bot and it's reaction handling. It has worked fine before but now for some reason (i am unsure how long) it doesn't work. There are no errors. Through a lot of debugging I have deduced that the issue is that the bot does not seem to actually listen to the event. I already cache the message in a separate handler which creates / edits the message that the reactions are to be put on, and it puts the reactions onto the post just fine even when I remove all the reactions and restart the bot. (Basically, the message is cached and everything works fine except for listening to the messageReactionAdd and messageReactionRemove events.
I am using Discord.js version 14.10.2.
Here is my event (they are identical with the obvious exception of whether it is adding or removing the roles, don't mind handleReaction function checking if it is add/remove, I used to have these two events in the same file until I did my cleanup today while trying to figure out why it was no longer working.)
messageReactionRemove.js
const Discord = require("discord.js");
const { ensureSettings } = require("../utility/LoadFunctions");
module.exports = {
name: "messageReactionRemove",
run: async (bot, reaction, user) => {
const { client } = bot;
ensureSettings(client);
client.log(
"messageReactionRemove",
"reaction = " + reaction + " - user = " + user,
false,
"debug"
);
if (reaction.message.channel.id === channelId) {
handleReaction(reaction, user, false);
}
},
};
const handleReaction = (reaction, user, add) => {
if (user.id === "314077814741532674") return;
let roles = client.settings.get(guild.id, "roles");
const emoji = reaction._emoji.name;
const { guild } = reaction.message;
const roleName = roles[emojis.indexOf(emoji)];
if (!roleName) return;
const role = guild.roles.cache.find((role) => role.name === roleName);
const member = guild.members.cache.find((member) => member.id === user.id);
client.log("Event - messageReactionRemove", "role = " + role, false, "debug");
client.log(
"Event - messageReactionRemove",
"member = " + member,
false,
"debug"
);
client.log("Event - messageReactionRemove", "add = " + add, false, "debug");
if (add) {
member.roles.add(role);
//sendLog(member, role, guild, "added");
} else {
member.roles.remove(role);
//sendLog(member, role, guild, "removed");
}
};```
The logs does not work. My event handler loads the event, it shows up in my console along with all the other events which work just fine. (Attached screenshot)
After doing some digging it seemed like I was suddenly missing the Intent for the reactions, so I added it but nada. I also found that if the message isn't cached I need the partial, but my message is cached. However, I decided to add the partials just to be sure and still the events aren't being listened to / giving any response when triggered.
index.js
```js
const { Client, Collection, GatewayIntentBits, Partials } = require("discord.js");
const Enmap = require("enmap");
require("dotenv").config();
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.MessageContent,
],
partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction,
Partials.User,
],
});```
Anyone that has dealt with this before that might know what's up? I obviously expect at least my *logging* that is triggered whenever the event triggers to go through, but not even that shows up. I am assuming I am missing something very obvious, or maybe my bot is just broke.
Might not be related but there’s a massive aws outage on rn
I see.
The outage has been resolved but services are still recovering
This has been going on for longer than the past few days though. Last successful run of the event was June 30th. I just can't pinpoint when it stopped working because I only noticed this myself the other day.
try updated your discord.js to the latest version 14.23.2
Will give that a go
Shitpost somewhere else
const modal = new ModalBuilder()
.setCustomId("modal3")
.setTitle("modal (3/3)")
const label = new TextDisplayBuilder()
.setContent("Make sure that the email you enter is correct and check your junk email before making a support ticket.");
const email = new TextInputBuilder()
.setCustomId("email")
.setLabel("Email Address")
.setStyle("Short")
.setPlaceholder("email")
.setRequired(true);
modal.addComponents(
new ActionRowBuilder().addComponents(label),
new ActionRowBuilder().addComponents(email));
return modal;```
why is this returning invalid form body?
Textdisplay is a top level component in modal, it doesn't go inside action row. also use label component for textinputs, action row in modal is deprecated
i have removed it from the actionrow and it is still giving me the error
modal.addComponents(
label,
new ActionRowBuilder().addComponents(email));```
try to migrate to the new modal components in v14.23.2
is there a guide anywhere that explains how to use select menus inside of modals? having trouble figuring out where i can put a label 
so how does one use label instead, the docs arent very clear as their examples are all in json format
here is the preview guide for both of you
https://discord-js-guide-3gofz1r1u-discordjs.vercel.app/legacy/interactions/modals
thanks man
oh lord, labels are now a builder
LabelBuilder isnt recognised for me
update your discord.js version to latest
fixed thanks
so the label can only be 45 chars or less.
any way i can make that value more than 45?
no
crud...
You could add a text display if more information needs to be displayed
But I recommend rewording the question
done thanks
#rules, thanks
Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.
read more
is there any way to send image files / embeds with higher pixel densities, e.g. a 2x image that actually displays at 2x density instead of 2x size?
You can't increase the amount of pixels the screen of the person viewing that image has. I don't understand your question really
They also look completely different based on device and screen size of the one viewing it
yeah i guess i could be a problem with also the way the image is generated, too. i'm generating attachments via skia-canvas, which supports a density when generating the output buffer, but an image with density: 2 simply displays as twice as big (but still blurry) on my mbp (which is a high dpi display).
so my question is, is there some way to communicate that this is a high dpi image to discord or via discordjs, for example by tacking @2x on to the filename?
dpi is something relevant for printing. As a file that always simply means "bigger size"
a monitor displaying the image it can render it at higher dpi/ppi if it knows to do so.
No. Monitors are dumb. All they can do is display pixels. Also none of this has anything to do with djs so you're in the wrong channel
damn, who hurt you
what is the right channel? (also, are you being challenging on purpose? systems can render images at higher pixel densities if they know the image has the pixel information to do so)
For general conversations: #archive-offtopic
As I said, none of this has anything to do with djs, which is what this server and explicitly this channel is about. Now stop
alright, thanks for your time.
Does Discord.js support all components in modals yet? Or just select menus and text input?
And Text Display
Just not file upload as of v14.23.2
Which d.js version I need to update bot guild profile?
The latest one, 14.23.2
Can i use rest method in the older version?
Probably
let's say i have an incoming message
in which case will i be able to reply to it, but not to send a message to its channel ?
await message.reply(...); // fine
await message.channel.send(...); // need to check if channel is sendable first
i think for both you have to check if you can send messages in the message channel
on a type level i don't need to
i can reply without checking if channel is sendable, but not send message to the channel without checking that
that's why i'm asking, maybe i'm missing an edge case or smth
a message is always in a sendable channel
otherwise no messages could exist
i think he means if bot has permissions to send messages
Replying is just sending with a reference
you dont have to check if bot has permissions to send messages on message replies?
You do (or catch the error)
okay, here's my discordjs question: how can i pass the width and height attachment fields documented here and defined in the api types and also in the attachment class, but not in the AttachmentBuilder?
yeah then it's a bug on a type level, i can't send without
if (message.channel.isSendable())
but i can reply without this check
You can't. Those are for received attachments, not things you can set
not necessarily, you can reply to a command interaction in a group dm, which will give you a Message for your own reply, but you can't send messages to that channel
the sendable check pretty much only exists for that case, currently
yeah it'd probably be a type nightmare to manage to get the reply method out, but djs is always open to contributions if someone does it
yupp
that's fine, i was just wondering if i was missing something
thanks 
is that true for the discord api or discordjs? i haven't used the api directly, but the docs for create message point to the same type (though the description does only mention "filename and description")
discord api
the last limitation says
For the embed object, you can set every field except type (it will be rich regardless of if you try to set it), provider, video, and any height, width, or proxy_url values for images.
oh wow
Do you mean Message#reply()
yes
i'm not using embeds, but yeah i guess the same limitations might apply. which is sad because this is exactly how you might specify images you would like to be rendered at higher dpi on supported displays and downsampled otherwise.
But if it's an incoming message then the typings should already make sure it's sendable. What context is this in?
ah, missed that, then yeah where you pointed out it's the only place where it's mentioned
you don't get any device info though, so even then it wouldn't be usable for that case
smth like this
async function exec(message: Message) {
await message.reply(...); // fine
await message.channel.send(...); // can't
if(message.channel.isSendable())
await message.channel.send(...); // fine
}
there is no need for device info at the api layer, that's a problem for the clients to solve. they know the expected image width/height, the device's display dpi, and the number of pixels in the image.
yeah, that's how it works
I thought you meant that it's sad it's not exposed because otherwise you (your bot) could do that
yep, your type is wrong. Message is not just an incoming message but all ways you could get your hands on one
now I'm not sure what you meant
yes, if you could specify width/height at attachment creation time, and send a buffer with enough pixel information to render at 2x density, then 2x clients could display the image properly.
which type should i use instead of Message ?
just send the attachment with the dimensions you can and discord will figure out the optimizations and whatnot
yeah, that doesn't work, it just displays the image twice as big.
The one messageCreate event uses
okk thanks it works
i didn't noticed the difference
I'm pretty sure the issue itself still exists though, you can reply without a check, but you can't send without a check
which is inconsistent because replying is just sending
not that it can be easily solved anyways
Theoretically the only way to get your hands on a Message in a GroupDM is through interaction methods. so all other methods could be typed to return the OmitPartialGroupDMChannel helper type too... ugly but would get close
and then the methods on interactions could omit the reply method instead (with another ugly helper type if in groupDM)
whats the difference with PermissionsBitField.Flags and PermissionFlagsBits
PermissionsBitField.Flags is PermissionFlagsBits
Does discord allow you to change forms instantly let’s say i select bug report it changes all of the modal to add upload
it isn't possible
What you want to do to get that behavior is to have a select menu that then shows the respective modal
sure, defers are part of interactions, not components
Why is my command deployment so slow?
deploy.js
const { REST, Routes } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');
const fs = require('node:fs');
const commands = [];
// Grab all the command files from the commands directory you created earlier
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
}
// Construct and prepare an instance of the REST module
const rest = new REST({ version: '10' }).setToken(token);
// and deploy your commands!
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
// Routes.applicationGuildCommands(clientId, guildId),
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
Months ago it was instant
it should still be instant unless you're rate limited. have you refreshed your user client?
console.log(`Successfully reloaded ${data.length} application (/) commands.`);``` does that log show up in your console?
Yep
Then restart your client and your commands should be updated
(your app, not the bot)
Been there done that but it doesnt show up
ooh like, discord?
Yes
That wasnt needed before back then
yes it was
Discord has always cached application commands on the client so you're not constantly fetching them every time you press /
That fixed it, cheers all
o7
Naah it wasn't. With my previous command added today it also wasn't needed but it took a few minutes.
sometimes it invalidates fine and sometimes it doesn't, life is weird
a restart should always fix it
is there a way to have a role select in my modal?
yes
put it in a Label
so a label component?
yes
const row1 = new ActionRowBuilder().addComponents(roleSelection)
modal.addLabelComponents(row1)```
hi there, I was wondering if there was a way to use the new components v2 system to use value to place a role in a selectmenu with the value, just like I can with textinputs. I have tried using raw role data in a JSON, and also the role ID, as shown in the segment of code below representing my modal with the select menu and then the middle textinput. I may just be being silly as this is just really using values with a regular role select menu, but any help is greatly appreciated
.addLabelComponents(
new LabelBuilder({
label: "Role",
description: "The role assigned to this button",
component: {
type: ComponentType.RoleSelect,
custom_id: "roleSelection",
value: '1429907176444399676',
required: true
}
})
)
.addLabelComponents(
new LabelBuilder({
label: "Emoji",
description: "The emoji of the role's button",
component: {
type: ComponentType.TextInput,
style: TextInputStyle.Short,
custom_id: 'emoji',
value: '🔥',
required: true
}
})
)
Ooh boi ooh boi. I want to sent a message to another discord and a specific channel when doing a slash interact on another guild its discord. How could I do so?
apologies for the massive text wall!
tag suggestion for @distant inlet:
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
- Caches in discord.js are Collections which extend the native Map structure.
- learn more
Yeah that part I did understand. How to get the channel. But I want do it in the interaction. of another guild where my bot is added. I want to post it on my discord not theirs
I don't have the client from my index.js bot, it's using the interaction from the commands folder
And that interaction is based of the guild it's being triggered on right
@polar karma
documentation suggestion for @visual musk:
RoleSelectMenuBuilder#setDefaultRoles() builders@1.12.1
Sets default roles for this auto populated select menu.
thank you! :)
You still get the channel the same way
Interactions don’t "natively support" sending messages outside of the channel the interaction occurred by design
const channel = interaction.channels.cache.get(boGlobalLog);
channel.reply(`OK: This server is ${interaction.guild.name} and has ${interaction.guild.memberCount} members.`);
Gives me undefined (reading 'cache')
interaction.channels does in fact not exist
You have to do interaction.client to get the client
thats what I meant, so I need the client
I usually just pass the client to all my events and commands
How could I do so? I'm getting tired 😅 I pop open 1 more beer and then Im really done.
You just change your event and command handler to pass in the client
every djs object has a client property
like Chewinky said, use interaction.client
My god, I overlooked this one
I was already wondering why I needed to pass my client
Sorry all, thanks for the help! Must been the beer 😅 🍻
not entirely sure how to use this with the setup I have:
.addLabelComponents(
new LabelBuilder({
label: "Role",
description: "The role assigned to this button",
component: {
type: ComponentType.RoleSelect,
custom_id: "roleSelection",
default_roles: '1429907176444399676',
required: true,
}
})
)
I can't use .setDefaultRoles() here, there is default_values: given to me with intellisense instead of what i put as a test default_roles: which didn't work.
I know it's an array, and I've tried using an array with default_values, but to no success
if you're going to use a raw object you might as well just not use the builder
but if you're having trouble with raw data then use the builder
specifically you need default_values, which is an array of { id: string; type: SelectMenuDefaultValueType }
thank you for your comments, got it working:
default_values: [{ id: roleData.roleId || '', type: SelectMenuDefaultValueType.Role }]
https://pasteboard.co/WNeTbyZF4pUW.png what is this error for?
show code
console.log(supportRow) at line 44
question, shouldnt message.pinnable be changed to use the pinMessage permission instead of whats it now ManageMessages?
Probably yes
should i just create a issue on github to let the devs know?
yes, github is where we track issues
thanks
Yo how do i use the ComponentType.MediaGallery in a modal?
You don't
That component is not available in Modals
oh okay that makes sense than
how do you get the role ids from a select menu based on the objects (multiple roles)?
documentation suggestion for @olive lantern:
ModalSubmitFields#getSelectedRoles() discord.js@14.23.2
Gets roles component
map the roles if you only want role id
gotcha, thanks!
no, but you can get it with the asset
const asset = member.avatarDecorationData?.asset ?? user.avatarDecorationData?.asset
client.rest.cdn.avatarDecoration(asset)
but there are function on both member and user to get the decoration url
hey, im just starting off with activities and im getting this error on my bot after turning them on. im trying to make a minesweeper game activity where people use the command to launch the activity, just like /wordle
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.
that suggests that (both points):
- you're deploying on start, which isn't recommended ("after turning them on")
- on your deploy, you're using a commands.set or rest.put, and you're not passing the entry point command
yes, im using rest.put, what should i change this to? or is there docs on that that i missed
that's not part of the problem, the last part of that sentence is
yea ill read the activites guide again see if i missed something
you just need to pass the entry point command in that data
otherwise you'd be telling discord you no longer want it (delete it), which isn't possible like the error says
shouldnt it be automatically added by my handler though?
well not according to that error
yea guess not, ill see
How exactly that can be done?
How can we pass Activity command as a command for bot? I don’t understand how that progress is happening
If you've turned it on, you need to define it
And which handling method you intend to use
As a command? Does discord.js even have a type for that? I see handler property in the link
what do you mean by "type"?
the command type (4)?
if yes, that's on dtypes, and every other api resource
v10: ApplicationCommandType - PrimaryEntryPoint
read more
if you mean a special class, no, no command type has a dedicated class
they're all in the same
ApplicationCommand discord.js@14.23.2
Represents an application command.
v10: EntryPointCommandHandlerType
read more
Hey guys, I found an issue with the components v2 embed whenever there’s a role mention or a user mention, it actually triggers a notification, unlike the old embed system.
I did some research but couldn’t find any option to enable or disable these notifications.
What’s the solution for this?
You can control which entities receive notifications via the allowedMentions option. You can:
- Set a default on the client
- Set for a specific message
- Use the
repliedUserkey to disable in-line reply mentions
{ ..., allowedMentions: { parse: ["users", "roles"] } }
MessageFlags#SuppressNotifications discord.js@14.23.2
This message will not trigger push and desktop notifications
How do I set a custom status like this?
any help ?

-# And if I’m being pedantic, components v2 aren’t “embeds”, they’re just components, separate from traditional embeds
Do you know if there is currently a way in discord.js to detect if someone has a tag from my server and use that to assign them a role?
UserPrimaryGuild#identityGuildId discord.js@14.23.2
The id of the user's primary guild
can i get user locale as interaction.locale from message?
No
sad
Only interactions
Are file uploads allowed in modals now
Not in discord.js yet
Guys, is there a djs package for webhooks? I mean, for those webhooks:
https://discord.com/developers/docs/events/webhook-events
can I use the interactions package to verify the signature?
discord-interactions exports functions to verify it, it also has middleware that you can just pass to express-like api service you have running
how do i get an embed to update without the user interacting with it
so when conditions are true in the backend the embed will update
If you have the message id in which the embed is, and your bot has permissions to access the message and edit (view thr channel, and not ephemeral message). You can simply use that
Otherway is to use interaction webhooks (works for ephemeral messages), but that is valid only for 15 min. So if you are planning to wait longer than that, it is not viable
MessageManager#edit() discord.js@14.23.2
Edits a message, even if it's not cached.
thankyou
ah, nice
I use sveltekit 😅 So I'd have to make a wrapper for that
Hello, I'm using Discord.JS 14.23.2 and I'm having a problem with "AttachmentBuilder." I get this error in my console:
TypeError [ReqResourceType]: The resource must be a string, buffer, or a valid file stream.
Here's my code snippet:
const width = 600;
const height = 300;
const canvas = createCanvas(width, height);
const ctx = canvas.getContext("2d");
return canvas.toBuffer("image/png");
}
await interaction.deferReply();
const chartBuffer = await createChart();
const attachment = new AttachmentBuilder({
attachment: chartBuffer,
name: "bot-stats.png",
});
const embed = new EmbedBuilder()
.setColor(config.color)
.setFooter({ text: config.footer })
.setImage("attachment://bot-stats.png")
await interaction.editReply({
embeds: [embed],
files:[attachment],
});```
constructor of attachment builder is as follows ref: GitHub
constructor(attachment, data)
for your case
const attachment = new AttachmentBuilder(
chartBuffer,
{
name: "bot-stats.png",
});
I've already tried this solution, but this time I get this error:
TypeError: Cannot read properties of null (reading 'byteLength')
what type does toBuffer return? this seems to be an issue with the object returned by it
This command:
console.log(chartBuffer, Buffer.isBuffer(chartBuffer));
Returns this:
<Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 02 58 00 00 01 2c 08 06 00 00 00 1f 3d cd 96 00 00 00 06 62 4b 47 44 00 ff 00 ff 00 ff a0 bd a7 ... 63836 more bytes> true
could you share your full code(file in question) and error(with stack trace)
Can I send you everything in a private message?
Uninstall undici if have it installed separately
i can do a collector.on(
anotherCollector.on()) right? im trying to think the best way to handle a paginator collectors but still needs to use a purchase system colelctor as each page refreshes the collector
I don't have really "undici" but I have cheerio, my complete error :
https://pastebin.com/uyBG1vyn
could you run npm ls
├── @eslint/js@9.38.0
├── axios@1.12.2
├── canvas@3.2.0
├── chart.js@4.5.1
├── cheerio@1.1.2
├── compression@1.8.1
├── cookie-parser@1.4.7
├── discord.js@14.23.2
├── dotenv@17.2.3
├── eslint@9.38.0
├── express@5.1.0
├── globals@16.4.0
├── luxon@3.7.2
├── moment@2.30.1
├── ms@2.1.3
├── node-cron@4.2.1
├── pg@8.16.3
├── sharp@0.34.4
└── uuid@13.0.0```
So the error is coming from cheerio, not attachment builder or when sending the attachment. Not really d.js issue then
That's not valid, on method takes event name as first param and then callback. What i do in this setiuation is use promisified collector in a function and recursively call itself for going to next step
The only way I can fix this is by removing cheerio?
Or investigate why you are getting that error and fix it. But that wouldn't be related to d.js
You can try #1081585952654360687
i just realized i could possibly chain
as i have, i could add another else if (purchase id logic checker){stuff}
paginatorCollector.on('collect', async i => {
if (i.customId === 'next_page') {
currentPage++;
} else if (i.customId === 'prev_page') {
currentPage--;
}
it shouldnt effect the page changin which was my worry to start with
Fyi, two collectors csn run independently side by side. If you create it inside another collector, every time that collect event is fired, you'd be creating a duplicate listener
oh
documentation suggestion for @toxic moat:
ModalBuilder#addLabelComponents() builders@1.12.1
Adds label components to this modal.
a useful site https://modal.builders/
show your code
just move it up
no etas, hopefully soon 🤷
*hopefully quicker than modals took
no?
they're talking about an html transcripts library?
looks like the context is cuz of a package that converts messages to html and containers are new so they dont display there
that's the context
or are you asking whether that library bugs with containers?
if so, according to that convo yeah
though it'd be better to ask the author instead
the discord html transcript package got support for component v2 but the dev isnt active so isnt properly released there
whens v15 any eta?
no eta
ok let me crash out again
why you want v15?
wanna see new stuff
there is no new stuff
discord releases the stuff, djs adapts
why are u always negative
negative? i am simply replying
ok sir
all the stuff you would have in v15 is what you alreayd have in v14, bearing modal file uploads but that'll come to v14 too
i finally made it complete and thanks for informing
I'm working on a bot that can store deleted messages
for the attachments, should I use the url (cdn.discordapp.com) or the proxy url (media.discordapp.net) ?
store? you shouldn't do that. the messages are deleted and should stay that way
fair
"bugging" in what way?
Yes. That code is indeed buggy. And why is it written like you pay per character
one character is one byte. surely you're not running it on 8086
Am i doing something wrong the channel ids dont seem to match?
Copying the channel id using a discord client:
"Channel": 666323496741371914
Channel id from using the following code using a slashcommand:
const data = new SlashCommandBuilder()
.setName('stickyadd')
.setDescription('Add a sticky message to a channel')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
.addChannelOption((option) =>
option
.setName('channelx')
.setDescription('Select a chat to send the message in.')
.setRequired(true)
).addStringOption((option) =>
option
.setName('text')
.setDescription('What text should be stickied?')
.setRequired(true))
const stickyadd: SlashCommand = {
category: "moderation",
data,
async execute(interaction) {
const { options } = interaction;
const channelToSend = options.getChannel("channelx")
const text = options.getString("text")
if (!channelToSend || !text) return interaction.reply("Something went wrong")
const actualChannel = interaction.guild?.channels.cache.get(channelToSend.id)
console.log(channelToSend?.id) // 666323496741371900
console.log(actualChannel?.id) // 666323496741371900
}
}
Returns the following:
"Channel": 666323496741371900
ids are not numbers
what your'e seeing is precisely why
ah
- Discord ids follow the snowflake format: learn more
- Discord ids must be represented as strings as they are larger than
Number.MAX_SAFE_INTEGER, the largest integer that can be represented in JavaScript
- client.guilds.cache.get(123456789012345678)
+ client.guilds.cache.get("123456789012345678")
Thanks ❤️
Hi. Did dicord had any commands changes for public bots? About a month ago commands stopped working on my public bot. It still works in the pivate one though
No not that I'm aware of
define "stopped working"
no slash commands are created on the servers. old text parcing and responding works correctly
Are you deplying commands per guild or globally?
globally
are you getting any logs from you hosting provider that indicate an error?
does discord.js already support the new modals features?
I have code that I run on a release public bot and on a tester private one.
The difference as far as i see is only that flag.
Private bot has slash commands working and private is not. No logs errors.
yes, minus file uploads #announcements
so good, thank you
How does that public bot deploy its commands?
according to the guide
await rest.put(Routes.applicationCommands(config.credentials.applicationId), { body: commands })
.then(() => console.log('Successfully created all application commands.'))
.catch(console.error);```
Did you run it for both bots?
it runs successfully on the private bot and gives nothing on public
What shows up in the Discord app?
if i have a modal with a stringselectmenu, how can i get the selected value using discordjs if the user can only select one value since the method on interaction.fields returns an array of strings?
Can you add rest.on('rateLimited', console.log) before that put call?
<array>[0]
This is just basic js
nothing to be honest
I'm modifying call atm to applicationGuildCommands, then i'll try rateLimited
for two guilds out of four it takes a loooong time to recreate commands
but it works
Hi!
Can we change the status of a voice channel in the current version of djs?
what does it do?
that is not documented by discord, so no
sadly, thx
tnx for the help, everybody
Why does it delete and create over and over? That's your issue
You should only deploy once. And then leave it untouched until you actually change something about your commands
it is designed to recreate commands on startup as restart occurs rarely.
A single put call would do that. Deleting is just wrong there
hm. I see, tnx
changed back to the original global commands and removed deleting. all works. thanks
if i use this to create a thread, can i later use thread.send() ?
const thread = await rest.post(Routes.threads(config.feeds.macrumors.forum), {
body: {
// ...
}
})
like will the djs methods work there too? id assume so but just wanted to check
No. rest gives you the raw object that Discord returns
ah so i would need to also use rest to send the message inside the threa
Yes
thank you 👍
Why don't you use djs methods to create the thread in the first place?
no client is available in the context
which is?
Then djs won't be available anywhere you pass that thread to either
Is there a way to somehow patch discord.js and like publish said patch?
*without cloning the entire repo and whatnot and having to publish some other package to do so
I just want to patch discord.js to send a user agent in the WS
We won't support TOS violations
I am not self botting
I didn't say you are
What else would be a TOS violation?
What do you want a custom user agent in the ws for?
trying to connect discord.js to not discord, and the server errors without the user agent
I've manually edited it and it works, I just want to be able to somehow make that easier for others
This channel is for support of djs which - as the name suggests - is for usage with discord. So again, we won't help with that
const [Userid] = interaction.fields.getUserSelectValues("king")
``` is this how it should be?
or this
const [Userid] = interaction.fields.getSelectedUsers("king");
documentation suggestion for @brittle current:
ModalSubmitFields#getSelectedUsers() discord.js@14.23.2
Gets users component
but it depens on what selectmenu you are using
user select
than the link method
thx
geting undefined
if (interaction.isModalSubmit() && interaction.customId === "alert") {
const [type] = interaction.fields.getStringSelectValues("typ");
const Userid = interaction.fields.getSelectedUsers("king");
const member = await interaction.guild.members.fetch(Userid);
let typ;
switch (type) {
case "1":
typ = "🚨 10 - 32 Zásahovky";
break;
case "2":
typ = "🛒 10 - 68";
break;
case "3":
typ = "🔫 Aktivní střelec";
break;
case "4":
typ = "🥷 Organizovaný zločin";
break;
case "5":
typ = "🏦 Hlavní banka";
break;
default:
typ = "Nespecifikováno";
}
// === Logika alarmu ===
const joinedUsers = [];
const alarmText = `
🚨 **POHOTOVOST JEDNOTEK SWEB a SWAT!**
Došlo k **narušení pořádku ve městě**.
Všechny jednotky se musí **okamžitě dostavit do města** a zajistit oblast.
**Instrukce:**
- Vybavte se taktickou výstrojí.
- Vyčkejte na rozkazy velitele zásahu.
**Velitel zásahu:** ${member.displayName}
`;
in member
2025-10-21T20:24:28.326850298Z at Object.execute (/home/node/events/interactionCreate.js:139:49)
2025-10-21T20:24:28.326857372Z at process.processTicksAndRejections (node:internal/process/task_queues:105:5)```
Userid is an array
they can choose only one user
so then you need brackets like [type]
did
or on the next line do Userids[0] also it is a user onbject not ids
- it's a
Collectionnot an array - I'd also suggest using
getSelectedMembersinstead and skip fetching them
ohhh
oh, that is right string select is an array all others are collections
const user = Userid[0]
``` this?
or im dumb
nope thats how you get first value in array
I think this is right
const member = interaction.fields.getSelectedMembers("king").frist();
is .members a thing? i think its just getSelectedMembers(id).first() enough
your right, misread the typing on the docs. fixed it
2025-10-21T20:37:00.380461045Z at Object.execute (/home/node/events/interactionCreate.js:49:77)
2025-10-21T20:37:00.380468579Z at Client.<anonymous> (/home/node/handlers/eventHandler.js:11:54)
2025-10-21T20:37:00.380474981Z at Client.emit (node:events:519:28)
2025-10-21T20:37:00.380480672Z at InteractionCreateAction.handle (/home/node/node_modules/discord.js/src/client/actions/InteractionCreate.js:101:12)
2025-10-21T20:37:00.380486864Z at module.exports [as INTERACTION_CREATE] (/home/node/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
2025-10-21T20:37:00.380493065Z at WebSocketManager.handlePacket (/home/node/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31)
2025-10-21T20:37:00.380499017Z at WebSocketManager.<anonymous> (/home/node/node_modules/discord.js/src/client/websocket/WebSocketManager.js:236:12)
2025-10-21T20:37:00.380505198Z at WebSocketManager.emit (/home/node/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)
2025-10-21T20:37:00.380511290Z at WebSocketShard.<anonymous> (/home/node/node_modules/@discordjs/ws/dist/index.js:1190:51)
2025-10-21T20:37:00.380517401Z at WebSocketShard.emit (/home/node/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)```
tip, add safe chaining in case user is not a member
still error
show your code now
2025-10-21T20:38:34.684495186Z at Object.execute (/home/node/events/interactionCreate.js:138:49)
2025-10-21T20:38:34.684498503Z at Client.<anonymous> (/home/node/handlers/eventHandler.js:11:54)
2025-10-21T20:38:34.684501298Z at Client.emit (node:events:519:28)
2025-10-21T20:38:34.684504013Z at InteractionCreateAction.handle (/home/node/node_modules/discord.js/src/client/actions/InteractionCreate.js:101:12)
2025-10-21T20:38:34.684507229Z at module.exports [as INTERACTION_CREATE] (/home/node/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
2025-10-21T20:38:34.684510786Z at WebSocketManager.handlePacket (/home/node/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31)
2025-10-21T20:38:34.684513852Z at WebSocketManager.<anonymous> (/home/node/node_modules/discord.js/src/client/websocket/WebSocketManager.js:236:12)
2025-10-21T20:38:34.684516797Z at WebSocketManager.emit (/home/node/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)
2025-10-21T20:38:34.684519482Z at WebSocketShard.<anonymous> (/home/node/node_modules/@discordjs/ws/dist/index.js:1190:51)
2025-10-21T20:38:34.684522298Z at WebSocketShard.emit (/home/node/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)```
tag suggestion for @brittle current:
ReferenceError: "x" is not defined: learn moreTypeError: Cannot read properties of undefined/null (reading "x"): learn more
if (interaction.isModalSubmit() && interaction.customId === "alert") {
const [type] = interaction.fields.getStringSelectValues("typ");
const member = interaction.fields.getSelectedMembers("king").first();
let typ;
switch (type) {
case "1":
typ = "🚨 10 - 32 Zásahovky";
break;
case "2":
typ = "🛒 10 - 68";
break;
case "3":
typ = "🔫 Aktivní střelec";
break;
case "4":
typ = "🥷 Organizovaný zločin";
break;
case "5":
typ = "🏦 Hlavní banka";
break;
default:
typ = "Nespecifikováno";
}
// === Logika alarmu ===
const joinedUsers = [];
const alarmText = `
🚨 **POHOTOVOST JEDNOTEK SWEB a SWAT!**
Došlo k **narušení pořádku ve městě**.
Všechny jednotky se musí **okamžitě dostavit do města** a zajistit oblast.
**Instrukce:**
- Vybavte se taktickou výstrojí.
- Vyčkejte na rozkazy velitele zásahu.
**Velitel zásahu:** ${member.displayName}
`;
dont think the error is there cuz nothing is named users there
where do you uses users? it is not in this code snippet
nowhere
Whats line 138 of interactionCreate.js?
also i dont think putting your const inside an array is a thing? const [type] unless im wrong
if it isnt it wont work
It is, that's destructuring the array
found it
oh okay learned something new
works now
problem was in allowedMenitons
documentation suggestion for @tardy sable:
Destructuring
The destructuring syntax is a JavaScript syntax that makes it possible to unpack values from arrays, or properties from objects, into distinct variables. It can be used in locations that receive data (such as the left-hand side of an assignment or anywhere that creates new identifier bindings).
can someone give me the docs to this?
Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.
read more
APITextDisplayComponent discord.js@14.23.2
A Text Display is a top-level content component that allows you to add text to your message formatted with markdown and mention users and roles. This is similar to the content field of a message, but allows you to add multiple text components, controlling the layout of your message.Text Displays are only available in messages.
was searching for this
is the /wordle activity bot's features exclusive to that bot (like discord partener feature), or is anyone able to do the same thing with their own bot?
what i mean by this is
- the authorization / however the bot keeps track of progress on the activity
- message updates and stuff
if so, is there any examples somewhere where i can see a example of how this is done? the docs for acitives have you just join a vc and launch it and theres no connection/auth or anything so im not sure what to do
djs doesn't support activities, at most only the entry point command
so there's no djs docs about that
ah ok that makes sense, so if i wanted to fully utilize these features i would have to do the requests myself?
maybe there's another library, no idea
alright, thanks. are people working on / is this a expected feature at least?
no, it's a very different workflow
it's the same thing like with oauth
as in, it's very different and not something the library would add
yea ok i see what you mean now, it would all have to be done on server and stuff i presume
are there any examples that you know of which contain a bunch of code/exmaples of a activity i could check out?
i searched for some time for the wordle / mainstream ones but couldnt find any src
never checked activities ¯_(ツ)_/¯
ask in ddevs
ok, thank you
i need some intent or anything to receive the guildAuditLogEntryCreate event?
i will combine guildAuditLogEntryCreate + messageDelete to make a feature, but i receive only messageDelete for now
tag suggestion for @zealous bison:
- Websocket intents limit events and decrease memory usage: learn more
- See what intents you need here
GUILD_AUDIT_LOG_ENTRY_CREATE is under GUILD_MODERATION
so that'd be the GuildModeration intent
it works now, thank you amgelo 
how can i launch a activity where it has the initial message? i tried this but that doesnt work and jsut results in the message being unknown and interaction failing
launchActivity is also an initial response, so you need to do followUp there
ah ok, thank you
wait but how would i ensure i get the full 15 mins for the interaction to recive a update from the activity once its done
documentation suggestion for @wintry laurel:
Window: setTimeout() method
The setTimeout() method of the Window interface sets a timer which executes a function or specified piece of code once the timer expires.
oh right, idk why i thouyght i needed defer reply 😭
It better to not wait exactly 15 min, since that's the interaction token lifespan
Perhaps 12-13
oh ok
how do i change the gateway and api url?
new Client({ rest: { api: "…" }})
does this also change gateway?
Gateway is fetched from Discord
Specifically from the /gateway/bot endpoint
yes i want to change that, is that possible?
No
can i not edit the discord.js package
It’s open source
Feel free to fork it and install it
You can’t change the ws url non-invasively (using public methods, config, etc)
ok, that's fine
do you know where it is, so that i can edit it
Sure it is. If you change the rest endpoint it fetches from to one you control then the response is yours to control too
thanks
Nothing to edit in there for it to work
what do you mean, I don't edit this one?
No. Your REST endpoint just needs to respond with the gateway URL you want to use
ok got it
Is it already possible to access a users server tag? In the docs there is some content for "guild tag"
documentation suggestion for @thick nymph:
User#primaryGuild discord.js@14.23.2
The primary guild of the user
hey so im trying to make a command usable in user dms but i dont understand how
Contexts
By default, globally-deployed commands are also available for use in DMs. You can pass in InteractionContextType to the setContexts method of the builder to restrict the command to only be available in guilds or DMs. It doesn't make much sense for your ban command to be available in DMs, so you can add setContexts(InteractionContextType.Guild) to the builder so that it is only available in guilds: And that's all you need to know on slash command permissions and contexts!
read more
@patent dune ^
uh
i have no clue what the builder is
this guide should everything you need, but as it says: your global commands should already work in user DMs
(if your app is a user-app)
wait so my slash commands are being registered with the rest api like they are in the example, is that not how i should be doing them?
you should, but is your app a user installed app or a guild installed app
its user installed
doesn't work in dms tho, unless its with the bot
set integration type to user
set context to private channel
.setContexts() can take an array as well if you want the command visible in both guilds, bot dm and other user dms
although I thought that was default if you didn’t specify anything
alright sick, so i put a new SlashCommandBuilder into a const, what do i do with that const to get it registered
nvm, figured it out, thanks!
Can I know message executor devices
no, the closest you can get is their language preference for the app
But wasn’t it possible before to get user websocket devices
Presence#clientStatus discord.js@14.23.2
The devices this presence is on
member.presence.clientStatus, keep in mind that presence may be null if not cached/fetched
I'm aware
does anyone know why member.presence is printing out null even with the Presence Intent enabled and GatewayIntentBits.GuildPresences being on?
Because member is offline and you never force fetched their presence
They are online as am trying it on myself
Show your client constructor
This one I guess? or
You sweep all users...
So why do you expect your member (which does contain a user) to be completely cached with presence
Ahh well well that answers the question thanks lol
is addlabel depracted
in modals
Nothing of modals is deprecated
Nevermind I didn't see that action rows were removed as a "modal component" in the docs
it says it is
its all good now
if it's marked as deprecated, it would tell you what to use instead
I mean, if it says it was...why did you ask then?
yes because now there is a label component and a LabelBuilder
if you hover over setLabel then it will tell you that as well
just says this Sets the label for this text input.
@param label — The label to use
@deprecated — Use a label builder to create a label (and optionally a description) instead.
like i havent used label buidler beforer
You put them in between the modal and the interactive component
ModalBuilder#addLabelComponents() builders@1.12.1
Adds label components to this modal.
great!
Try now?
This should be fixed!
I'm trying to upload the banner of my bot it's a gif but it shows this
your gif has transparence not really a djs issue
do I need GuildPresences intent for member.presence
yes, the api docs list which intents enable which events/data
need help it falls to if (!difficulty || !partner)
if (interaction.isModalSubmit() && interaction.customId === "heist") {
const difficulty = interaction.fields.getStringSelectMenuValue
? interaction.fields.getStringSelectMenuValue("difficulty").first()
: null; // fallback, pokud by nefungovalo
const partner = interaction.fields.getSelectedMembers
? interaction.fields.getSelectedMembers("partner").first()
: null;
if (!difficulty || !partner) {
return interaction.reply({ content: "❌ Musíš vybrat obtížnost a partnera.", flags: 64 });
}
oh im dumb
i see it now
getStringSelectValues not getStringSelectMenuValue
also it returns a string array not collection
ModalSubmitFields#getStringSelectValues() discord.js@14.23.2
Gets the values of a string select component given a custom id
yea i saw it thx
what are the cons of passing Partials to the client?
they only do what they're designed for, allow uncached objects to be emitted
whether that's a con depends on your case
uh ok thx
if any of your code assumes information exists and you aren't handling situations where it doesn't...then that's a con
<@&839912195994812420>
Hello! Does anyone know how to disable some commands in guilds where the bot isn't here?
Cool story bro
For your own bot? Set integration types of that command to GuildInstall only, not UserInstall
Supplying only repliedUser to allowedMentions always results in disabling all other mention types, is this intended? It is quite annoying passing the array of mentions to parse each time when only the replied user mention should get disabled. I'd expect it sets unspecified properties to undefined rather than an empty array
djs doesn't set empty arrays as default
maybe you have it like that on your client constructor?
is there a event for when a client closes my bots activity? or a way to know when the activity launched by .launchActivity() ends?
Double checked this and the default value is an empty object, but as soon as repliedUser is provided as single property all other mentions get disabled without supplying parse
which i would believe is discord's behavior
Hey with the new discord age restrictions is it possible to get the users are verified over 18
that information is not available to the API
Ahh ok got it
I'm struggling to understand what I'm doing wrong here. I used modal.builders to construct the modal itself.
const modal = new ModalBuilder()
.setTitle('Report Message')
.setCustomId(`message.report-${interaction.targetId}`)
.addTextDisplayComponents(
new TextDisplayBuilder()
.setContent(`**${quotedAuthor}:** ${quotedContent}`)
)
.addLabelComponents(
new LabelBuilder()
.setLabel(`What's wrong with this content?`)
.setStringSelectMenuComponent(
new StringSelectMenuBuilder()
.setCustomId('b24a4209fe9541b2862d96f64375ddf4')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Spam')
.setValue('76b41a846d5d488ba60fb6e05d6d79ed'),
new StringSelectMenuOptionBuilder()
.setLabel('Harassment ')
.setValue('2361676c89794225af53e0327fd7bba0'),
new StringSelectMenuOptionBuilder()
.setLabel('Hate Speech')
.setValue('b46097b2a90a40c584ebb59496ef7c2d'),
new StringSelectMenuOptionBuilder()
.setLabel('Adult Content')
.setValue('cd48da04184c473b9629d633377d6a97'),
new StringSelectMenuOptionBuilder()
.setLabel('Something Else')
.setValue('423d1ce95b3e4a1580abc71fc583473e')
)
)
)
.addLabelComponents(
new LabelBuilder()
.setLabel('Additional Information (optional)')
.setTextInputComponent(
new TextInputBuilder()
.setCustomId('ec3b4bfb75de40d6a5862bf99f8ea95e')
.setStyle(Discord.TextInputStyle.Paragraph)
.setMaxLength(3000)
.setRequired(false)
)
)
.addTextDisplayComponents(
new TextDisplayBuilder()
.setContent(
"By submitting this report, I agree that it's in good faith and true to the best of my knowledge."
)
)
.addLabelComponents(
new LabelBuilder()
.setLabel('Acknowledgement')
.setStringSelectMenuComponent(
new StringSelectMenuBuilder()
.setCustomId('a59240d2b2c1453c8e1081b54e6c6917')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('I agree')
.setValue('8030a917752744b3b83bca271992b6c6')
.setDefault(true)
)
)
);
return interaction.showModal(modal);
}
D.js v14.19.3
TypeError: (intermediate value).setTitle(...).setCustomId(...).addTextDisplayComponents is not a function
update your djs
label builder was added in v14.23...youre on v14.19
Thank you so much
Strangely i'm getting the same exact error having upgraded to 14.23.2, but i'll keep troubleshooting
Run npm why @discordjs/builders
node_modules/@discordjs/builders
@discordjs/builders@"^1.12.1" from discord.js@14.23.2
node_modules/discord.js
discord.js@"^14.23.2" from the root project```
oh lord i see lol
Hi, does this still work?
undocumented features can change at any time. i do not suggest using it
I understand this, but it will not break anything if it suddenly stops working, just cosmetics. I've seen other bots like cloudy music bot able to use this and would like to test it as well.
we do not support undocumented features
It’s prob faster if you test it out yourself than wait for a response from him tbh
The builders version looks fine. You found the issue?
Sadly not, I really don't want to be a burden though lol
I just wish the error wasn't so vague
I mean, it’s pretty straightforward
Ur sure the error points to the first addTextDisplayComponents?
Only ppl that don’t listen are a waste of time helping btw
Yes,
const modal = new Discord.ModalBuilder()
.setTitle('Report Message')
.setCustomId(`message.report-${interaction.targetId}`)
.addTextDisplayComponents( //errors here
new Discord.TextDisplayBuilder()
.setContent(`**${quotedAuthor}:** ${quotedContent}`)
)
const Discord = require('discord.js');
if this wasn't clear
Done, it works 😄
why doesnt v14.23.2 have the new component type enums? just getting back into js not up to speed with 14.14+
Which ones?
Im not aware of any its missing
Could you just make a test file that makes a modal builder with those 3 method calls and run that?
Sure
this is all i got rn. but when i use
import { ComponentType } from 'discord-api-types/v10';
i got access to the new ones
what could be the reason of seeing duplicate commands?
tag suggestion for @normal flare:
If you have duplicate commands on your server, you registered both global and guild commands.
You can remove the duplicates by resetting either the global or guild commands
- Resetting global commands:
rest.put(Routes.applicationCommands(clientId), { body: [] }) - Resetting guild commands:
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
that was fast thanks 👍
does it make sense to have global commands when I intend to use the bot just in 1 server?
doesnt really matter...but it can be nice to prevent commands from being used in dms
or is the global commands meant for bots that are used in multiple servers?
Yea
You can use either or both (ideally not for the same commands)
Chewinky, serious question. Could this be because my node v is out of date?
No
Ok
for my single server bot, i use guild commands for administrative commands in our mod only server (so technically its a 2 server bot)
Missing methods that should be there is usually caused by outdated package version installed, not restarting bot, or editing files in node_modules
Did you try the test file yet?
yeah I had this
if (guildId) {
await rest.put(Routes.applicationGuildCommands(config.discord.clientId, guildId), {
body: commandsData,
});
} else {
await rest.put(Routes.applicationCommands(config.discord.clientId), {
body: commandsData,
});
}```
`guildId` is coming from `env` which I added later, but now is required anyways
Ok so it's working when I run the bot locally, but when I run it on a VPS it fails.
Both are on v14.23.2
Is it installing dependencies properly?
I believe so, it didn't complain about anything when I installed the newer version of d.js on the VPS
Check the builders version on the VPS
Both VPS and local mirror this
have you tried nuking node_modules and reinstalling just in case
I will certainly try that now
Which video did y'all watch to learn how to program a bot
None tbh
I actually read an idiots guide one before I started reading the official one
That was back in v11.3 era tho
No dice. This bot is cursed, and I need to go to bed 😭
Thanks yall for the help!
Make sure the bot is actually being stopped and restarted
We're using PM2, i've pm2 restarted and pm2 stop/started several times now with no luck
What will be best to use for making a Queue system . when a user click a button he being added to that button queue . BullMQ or any better ?
queue for what?
after nuking node modules you need to do npm install inside the bot folder first before using pm2 again
Oh my god thank you so much
No problem, hope it worked!
It did!
Perfect!
is it possible to make it so that you can only pick the options given to you by autoComplete and not just submit random things
No, the closest behavior to that which I can think of would be to validate the received option after the user sends the command to ensure it was one of the valid autocomplete options
aw okay, thanks
Or use choices, if those values you want to autocomplete are static
it is static but there's like hundreds of them 😅
I've missed a bit of a trick here. What's the new deal with .setLabel not being a thing anymore on TextInputBuilder? Something about using a LabelBuilder. Do I need to create a modal, attach an action row that has a LabelBuilder that has some kind of String Input Builder?
LabelBuilder discord.js@14.23.2
A builder that creates API-compatible JSON data for labels.
yes, you add a component to that label using one of the various setXComponent function
So does that mean role/string select menus are now supported in modals too?
You replace the actionrow with a label. Not use both
oh damnnn that's nice - thanks!
Guy's can we set the secondary button inside the embed msg?
If you mean the cancel&submit? Then you can’t change them
Oh I read wrong ignore me
not inside of an embed, no
oh ok
i mean i want like this
i want the buttons to be under the msg
the buttons ( Support Server & Invite Rythm )
then you need to use components v2
aka a container
Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.
read more
Just a quick question, What does the "required" boolean do when getting an Interaciton Option?
Example here; interaction.options.getString("something", true); (the true here)
i think it will throw error when it isnt found
Yup
Interesting to know
When that could be useful?
To make sure your code doesn't accidentally try to respond to another command than it's intended to
Or something in my use case, a required input before another required input depending on the one before it (auto completions)
if I understood correctly, v2 components work when u do channel.send and not interaction.reply?
v2 components work in both cases, if the flag is provided.
not when deferring interaction responses.
what do we mean here?
// won't work
await interaction.deferReply({flags: MessageFlags.V2}) (the actual flag)
// will work?
await interaction.deferReply()
...
await interaction.editReply({flags: MessageFlags.v2})
Question i think i can answer for my self if i send a v2 i can not edit it to a embed
No
It will have to be another v2
yes
Thanks for answering
Yes. Once v2 you can't go back (on a message)
I kinda of figured as much
thanks 👍
I cant seem to find it but anyone know the character limit for custom activity type state ?
I use it in typescript. When I know an option is going to be required, I'll mark it as true so I don't have to test if it's there for type guard
Does a bot need manage messages to delete its own message?
no that would be weird
I don't know you're going to need to test the Discord documentation does not specify a Max character length
https://discord.com/developers/docs/events/gateway-events#activity-object-activity-structure
can we have a markdown table in an embed?
here I would like to display the browsers in a table if that's possible
Currently Discord doesn't support tables in markdown
I see, thanks
how does djs handle message channel send ratelimits, does it just add a timeout for next message so theres no ratelimit?
From my experience you can spam messages then the bot gets rate limited after a few minutes (one of my commands kept replying to its self a few years ago) it got so bad that discord reset the token at one point
when i want to edit a response to a command interaction, must i call editReply() on the interaction or can i also edit the message by edit() as retrieved by response.resource.message?
If that happened then you didn't use a single djs instance. DJs handles ratelimits for you in the sense that it queues requests that would otherwise hit a ratelimit if sent
If you have a bot user with permissions in that channel you can do both. If not then only the interaction webhook can, hence editReply
Yeah i will just assume its same as what a user can have ( i guess its 128 for user)
it doest seem to throw error either so thats for the info anyways
Suggestion for what?
This server, the library discord.js, the discord API or discord in general?
My friend wanted to give a suggestion for a new button idea so was asking
Idk why he's banned here
We are not Discord, just some nerds who develop Discord bots!
- /report appeals and age updates
- /howtoreport reports (harassment/hacking/spam/abuse)
- /support anything Discord related
- /billing payment/nitro
- /feedback feedback/feature requests
How can my friend appeal to join this server He doesn't know why he got banned and by /report there is option to report someone not appeal
move to #archive-offtopic for further discussion, this channel is only for help with djs itself
is there somewhere i can find out how djs handles ratelimits?
it sets a timeout based on the response from the api, then it tries the request again after the timeout is done
that's the default behavior at least, you can set different behavior in the client options
how to add those lines? those arent emoji
those are separators
what are those?
the lines you see
how to write them?
Separator
A Separator is a layout component that adds vertical padding and optional visual division between components. You can select the amount of padding used for the Separator component (small or large) as well as whether a visual divider should be displayed (defaults to true). You can use the SeparatorBuilder class to easily create a Separator component. When a Separator component is used without any non-Separator components in the message payload, the message will not have any visible content.
read more
wow since when? you can add button and menu in embeds
containers, not embeds
No
nope thats a container
so this isnt embed too?
no
its a container
in setAccentColor can I pass "Green" like embeds or no?
yes
ContainerBuilder#setAccentColor() discord.js@14.23.2
Sets the accent color of this container.
well not really a string color
but you can set a color like embeds
no but you can use resolveColor('Green)
resolveColor discord.js@14.23.2
Resolves a ColorResolvable into a color number.
ok tnx
is it possible to update a voice channel status without using rest, yet?
its possible to set it, but it's not documented
containers are available in ^14.22.1 ?
any ideas on how i would do that?
since its not documented, we do not support it
alr
they are in ^14.19.0
tnx
but you should be using the most up to date version
Whats this error for?
ExpectedConstraintError > s.array(T).lengthGreaterThanOrEqual()
Invalid Array length
Expected: expected.length >= 1
Received:
| []
at Object.run (/root/GardenBoi/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1045:79)
at /root/GardenBoi/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:67
at Array.reduce (<anonymous>)
at _ArrayValidator.parse (/root/GardenBoi/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:29)
at validateComponentArray (/root/GardenBoi/node_modules/@discordjs/builders/dist/index.js:1767:233)
at SectionBuilder.toJSON (/root/GardenBoi/node_modules/@discordjs/builders/dist/index.js:2400:5)
at /root/GardenBoi/node_modules/@discordjs/builders/dist/index.js:2105:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (/root/GardenBoi/node_modules/@discordjs/builders/dist/index.js:2105:35)
at /root/GardenBoi/node_modules/discord.js/src/structures/MessagePayload.js:151:46
I tried to add button to container and I got this error
Section components is prob empty
container.addSectionComponents((section) =>
section.setButtonAccessory((button) =>
button.setURL("https://www.fortnite.com/@sypherpk?lang=en-US").setLabel("PLAY NOW").setStyle(Discord.ButtonStyle.Link)
)
);
That’s an accessory, not a component
so I have to pass a text with it ?
SectionBuilder#addTextDisplayComponents() discord.js@14.23.2
Adds text display components to this section.
Yes
Why use a section if ur not gonna have text above it? That’s just a row
oh so I should use .addActionRowComponents((actionRow) =>... instead
I am new with containers srry XD
If you want text only, add a TextDisplay to the container
If you want an accessory (a button or image on the right side), use a section
If you want several buttons, use an action row
Yea
Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.
read more
You can see ALL the components here and how to use them
if you mention a role in container it will mention users in that role or it works like embed description?
It will mention them. Same behavior as message content
okay tnx
im using something like:
container.addSectionComponents((section) =>
section
.addTextDisplayComponents(
(td) => td.setContent([
`# ${userData.global_name || userData.username} (${userData.discriminator !== '0' ? `\`${userData.username}#${userData.discriminator}\`` : `\`@${userData.username}\``})`
].join('\n'))
)
.setButtonAccessory((button) =>
button.setStyle(ButtonStyle.Link).setEmoji(`:sparkle:`).setURL(`https://almightynan.cc`),
),
);
and the .setEmoji() expects an object, but i'm not sure how i'm supposed to use that
this was the error:
ValidationError > s.object(T)
Expected the value to be an object, but received string instead
Received:
| ':sparkle:'
at _ObjectValidator.handle (/home/almightynan/Downloads/miku-rewrite/node_modules/@sapphire/shapeshift/src/validators/ObjectValidator.ts:147:102)
at _ObjectValidator.parse (/home/almightynan/Downloads/miku-rewrite/node_modules/@sapphire/shapeshift/src/validators/BaseValidator.ts:126:2)
at ButtonBuilder.setEmoji (/home/almightynan/Downloads/miku-rewrite/node_modules/@discordjs/builders/src/components/button/Button.ts:110:98)
at <anonymous> (/home/almightynan/Downloads/miku-rewrite/src/commands/Profile/Profile.ts:351:47)
at resolveBuilder (/home/almightynan/Downloads/miku-rewrite/node_modules/@discordjs/builders/src/components/Components.ts:186:10)
at SectionBuilder.setButtonAccessory (/home/almightynan/Downloads/miku-rewrite/node_modules/@discordjs/builders/src/components/v2/Section.ts:80:59)
at <anonymous> (/home/almightynan/Downloads/miku-rewrite/src/commands/Profile/Profile.ts:350:12)
at resolveBuilder (/home/almightynan/Downloads/miku-rewrite/node_modules/@discordjs/builders/src/components/Components.ts:186:10)
at <anonymous> (/home/almightynan/Downloads/miku-rewrite/node_modules/@discordjs/builders/src/components/v2/Container.ts:164:73)
at Array.map (<anonymous>)
For Unicode emojis you can just have the emoji in a string
"✨" if on windows use win + . to open the symbols menu
im using a discord emoji, not unicode
im using a different sparkle emoji
must be full emoji format then
or object { name, id }
here is the object type
https://discord-api-types.dev/api/discord-api-types-v10/interface/APIMessageComponentEmoji
thats what i was looking for, thank you both of you 
np
hey guys, the status of my bot always resets after some time. Any idea why? I set it once in the clientReady event but it clears itself after some time (sometimes hours, sometimes days)
your bot reconnects but the clientReady event doesn't emit on reconnect
if you don't plan on changing it, you can set it on your client constructor
oh wow
you should set the presence data in your ClientOptions, and it wil- damn you samtino
ClientOptions#presence discord.js@14.23.2
Presence data to use upon login
Default value: {}
oh, neat. didnn't know I could do that. thx


Hello!
I'm trying to find where this warning is triggered, but I've changed all ready events to clientReady on my code, except for shard events :
(node:18748) 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)
"(Use node --trace-deprecation ... to show where the warning was created)"
I have added it to the configuration on intellij, but I haven't any information on it
Is there a specific event to fetch context menu action commands?
It feels like my bot is not catching any command I run for it and it throws a "IntBot didn’t respond in time" / "The application did not respond"
The same one as with slash commands or any other interaction, interactionCreate
Hey, is it possible just to send a Container Component v2 with a separator?
const separatorContainer = new ContainerBuilder()
.addSeparatorComponents((separator) => separator.setSpacing(SeparatorSpacingSize.Large));```cuz this doesnt work :/
Is it not possible that my discord js bot stops an entitlement? I use my bot to offer various benefits on my server, but if they leave the server I want to stop the entitlement, because they cannot use the benefits.
how we can turn this section on in our bot?
no popular slash commands section in our bot page inside discord
Interesting, I went back to the simple method.
client.on(Events.InteractionCreate, (interaction) => {
if (interaction.commandName === 'Get User ID') {
interaction.reply(`User ID: ${interaction.targetId}`);
}
});
this doesn't reply whatsoever.
It does not 'respond in time'
The context commands are there and everything, it just fails to execute anything. 
documentation suggestion for @lyric bobcat:
ClientEvents#guildMemberRemove discord.js@14.23.2
documentation suggestion for @gilded tendon:
BaseInteraction#isContextMenuCommand() discord.js@14.23.2
Indicates whether this interaction is a ContextMenuCommandInteraction
your bot need to be verified and Discord needs enough data on your app
How do I stop the user subscription though? That was my question
My bot has been in use for two/three weeks now, and it’s verified for sure.
it's not a question of time, it's a question of usage
^^^ can someone please answer this? i only get this here and looks like putting a content to it, wont help either...
Is it not possible to cancel the user subscription of an user via my bot?
Don't think this is helpful for me, it feels like my bot is completely blind to any and all "InteractionCreate" events.
just console.log(interaction) and see if that is logging at all
Yeah I tried that, It doesn't log anything.
I believe that is accurate
https://discord.com/developers/docs/resources/entitlement
is your event handler in a different file than your main index.js?
It is likly there but your container is too small for the separator line to appear but that is a guess
Sad to hear, thanks though
Apparently it wasn't even my code's fault 😐
I don't know what I changed on Discord Developer Portal, but that resulted in a response.
Sounds like you had an interactions endpoint set
did you possibly have a space or something here?
found the fix, ty for helping
what did you end up doing?
Very well possible, the page was issuing me an error before.
ya im curious
That code is supposed to do what you sent as screenshot. If you want the separator to be an actual visible divider line you'd need to setDivider(true), else it's just space
I tried adding invisible content, like an invisible character or just space, but that didnt work, it has to be visible like ABCDE
also didnt work, i have to add something to it :/
Why do you want a separator in a container with no content
Not work in what way? You showed a screenshot looking like it did work
How do I make my bot be usable in private-like environment? like DMs n such for context menu actions?
Set integration type to include UserInstall and contexts to include PrivateChannel
I have many components stacked vertically and I wanted a separator that works independently, since otherwise it would be too confusing.
On the commands you want to be usable there
Is this a thing I can enable in the Discord Portal or via code?
Then just add a separator in between those components, why would it have to be a separate message and in a container?
You need to do both actually
Mm, well I have no idea how to do either ☠️
documentation suggestion for @gilded tendon:
ContextMenuCommandBuilder#setIntegrationTypes() discord.js@14.23.2
Sets integration types of this command.
separator is a top level component and can be added right to messages
Yea, remove the container around the separator, put both containers and the separator between the containers on the same message
thanks
How can I put the buttons inside the container / embed
Like discord add this inside
Refer to the bottom part of that container
Display Components
While you might be familiar with embeds in Discord, there are more ways to style and format your apps messages using display components, a comprehensive set of layout and content elements. To use the display components, you need to pass the IsComponentsV2 message flag (in docs: MessageFlags) when sending a message. You only need to use this flag when sending a message using the display components system, not when deferring interaction responses.
read more
Is there a way for me to fetch a users nickname in a guild after I use a context action on them?
The bot is not in the same server and I want to fetch their nickname in the same server.
Interaction.guild is null.
same goes for Interaction.channel.
UserContextMenuCommandInteraction#targetMember discord.js@14.23.2
The target member from this interaction
GuildMember#nickname discord.js@14.23.2
The nickname of this member, if they have one
how to add buttons insdie container
You either use a section to add a single right aligned button
Or you use an action row to add 1-5 left aligned buttons
anyone know of a way to tell when a user closes my bots activity? i want to have it send / update a message but i cant seem to find a way to detect if the activity is closed. i have tried the following things
- adding event listener for
beforeunload
- does not work
- subscribing to
ACTIVITY_INSTANCE_PARTICIPANTS_UPDATEvia the discord sdk
- works presumably (event is emmitted when joining), but when leaving my code either has no time to run or gets terminated somehow (console logs of discord show that the event is sent)
anyone have any ideas? thanks
would be better to ask that in ddevs
i did
figured i would ask here as well get more chance of someone answering
yeah, but we only handle discord.js, sorry
The nickname of this member, if they have one
do you have a question?
ah nvm, one of those spam bots
why Presense#clientStatus have desktop, mobile, web all seperate?
i thought discord status are shared between all devices
They're not in the API. You can be idle on desktop and online on mobile
so discord's auto idle feature makes desktop idle but not online?
It only makes the desktop presence idle, other platform presence statuses can "overwrite" it in the client GUI
so it is possible to have multiple status for device using modded discord clients
or specific cases in vanilla discord like auto idle?
Not exactly sure what you're trying to ask, but I'm going to steer clear of it since modded clients are against Discord's ToS
i meant, unless people is using modded clients, i can assume that mismatched status will only caused by auto idle, right?
As far as I have seen, yes
so will auto-idle caused mismatch status refreshed when changing status manually?
tbf those are all api questions
we can only answer with as far as we've seen, we don't know how the api actually works
only that that is what the api exposes, so that is what djs has
other than that, not much else, you might have better luck for better answers about specific api behavior in the ddevs server #useful-servers
If the member you're trying to access is not in the guild that your bot is in you're not able to read from it
Hello @snow onyx,
I'm taking the opportunity to ping you about our discussion yesterday
That's just wrong, they've been linked to the docs how to achieve what they want directly after their message
well if that doesn't work I can't help you either xD
Because you'd need to add the flag to the child processes spawned by ShardingManager. Use execArgv for that
Interaction.member.nick is what I wanted.
Which yes, if the member aint in the guild, they don't have a nick for the guild.
If the member is not in the guild they couldn't run the interaction in the first place
Why i cant use messageUpdate?
bot will read edited message
You can, what's your issue with it?
data: 'messageUpdate',
async execute(oldMessage, newMessage) {
console.log('editted')
l }
}``` no matter how many times i edit the message the log still does not show up
How do you load that event handler?
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}```messageCreate and interactionCreate... etc all run but that one doesn't
So it should be name: not data: in your event file
Oh shit… thanks
newMessage console.log out 2 times?
What is that question supposed to tell me? The code you sent won't ever do that, so you probably changed your code and are you asking if that should happen while it doesn't. Or if it shouldn't but does. Or if you should write your code to do so or ...?
who is the message author of these type of messages that sent when someone joined to Server? and how can I check a message is in this type or not?
The user is the author. You can check the message type by checking the message#type
documentation suggestion for @main axle:
MessageType#UserJoin discord.js@14.23.2
ok tnx a lot
and also how can I add image and thumbnail in container?
setThumbnailAccessory and MediaGalleryBuilder??
Thumbnails can only be added to sections. Sections require both an accessory component and a text display component
Section
Sections represent text (one to three Text Display components) with an accessory. The accessory can either be an image (thumbnail) or button. If you do not want to send an accessory, use a Text Display component instead. You can use the SectionBuilder class to easily create a Section component:...
read more
and what about an image?
What about it?
how can I use an image in container? not as a thumbnail as a big image like .setImage in embeds how can I do it?
Oh, you need to use a media gallery for that
so I should create a media gallery using MediaGalleryBuilder() ?
You can do it however you want but I would recommend using the builder
well after I create a mediagallery using the builder how can I put it in my container?
ContainerBuilder#addMediaGalleryComponents() discord.js@14.23.2
Adds media gallery components to this container.
I mean media gallery is a component for it self tnx
container.addMediaGalleryComponents((mediaGallery) => mediaGallery.setComponents(mediaGallery))
is this correct?
No,
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
I have my mediaGallery
const mediaGallery = new Discord.MediaGalleryBuilder().addItems((mediaGalleryItem) => mediaGalleryItem.setURL(url));
now I want to put it in my container
container.addMediaGalleryComponents((mediaGallery) => mediaGallery.setComponents(mediaGallery))
oh I should use .addMediaGalleries instead of .setComponents got it
Use addMediaGalleryComponents
Listen, I think you should read the full display components guide.
All the answers you want to the basic use of components V2 is in there
okay tnx
If you have questions after or need clarifications, don't hesitate to ask
hey i have a quick question can i use a discord invite url to check how many members are in the server?
documentation suggestion for @dry star:
InviteGuild discord.js@14.23.2
Represents a guild received from an invite, includes welcome screen data if available.
Here's what information is available from an invite
alr ty
I doing everything according to the documentation... i want to use the select menu function in the modal but the problem is that it throws me an
code: 50035,
status: 400,
method: 'POST',
I dont know whats wrong anymore
Show the full error
can you show the full error?
files: undefined,
json: {
type: 9,
data: {
title: 'title title title',
custom_id: 'ticketModal',
components: [
{ type: 1, components: [Array] },
{ type: 1, components: [Array] },
{ type: 1, components: [Array] },
{ type: 1, components: [Array] },
{ type: 1, components: [Array] }
]
}
}
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: {
data: {
components: {
'0': { components: [Object] },
'1': { components: [Object] },
'2': { components: [Object] }
}
}
}
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1431277083786608741/aW50ZXJhY3Rpb246MTQzMTI3NzA4Mzc4NjYwODc0MTozemVZd3Z3a05hSFdWbEpQQnFlbGxRc0JzYjRQV2x2VFJUMUVWWllDM1RWVGd6RjNXbkFrVW1IcXFtNGg3ZWlNVVhJWkVKNEtqVmw0WTh2eDFFdkhMYUJyQVlQQUR4TTVzZVdSNktWc3laVzRGeHhhT2RmY2JvaVExMzRZeU1aMg/callback?with_response=false'
}```
i know theres something wrong with the body here but even when it works once i still cant read the data from that select menu in the modal 🙁
And the code causing that?
@scarlet nacelle ^
Action rows with select menus are not supported in modals. you have to uses label component instead of action row component
I wanna ask if I can update the continuer in the same message like
interaction.update
And also if I can change the continuer to embed in the same message ( I believe it's impossible)
if you mean componentv2, previous message must have been a componentv2 in order to edit it. cant change an embed to container
vice versa
So you mean if the message was V2 I can like Change it normally like the embed?
No? you just can't go from cv2 to standard. you can go from standard to cv2
Wdym? " Stander"
i can update something like an embed to cv2? i thought that wasnt possible
File upload cv2
Guide ?
not availible yet
😑
thats for modals
I meant the guide is not available yet
I knew Ok?
it is possible
thanks for clarifying
I want example code.
How to do it?
Which is not available yet
The same is embed?
Interaction.update?
you edit the message to include components and the flag, instead of embeds
cv2 means the component v2s not modals
I knew bro
There's new modal for cv2
It has file upload feature
cv2 and modals are two different things
https://discord.js.org/docs/packages/builders/1.13.0/ModalBuilder:Class#addLabelComponents
You build the modal and add label components, then you can put a component in the label (like the file upload component)
You then access that with the ModalSubmitFields (interaction.fields)
https://discord.js.org/docs/packages/discord.js/14.24.0/ModalSubmitFields:Class
I didn't understand anything 🙂
what do you not understand?
what am i doing wrong: FileUploadBuilder is not a constructor
modal.addLabelComponents(
new LabelBuilder()
.setLabel("File")
.setFileUploadComponent(
new FileUploadBuilder()
.setCustomId("file")
)
are your getting an error?
yes FileUploadBuilder is not a constructor
update your djs
oh yh bruh forgot that
Make a normal modal?
And add this for it?
? whats a normal modal
Const modal= Modalbuilder()
That was not the issue...
thats not the error. i already got my answer
Can Select, Label, and TextDisplay now be used in modals?
yes for some time #announcements message
ahh ok good I overlooked that, I didn't get a ping, but I already have the update, thanks 👍
v14.23 added that
File upload was just released separate from select menus for the API
yes
you cant set file size limit directly in the fileuploadbuilder right?
correct it is not an option that Discord gives
The max file size a user can upload is based on the user's upload limit in that channel.
const {
Client,
GatewayIntentBits,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
InteractionType,
ModalBuilder,
LabelBuilder,
FileUploadBuilder
} = require("discord.js");
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages],
});
client.once("ready", () => {
console.log(`✅ Logged in as ${client.user.tag}`);
});
client.on("messageCreate", async (message) => {
if (message.content === "!uploadtest") {
const uploadButton = new ButtonBuilder()
.setCustomId("open_upload_modal")
.setLabel("📤 رفع ملف")
.setStyle(ButtonStyle.Primary);
const row = new ActionRowBuilder().addComponents(uploadButton);
await message.reply({
content: "اضغط الزر لفتح نافذة رفع الملف 👇",
components: [row],
});
}
});
client.on("interactionCreate", async (interaction) => {
if (interaction.isButton() && interaction.customId === "open_upload_modal") {
const modal = new ModalBuilder()
.setCustomId("upload_modal")
.setTitle("📁 Upload your file");
modal.addLabelComponents(
new LabelBuilder()
.setLabel("Upload a file")
.setFileUploadComponent(
new FileUploadBuilder()
.setCustomId("file")
)
);
await interaction.showModal(modal);
}
if (interaction.type === InteractionType.ModalSubmit && interaction.customId === "upload_modal") {
const uploaded = interaction.files;
if (!uploaded || uploaded.size === 0) {
return interaction.reply({ content: "❌ لم يتم رفع أي ملف!", ephemeral: true });
}
const file = uploaded.first();
await interaction.reply({
content: `✅ تم رفع الملف: **${file.name}** (${file.size} bytes)`,
});
}
});
client.login("");
bro remove your token @lofty topaz
i forgot that
and reset it
Thanks!
So it seems to be related to sharding ?
i will reset it now sorry
check this code'
Are you getting an error?
give this a read first #how-to-get-help
no. but it tells you exactly what the warning is about
yes
TypeError: FileUploadBuilder is not a constructor
at Client.<anonymous> (C:\Users\pc\OneDrive\Desktop\file uploader\index.js:52:11)
at Client.emit (node:events:524:28)
at InteractionCreateAction.handle (C:\Users\pc\OneDrive\Desktop\node_modules\discord.js\src\client\actions\InteractionCreate.js:101:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\pc\OneDrive\Desktop\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\pc\OneDrive\Desktop\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketManager.<anonymous> (C:\Users\pc\OneDrive\Desktop\node_modules\discord.js\src\client\websocket\WebSocketManager.js:236:12)
at WebSocketManager.emit (C:\Users\pc\OneDrive\Desktop\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:2504:31)
at WebSocketShard.<anonymous> (C:\Users\pc\OneDrive\Desktop\node_modules@discordjs\ws\dist\index.js:1190:51)
at WebSocketShard.emit (C:\Users\pc\OneDrive\Desktop\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:2504:31)
at WebSocketShard.onMessage (C:\Users\pc\OneDrive\Desktop\node_modules@discordjs\ws\dist\index.js:1007:14)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:407:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)