#djs-help-v14
78874 messages · Page 55 of 79
Then where do you check its offline status 
i have a dm with it
You won't see presence of a user you don't share a guild with
oh
mkay in that case i'll be right back
i set it to be possible to add it to servers but any time i add it to my server it just doesn't exist??
its fuckin with me
aha it works!
ty :3
You can use the resolveColor()
resolveColor discord.js@14.24.1
Resolves a ColorResolvable into a color number.
Anyone know what "You cannot remove this app's Entry Point command in a bulk update operation." means?
Adding a few new commands, never gotten this before
Does your app actually use activities?
Oh I was working on one, I think the code might be split between branches
Then you'd need to include the entry point command in your array of commands you deploy
How is that djs related?
Ah ok, just a command to call the activity?
The command that already exists, yes
By you ticking the box in Dev portal it was created for you
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
ok, so i may leave
If you just use channel.messages.fetch() without specifying a limit or anything, what will it fetch?
The default amount, which is 50 afaik
I see, thanks for the help!
Messages Resource - Get Channel Messages GET channels/{channel.id}/messages
Retrieves the messages in a channel. Returns an array of message objects from newest to oldest on success. If operating on a guild channel, this endpoint requires the current user to have the VIEW_CHANNEL permission. If the channel is a voice channel, they must also have the CONNECT permission. If the current user is missing the READ_MESSAGE_HISTORY permission in the channel, then no messages will be returned.
read more
Yup, default is 50
Thanks
What can I do, that my bot react to timeouts? If I use guildMemberUpdate my bot doesn't react to a timeout.
Enable the guild members intent in the code and the bot page
It is.
Ur talking abt editing timeouts, right?
W8 I check th code
-edit yes it have the intent
No not really, it should call a function if a timeout ended.
see
const discord = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildVoiceStates,
],
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});
how to convert Collection to Map?
can i just cast it?
You're missing the GuildMembers partial so the event won't emit for uncached members. But also note that you won't be able to tell that a timeout ended from a partial guild member, because the data isn't there
Yea, that’s not a thing
Collection already extends Map
There’s no reason to cast
waitttttttttt
it is { [key: string]: ...} not Map
Best you can do is fetch all members and check timeout remaining time
my bad
can i convert to object too?
No, that’s an Object, probably Record in TS world
Bruh unessesary
You can
uh so how do i..?
Object.fromEntries()
The Object.fromEntries() static method transforms a list of key-value pairs into an object.
Or just
Why tho?
Map.prototype.entries()
The entries() method of Map instances returns a new map iterator object that contains the [key, value] pairs for each element in this map in insertion order.
Or similar
Depends what you actually want
That’s an Iterable of entries tho
Well, they didn't really say anything useful for us to go off of
So we can only throw random things
Object.fromEntries(myCollection.entries())?
What do you want to do
Don't make this an XY problem
.entries() is a bit redundant, unless you want to be explicit
attachments: Object.fromEntries(m.attachments.mapValues(attachment => adaptDiscordMessageAttachment).entries())
attachments accepts {
[key: string]: MessageAttachment;
}, here the type is my own type
and i have m.attachments, which is discord.js' type
i need to convert discord.js' Collection<string, DiscordMessageAttachment> to my { [key: string]: MessageAttachment }
Is there a need for you to make such type?
Collection is perfectly fine for a lot of things, and it's almost exactly that type already, bearing the actual difference between object and Map
yes, that is generated by ts-proto and i want to share the proto definition across other things/languages, not just nodejs/discord.js bot
Ah
i think protobuf is absolutely better than using discord.js' toJSON to send requests/save data
Are you using v14 now?
Except our toJSON makes sure that stuff is serializable (and what discord api wants)
Wait a second, isn’t MessageAttachment v12?
wat
You still didn't update, did you?
idk i just imported it to match my protobuf's name
D.js doesn’t use MessageAttachment anymore
it is in my plan, and thats not problem for now (because it works)
you said you use v13 before. So unless you update we can't and won't support you in here
Although if ur going for shared interface across langs, you prob shouldn’t be using d.js structures at this point anyways
it is related to Collection not the library
At least use the discord type from discord-api-types
but i have to listen for discord's events
i have to convert that type to my own at least once before processing
Or you use @discordjs/core or even /ws directly if you don't actually want the library structures
ok
how to use file upload in modals?
documentation suggestion for @junior ore:
LabelBuilder#setFileUploadComponent() discord.js@14.24.1
Sets a file upload component to this label.
Hey everyone,
I’ve run into a strange issue while working with Discord.js Components v2, and I can’t seem to figure out what’s causing it.
I’d really appreciate any insights or suggestions from anyone who’s dealt with something similar.
and there's nothing that uses ButtonBuilder or something like that
you have a section that is missing an accessory
should i do buttons and thumbnails ?
one or the other. else just uses the textdisplay on its own
i'll try
I cant find any information about the labelbuilder, using v14.24.2
LabelBuilder#setLabel() discord.js@14.24.1
Sets the label for this label.
ahh thanks! How do i then use that label? Theres nothing in the djs guide about using it is there?
You'd put the label component inside the modal (no action row needed) and then the label takes a component and that's where the text input component would go, the guide is still being updated for the new modal changes
ahh switching it up, i see alrighty!
there is a preview guide, but it is not offical yet
https://discord-js-guide-3gofz1r1u-discordjs.vercel.app/legacy/interactions/modals
ill dig in!
thanks
Oh this is actually an improvement once you get over the fact its different from what it used to be
Theres a typo, the text should be he maximum values that must be uploaded => he maximum values that can be uploaded
Idk where to report it tho
so I'm switching to /core and i've already run into some issues:
const rest = new REST({ version: '10' }).setToken(secret.token);
const gateway = new WebSocketManager({
token: secret.token,
rest: rest,
intents:
GatewayIntentBits.Guilds |
GatewayIntentBits.GuildMessages |
GatewayIntentBits.MessageContent,
});
const client = new Client({ rest, gateway });
//const eventsManager = new EventsManager(client, 'events');
try {
client.once(GatewayDispatchEvents.Ready, (payload) => {
console.log('event: ready');
});
client.on(GatewayDispatchEvents.MessageCreate, (p) => {
console.log('event: message_create');
});
//await eventsManager.loadEvents();
await gateway.connect()
.then(() => send({ type: 'ready', shardId: SHARD_ID }));
} catch (err) {
console.error(`Unable to connect to gateway`, err);
process.exit(1);
}
despite registering the events they aren't listened, to and I can't figure out why. what could be the reason?
on the github page
hi, I can’t find this permission in discord.js?
it is undocumented
ah why?
Blame Discord
So to avoid having an error, I must use the manage channel permission instead?
you wont necessarily encounter an error its just undocumented. so in case you wont find how to find that permission i think you can use manage channel permissions for that
I have a permission error, but yes I will have to use the manage channel permission
how did you get a permission error if editing the voice status isn't supported in djs?
if you're using the undocumented endpoint then not being able to find stuff in djs should be expected
lack of the permission is still bad on its own
because it means you can't meaningfully touch the permission on roles or overwrites
you add a label which has the file upload component
ModalBuilder#addLabelComponents() builders@1.13.0
Adds label components to this modal.
LabelBuilder#setFileUploadComponent() discord.js@14.24.1
Sets a file upload component to this label.
FileUploadBuilder discord.js@14.24.1
A builder that creates API-compatible JSON data for file uploads.
on discord
the latter
well you get a full Attachment object
but usually you only want the url
which it holds
the Attachment also doesn't have the actual data
only metadata and a link for you to get the actual file
They are ephemeral so they will be deleted but discord does not give a time on when
Ephemeral attachments will automatically be removed after a set period of time. Ephemeral attachments on messages are guaranteed to be available as long as the message itself exists.
public static async setVoiceStatus(client: Panais, channelId: string, message: string): Promise<void> {
try {
await client.rest.put(`/channels/${channelId}/voice-status`, {
body: { status: message },
});
} catch (err) {
console.warn(`setVoiceStatus failed for channel ${channelId}:`, err);
}
}
setVoiceStatus failed for channel 1431208550327128165: DiscordAPIError[50001]: Missing Access
at handleErrors (/home/pi/Canary/LucasB25/Canary/node_modules/@discordjs/rest/dist/index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async SequentialHandler.runRequest (/home/pi/Canary/LucasB25/Canary/node_modules/@discordjs/rest/dist/index.js:1163:23)
at async SequentialHandler.queueRequest (/home/pi/Canary/LucasB25/Canary/node_modules/@discordjs/rest/dist/index.js:994:14)
at async _REST.request (/home/pi/MusicBot/LucasB25/Canary/node_modules/@discordjs/rest/dist/index.js:1307:22)
at async Utils.setVoiceStatus (/home/pi/Canary/LucasB25/Canary/dist/Client.js:628:7)
at async PlayerDestroy.run (/home/pi/Canary/LucasB25/Canary/dist/events/player/PlayerDestroy.js:413:9) {
requestBody: { files: undefined, json: { status: '' } },
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/channels/1431208550327128165/voice-status'
}```
^^
guide suggestion for @pale flume:
Implicit permissions
Some Discord permissions apply implicitly based on logical use, which can cause unwanted behavior if you are not aware of this fact. The prime example for implicit permissions is ViewChannel. If this flag is missing in the final permissions, you can't do anything on that channel. It makes sense, right? If you can't view the channel, you can't read or send messages in it, set the topic, or change its name. {/* prettier-ignore */} - Text Channels require ViewChannel as detailed above.
read more
prettier-ignore, nice
if i had to guess it's the connect permission being missing
No, the error only concerns the update of the channel status, all other permissions are mandatory. Surely, the bot does not work
because the voice channel status system does not exist on DJS
well, missing access is an implicit resource check, don't know what to tell you
so for that route it'd be access to /channels/:id
be that through permissions, missing app user, or w/e else - see the article above for some more ideas on what could be missing re: impicit checks
guys how can I set the presence of my bot in the constructor?
ClientOptions#presence discord.js@14.24.2
Presence data to use upon login
Default value: {}
presence: {
status: "dnd",
activities: [
{
type: ActivityType.Custom,
name: "custom",
state: ""
}
]
},
This is how I do mine
oooh nice
state is incorrect btw. status is is.
#1142187561729658942 message (I removed the state I use)
Didn’t realise there’s also an example of it in the client options there too
ooooh
oh mb
for message.mentions.members.first(). and i reply to someone but also mention someone in the message reply. is the first member the member i replied to or the member in my message mention?
The latter
Heyo was wondering if there was a way to pull message id from a message being replied too so for example. User A types something in a foreign language, User B can then reply to the message with /translate and itd pull the message id of User A's message?
Sounds like you'd want to use a message context menu command for that
Context Menus
Context Menus are application commands which appear when right clicking or tapping a user or a message, in the Apps submenu. This page is a follow-up to the slash commands section. Please carefully read those pages first so that you can understand the methods used in this section.
read more
Is there something wrong with the /guide command? Everything leads towards the same link called: "usernameOnClick"?
like this here? no? the link works fine for me
Yeah
But if I copy and paste it somewhere, then it's correct.
Can you explain a bit more or show what you mean?
When i click on this link, it directs me to: "https://usernameonclick/"
I've cleared discord cache + data just to see if it's a bug and it is... wtf.
Every link was set as that
This is probably something related to discord client. So perhaps log a bug report to discord
can I use just message ids array in bulkDelete
TextChannel#bulkDelete() discord.js@14.24.2
Bulk deletes given messages that are newer than two weeks.
// Bulk delete messages
channel.bulkDelete(5)
.then(messages => console.log(`Bulk deleted ${messages.size} messages`))
.catch(console.error);
Hi someone could guide me why this error?
Error in help command: CombinedError (2)
Received one or more errors
1 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ButtonBuilder]
|
| Received:
| | undefined
2 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ThumbnailBuilder]
|
| Received:
| | undefined
at _UnionValidator.handle (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1965:23)
at _UnionValidator.parse (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at SectionBuilder.toJSON (/home/container/node_modules/@discordjs/builders/dist/index.js:2525:37)
at /home/container/node_modules/@discordjs/builders/dist/index.js:2226:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (/home/container/node_modules/@discordjs/builders/dist/index.js:2226:35)
at /home/container/node_modules/discord.js/src/structures/MessagePayload.js:151:46
at Array.map (<anonymous>)
at MessagePayload.resolveBody (/home/container/node_modules/discord.js/src/structures/MessagePayload.js:150:49)
at ChatInputCommandInteraction.reply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:191:56)
You didn’t set an accessory for a Section
nope i did it
statsSection has no accessory
ohh wait now i see that :(
sorry for it i didn't notice i thought it is an new TextDisplay
It’s fine, happens
:) btw thanks
ive got this snippet of code here
await bInteraction.showModal(roadNamer);
const mdInteraction = await bInteraction.awaitModalSubmit({time: 60_000});
await mdInteraction.update({ whatever });
ide is telling me that update() doesn't exist on a ModalSubmitInteraction, even though the guide says it should since it's from a button and it works as expected when compiled and run. not much of an issue, but i wanted to check if i'm doing something improperly or if this is a djs issue
Will this code work when someone boost the server?
That client check is not needed, but other than that yes
The Discord API does not provide a dedicated event for guild boosts, but you can check for it in the guildMemberUpdate event:
client.on("guildMemberUpdate", (oldMember, newMember) => {
// Check if the member wasn't boosting before, but is now.
if (!oldMember.premiumSince && newMember.premiumSince) {
// Member started boosting.
}
});
Oh okay, thanks
Use the isFromMessage() typeguard to narrow the type to know the ModalSubmitInteraction is from a message and can update()
ModalSubmitInteraction#isFromMessage() discord.js@14.24.2
Whether this is from a MessageComponentInteraction.
Await the .reply call, else you won't be able to catch it there
wait
the stacktrace is the relevant part. Copy instead of screenshot
PS D:\AF-BOTS\Almasa> bun run src/
DOMException {
line: 0,
column: 0,
stack: "abort@[native code]",
code: 20,
name: "AbortError",
message: "The operation was aborted.",
INDEX_SIZE_ERR: 1,
DOMSTRING_SIZE_ERR: 2,
HIERARCHY_REQUEST_ERR: 3,
WRONG_DOCUMENT_ERR: 4,
INVALID_CHARACTER_ERR: 5,
NO_DATA_ALLOWED_ERR: 6,
NO_MODIFICATION_ALLOWED_ERR: 7,
NOT_FOUND_ERR: 8,
NOT_SUPPORTED_ERR: 9,
INUSE_ATTRIBUTE_ERR: 10,
INVALID_STATE_ERR: 11,
SYNTAX_ERR: 12,
INVALID_MODIFICATION_ERR: 13,
NAMESPACE_ERR: 14,
INVALID_ACCESS_ERR: 15,
VALIDATION_ERR: 16,
TYPE_MISMATCH_ERR: 17,
SECURITY_ERR: 18,
NETWORK_ERR: 19,
ABORT_ERR: 20,
URL_MISMATCH_ERR: 21,
QUOTA_EXCEEDED_ERR: 22,
TIMEOUT_ERR: 23,
INVALID_NODE_TYPE_ERR: 24,
DATA_CLONE_ERR: 25,
toString: [Function: toString],
}
So bun doesn't give you a stacktrace? One more reason for me not to use it
wait i 'll build it and run using nodejs
@steel trail
Seems like something is blocking or slowing down your way to discord. Where are you hosting? Any VPN/proxy/firewall between you and Discord?
no
AbortError: The user aborted a request.
A request took longer than the specified timeout (15 seconds default), and was aborted to not lock up the request handler.
- This can be caused by an internal server error on Discord's side, or just a slow connection.
- In case of a slow connection, the
timeoutoption in RESTOptions can be increased to prevent future AbortErrors.
Or did you set the timeout to something very small by accident? Show your client constructor
im uploaded all images to my server
can the media element in the componentv2 work with videos?
Yes
alr thank you so much
with components v2 is not then possible anymore to have 2 columns in parallel with fields?
there are no fields in components v2, so correct
Is there a practical way to use discord.js with HTTP interactions, or even plans to implement support for them in the future?
What's the problem with the package?
idk and im having the same problem. tried updating to latest package version
Ok what can I do 🙂?
wait for a response from someone with knowledge about it
there isn't much to offer for HTTP only
if you want utils for verification, you can check out the discord-maintained https://github.com/discord/discord-interactions-js
if you want to deal with signature verification yourself you can also do that (node subtle crypto)
and if you want to use the rate limit handler and thin rest wrapper we made, you can use @discordjs/rest for it
update voice
Hi – Does anyone know if there's some way to host the websocket instance on another HTTP server and have the Discord.JS client remotely use that websocket?
I want to be able to host the Discord.JS client on Hono on a serverless endpoint (Vercel), but I can't connect to a websocket on serverless.
If I'm understanding you question properly. You want to separate websocket instance with your bot services. You can implement microservices using different d.js submodules communicating with each other like /ws, /rest (or /core) . You can have a websocket instance running that will make requests to your bot's api on events.
is there a downside from registering guild commands on bot startup (in main.ts via REST) instead of having it in a seperate script that I'd manually run?
Okay. I guess more what I'm getting at is there some way to replace the way that Discord.JS handles websocket events in the client and sort-of "splice" in another WebsocketManager.
Much easier to get rate limited. You should only be deploying new command data to the API, and you should know when that is needed
No need to send the same data every time
okay that makes sense thanks
with HMR yeah that would send the call on each save
Hey, I know it's possible to display a command using the format </command_name:command_id> and the user can click on it to try the command
but if a command has options, is it possible to fill these ?
you can only mention subcommands, not any other options
okay, thank you
he wants to use the api itself not the discord.js lib.
they were already helped 3 days ago
message search is in public preview but not yet documented
discord.js will implement it once it's officially released and documented by discord
as per usual you can use Client#rest to do raw api calls, but we cannot guarantee you won't experience bugs in library internals when doing so and cannot help you with it/fixing any resulting issues
this would be really useful 🤯 currently mapping through each channel and fetching all messages -> filtering by author id
once it's officially released and documented by discord
any clue when that would happen?
Ask discord
How do I clear the text input value of a modal (discord caches it everytime the modal is opened until it gets submitted)
you can setValue to empty string i think. if thats not possible thats just discords intended way
alright
I have a bot that today uses the shard system and I have noticed that dealing with the shards is complicated, and I saw that with http I would dispense with the need, I like discord.js because of the linked methods such as interaction.reply, but I really understand it makes no sense to have or offer both potions, I think about using bun + elysiaJS to do in the form of restfull api
can "ephemeral" attachments be embedded in some way? i have attachments from a modal which i have to send over to a text channel, however sending the link doesn't seem to embed them (even though when i open them thru my browser they load just fine)
is reuploading them the only way? though i wouldn't want some stupid kid exploiting this to make the bot send 1gb of attachments (100mb per attachment)
correct, reuploding or using your own cdn
alright, ty
can i make a file upload in module and when the module is submitted the img is sent as an attachment in a embed or what
-# in the api
I have a discord question, are spoiler hacks still a thing? I'm building a spam detection functionality, do I need to check for those or did discord handle that from their side? I was looking at nother bot and they're using this snippet
export function replaceSpoilerHack(messageContent: string | null, replacement = "[...]") {
return (messageContent ?? "").replace(/(\|\|\u200b\|\|)+/g, replacement);
}
I don't even know how this could be used in a harmful way unless discord patched it because I tried sending the spoiler hack on my server but nothing really happened that shouldn't happen
yes its just as any other file attachment
getUploadedFiles method in ModalSubmitFields class (Discord.js v14.21.0)
Hi Discord Developer Support Team,
I'm encountering an issue with the Discord.js library where the ModalSubmitFields class is missing the getUploadedFiles method that appears in the documentation.
Details:
Discord.js version: 14.21.0
Issue: When trying to use interaction.fields.getUploadedFiles('customId', false) in a modal submit handler, I get a TypeError: "getUploadedFiles is not a function"
Expected behavior: According to the docs at https://discord.js.org/docs/packages/discord.js/14.24.2/ModalSubmitFields:Class#getUploadedFiles, this method should return a ReadonlyCollection of uploaded files
Current workaround: Using fields.getField('customId', 19) and manually resolving attachments from interaction.data.resolved.attachments
The documentation for v14.24.2 shows this method exists, but it doesn't seem to be implemented in v14.21.0. Could you clarify:
When was this method added?
Is there an alternative way to access uploaded files in modals for v14.21.0?
Should the documentation be updated to reflect version availability?
Code example:
const fields = interaction.fields; // ModalSubmitFields instance
const uploadedFiles = fields.getUploadedFiles('file_upload_custom_id', false); // Throws error
TypeError: fields.getUploadedFiles is not a function```
This is blocking proper handling of file uploads in modal interactions. Any guidance would be greatly appreciated!
- Thanks
-# AI generated
whats a spoiler hack?
if your question is if message content contains the spoiler symbols || then yes it contains it
why did you ai generate? be sure youre on latest package version. just stating your issue is easier than letting ai write it
ModalSubmitFields#getUploadedFiles() discord.js@14.24.2
Gets file upload component
i wrote it to ai to format and clean spelling mistakes
getUploadedFiles is from 14.24.0 so you simply have to update in order to get that
I'm asking about it, I'm checking another bots code and they have that snippet, so I'm trying to understand what it is, because when I tried sending in my server what that snippet is checking for, it was a simple empty line, not sure how is this used in a harmful way, for that bot to be checking for it.
Why do you want to implement something you dont know what it is? Im confused to what a spoiler hack is and therefore dont understand your question
:)
anyways, this is the code I'm inspecting if anyone has any idea what is this trying to prevent
https://github.com/vue-land/vue-land-bot/blob/0992fda4f4cc3f287cba5eaebacaa0fd31aa9256/src/core/utils.ts#L76
the comments above the function explains whats it doing
but i dont think thats still a thing
I just got a person to test it on, it's still a thing 
is there any possible way to see more detail about what is causing "Received one or more errors" on an embed builder
place the try catch as close where youre making the embed
could you share the embed that you are trying to send?
you can just make a function to replace all spoiler symbols from a message content then
its all good i did the try/catch thing and i realised I'm putting title not name on the fields
this is what that function is doing, replacing the spoiler hacks, not all spoilers
What is required to make it so you're app can listen to slash commands being used in private text channels between friends on discord?
i've defined the data in my slash command data object
nevermind i solved it
Is it possible to host any part of Discord.JS on Vercel? I'm fine if the WS has to be hosted somewhere else.
discord.js is not meant for web development
I mean like run it "in parell" (per-se) to a Hono server, on vercel – I don't mean make a website with it.
The WS is the only reason you’d use d.js tbh
I guess the correct question here is why?
how to stop a invalid webhook token i have added check but that doesnt seem to work
"stop" how?
you mean catch the error, or...?
you can't know beforehand if the token is invalid, if that's the question
maybe you could do some basic checks but that's about it, nothing definite
Are you referring to interactions expiring?
Also please show code and the entire error (with stack trace)
does modal submit interactions include in interaction.isMessageComponent() this check ?
no, modal submits aren't message components
documentation suggestion for @swift jewel:
BaseInteraction#isModalSubmit() discord.js@14.24.2
Indicates whether this interaction is a ModalSubmitInteraction
alr thanks
How many components with LabelBuilder can I put in the "labelComponents" array in the code ts .setLabelComponents(labelComponents); in a modal?
I couldn't find any sources about this.
A modal can have 5 components, but I’m not sure if the components inside the label count
They don't. Modals have a Max of five top level components. Components included inside labels do not count
does anyone know how I can display the commands bar, as seen in the dank memer's bio?
You can't, to get them your but must be verified and Discord must have enough data on command usage
I'm verified on discord and I have 46k server joins
it is not servers joined but command usage Discord does not disclose what the thresholds are
oh, and it auto displays them? and im assuming i didnt meet that threshold
corrent, DDevs may be able to help more
okay, so nothing I can do but wait -_-
pretty much
Why can't we assign strings to InteractionContextType? Using integers like 0, 1, 2 makes it confusing sometimes
thanks anyways my goat!
You shouldn't really be using integers directly. Use InteractionContextType. Like InteractionContextType.BotDM
I was trying to avoid that for simplicity as I thought I could assign strings to InteractionContextType like "Guild", "BotDM", etc. But I guess that's better than integers thanks
You can destruct the enum
const {Guild, BotDM, PrivateChannel} = InteractionContextType
data.components[BASE_TYPE_MAX_LENGTH]: Must be 5 or fewer in length.```
yes?
There is a modal label component limit. Yes
My whole plan went to waste 😭
code?
const modal = new ModalBuilder()
.setCustomId(`anket_${optionCount}`)
.setTitle("Anket Oluşturma");
const questionLabel = new LabelBuilder()
.setLabel("Anket Sorusu")
.setDescription("Deneme")
.setTextInputComponent(
new TextInputBuilder()
.setCustomId("question")
.setStyle(TextInputStyle.Short)
.setPlaceholder("Anket sorusunu girin")
.setRequired(true)
.setMaxLength(80)
);
const labelComponents = [questionLabel];
for (let i = 1; i <= optionCount; i++) {
const optionLabelComponent = new LabelBuilder()
.setLabel(`${i}. Seçenek`)
.setTextInputComponent(
new TextInputBuilder()
.setCustomId(`option_${i}`)
.setStyle(TextInputStyle.Short)
.setPlaceholder(`Anketin ${i}. seçeneğini girin`)
.setRequired(true)
.setMaxLength(80)
);
labelComponents.push(optionLabelComponent);
}
modal.setLabelComponents(labelComponents);
interaction.showModal(modal);```
this code is inside the slash command
what are you looking for modals can only have 5 top level components?
Hi, the modals guide mentions using modal.addComponents() but the reference docs don't include that method. Is the guide outdated? And if it is, is using label components the same as the previous use of action rows with respect to modals?
I'm going to create a poll system and display a modal that allows the user to enter the same number of options as the optionCount argument in the slash command. I think I should limit the number of options to 4 or 5, or do it some other way.
I'm using v14, that takes me to v1.13.0?
Hey guys! Hope your all well, can I get some help in #1434225988962615388 if possible? 🙂
That's not discord.js, that's @discordjs/builders
Hey everyone, is this a common error with the newest d.js version?
...\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4
client.actions.InteractionCreate.handle(packet.d);
^
TypeError: Cannot read properties of undefined (reading 'handle')```
No
So how i can fix this? Maybe my node.js version is to old, i use 22.2.0.
I'll wager a guess and say you extend client and overwrite the .actions property
That would be my guess too
I checked and you were right. I apologise for the inconvenience and thank you.
how to check that emoji is custom(uploaded) or not(unicode)?
Where do you get that emoji you want to check?
reactions
MessageReaction#emoji discord.js@14.24.2
The emoji of this reaction. Either a GuildEmoji object for known custom emojis, ApplicationEmoji for application emojis, or a ReactionEmoji object which has fewer properties. Whatever the prototype of the emoji, it will still have name, id, identifier and toString()
This?
yes
If it has an id it's a guild/app emoji. If not then the name is the Unicode
so you mean if unicode name will have like 😄
if it has id it is like
?
The former will have .id === null, the latter a snowflake, yes
Assuming you did finally update to v14
so i have to make type guard?
btw is the emoji url must have that tokens like attachments do?
You need to check for id if you want to determine the type of emoji, yes
Can you rephrase that question?
every valid attachment urls must have some timed access token in its parameter
but what about emojis?
You mean the expiration, no, emoji URLs don't expire
How to get attachment from file upload?
documentation suggestion for @fair palm:
ModalSubmitFields#getUploadedFiles() discord.js@14.24.2
Gets file upload component
I can upload multiple files to a single FileUpload?
wait now we have file upload on modal??
yes #announcements
up to 10
question if i remove send messages permission from user and view channel permission can they not click on buttons
well yh cuz they cant see the channel
send message permisssions doesnt affect buttons
I have an issue with my reaction role system, if I turn the bot off then back on, if I had a reaction role set before it went offline when it goes back online it doesn't register it or count it when I react
If you remove only send messages, no they can still click button but if you remove view channel... well they can't see the channel to even see or click the buttons. Pretty simple
You need Partials for reactions and fetch them when you receive a partial reaction
What are the docs for partials pls
documentation suggestion for @sand minnow:
PartialMessageReaction discord.js@14.24.2
don't think that's the correct one
I'll check, thanks
docs can be confusing lol, it think its somwhere in the guide
@sand minnow you have to enable partials for message reactions and if reaction partial fetch it
guide suggestion for @sand minnow:
Listening for reactions on old messages
Messages sent before your bot started are uncached unless you fetch them first. By default, the library does not emit client events if the data received and cached is not sufficient to build fully functional objects. Since version 12, you can change this behavior by activating partials. For a full explanation of partials see this page. If you use gateway intents but can't or don't want to use the privileged GuildPresences intent, you additionally need the User partial.
read more
Thank you guys
@tardy sable @fallow finch it works now, thanks a lot
is it mandatory to disable button after duration of time?
No
I don't think so atleast
saw many many bots disabling for inactive
I would say it's a good design so the user knows they can't click it anymore
thats up to you to decide what you want to do with your buttons
okir
so buttons don't expire huh'
Correct
if you dont use them in a collector theyre always active
ooo
thx for info
Anybody understand why my embed sends if I run another command first?
Whenever I run /info, it'll not respond. But if I do /ping, then it'll respond.
Probably because your code does something weird... without seeing your code it's hard to say more
I mean the commands are quite basic nothing crazy that's why I'm confused
is it possible to make a browser extension that adds multiple context menu buttons
the one youre using execute message, and the other interaction?
djs is for discord apps
I'm still learning but I wouldn't understand how this could be a problem?
It's definitely confusing to name an instance of ChatInputCommandInteraction message but not an error. Show your command loader and interactionCreate handler
And are you sure your bot was online while doing the first command?
Look at your first three lines and tell me why
I am going off the docs and must've pasted it twice
You're basically adding a new listener every time a command is run. Your third command use should actually cause an error in console
Yeah, it was a interaction error and looking at that I should've known. 😅 It works now tho!
What would stop the bot actually playing a stream.mp3 link? It joins channel but no sound at all
Many things can. Make a post in #998942774994927646
I posted in there yesterday with as much info as possible
what does this error mean it happens when i submit a modal
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
Hello d.js Support
I'd like to ask if the red line indicating an error in await is normal, or is the problem on my end?
I'm currently following the guide in order and would like to know if this is normal or not.
async (interaction) => {
You forgot an async
Can't use await without async
Oh thx, and thank you also for the information: "await cannot be used without async."
documentation suggestion for @mental idol:
await
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async function or at the top level of a module.
you can search on mdn for usage of js operators and js syntax in general
it also mentions your solution
It can only be used inside an async function or at the top level of a module.
I'll review mdn because I'm currently in the learning phase. I don't want to delve too deeply into something I'm not yet ready for.
It's true that I need to know some JavaScript to learn Discord.js. I wouldn't say I'm good, but I watched a few videos and then started with the guide.
Currently... I'm thinking of proceeding step by step with a guide.
Strong recommendation. Do not use AI. It's the fastest solution to a problem but it frequently makes mistakes and even when it doesn't, you don't end up learning
Do it the "hard way" and search places MDN and StackOverflow and try and solve problems there first
I think I'll use AI to detect spelling mistakes.
But what problems are you not recommending using AI for?
Like "hey this code has an error, can you fix it"?
Like AI chatbots, not editor tools like autocomplete and spell check...those are fine
Will I find solutions for all errors in mdn and StackOverflow?
When would you advise me to seek help from d.js support?
Because I don't want to always come back here to solve my problems, I want to learn to fix my problems myself.
We will happily solve any issue you have with DJS itself, or at least point you to where you can solve it yourself
MDN and StackOverflow are good for JavaScript in particular issues
But my recommendation is more general. AI is a great tool, I use it a lot. But I also know that by using it, mistakes (bugs or bad practices) could be introduced or that I just won't have as good of an understanding of how my own project will work
Use your own personal judgement on when to use it or not. Just don't rely on it or you can dig yourself into a hole
Sry you had to go through that🥀
What does that mean?
👍🏻 Understood, and thank you for your advice.
Sry you had to tell someone you can't use await without async, must've been hell for you lol
It's really not. It's a common typo of a callback function. They're fairly unintuitive for people who haven't used JS
...ya
Use #archive-offtopic for off-topic talk
Yh we didn't realize it was in support, sry about that
Can i make a Button without label in ContainerBuilder?
You can't
A button needs to have a label otherwise you'd get an error
okay
It needs a label or an emoji
ButtonComponent discord.js@14.24.2
Represents a button component
I thought it would show the required components
Since that is what djs constructs for data it receives, not meant for creating buttons, no
The DJS docs don't show most requirements. That's where you want to go to the discord API docs to see
Oh ok
Yeah sounds about it
Can bots set vanity links
Hello Discord.js support,
I have a question regarding the difference between using:
const { SlashCommandBuilder } = require('discord.js');
const data = new SlashCommandBuilder()
.setName('echo')
.setDescription('Replies with your input!');
and using:
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
await interaction.reply('Pong!');
},
};
Because in the guide, it initially used module.exports, but when it entered the "echo" command example, it switched to using const data = new SlashCommandBuilder().
As I understand it, the code should contain both "data" and "execute". Therefore, the second example, const data = new SlashCommandBuilder(), will not work without execute.
Which is correct and better: using module.exports or const data = new SlashCommandBuilder()?
doesnt matter
The only difference is you still have to export const data later instead of doing it directly
DiscordAPIError[50027]: Invalid Webhook Token
at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:1163:23)
at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:994:14)
at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1307:22)
at async InteractionWebhook.editMessage (/home/container/node_modules/discord.js/src/structures/Webhook.js:351:15)
at async ChatInputCommandInteraction.editReply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:247:17)
at async Object.execute (/home/container/Events/Interaction/InteractionCreate.js:87:7) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: [Array],
components: [],
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: { message: 'Invalid Webhook Token', code: 50027 },
code: 50027,
status: 401,
method: 'PATCH',
url: 'https://discord.com/api/v10/webhooks/'
}
How to fix this error and what's the cause
Did you attempt to edit after more than 15 minutes
Though that URL seems odd, where the rest of it
its an epphemral reply and yes its like a automated thing where the bot does stuff fdor you.
Is the webhook id and token being omitted?
Yeah they invalidate after 15 minutes
Did you omit it? Or you just copied pasted the error as is?
i jsut remove most of the url, everything else is how it is
Okay, I'm currently learning. Does each method have other uses, or do they both work, but the difference is that I still need to export the const data later option?
If you're learning, which method do you prefer? Or would you recommend using both methods?
i also know what its coming from its a automated command where the gbot updates the progress oin an embed then sets up everything for you
It’s all preference
remvoed it, dk why i jsut thought i would
Neither of these are really even "methods"
Both define a variable named "data" and to use it in other files, it needs to be exported
DiscordAPIError[50027]: Invalid Webhook Token
at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:1163:23)
at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:994:14)
at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1307:22)
at async InteractionWebhook.editMessage (/home/container/node_modules/discord.js/src/structures/Webhook.js:351:15)
at async ChatInputCommandInteraction.editReply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:247:17)
at async Object.execute (/home/container/Events/Interaction/InteractionCreate.js:87:7) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: [Array],
components: [],
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: { message: 'Invalid Webhook Token', code: 50027 },
code: 50027,
status: 401,
method: 'PATCH',
url: 'https://discord.com/api/v10/webhooks/1360006420619329727/aW50ZXJhY3Rpb246MTQzNDU4MDYzNDkyNzUwMTM5MzpnTDNhZUpZb2xqc0JBcm53dkpDb0pBRTNJTURVUjZraWhDeE5Db0piaUF4eUZiNU9sT3NFdkRtQkt3cWFsS2hzVmtldjBpTFNGOHBDT2VLQm5MTEdGWFlIejJIeU44MXFabUVkZm52QXZRRno5MEp2emt6OWxvT2p4QjNXNlFVTw/messages/%40original'
}
^ the answer is still this
i know mate, i dont klnow how to get around it
You dont
You take less than 15 minutes
Or send new messages some other way
Do they perform the same purpose?
In the former code, you still need to export data. Not sure if you just omitted that or aren’t aware of that
yes, entirely
But yeah I already pointed out it still needs exporting
Actually, I'm currently following the guide step by step, but the point is that initially the guide used module.exports, but then it switched directly to using const data = new SlashCommandBuilder() without explaining why, so I came to ask.
ye but the select menu sued expries in 30secons
const data = ...
const execute = ...
module.exports.data = data;
module.exports.execute = execute;
module.exports = {
data: ...
execute: ...
}
These are essentially identical for your needs, unless you for some reason needed to reuse the const references to this (which you probably dont)
You're overthinking it. Sometimes it just easier to show it that way
Its not the relevant part of the code at all
No they dont?
i set it as that
Its possible the ephem was dismissed then
Nothing to update
howits ephemral
User presses the dismiss message button at the bottom of the ephemeral message
done that before error doesnt pop up then
And the message is deleted and no longer exists
so what should i do make it not epehrmal
Handle the rejection
It can still happen with non-ephemeral messages
What do you mean "make it not ephemeral", its your message isnt it? You chose for it to be ephem?
Admin deletes message and now you can’t update it anymore
It's true I overthought things a bit, but I didn't want to miss any point in the guide. That's what surprised me, but it clarified the idea somewhat.
However, I still want to know if they serve the same purpose. Why not use the first one, module.exports, since I think it's easier?
Or is it a matter of personal preference?
"Easier” is subjective
Perhaps because I'm still learning, I might choose the easier method, but maybe later I'll switch to the other one.
But you've explained that they both serve the same purpose.
So thank you and monbrey.
Some prefer less lines, some prefer less indents
I don’t see any benefit of factoring out data and execute besides indent
To confirm the information I have in mind:
const { SlashCommandBuilder } = require('discord.js');
const data = new SlashCommandBuilder()
.setName('echo')
.setDescription('Replies with your input!')
.addStringOption((option) => option.setName('input').setDescription('The input to echo back'));
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('echo')
.setDescription('Replies with your input!')
.addStringOption((option) => option.setName('input').setDescription('The input to echo back')),
};
They are the same thing.
I apologize for the repetition.
module.exports.data = data is needed for the first one
like this:
const { SlashCommandBuilder } = require('discord.js');
const data = new SlashCommandBuilder()
.setName('echo')
.setDescription('Replies with your input!')
.addStringOption((option) => option.setName('input').setDescription('The input to echo back'));
module.exports.data = data; // or module.exports = { data }
Or
module.exports = { data }
Yes
thx
tag suggestion for @open musk:
Frequently Asked Questions: learn more
Hi, is anyone aware if the Discord API / DiscordJS has support for the apply to access for guilds? (i.e. approving / denying applicants)
No, there’s no bot api for that
Gotcha, thanks :)
how to get image tag
UserPrimaryGuild#badge discord.js@14.24.2
The guild tag badge hash
User#guildTagBadgeURL() discord.js@14.24.2
A link to the user's guild tag badge.
@@bleak owl get me image tag
what image are you referring to? also, a "please" is helpful
show to how to get badge Tag Color and name in image
Generating images has nothing to do with discord.js
can select menus have autocomplete or no?
not at this time, no
alright i felt like they did but i guess not
i just wanted to be sure before i wasted time thinking of an idea to do.
there are auto populating select menus like user, channel, role and mentionable, but not string menus unfortunately
Hi, does discordjs have any datetime pickers or similar interaction components?
We do not dictate what kinds of components exist on Discord, we can only implement support for existing ones
Ah okay so discord just doesn't support them at all. Thanks!
did discord break the bot statuses (i cannot see the “watching” part in my bots status, the rest is there)
well, it's hard to say since we are not discord
But to save you a trip to DDevs, yes they're going away. It's an experiment
Are you able to make it so you can just type what you want in a select menu without it being choices?
No
Only slash commands support autocomplete on string options
alright
can you still use text inputs on modals?
Yes
alright i'll do that thank you for replying to me
name: `ticket-transcript-${Ticket.ticketId}.html`,
description: `Transcript for ticket ID: ${Ticket.ticketId}`,
});
sorry question is this how you send attachments
This is the example from the guide of how to send an Embed with an attachment
const { AttachmentBuilder, EmbedBuilder } = require('discord.js');
// ...
const file = new AttachmentBuilder('../assets/discordjs.png');
const exampleEmbed = new EmbedBuilder().setTitle('Some title').setImage('attachment://discordjs.png');
channel.send({ embeds: [exampleEmbed], files: [file] });
Make sure to send the attachment in the files field
Why would this type be never ?
How is collector defined?
that collector doesn't collect modal interactions
use awaitModalSubmit instead
Can you use that if the modal is used more then once?
or it listens for 1 use of the modal
How can a single interaction have 2 modal submits?
How would i listen to my modal from inside the collector?
You’ve already replied to the interaction. You can’t show a modal at this point
Ah okay so that won't work atleast but i moved on from trying that
You can wait for a button press or select menu selection then show modal and wait for it
interaction.awaitModalSubmit(…)
thanks
I don’t think you need the response from showModal
prob not
Do select menus support multiple selections? I had assumed they do, given the min and max values u can set, but when I try adding more than one choice, the dropdown seems to bug out and keeps instantly closing when trying to open it
they do assuming you passed valid min and max values (min <= amount of options < max)
the api will validate you're passing valid values anyways
that sounds more like a UI issue though
why is this type never?
i'm trying to get the values from a select menu on a modal
i log it and this shows.
given the fact that its actual type is Extract<ModalData, { type: Type }> it might just be a TS interpreter issue, since its definitely mapping to SelectMenuModalData, but it thinks extract cant map to it?
you should be able to define loaderInput as SelectMenuModalData if you reallyyyyy want the properties
you should use the getter for string selects instead
ModalSubmitFields#getStringSelectValues() discord.js@14.24.2
Gets the values of a string select component given a custom id
you're not supposed to use the raw getField
yeah it does seem to be a ui issue. I was thinking i might have been missing some required values or something but I imagine it should error if that was the case:
const excludedUsersSelect = new UserSelectMenuBuilder()
.setCustomId('excludedUsersSelect')
.setRequired(false)
.setPlaceholder('Select any members that should not be purged regardless of activity')
.setMaxValues(25);
Would I be correct in thinking this may be more a discord ui issue rather than something related to discord.js? Also if it's relevant, I'm using the select inside a modal using a labelbuilder
that looks fine, also if shows the modal correctly then yeah it's a ui issue
make sure your client is up to date
yeah it is. I'll investigate further and/or pray it automagically fixes itself lmao
didnt even see this when i was on the page 
probably version mismatch somewhere. If restarting ts-server doesn't fix it check npm ls discord-api-types
discord question, is there a Message limit in threads, as in, how many messages can a single thread have?
hey I've been getting this err for a long time now, but I dont seem to understand why im getting this, interactionCreate - https://srcb.in/KWXDvs4NsB . ping.js - https://srcb.in/Q4XyRCqQhd
No
Can't tell just from this but it doesn't seem to be executing. You should be using interaction.isChatInputCommand() though
thanks
are you getting any errors in the termnial? is the bot online?
no errors
thank you, but i've rechecked almost everything nothing seems to be a problem for now
you're passing interaction, client args, where did you get those from? pretty sure it's just interaction for both the slashcommand and the interactionCreate event
it doesnt matter
wdym, you're using the second arg in your code, client
yeah it doesnt matter if I use it or not, it wont affect the output
it does. ts const command = client.commands.get(interaction.commandName); if(!command) return;
change this to
if(!command) {
await interaction.reply({content: "command not found"})
return
}
yeah i've tried your way, still no result
it jsut says command not fouind
.
I did that, they way you've said
send your updated code.
That seems like a useful error
module.exports = {
name: "interactionCreate",
async execute(interaction, client) {
if (!interaction.isChatInputCommand()) return;
const command = client.commands.get(interaction.commandName);
// if(!command) return;
if(!command) {
await interaction.reply({content: "command not found", ephermeral: true})
return
}
try {
await command.execute(interaction, client)
} catch(err) {
console.error(err)
}
}
}```
const { SlashCommandBuilder } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("replies with ping, for now.."),
// .ephermeral(true)
execute (interaction) {
interaction.reply("pong!")
}
}```
I've checked the path, its all good
module.exports = {
name: "interactionCreate",
- async execute(interaction, client) {
+ async execute(interaction) {
if (!interaction.isChatInputCommand()) return;
- const command = client.commands.get(interaction.commandName);
+ const command = interaction.client.commands.get(interaction.commandName);
same error "command not found"
also in the same file
- await command.execute(interaction, client)
+ await command.execute(interaction)
yeah I did that already
is it normal for a typescript bot to use 150mb+ of memory when deployed to heroku
Yes, that’s normal. #1081585952654360687
@normal flare any idea why its happening?
interaction create isnt the issue, youre not registering it properly
could you explain it better?
you are registering them right
what is your "client.commands"
So your issue is loading the commands, not deploying them
client.commands is not something added by DiscordJS. Where are you making it and how are you filling it with data?
This is the example of how to do that from the guide
client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);
for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter((file) => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
yeah its there in index.js
But...specifically how are you filling that collection
That there looks like an empty Collection just called commands which would explain why it's not finding a command by any name in your interactionCreate event
wait
how do I do this ? , the red and green
```diff
- green
- red
```
- client.commands.set(command.data.name)
+ client.commands.set(command.data.name, command)
``` in line 11 I made this change if that would make any difference
Yes it would. collection.set(key, value) means that now you can search for an Object value using the String key of the name of the command
Map
The Map object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and primitive values) may be used as either a key or a value.
Not adding a Value meant that getting a value was returning undefined
Still no results..
wait, I reloaded discord after making this change, it works.
thanks so much
Are you deploying command every time you start your bot?
That's a different issue and can cause rate limiting. But happy it's working for now.
Try and separate command loading and command deployment (actually sending to Discord) to avoid the rate limit
I will thanks.
how can I make messages ephermeral?
const { SlashCommandBuilder, MessageFlags } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("replies with ping, for now.."),
flags: MessageFlags.Ephemeral,
execute (interaction) {
interaction.reply("pong!")
}
}``` I tried this but its not working
Where did you get that it works like that?
Ephemeral responses
You may not always want everyone who has access to the channel to see a slash command's response. Previously, you would have had to DM the user to achieve this, potentially encountering the high rate limits associated with DM messages, or simply being unable to do so, if the user's DMs were disabled. Ephemeral responses are only available for interaction responses; another great reason to use the new and improved slash command user interface.
read more
thank you so much
is it just me or client.on messageCreate dont return .content anymore?
it does
if it's an empty string then you probably don't have the MessageContent intent
it is an empty string, but i also do have the messagecontent intent on the discord developer apps
this one right?
that allows you to request it without getting an error
you'll still need to actually request it on your Client constructor
oh, one sec let me try it
ohh it worked now, i dont know why it doesnt work now though, i changed nothing for the intent bits. it was 32767. i currently have another active bot thats using this intent bit and still worked, i guess its a new change in the update?
tag suggestion for @west pier:
We highly recommend only specifying the intents you actually need.
- Note, that
98303,32767or whatever other magic number you read that represents "all intents", gets outdated as soon as new intents are introduced. - The number will always represent the same set of intents, and will not include new ones. There is no magic "all intents" bit.
i just found out im illiterate, thank you though 😺
an actual intents list would also let you easily know what you do and don't have
yeah i shouldve used that instead of these funky numbers, hate to admit i was too lazy to care about the intents i needed... 💔
Hey everyone, wondering if there's a "proper" way to write the following code:
async function main() {
const client = new Client({intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers]});
client.login(config.token).catch(console.error);
const channel = await client.channels.fetch('get ID from some persisted data');
if (channel) {
if (channel.isTextBased()) {
// TS error: Property 'send' does not exist on type 'Channel'.
channel.send({content: 'Hello world!'});
// Just hack around it
const ch = channel as TextChannel;
ch.send({content: 'Hello world!'});
}
}
}
during regular interactions replying has no problems since the interaction has a strictly typed channel, but when fetching it like this it could be anything and the isTextBased() doesnt seem sufficient for TS
I'm not the most proficient with TS itself so I don't know what the feasability of a typeguard like that is mind you
BaseChannel#isSendable() discord.js@14.24.2
Indicates whether this channel is sendable.
Use this instead ^this
ah perfect, that did the trick 👍
are there text based channel types that lack a send method then?
Group dms I think
hm 🤔
Would a groupdm not just become a DMChannel?
They're two different types
oh wait nevermind its specifically worded as "between 2 members"
hey is it possible to unemphemeral a message via interaction.editreply?
Nope
oh alr
I get a warning that TextIunputBuilder.setLabel is deprecated and I should use a LabelBuilder but how do I add the LabelBuilder to the TextInput?
You do the opposite, you add the TextInput to the labelbuilder
oooh
thanks
LabelBuilder#setTextInputComponent() discord.js@14.24.2
Sets a text input component to this label.
Is there a section in the guide that covers monetization/skus?
is there a way for me to defer an interaction and then send an modal* ? i need to make 1-2 web calls before i can answer and i could potentially run into the window of not beeing able to answer in time
specificly talking about AnySelectMenuInteraction and the <interaction>.showModal() function (or any other way if thats even possible)
Example: https://pastebin.com/B8HPwF6Z
you just editReply with the embed
oh sorry i misstyped that it was ment to say Modal*
ah well than no. showModal must be a first respose to an interaction
What's the most efficient way to check if a guild has a particular Entitlement?
i think thats called guild features
Don't think so
What do you mean by entitlement?
Ah. Give me a sec
documentation suggestion for @ivory wasp:
ClientApplication#entitlements discord.js@14.24.2
The entitlement manager for this application
you then need to check the entitlement for the guild
And subsequently I have to manage the caching myself then?
not necessary ClientApplication#entitlements is a EntitlementManager which has a cache
it works similarly to UserManager or GuildManager
EntitlementManager discord.js@14.24.2
Manages API methods for entitlements and stores their cache.
Ok so in theory if I call eg fetch() on entitlements on every message send, it's fine since the internal cache will manage it? My bot handles every message sent so I want to make sure I'm not looking up entitlements repeatedly on every message
correct
Ok thank you
I am not happy with my solution so I am looking at FetchEntitlementOptions and FetchEntitlementsOptions on how to make it better (ie limit to target guild)
got it in FetchEntitlementsOptions give me a sec to write it down
hi! I haven't worked with Discord bots in a long time and I was just wondering how I could add horizontal breaks and embedded buttons like these
guide suggestion for @fleet patio:
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 think I got the best option
const guildEntitlements = await client.application.entitlements.fetch({
guild:interaction.guild,
excludeEnded:true,
excludeDeleted:true
});
can someone help me? im trying to build a bot im using replit and keep getting errors, i can invite u to my replit project
Just ask about the problem you're having, we don't want to go to replit
i tried helping you in ddevs, but you haven't shown what errors you get
can i invite u to my project? u can see it? its the epehermal one but i fixed and it keeps occuring over and everywhere
nope, please send the error here
i would need to share the whole program in order for u to understand the problem
you do not, please send the error here
if u dont trust me, ill redo the cmd and see what error i get
no one here can help you if you don't explain the problem by showing your code and error
[dotenv@17.2.3] injecting env (10) from config.env -- tip: 🔐 prevent committing .env to code: https://dotenvx.com/precommit
Successfully registered application commands.
Connected as 10#2798
node:events:502
throw er; // Unhandled 'error' event
^
TypeError: Cannot read properties of undefined (reading 'EPHEMERAL')
at Client.<anonymous> (/home/runner/workspace/index.js:315:34)
at Client.emit (node:events:524:28)
at InteractionCreateAction.handle (/home/runner/workspace/node_modules/discord.js/src/client/actions/InteractionCreate.js:101:12)
at module.exports [as INTERACTION_CREATE] (/home/runner/workspace/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/runner/workspace/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31)
at WebSocketManager.<anonymous> (/home/runner/workspace/node_modules/discord.js/src/client/websocket/WebSocketManager.js:236:12)
at WebSocketManager.emit (/home/runner/workspace/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)
at WebSocketShard.<anonymous> (/home/runner/workspace/node_modules/@discordjs/ws/dist/index.js:1190:51)
at WebSocketShard.emit (/home/runner/workspace/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:2504:31)
at WebSocketShard.onMessage (/home/runner/workspace/node_modules/@discordjs/ws/dist/index.js:1007:14)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:407:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
Node.js v20.19.3
when i fix one line then it goes to another line
to fix the error, you need to use MessageFlags.Ephemeral
thanks
im using that, wait ill go to the line 315 and send u here
flags: [MessageFlags.FLAGS.EPHEMERAL],
thats not quite what i suggested
oh so like this:
flags: [MessageFlags.EPHEMERAL],
no,
MessageFlags.Ephemeral
do i need to change everywhere its that? to that?
correct
i dont include flags: bit?
no
MessageFlags.Ephemeral
ok let me try that now
/home/runner/workspace/index.js:73
MessageFlags.Ephemeral,
^
SyntaxError: Unexpected token '.'
at wrapSafe (node:internal/modules/cjs/loader:1472:18)
at Module._compile (node:internal/modules/cjs/loader:1501:20)
at Module._extensions..js (node:internal/modules/cjs/loader:1613:10)
at Module.load (node:internal/modules/cjs/loader:1275:32)
at Module._load (node:internal/modules/cjs/loader:1096:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
at node:internal/main/run_main_module:28:49
Node.js v20.19.3
please show your code, you have a syntax error
its manyy lines shall i send one line?
Hello, I want to add a feature where the user manually adds a role to himself, role is pre-determined (1 role), should I do this with reactions or with a button?
MessageFlags.Ephemeral,
line 73
button
can i sharescreen and show u? or smtg?
please send a picture of your code, showing the error
How are you importing MessageFlags
did you make that code yourself?
you're using an outdated api version
using a button, would I be able to disable it for users who already got the role?
can't, you'd just check if they have it and return if they do
oh shoot, how to fix that
yes by adding a simple check. you can choose what you prefer for adding roles
did you make that code yourself? what version of discord.js are you using?
makes sense thanks
can someone explain what a PrimaryEntryPoint is?
─ discord.js@14.24.2
did you make this code yourself
no
who made it then?
idk what that means sobbing
it invokes a discord activity
half is open source rest me with help of chatgpt
ah like the games?
yeah then if you didn't code this then i can't help you
yes
bro
ty
based
it's hard to help someone that didn't make their own code and has no idea how to fix it, especially with code that is outdated and incorrect
can u help me build
i did already
but it would seem like parts of your code still do not work
so i suggest looking at the discord.js guide to start over
yh if i fix, it kills the rest
how does this work exactly,
bot sends a button component in some channel that users click to get a role
bot gets restarted for any reason (re-deployment)
what happens now, is the old button component that was already sent still working?
Do I need to delete it and send it again?
no
any new button pushes will send a new interaction for your bot to respond to irrespective of the message's age or cached status
this means the old will still be working normally right? 😅
yes
got it, thanks again
To get the display name of the member who sent a message, would it be message.author.displayName or message.member.displayName? I'm a bit unsure
author is their User, member is their GuildMember
Despite sounding similar there is a distinct difference between users and members in Discord:
- User: global Discord user data (global avatar, username, tag, id)
- GuildMember: user data associated to a guild (guild, nickname, roles, voice, guild avatar, etc.)
- Conversion: User ➞ GuildMember | GuildMember ➞ User
* Note: Events received in cached guilds will often have both the member and user available, eg.interaction.userandinteraction.member
anyone know why this might be incorrect
Can’t use reply after deferReply
Either remove deferReply (recommended), or use editReply instead of reply
sorry I forgot to change it back to editReply, that's when it breaks
I can do a reply on its own, but when I do editReply after deferring, I get Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
Show the entire error w/ stack trace
Could be bc the deferReply wasn’t awaited tbh
it's a synchronous function tho
Change it to async
It’s returning void anyways
But yea, the deferred state is only updated after the deferReply finishes
node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:253
if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied);
^
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
at UserContextMenuCommandInteraction.editReply (node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:253:48)
at UserInfo.run (user/src/actions/user/UserInfo.ts:11:21)
at Bot.dispatchUserAction (src/core/Bot.ts:197:16)
at Bot.dispatchInteraction (src/core/Bot.ts:181:18)
at InteractionCreate.run (/Users/joey/Documents/Code/bot-lib/user/src/events/InteractionCreate.ts:7:11)
at Client.<anonymous> (src/core/Bot.ts:307:23)
at Client.emit (node:events:508:28)
at InteractionCreateAction.handle (node_modules/discord.js/src/client/actions/InteractionCreate.js:101:12)
at module.exports [as INTERACTION_CREATE] (node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31) {
code: 'InteractionNotReplied'
}
can't without making the base abstract function async too
@noble pendant Please do not send me DMs, I do not know you
Question about ids, what's the scope of defining an ID, is it the whole client? the channel where the component is sent to, or the message containing the component
would it be possible for all djs errors to return a non-zero exit code? I'm currently struggling with a github pipeline because it doesnt halt, even though there is a command deploy error
your question doesn't make sense. which id are you talking about?
That looks like you logged the error, sounds like you caught it, no? That's probably why
like a button, where I give it an id, then I send that button via, channel.send
oh right
hah
💀 did i do anything wrong dming you? just ignore it then
Yes, as per the Server Guide
Is it possible to set a custom profile picture for a bot for a specific guild like i can with discord nitro?
GuildMemberManager#editMe() discord.js@14.24.2
Edits the current application's guild member in a guild.
can you rephrase your question?
Ty!
Use Promise.then nesting if you don’t want to change the base
why my bot can't ban even if it has admin perms
DiscordAPIError[50013]: Missing Permissions
at handleErrors (/home/container/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:148:10)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:417:20)
at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:169:11)
at async _REST.request (/home/container/node_modules/@discordjs/rest/src/lib/REST.ts:210:20)
at async GuildBanManager.create (/home/container/node_modules/discord.js/src/managers/GuildBanManager.js:169:5)
at async BanCommand.run (/home/container/modules/Utility/ban.js:42:13)
at async InteractionCommandHandler.interactionCreate (/home/container/modules/InteractionCommandHandler.js:49:13)
at async BotClient.<anonymous> (/home/container/structures/ModuleManager.js:80:33) {
requestBody: { files: undefined, json: { delete_message_seconds: 0 } },
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/guilds/607686647307304970/bans/1429421261984895039'
}
are you trying to ban the server owner?
- Bots cannot moderate (kick/ban/nickname/...) a target with a higher or equally high highest role or the guild owner.
- Bots cannot modify (edit/add/remove) roles that are higher or equally high compared to the bot's highest role.
- The
Administratorpermission does not skip these checks.
i forgot i did some role reworking those days and yea i put the bot role under the members one so that's why 🥲
Thank you!
Not a super complex question, but I've been trying to figure out how to use these little rich presence icons to the left of the activity (the little green tv, here)
are you streaming in a voice channel at that time?
bot's can't stream video
Not really, I'm using an app that displays what I'm watching on Plex as an activity (similar to Spotify's status)
But if bots just can't show that kind of status that's that lol
oh, well, bot's don't have rich presence, sorry
At least it's an easy solution lmao
do i need attachfiles perms to attach files in ephemeral messages?
doesnt look like it
thanks
np
When will this page be updated? https://discordjs.guide/legacy/interactions/modals
SoonTM
When it's ready. It's in the finishing touches phase
There's a preview link if you want to use the WIP version
Thx
But what do you mean by "It's in the finishing touches phase"
Read the PR. The content is finished, it's just grammar and formatting changes right now
ok thx agine
this is for support with the discord.js library
nvm i figured it out mb
no worries, next time for api-related questions or something about the panel, you can ask in ddevs instead #useful-servers
I am taking emoji input as a string option in a slash command and need to get the id.
I have to have the id because I am storing the emoji in mongodb until a later date and it would seem that a good number of the discord default emoji are not a part of the unicode library so they get borked when I store them.
Unfortunately, from what I cant find in the documentation, there seems to be no way to get the id if you don't already know the name.
I really feel like I must be missing some foundational knowledge here so if I am just an idiot who can't read, feel free to say as much but do please still tell me what I failed to read.
How do you expect to get the emoji without anything to identify it? Be it their name or id. Also do note that emoji name is not unique across servers
I wasn't sure if I had just misinterpreted the documentation. From what I read, what I need seems impossible. Unfortunately, I don't really see any other way to do what I am trying to do in the bigger picture. Take emoji as text, store it, repost it later. Because the client converts it to the image before sending off the command, I was pretty sure this is a dead end, I just wanted to be 100% sure before I gave up on it and moved onto working out another feature.
You can just use modal with text input
but you get both the name and id when you get the command interaction
with the <:a?:name:id> format
So the emoji is buried somehwere in the message structure? I must be too tired to be doing this right now to have not explored that.
well in any string you get from the api, emojis are either in unicode or with the mentioned format
you can then send that same string and it'll show the emoji
basically
const content = message.content; // or any other user input with emojis
await channel.send(content);
should show the original content, including the emojis, without issues, though it must have the use external emojis permission
though if you're sending the content on another guild, then (in addition to the permission), the bot must be on the guild from where the emoji comes from
I am not sure how to get that out of the interaction. getting interaction.options gives me this: CommandInteractionOptionResolver { _group: null, _subcommand: null, _hoistedOptions: [ { name: 'role_name', type: 3, value: 'testing' }, { name: 'role_emote', type: 3, value: '📝' }, { name: 'role_month', type: 3, value: '1' } ] }
Best to rely on the guide and docs
const value = interaction.options.getString(optionName);
Advanced Command Creation
The examples we've covered so far have all been fairly simple commands, such as ping, server, and user which all have standard static responses. However, there's much more you can do with the full suite of slash command tools!
read more
Apparently it’s covered in this part
Then it links to parsing options at the bottom
This is where I think I am missing some foundation. Any time I try to get that data, JS interprets it as a unicode emoji and then breaks the non standard emoji. I understand getting the data out of the command but I need the id. I will continue to play with it for a bit and then revisit this tomorrow if i cant figure it out tonight
Not sure what you mean
Unicode emojis and custom emojis are completely different formats
Custom emojis are always in the form <:name:id> (or <a:name:id> for animated ones)
My issue is that some discord emojis are not in the standard unicode library. 🪨 🪶 and 🫄 are among a few that break in the flow that I have set up
\🪨
Why does the discord bot die after some time of it being online without being used? (Not sending heartbeats or?)
Ah, ur trying to validate Unicode emojis
are you then displaying them in some other platform or something? otherwise you can just send them back to discord and it'll work fine
define "die", does the process stop?
I am storing them in a mongodb instance and that is whats breaking them. I would like to store them as just raw text but I gues I cant get the unicode id of these things.
Not the process stops, it’s like when after a while of not being used it doesn’t register running commands like /help, etc
I don't think there's really much you can do in the discord side, maybe as a workaround you could replace them with something representable on mongo and then "serialize" back to the original emoji?
I'd look into how to make mongo not break with those values, haven't used it
what specifically happens when you try to use commands? and are you using some kind of process manager, or plain node index.js
Should just store it as buffer/bytes?
I don't think there is much I can do since JS doesn't even seem to know what to do with the non standard ones. It gives me the doom rectangle if I try to output them to my console.
Have you tried printing the code points of the string?
Could just be ur console that can’t display them
yeah but you can still send them back to discord and it'll work fine, it's just not a standard emoji so it can't show it
No response when running the commands, and i am use plain node (It’s that i need to restart the server for it to work)
The emojis you mentioned are official https://emojipedia.org/pregnant-person#technical
I get invalid form body when I do and the specific error is "invalid emoji"
Are you putting the Unicode emoji in the name property?
no response as in, it shows "The application did not respond in time"?
Well, nuts. They dont show in the unicode library that I had come to trust. 
Do you have any logging set up in your event handlers to acknowledge that you're receiving the interaction?
Have you tried logging the DJS debug events to see when the heartbeats stop?
when you do what specifically? can you show your code and the error (with the stacktrace)?
Yeah pretty much
pretty much as in yes, or...? since that's a built-in discord error
No errors of any kind from your console?
Well the events aren’t getting called that’s what i think is happening
I try to post them back to a poll as the emoji for one of the entries and get invalid form body.
I will ahve to fire it off o get the error out of it
Nope, just the information like Loaded command: blah and so on
Then that means you're losing your gateway connection...or your application is hanging
then this: #djs-help-v14 message
Ah, any way i could resolve that?
Can't. Without diagnosing what it is...and where it's happening
Both of which can be done with logging
(event) Client#debug discord.js@14.24.2
Emitted for general debugging information.
Ladybugs and Gentleworms, I am an idiot. The array that I had stored in mongodb and was mapping data from was formatted incorrectly!!!
This is your friendly reminder to not write code 4 hours after dinner. You are too tired. Go to bed.
glad you worked it out though
Hello, what would be the correct way to check user's roles from ButtonInteraction? I'm trying to check if user has one of the required roles when clicking the button. It's a bit confusing with these 3 typings
huh, where's that type from?
https://discord.js.org/docs/packages/discord.js/14.24.2/GuildMember:Class#roles
I guess when member is APIGuildMember
You have to make sure the interaction came from a cached guild
Or just type the interaction as such and pass the responsibility onto the caller
ChatInputCommandInteraction#inCachedGuild() discord.js@14.24.2
Indicates whether this interaction is received from a cached guild.
You need this type guard either way
Thank you! So with that I just check roles.cache.has?
Yea
Great. And if user is not cached, it'll auto-fetch his roles?
Interactions come with the user and member
Perfect, thank you!
Is it secure using user uploaded files?
I want to create something like ToS system. I want to give the ability to server owners update their ToS/Privacy Policy by uploading files.
export async function execute({ interaction, options }: CommandOptions<ModalSubmitInteraction>) {
const [tosFile] = options;
const attachment = tosFile.values().next().value
const response = await fetch(attachment.url)
const text = await response.text()
console.log("File contents:", text);
}
Is it secure trusting user submitted files? I think file size is handled by discord as well as the content is displayed only as text. It's stored in discord cdn.
So my bot is going to store the url, fetch and send the file whenever its needed. Is there any security issue in that?
Ur assuming that the file is text?
Also, that url only lasts as long as the interaction does
Files sent via slash commands and modals aren’t stored/accessible forever
You could use the virustotal API to check if files are harmful https://docs.virustotal.com/reference/overview
I remember that there used to be certain characters that would crash iOS devices when rendered
wouldn't exactly be more ideal than just uploading the file for everyone to view
how to check if bot working
Make sure it responds as you programmed it to
If it’s supposed to reply to a specific slash commands, try executing the slash command
Stuff like that
now the bot is online
then i reset the token, how to check is the bot online or offline
Check Discord
no in the code
See if the bot still responds
Oh, you get an error
Well, most likely will get an error if you try to use an invalid token
If ur bot hasn’t alr shutdown due to being disconnected from Discord
there is event like on shutdown
(event) Client#shardDisconnect discord.js@14.24.2
Emitted when a shard's WebSocket disconnects and will no longer reconnect.
There’s prob a node event on process
thaanks
'beforeExit'
The 'beforeExit' event is emitted when Node.js empties its event loop and has no additional work to schedule.
As that description mentions, there’s also a process exit event, depending on ur intentions
The process stuff only fires if you don’t have other stuff running in the code tho
Usually db connections
export const autoRoleAssignment = createEvent(
{
name: Events.GuildMemberUpdate,
},
async (member) => {
await member.fetch(); // with and without, log below shows roles before they changed
console.log(
`member ${member.user.tag} roles: ${member.roles.cache.map((r) => r.name).join(', ')}`
);
}
);
I have this code, createEvent is just a wrapper to create an event object
if the user has no role and I add role A -> log: @eveyone
if I then add role B -> log: @everyone, Role A
how do I get the updated roles list instead of the old list?
Use the second parameter of the event
(event) Client#guildMemberUpdate discord.js@14.24.2
Emitted whenever a guild member changes - i.e. new role, removed role, nickname.
Notice that you get the old and new member in that order
thanks 👍
Is it possible to show some commands only to users that have a specific role?
through the bot integration page on your server settings
Is that the only way? Seems kinda tedious.
No, if you google d.js slash command only for role you'll find a few examples
Its a pretty good way to view all your command and permissions. i dont think thats tedious at all
instead of hard coding it for every server
dont think thats a thing
Do I really need to post more things google is showing me?
the first link is an outdated page. the second link only shows the command permissions. not how to hide a command for a specific role
Also Ctrl+F will probably tell you a lot more about the same question being asked here
those are not the same question
u can better link to a discord js doc instead of showing things that dont exist
see 3rd message
Not to be rude but I don't think this is what I asked for.
thats still not the same question
It is if you are planning to limit it to admin or other permissions
and thats not what they asked
no it's not. they want to hide commands based on what role the user has, which cannot be done through a bot without oauth.
I don't think this will be an issue for me since the bot I'm working on is for a single server.
thats the only way for now to hide commands for specific users/roles/and channels
I think I've seen this somewhere before, so I thought it would be a good thing to not flood all users with staff-only commands.
the only way, without oauth, would be to configure it in the server settings > integrations, itself
Through the server settings? I mean if it's the only option, I guess I'll take my time to set them all up.
Okay, I'll do that. Thanks!
if theyre all the same permissions you can also sync permissions to make it quicker
they want to do it with a role, please read the conversation
Just check the kick permission and you are done, only staff that can kick have the command
?
I did.. he want it for staff, those probably have kick perms
a role, not permissions
Implementation
you cannot hide a command based on a role in code without oauth
Um, wdym? To be honest I hate dealing with perms so I like using roles to verify user's permissions.
Thats why Im saying he can with perms
they don't want to do that though, that is the whole point
You are autisticly focussing on words instead of what he really wants
dont be rude, you're not being helpful on what they want
I'm out
at the very top you can set roles/users/channels that will apply to every command
I don't know what's so confusing about this. Also, I can't just give kick permissions to my support agents @distant inlet.
Then use a perm they all have
you are suggesting them stuff they do not ask for. stop it
I mentioned a few times that what you're suggesting is irrelevant to my needs. Why are you being rude when the only one "autisticly focussing" on what I don't need is you? No need to be rude.
Great, thanks!
Hi guys
Hi how can we help?
When I use :
(àwait interaction.guild.members.fetchMe()).user
All the Bot info are returned but the banner is undefined but my bot as a banner
id: '1332251376968794182',
bot: true,
system: false,
flags: UserFlagsBitField { bitfield: 65536 },
username: 'MultiBrawlBot',
globalName: null,
discriminator: '4977',
avatar: 'e105da50ba02593c33164c44ae126aa3',
banner: undefined,
accentColor: undefined,
avatarDecoration: null,
avatarDecorationData: null,
collectibles: null,
primaryGuild: null,
verified: true,
mfaEnabled: true
}```
```Caught exception: TypeError: AppInfo.displayBannerURL is not a function```
Where did you set the banner?
in discord dev
try force fetching, pass { force: true }
okok i will try
@rose tangle now i have the banner but the same error is not a function
It should be bannerURL()
documentation suggestion for @late apex:
ClientUser#bannerURL() discord.js@14.24.2
A link to the user's banner. See banner for more info
ok thanks i was in the
GuildMember#displayBannerURL() discord.js@14.24.2
A link to the member's guild banner if they have one. Otherwise, a link to their bannerURL will be returned.
ideally you should use that if you want your banner in a server
just in case you set a custom one for that server
im doing a command to see and change the logo, banner and name for each guild
then yeah, use displayBannerURL, but on the member, not the user
oh ok i will try
@rose tangle thanks a lot u saved me a lot of time
Amgelo is big smort
so im trying to add select menu + 3 text input text field in modal form, it is only showing select menu and not the text input field:
const GameServerMenu = new LabelBuilder()
.setLabel("Creator Verification")
.setTextInputComponent(gameIdInput)
.setTextInputComponent(channelProfileLinkInput)
.setTextInputComponent(contentPlatformInput)
.setStringSelectMenuComponent(inGameSrInput1);
verificationModal.setLabelComponents(GameServerMenu);```
so what am i suppose to do? how do i make the 3 rows come?
A label can only hold one component, so you are basically overwriting it everytime
Use separate label for each
can i use actionrowbuilder too? like one label builder and other typical action row?
You can, but action row in modal is deprecated. So better you use label
you need to use four labels one for each interactive component
worked thanks guys!
hi how to create embed like this?
That’s not an embed, that’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
so how to create like this?
Refer to the link above your message
can you help me?
read the guide first than ask for clarification on part you don't understand
Anyone run into this issue before? I tried playing around with DNS servers (as logs indicate), but no luck. tracert gateway.discord.gg says it doesn't exist as well.
[2025-11-04T19:05:04.160Z] INFO: Registered messageCreate listener for tag proxying.
[2025-11-04T19:05:04.160Z] INFO: Attempting to login to Discord...
[2025-11-04T19:05:04.440Z] ERROR: Failed to login to Discord: - getaddrinfo ENOENT gateway.discord.gg
[2025-11-04T19:05:04.442Z] ERROR: Unhandled error during startup: - getaddrinfo ENOENT gateway.discord.gg
[2025-11-04T19:05:04.442Z] ERROR: Error stack: - Error: getaddrinfo ENOENT gateway.discord.gg
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26)
ELIFECYCLE Command failed with exit code 1.
Curl is not happy with it as well:
Fen> curl -v https://gateway.discord.gg
VERBOSE: GET with 0-byte payload
curl : The remote name could not be resolved: 'gateway.discord.gg'
At line:1 char:1
+ curl -v https://gateway.discord.gg
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
I mean, it’s a ws url
yeah, it is just weird since I did get a handshake with this in the past
fetching last 100 messages in 1 channel in guildMemberLeave event will spam the API?
if you do it repeatedly and not one by one, no
wdym by one by one?
i assume you will fetch like this await channel.messages.fetch({ limit: 100 }); ? and not message by message. then youre good
yes but each time for each member leave doesn't spam the API?
it does. but i think djs handles that and will check cache first
okay tnx so I will set it as premium feature to don't do it a lot
if i can ask, why are you fetching messages on guild member leave? there is probably a better way to do what you want
bulk requests don't check cache
only individual ones do
so that will always call the api
good to know
it doesnt without specifying limit right?
and yeah it can be spammy if you're on a guild with frequent leaves/joins, would be better to know the use case to know a workaround
if you don't specify a limit then it'd be an individual fetch, and that does check cache
You know some guys just join to a server and left immediately and then if you seted up Discord Welcome message it could be annoying specially when you set it up in chat channel and your members will say welcome to them but they are not in the server!
So I want to create a feature which remove those messages if user left immediately so I need to fetch the last 100 messages and check if their welcome message is there then delete it
I'd do a LimitedCollection of reasonable size where you store the welcome message ids of each member
then on leave you delete the message (you can pass the id directly to the manager)
as said above. listen for those messages and keep them in memory. then why they leave delete the message. thats a much more efficient and better way
okay tnx so in message create event how can I check those type of messages? I mean what is those messages type
v10: MessageType - UserJoin
read more
the author is the user who joined