#djs-in-dev-version
35223 messages · Page 7 of 36
I guess only certain components can be added to a modal
how did u fix the select menu, i have this ```pl.map((playlist) => {
resultplay.push({
label: ${playlist.name},
value: ${playlist.id},
});
});
const playinput = new ActionRow().addComponents(
new SelectMenuComponent()
.setMinValues(1)
.setMaxValues(1)
.setCustomId("select_playlist_play")
.setPlaceholder("Select a Playlist to play")
.addOptions(resultplay)
);
components[0].components[0].options[0].label[BASE_TYPE_REQUIRED]: This field is required
components[0].components[0].options[0].value[BASE_TYPE_REQUIRED]: This field is required```
like this
.addOptions(
{
label: "DPS",
value: "dps"
},
{
label: "Tank",
value: "tank"
},
{
label: "Support",
value: "support"
}
)
it's not an array
like this ↑
got it
thx
np
Is this not a valid intent?
you have to use enums / numbers. Read the pinned guide preview
oh
iirc you can also use Pascal cased strings here but that's not encouraged to use
ah ok
pain, im guessing this is the slash command options types?
where can i find the new ones, if they are new ones.
BRUH
i tried it for the past hour, but how the am i gonna add to the options, the things i have in the resultplay array
...array
.addOptions(...resultplay)
try this ↑
@fiery anvil
ok
wow that was easier than i expected, now i know something new
thx a lot
no problem
im confused
check pins
thanks
TypeError: embed.addField is not a function
const embed = new Embed()
.setTitle(`\\✨・Nouvelle demande de recrutement`);
embed.addField({
name: "Pseudo Zenith",
value: pseudoZ,
inline: true
})
why ?
removed, use the plural #addFields, same usage
oh ok thx
OH ok
thx
Understood thanks
the .setEmoji in the button component is now a object too?
yes
How to fix it?
you have to use toJSON() on the buttons if you want to pass them in the constructor iirc
will be fixed in the next dev release
ok, thx
Sorry I forgot to reply to this but I meant it should be throwing DiscordAPIError
how can i find the colors as numbers
example 0x7289da
or how can i convert them to numbers using djs
you can use 0x7289da, that's a hex literal
Ik, but what if i want different colors
0x<hex>, you can use a color picker or something
One only receives that error from Discord. That wasn't from Discord, so no, it should not return that
ohhh, ty
https://convertingcolors.com/decimal-color-11010294.html?search=Decimal(11010294) i used this and put the color in the config
so for the .setFooter and .setAuthor field what should be the input, cuz i give it the string but says received undefined
Tag suggestion from @copper jetty:
<MessageEmbed>.setFooter() and <MessageEmbed>.setAuthor() now each take an object:
- embed.setAuthor('This is an example text', 'https://exampleicon.com', 'https://websiteofauthor.com')
+ embed.setAuthor({ name: 'This is an example text', url: 'https://websiteofauthor.com', iconURL: 'https://exampleicon.com' })
- embed.setFooter('This is an example text', 'https://exampleicon.com')
+ embed.setFooter({ text: 'This is an example text', iconURL: 'https://exampleicon.com' })
Why there are many breaking changes in v14
ohh ok
bruh
because it's a semver major version bump. would you rather have a major for each breaking change and end up at d.js v1320?
you can find a reason for the changes in the pins
does discord.js/voice have breaking changes too?
It's probably SelectMenuComponent
this channel is for discord.js@dev, not voice, but afaik no
thats what i thought, lemme try
What?
components has to be an array
pretty self-explanatory, show the code
.addOptions([
{
label: '🎟️Autorole',
description: 'Server Config for Auto Role!',
value: 'autorole',
}, {
label: '🔥Role Keeping',
description: 'Server Config for Role Keeping!',
value: 'rolekeep',
}, {
label: '✅Verification',
description: 'Server Config for Verification System!',
value: 'verify',
},
{
label: '🥣Logging!',
description: 'Server Config For Logging!',
value: 'logging',
},
{
label: '🪙Voice Role',
description: 'Server Config For Voice role!',
value: 'vr',
},
]),
at options: put ...menu
remove the [], you have to use rest parameters
oh
thats so weird
thanks bro
thx
so with the new gatewayIntents if i put it like this it's the same as the v13 form: intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_MESSAGES, ], or do i have to use flags still?
you can either use the enum directly or IntentsBitField.Flags
What does even this mean?
It fails to send the embed
but i don't know why
you tried to send an api request before logging in the client
ehm
The client is logged in
or after destroying it
only possibility of this happening while the client is logged in is a bug where you try to use a wrong token for a webhook which in turn sets your bot token to null
Hmmm
Like this one?
exactly
But how can i find the error for that one?
there's an open pr to fix it, for now you could check for a 401 status and do rest.setToken again
so i could use GatewayIntentBits.Guilds_VOICE_STATES
For befor i havent had this problem befor with v13 but when i changed to v14 it started happen but okay
#7508 in discordjs/discord.js by vladfrangu opened <t:1645277692:R> (approved)
fix(RequestHandler): only reset tokens for authenticated 401s
📥 npm i discordjs/discord.js#fix/rest/reset-token-on-401-only-for-authenticated-calls
it's a bug with the rest lib
or rather with discord sending the wrong status code
will this uninstall v14?
you can't really use this install link
that command wont work out of the box
pascal case
oh yeah
forgot that
What should i do then :/
should i add the error event?
and listen for the 401 status?
you can do that, or wait till the pr gets merged and released
any release date?
or
as always no eta but there's no blocking requested change currently
GuildVoiceStates
GuildMessages
That makes sense
still wont work tho
Nvm found
Thx for the help
the setToken() should be my bot token right?
yes, I think you also have to do <Client>.token = ...
Idk if it resets both
Hmm
This fixed half of my bot
Still learning sry for all the stupid questions
So like this right?
if am not wrong
you don't have to do it in 1 line
setToken is sync, no need to await it. the error event will only be emitted if a listener callback throws btw
But how can i listen for the 401 event then?
error*
catch and handle it everywhere you send something with a webhook
if you want to use the error event await webhook send calls
and check if <DiscordAPIError>.code is RESTJSONErrorCodes.InvalidWebhookToken
how do you set a emoji to a button now
{ name: "emoji here" }
oh ok
ty
Im not using the toJSON function
yeah it's internal
show your error with the stack
const allButtons = [startButton.setDisabled(true), backButton.setDisabled(true), forwardButton.setDisabled(false), endButton.setDisabled(false)]
let group2 = new ActionRow().addComponents(allButtons)
let helpMessage = await interaction.followUp({
content: `Click on the buttons to change page`,
embeds: [em1],
components: [group2],
})
``` code
Spread syntax (...)
Spread syntax (...) allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected.
spread the array and pass that addComponents(...allButtons)
oh
ehm
Looks to be working as intended
Should be validated by zod once the PR is merged but yeah labels on select menu options are required
?
Need to use node 16.9 or higher
Ok thanks
guys in the Modals PR example there is a type ModalActionRowComponent import, how do i require it in js?
You don't need it in js
No that import is only needed for typescript
i removed it thanks but i got this error
Can you show me your entire code
All 250 lines?
The code for the modal
wait that error could be due to the fact that im using messagecollector?
or it doesnt matter?
It doesn't matter
This is all the modal
nothin else
Add TextInput to ActionRow and the ActionRow to Modal
const modal = new Modal()
.setTitle('Add songs to the playlist')
.setCustomId('add_modal');
const ModalTextInput = new TextInputComponent()
.setCustomId('add_modal_text_input')
.setLabel('Insert URLs to add')
.setStyle(TextInputStyle.Short);
modal.addComponents(ModalTextInput)
await i.showModal(modal);
}``` u lost me what do u mean
You need to put the TextInput in an ActionRow
Same as you do buttons etc
oh thats why
Theres an example https://github.com/discordjs/discord.js/pull/7023
const rows = [tvShowInputComponent, haikuInputComponent].map(
(component) =>
new ActionRow<ModalActionRowComponent>().addComponents(component)
);```
this part right>
it gives me an error like this
im gonna try again
you dont need the generics unless youre using TS
You dont use ...rows if its not an array
its only one row
It worked, thx for the patience
im noob for now 🙂
is there a way of checking if the interaction is already replied?
Documentation suggestion for @fiery anvil:
CommandInteraction#replied
Whether this interaction has already been replied to
i need help
i went by everything in discord.js
and im getting errors
send the error
ill send them later
i just wanted to let u know cuz im eating my dinner rn
ok i can send them now
let me find it first
lmao what
whenever i try to add in a new slash command, this pops up
One of your command files don't have data property exported
ive gone by the whole discord.js guide so far
ok
what do i do then
export data property in every command file
how do i do that
this is ping.js
follow the guide again, you likely missed a data: property in one of your command files
thats echo, i copy pasted from discord.js
yeah, you messed up echo
what was i supposed to do
well, compare it to ping.js and you'll work it out
ok thank you
what does module.exports do
is that how i use my slashcommands, and register them
from deploy-commands.js and slash-register.js
i know it exports it from another fiel
I suggest you take some time to learn some basic JS before you start messing with development versions of d.js
where do i start
and how long does it take to learn
few hours
deadass
where do i start
like which one should i click on
@copper jetty
@pallid ice
lmao what?
ik its not v14
and ill ping people if i want to, i was talking to them
secondly, im new here, so i was looking whre to find help
hi
a question Djs dev needs djs builders dev?
generally yes
yes
.setColor(Discord.Util.resolveColor('Green'))
its correct?
You can use just ‘Green’ now in the latest version
TypeError: Cannot read properties of undefined (reading 'resolveColor') at Embed.setColor (/home/liyue/bot/node_modules/discord.js/src/structures/Embed.js:24:32)
wtf?
okay
same
has solution?
replace src/structures/Embed.js with
- const { Util } = require('../util/Util');
+ const Util = require('../util/Util');
TY
alr thank you
welp did modals release?
v14 it's merged, 13 it's still a pr(?)
Question: If canceling a modal isn't indicated against the api, how would I handle a user cancelling a modal and reopening another? Is there a way/example of how to do this with the promises instead of collector?
When i use deferReply on a <ModalSubmitInteraction>, interaction.replied says undefined
await interaction.deferReply({ephemeral: true})
if (interaction.isRepliable()) {
console.log(interaction.replied) //false
}
And trying to reply to it returns 'INTERACTION_ALREADY_REPLIED'
Modals in v14??
you can't reply to already deferred/replied interaction. use editReply()
also Interaction#isRepliable doesn't check the interaction is deferred, or replied.
yes
I know. But interaction.replied should be true or false when i defer the reply to it.
Not Undefined
Nice
The reason why i use isRepliable() is for typings only.
- Yeah it should be false not undefined.
- When you defer replied is still false but deferred will be true
True, i can use deffered instead. Thanks.
Whenever I try editing a ephemeral reply, I get this error. This happens when I click a button, it sends a reply and try to edit it
why?
Do you have fetchReply?
no I dont
Try use that
Like this message.reply({content: "your message", fetchReply: true})
You can't fetch ephemeral reply, use editReply method
Ahh yea forgot that
I'm doin such thing, but it throws an error when it edits the reply
Hmm
Have you tried use deferReply?
If you haven't try use it before you editReply
Use collected.update()
Or do that ^^^
That how i do it. @crude valley
You can't reply twice, update is a reply
Update updates the reply
no
Im gonna test
Try defer the reply and use editReply
You are right. On my side, i'm able to do it as my first reply has a button in it so i'm updating the message from the interaction inside the ephemeral message. Otherwhise, i think you can't edit an ephemeral message.
I would suggest you to simply defer the reply instead of saying please wait. Discord will already show a loading thing
Update updates the message the the component is attached to
Ahh yea
True
ohh
ok give me a sec
The thing works fine, but it throws 2 errors on edit
You will need to use .followUp()

When deffering
what are you even trying to do?
@cerulean bay@urban belfry
okay but what are you trying to do?
edit the message, like what? what's the process?
Also, why are you using a collector?
on collector#collect
what do I use exactly?
A simple interaction. With interaction.isButton() and comparing the customId if the interaction matching the one you've set for the button
Like this, you will not be waiting for someone to click the button
no I want the buttons to expire
that's why I'm using a collector
Then, simply disable it after your timeout instead
Disabled button is better than a not working one
And what's the difference between a collector and interaction create event?
If your bot crashes or reboots, the button will still be working if not a collector.
I mean, the button works fine. but this error is making me confused
mhm I see
I think this issue isn't related to @dev so u can ask in #djs-help-v14
True
ah but the error doesn't show up in older versions, that's why I'm asking here
d
is there any docs for djs v14?
Read pins
Hi, Is there any reason why Discord.Util.resolveColor() isn't working anymore?
not working as in...? show your usage as well
Not to worry, I've figured it out now.
It seems you can't use .setColor(Discord.Util.resolveColor('Blue')) now when building an embed, and after looking at the code and realising that it should now accept a string again as it did with v13, I tried that and it still doesn't work.
I worked around it for now by removing the new colour setter method from the structure.
there's currently a fix in a PR
I noticed it in #archive-github-djs, for now I'll work with my modified structure and wait for the fix before turning all my setColor() methods back to strings.
I must say I am always happy with the help and support offered here.
Did anything change in displayAvatarURL for when i try to get the Bots Avatar URL in png format it still gives it has a webp
and it even shows the formats that i can put
`you're looking at the wrong docs
this is what they take in now https://discord.js.org/#/docs/rest/main/typedef/ImageURLOptions
how do you use Custom Emojis in SelectMenu Options setEmoji(APIMessageComponentEmoji)
The Guide does not mention anything related to that
nor do the Docs explain what an APIMessageComponentEmoji is
Instead of using format: 'png' use extension: 'png'
ahh okay
probably { name: "emoji" }
neh, had to look at code to figure it out

has to be converted to
{
"name": "disableNoSwitch",
"id": "831557873070637066",
"animated": false
}
kinda shitty how they removed the resolvers
they exist on djs, the package, on the util class, not on builders, moving it out to builders means they wouldn't have access to that
probably can be added back to djs builders
How can I collect a modal text input after user submit?
Construct new InteractionCollector or listen to interactionCreate event
Over the interaction event. Check with isModalSubmit() i guess.
isModalSubmit()
Thx ❤️
Can I get an example function for Sweepers.guildMembers.filter?
Hey its me again, So I've been working on the modal submit collector and this works:
let string: string = '';
const modal_collector = new InteractionCollector(client, { interactionType: InteractionType.ModalSubmit, max: 1})
modal_collector.on('collect', async (modal_interaction: ModalSubmitInteraction) => {
string = modal_interaction.fields.getTextInputValue('textinput')
await modal_interaction.reply({content: `Entered ${string}`})
})```
However, I'm wondering if this is the right way to go. Does it work the same as https://discord.js.org/#/docs/discord.js/main/class/Message?scrollTo=createMessageComponentCollector ?
This is the right way to go
ok thanks
components[2].components[0].emoji:
{ id: '946108238737338388', name: 'News', animated: false }
components[2].components[1].emoji:
{ id: '946108238817030174', name: 'Category', animated: false }
DiscordAPIError[50035]: Invalid Form Body
components[2].components[0].emoji[MODEL_TYPE_CONVERT]: Only dictionaries may be used in a ModelType
components[2].components[1].emoji[MODEL_TYPE_CONVERT]: Only dictionaries may be used in a ModelType
whats the issue here
both emojis are valid


new Discord.SelectMenuOption()
.setLabel(<channel>.name)
.setValue(<channel>.id)
.setEmoji(<client>.objectEmotes.channelTypes[<channel>.type]);
<client>.objectEmotes.channelTypes:
"4": { "name": "Category", "id": "946108238817030174", "animated": false },
"5": { "name": "News", "id": "946108238737338388", "animated": false },```
this the code for it
What is c? It's obviously not getting the object, so there is where you begin debugging
missed the edit
was looking at the wrong class to fix
:
Hi guys, is there an example for the modal builder available?
Thanks
Much appreciated.
Hello how can i install 13.7.0 dev version
you can't
Read guide from pins
It's Embed in v14
Is <Client>.user.setActivity() removed in v14?
new Discord.Embed()
no
Don't know why but if I do client.user.setActivity('.help') It doesn't work
guys
can you send an example to create a modal
@scarlet tangle
thanks
would that work?
i dont feel like using the modal constructor
one way to find out
.addChoice() got removed too? ._.
in the sense I dont think it ever existed, probably
in the SlashCommandBuilder
But yeah I think we're shifting to use the plural methods only
I see, thanks
how does .addChannelTypes() work?
takes rest parameters similar to all other plural methods
thanks
how i can get label or min max values of a input text
how does <Embed>#setColor() work now?
You can read docs here https://discord.js.org/#/docs/builders/main/class/Embed?scrollTo=setColor
I did
👍
.setColor(member.displayColor)
TypeError: Cannot read properties of undefined (reading 'resolveColor')
at Embed.setColor (H:\IdrisGaming\Discord Bot\ObitoInteractions\node_modules\discord.js\src\structures\Embed.js:24:32)
at Object.execute (H:\IdrisGaming\Discord Bot\ObitoInteractions\commands\utility\userinfo.js:67:18)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.execute (H:\IdrisGaming\Discord Bot\ObitoInteractions\events\interactionCreate.js:55:17)
at async Client.<anonymous> (H:\IdrisGaming\Discord Bot\ObitoInteractions\Structure\Client.js:48:25)
That's a bug that has a current pull request
any alternative?
No
rip
i can not right?
only type value and customid
Yeah the ModalSubmit doesnt receive those values
F
so they copy paste in the src of djs builders lmfao
...what
in the builders input text there are this.data.label lmfao
and its null for a ModalSubmitInteraction
Not seeing the issue
The label needs to exist in builders
it's going to be removed soon when we don't return builders from the API
is there a way to check to avoid Interaction has already been acknowledged errors?
bruh
how do I get guild id in modal submit interaction
ok its extending Interaction so guild.id
can i collect modal replies through MessageComponentCollectors on Messages or Channels
it seems like i cannot, are there plans to add this?
Use the InteractionCollector
They interactions, not message components
(quick dumb question) does .addField got removed? if yes then what is the alternative? [I got error when adding an Embed with .addField]
plural, same usage
.addFields(...fields), also works with one
oh alr thx
did modals release 😐
its available on the dev branch
Is there a way to put the menus inside the modals?
not yet, more types coming, so far only text input
From no where the setColor on the Embed Not work anymore and its a DecimalColor
So idk what changed
It's a bug
Okay should i do?
use 0x?
or
setColor now takes a number iirc, so 0x would work ig
For i have it like this
Jiralite said theres no alternative so i think you have to downgrade
Have anything changed in setEmoji? to for
{ name: "emoji" }
Ahh ok
So would this work?
just read it is a bug so prob not, didn't know it was there srry
ahh okay
Hi guys
when try to add emoji to selector i've this error
Only dictionaries may be used in a ModelType
{
label: "HTC Vive",
value: "vive",
emoji: "950797639237128252"
},
This is an option ↑
can u help me pls
you want to pass an object to emojis
pass that as emoji:{id: id}
oh
thx bro
Hi , when im trying to get user avatar url
Iw always give me webp format in v14
user.displayAvatarURL({ format: "jpg" })
it's extension now
How ?
const yy = user.displayAvatarURL({ format: "png" })
Didnt work
did you read the linked documentation?
Yes
where did you find format in it?
and my message? ._.
there's no format, there is extension
Ohhh
Thx
Also messagecreate event not working
Discord api was having some issues try again
Hey, where is the MessageComponentsOptions type ?
Do you mean ComponentType
No, MessageComponentsOptions
Where in the source code?
No, it's impossible to import the type
because it doesn't exist
That's what I said

What are you trying to do?
It seems that the components are broken
Go to v14 ( dev )
What?
I develop in Typescript
What code is not working?
The types that correspond to the components are not present in the dev version
{ name: “emojiName” }
They come from discord-api-types
Oh okay ! Thanks !
I have a problem with my node_modules
i get an error that he can't find discord.js
Then I suggest installing it
no i have it installed
npm ls discord.js
i know i know
show it
show the output when using that command
how to make a discord bot
hmmmm
interesting
Follow this https://discordjs.guide/
ight
ty m8
i get something like this?!
again
npm ls discord.js
show the output
k
npm install discord.js@dev
alright, now you move to #djs-help-v14 since thats obviously not dev related 
k xd
I've just noticed that my bot doesn't receive directMessages since i upgraded to djs14. Anyone having this issue?
Yes
Ho, actually, i've disables partials. Let me try that.
I see.
That was the issue. Thanks xD
/Users/nikan/Nikan-Utilities/node_modules/discord.js/src/structures/Embed.js:24
return super.setColor(Util.resolveColor(color));
^
TypeError: Cannot read properties of undefined (reading 'resolveColor')
at Embed.setColor (/Users/nikan/Nikan-Utilities/node_modules/discord.js/src/structures/Embed.js:24:32)
at nikansUtil.<instance_members_initializer> (/Users/nikan/Nikan-Utilities/src/structures/Client.ts:35:110)
at new nikansUtil (/Users/nikan/Nikan-Utilities/src/structures/Client.ts:55:5)
at Object.<anonymous> (/Users/nikan/Nikan-Utilities/src/index.ts:4:23)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (/Users/nikan/Nikan-Utilities/node_modules/ts-node/src/index.ts:1455:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/Users/nikan/Nikan-Utilities/node_modules/ts-node/src/index.ts:1458:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
why do I get this error on Util import?
known bug at the moment
so i'm not really sure if this goes here or in #archive-builders since it's builders @ dev (sorry whoever i pinged), but
do UnsafeModals need to go through @discordjs/rest (like Slash Commands or Context Menus) or can you use them like Buttons or Select Menus?
Neither, you use them with interaction.showModal()
huh

Not sure what else your question wants
no that was it lmao; ig the way i was thinking was like: oh somebody joined a server, lemme throw a modal up in their face 
Nope, its a type of reply :(
interesting, thanks
How do I make interaction.fields.getTextInputValue not throw an error if the field doesn’t exist? (TypeScript)
✨ try catch ✨
Why do you try to get a non existing field tho?
This field will exist if a user selects something in the slash command and will not exist if not
could also make it required (if it should be always present)
if the field is empty it returns an empty string, not error
No, the field will not exist at all
Yes, was talking to mega
Ok
Hello when using the guildMemberAdd Event
Can I get the Inviter ?
no
.addField({name: "Kick", value: `${message.guild.me.permissions.has("KickMembers")? "Yes": "No"}`})```
It shows yes even if it doesn't have the permissions. Any idea why?
Did the <member>.presence.activities change? for everytime i try to eval it i just get null
and one more question did message.args get removed?
message.args? was never a thing
Well it was
or not
nvm it was nothing
I have an engineering question (not sure if this is the right channel). If I'm trying to make my bot configurable for different servers, I should just store the settings in my database mapped to the server ID, right? Or is there a clearly better solution?
Right but this channel is for dev version of discord.js
ah okay
thanks
Hello the messageReactionAdd event Not Working in v14
Where ıcant find
look changes for partials
show full error
How do you add the AttachmentOption type with the discordjs/builders
.addAttachmentOption()
How about normal slash commands?
The same
const command = {
...,
type: 4,
};
Thank You!
type: 'AttachmentOption'?
11
ApplicationCommandOptionType.Attachment
Alright
Documentation suggestion for @latent lion:
Discord Developer docs results:
• Change Log: Interaction Modals and Application Command Attachment Option Type
• Application Commands: Application Command Object
Please don’t recommend magic numbers
they were using them so I gave that too ._.
Oh I missed that ignore me
I am getting this issue: TypeError: (intermediate value).setName(...).setDescription(...).addAttachmentOption is not a function The current version of discordjs/builders I am using is ^0.12.0 should I be using a different version to have the addAttachmentOption()?
use builders dev version
npm i @discordjs/builders@dev
Thanks!
I had a feeling that was the cause
how does it work
try by writing it in PascalCase
or enums
Ok
still doesnt work
How about you show us what you're doing
This isn't a mind reading game
channels aren't bitfields so they should be using enums right?
Please don't send pictures
Yes
if(type === "threads" && !interaction.guild?.features.includes("PrivateThreads")) return await interaction.reply({ content: `:Failure: This server does not have access to private threads.`, ephemeral: true })
You use the GuildFeature enumerable
GuildFeature.PrivateThreads?
Try it and see
O K
Your IDE should autocomplete it
im using pterodactyl
What is that?
its a panel used by a lot of hostings
Yes it worked
Why doesn't streaming activity type work?
needs to be a valid twitch stream url
Let me try
unsure of the rest of the syntax but that's not optional
Wdym?
pretty sure the type is wrong as well
Oh
ActivityType.Streaming
Thanks
Yeah basically you can only fake streaming with a bot or a bot user and/or client mods
I am receiving this error, and I am confused to what could be causing it.
^ it repeats itself multiple times
The .setname command's code is ```js
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('setname')
.setDescription('change the name of a channel')
.addChannelOption(option => option.setName('channel').setDescription('the channel you want to rename').addChannelTypes('GuildText').setRequired(true))
.addStringOption(option => option.setName('name').setDescription('The new name of the channel').setRequired(true))
.addStringOption(option => option.setName('reason').setDescription('The reason for the change').setRequired(false)),
async execute(interaction) {
const Channel = interaction.options.getChannel('channel');
const Name = interaction.options.getString('name');
const Reason = interaction.options.getString('reason') || 'No Reason Provided';
Channel.setName(Name, [Reason]);
await interaction.reply({ content: `I have changed ${Channel.name} name to ${Name} successfully.`, ephemeral: true });
},
};```
use the enum values for addChannelTypes
Okay
Where can I find the enum values for addChannelTypes?
ChannelType.GuildText
Thanks! For future reference where did you find that?
in the docs
Okay.
or you can find it in the source code if you want
Thank You!
I cant find message button in v14 docs for some reason
check the guide
pins
ButtonComponent
Does it work with other urls other than YouTube and twitch?
No, only those two will work.
What is this mean
{ name: 'string' }
thx
Why are UnsafeModal and UnsafeTextInputComponent not re-exported in discord.js?
what's the problem, I cant set color for embed
because it's dev version
It's a bug
yeah
is there already issue for this in github ?
#7615 in discordjs/discord.js by Raiden-Ei opened <t:1646627434:R> (approved)
fix(Embed): fix incorrect destructuring import
📥 npm i Raiden-Ei/discord.js#main
I was testing the new Attachment option but the error says it's not a function
oh cool
send code
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('attachment')
.setDescription('Attach files.')
.addAttachmentOption(option => option.setName('file')
.setDescription('the file to attach.')),
permissions: 'Administrator',
async execute(interaction) {
console.log(interaction.options.getAttachment('file'));
await interaction.reply('Pong!');
},
};```
Yeah I was just asking whether this is an oversight
most likely an oversight yeah, will pr
Do npm ls @discordjs/builders in your terminal and send the output
and your error?
could someone show me how to add a string option for choices? since the documentation isnt complete its very confusing
got it working - for the future if you want to add a single choice you'd do stringoption.addChoices({ name: '', value: '' })
pretty self explanatory, and that is explained in the guide
not self explanatory when you've been using d.js for years and so many drastic changes have been made that break the predictability of the library
also colours in embeds appear to be broken i am unable to set numerical RGB colours or resolvable colours <embed>.setColor('Blurple') / <embed>.setColor('0xFFFFFF')
TypeError: Cannot read properties of undefined (reading 'resolveColor')
known bug
sound
any temp fixes? otherwise I can quickly hook up a temp solution for myself by manually adding back the resolveColor method into the code
you can import the embed from builders directly if you don't use camelCased constructor input or you edit the local file with the fix which is to remove the {} from the util import
otherwise wait for the pr to get merged and released
yeah fixed the import for now
hi, so i ran into a problem whilst updating to the newest dev version
const jumpButton: ButtonComponentData = {
label: "Jump to your DMs",
url: startMessage.url,
style: ButtonStyle.Link
};
const jumpRow = new ActionRow({
components: [jumpButton]
});
interaction.reply({embeds: [successEmbed("Started the application process in your DMs")], components: [jumpRow]});
used this code and ran into the error Error: Cannot serialize component type: undefined, which I found someone asked earlier and components doesn't take an array anymore... so I changed that
const jumpButton: ButtonComponentData = {
label: "Jump to your DMs",
url: startMessage.url,
style: ButtonStyle.Link
};
const jumpRow = new ActionRow({
components: jumpButton
});
interaction.reply({embeds: [successEmbed("Started the application process in your DMs")], components: [jumpRow]});
then i ran into this error TypeError: components?.map is not a function, which wants me to change it back to an array
im a bit stuck, any help?
You need to specify type
ComponentType.Button
components: jumpButton
Keep the jumpButton in array
ty
one more question, curious why this throws a type error
const jumpButton = new ButtonComponent({
label: "Jump to your DMs",
url: startMessage.url,
style: ButtonStyle.Link,
});
const jumpRow = new ActionRow({
components: [jumpButton] // ERROR HERE
});
Type 'ButtonComponent' is not assignable to type 'APIMessageActionRowComponent | APITextInputComponent'.
Type 'ButtonComponent' is not assignable to type 'APIButtonComponentWithURL'.
Types of property 'url' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
it works fine with my method above using a ButtonComponentData object, but not a ButtonComponent
It needs to be in an action row
Oh wait nvm
yeah thats why i did the mistake of forgetting ComponentType earlier, I switched from ButtonComponent to ButtonComponentData and forgot to add the type back
but i prefer ButtonComponent because of the camelCase customId so just wondering why this throws that error, i can use ButtonComponentData object but its not ideal
hi, for addChannelTypes, i see that it should be taking rest params (but docs doesn't show it properly), any example for this?
nvm got it to work, missed out on a bit in my code
how is the "manage permissions" permission called?
I dont think theres manage permissions permission
ManageChannels
nope that doesnt work
thats ManageRoles
Ok
It says channels permissions
but discord
good for you that you can read, doesn't matter tho
ManageChannels is just the channel name and stuff
why
seems like you have no perms to send msg to the channel
No perm to create the channel*
probably a good idea to check your bot's actual permissions, that tick screen is just an invite url generator...
i used to set the presence like this, client.manager.init(client.user.id); client.user.setPresence(client.config.presence); client.log("Successfully Logged in as " + client.user.tag); but now it gives me this error TypeError: Cannot read properties of undefined (reading 'presence')
Do you need the webhook intent to make webhooks works or??
Do you have it in the ready event?
yeah
doesnt seem like a d.js error, make sure your "config" property is actually set
oh ok
Thx u were right
someone know what is this ? (node:18624) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time (Use `node --trace-warnings ...` to show where the warning was created)
you can ignore it
does ChatInputCommandInteraction was the new BaseCommandInteraction?
ChatInputCommandInteraction different from BaseCommandInteraction iirc, you might be looking for CommandInteraction instead
Did the <member>.presence.activities change? for everytime i try to eval it i just get null
If the member is offline, its null
Or if the presence isnt cached
<Embed>#setColor() now takes a ColorResolvable?
not just a number?
Yes
interaction.channel.send({embeds: [new Discord.Embed().setTitle('hi').setColor(Discord.Util.resolveColor('AE6800'))]})
whats wrong
i need help
#AE6800
how do i make this
Read this https://discordjs.guide/popular-topics/embeds.html but apply v14 changes
tf no
status: "online",
activities: [
{
name: "Music on a few guilds",
type: "LISTENING",
},
],
});``` this code doesn't give me errors but dont show up on discord either
Use enums instead of strings ActivityType.Listening
have to import it?
yes
You can't use something that isn't defined
Thank you
guys, i used to use this way in V13
const client = new Discord.Client({
intents: Object.keys(Discord.Intents.FLAGS)
})
how can i do it in V14?
GateawayIntentBits
Don't use all intents, choose the ones you need
i want them all
i don't want to type them all
btw this haven't worked
Uncaught TypeError TypeError: Object.hasOwn is not a function
update Node.js to 16.9.0 or newer
ok
it worked, thank you
Code: ```js
const TextInput = new Discord.ActionRow().setComponents(
new Discord.TextInputComponent()
.setLabel('Label')
.setCustomId('customId-example')
.setPlaceholder('type:')
.setStyle(1)
)
await i.reply({ ephemeral: true, embeds: [Embed], components: [TextInput]})
```console
DiscordAPIError[50035]: Invalid Form Body
data.components[0].components[0][COMPONENT_TYPE_INVALID]: The specified component type is invalid in this context
what is the problem?
You need to add that ActionRow to Modal
i will see
Worked, thank you
Btw setColor should be fixed now
gonna bump this here, any solutions?
why is there a error?
oh, figured it out, I did { name: ... } instead of { text: ... }
only icon and not icon_url
It’s iconURL
it doesn't matter both work
icon doesn’t I’m 99% sure
It’s iconURL not icon
Yea meant icon_url and iconURL will work
Oh
Oh this is the dev version
format isn't an option anymore, it's extension now
and dynamic is now forceStatic
@willow garnet can u help me
just a lil help
#rules 6 dont ping people for help
May i know the reason why Embed#addField is removed?
Because we have addFields() which does the exact same thing, but can do multiple
the same change will be happening across all builders as well, so addComponent will be removed etc
But now we need to pass objects
you had to pass objects to addField anyway even if it wasn't removed?
MessageEmbed#addField(name, value, inline)
that was for v13, in @dev it was changed to use an object
Thats my issue
its been discussed many times and this is the change that came out of it, it's easier to have a single method that can do one or multiple
My problem is now i have to construct an object for each fields
oh no, we need to add a few more characters and now we have intellisense for field options and it removes a useless method... yeah I'm team addFields ngl
i find it easier to use addFields, can just create an array of fields and spread them into the method, saves having loads of addField... i feel it actually declutters rather than creates more
You could also do that in v13
But anyways, i can define Embed#addField by my own, i don't want to talk about it anymore
Where can we now find APIErrors that lived under Constants?
RESTJSONErrorCodes enum
i use addField more because if i get any error it will then declare which line aka which block of field generated that error which is difficult to find in addFields
i would suggest to add addField back as it's useful
you can just use multiple addFields?
can we?
why you can't?
i thought we can use only one lmao
then there's no issue
yep
it has been removed yes
What's the new way of initializing a MessageActionRow? Apparently it isn't a constructor anymore: js new Discord.MessageActionRow()
Read the pins
So you couldn't have told me it was just js new Discord.Modal()
...
Considering that's still wrong, no
It worked
A modal != action row
oh sorry got it fixed now
why is custom ids now required for URL buttons?
It’s not
v14 is out?
Pins
I kept getting the error with a url button and I added a custom I'd and it's gone now
That's a bug if that's the case, but you might not have correctly changed the button style to the new input?
can u share ur code?
yeah i think theres a problem with button typings, for example:
const jumpButton = new ButtonComponent({
label: "Jump to your DMs",
url: startMessage.url,
style: ButtonStyle.Link,
});
const jumpRow = new ActionRow({
components: [jumpButton] // ERROR HERE
});
Type 'ButtonComponent' is not assignable to type 'APIMessageActionRowComponent | APITextInputComponent'.
Type 'ButtonComponent' is not assignable to type 'APIButtonComponentWithURL'.
Types of property 'url' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
correct me if im wrong, its just no one has given me a solution so im assuming there is probably none
What's inside of the startMessage.url variable?
startMessage is just a message url
it’s not a problem with that, i’ve even used a ButtonComponentData object with the same info it’s just the ButtonComponent which is messing it up
Hmmm
Maybe try use the beta builder
There's a fix for this in a PR
How do I use modals?
Check out the guide on creating, sending and receiving modals here:
https://deploy-preview-1060--discordjs-guide.netlify.app/interactions/modals.html
awesome thanks
Np
Also will the .showModal() function be added in ModalInteraction event?
Ask discord
?
Oh it's Discord's API limitation?
oh you mean responding to a modal with another modal
Mhm
yeah discord api limitation
So we can make a big form
Oh sad
C:\Hydro\node_modules\discord.js\src\structures\Modal.js:6
class Modal extends BuildersModal {
^
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (C:\Hydro\node_modules\discord.js\src\structures\Modal.js:6:21)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Hydro\node_modules\discord.js\src\index.js:127:17)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
Node.js v17.5.0```
I get this error when I update to the latest version of discord.js@dev
Show the code for BuildersModal (where you import it)
I don't import it
Oh that's from discord.js
Yes
Are you using a modal anywhere?
Nope
So is this a bug ?
I think so I haven't seen that b4
Nvm
I uninstalled discord.js@dev
and reinstalled it
Also, How do I show modal to a specific channel ?
Look at the guide, link is in pins
It says about interaction
what bout message ?
Also was .addField changed again ?
TypeError: (intermediate value).setTitle(...).setThumbnail(...).setDescription(...).addField is not a function```
.addField({name:"About Me:", value:"I am Gamecord. A Bot Made To Display Game Stats Directly in-to your servers.\n I Do This With The Help Of Official And Unofficial API's.",inline: false})```
This is where the error is coming from
What's ur builders version? npm ls @discordjs/builders
I don't have it installed
gamecord@1.1.0 C:\Hydro
└── (empty)```
Can you run it anyways?
there you go
Use npm why instead of npm ls
kk.
C:\Hydro>npm why @discordjs/builders
@discordjs/builders@0.13.0-dev.1646913825.dcd4797
node_modules/@discordjs/builders
@discordjs/builders@"^0.13.0-dev" from discord.js@14.0.0-dev.1646914074.dcd4797
node_modules/discord.js
discord.js@"^14.0.0-dev.1646914074.dcd4797" from the root project```
Oh right, the singular method was removed
You can safely change it to addFields (plural)
ooof
Iirc you can respond with model only for interactions
Though I don't think so...
A Person Made This
And this is a command, so it will obviously use message.
a button is an interaction
so How do I show modal using it ?
<ButtonInteraction>#showModal ig
I'll let you know if that works...
did anything change for button emoji it keeps returning me a cracked error
var _this = _super.call(this) || this;
^
ZodError: [
{
"code": "invalid_type",
"expected": "object",
"received": "string",
"path": [],
"message": "Expected object, received string"
}
]
at new ZodError (F:\Hurricane\node_modules\zod\lib\ZodError.js:81:28)
at handleResult (F:\Hurricane\node_modules\zod\lib\types.js:115:21)
at ZodObject.ZodType.safeParse (F:\Hurricane\node_modules\zod\lib\types.js:192:16)
at ZodObject.ZodType.parse (F:\Hurricane\node_modules\zod\lib\types.js:173:27)
at ButtonComponent.setEmoji (F:\Hurricane\node_modules\@discordjs\builders\dist\index.js:3:4858)
at Base.run (F:\Hurricane\Src\Interface\Commands\Base\Security\antinuke-wl.js:151:79)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
issues: [
{
code: 'invalid_type',
expected: 'object',
received: 'string',
path: [],
message: 'Expected object, received string'
}
],
format: [Function (anonymous)],
addIssue: [Function (anonymous)],
addIssues: [Function (anonymous)]
}
any idea? how can i fix it?
provide an object
with what properties?
id, name and/or animated
i see but if its a inbuilt discord asset cuz they don't have ids
I think you do { name: '🍴' }
ok i'll try thanks for helping me out
theres a pr to accept emoji strings
#7616 in discordjs/discord.js by suneettipirneni opened <t:1646667379:R> (changes requested)
refactor: allow button builders to accept emoji strings
📥 npm i suneettipirneni/discord.js#discord.js/refactor/allow-emoji-strings
Do autocomplete responses not accept an array of objects or something?
AutocompleteInteraction#respond()
Sends results for the autocomplete of this interaction.
Same as v13
actually, why are they not using var args
Same thinking xD I'll make a pr today
Ig this is the only method left which accepts array
error
Bot is online!
C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\commands\help.js:9
const exampleEmbed = new MessageEmbed()
^
ReferenceError: MessageEmbed is not defined
at Object.execute (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\commands\help.js:9:28)
at Client.<anonymous> (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\index.js:51:37)
at Client.emit (node:events:520:28)
at MessageCreateAction.handle (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:23:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketShard.onPacket (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:447:22)
at WebSocketShard.onMessage (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:304:10)
at WebSocket.onMessage (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\ws\lib\event-target.js:199:18)
at WebSocket.emit (node:events:520:28)
Code
const { Embed } = require('discord.js')
module.exports = {
data: {
name: 'help',
description: "help how to use this bot",
},
execute(message, args){
const exampleEmbed = new MessageEmbed()
.setColor('#ff2436')
.setTitle('Help')
.setDescription('This command is a help command')
.addFields(
{ name: 'Commands', value: '-about\n-help\n\nAdmin commands\n-ban\n-kick' },
{ name: 'Roles', value: 'Owner = Owner of the roblox server\nDiscord Owner = Owner of the discord server and me the bot\nHigh Mod = High Mod in discord and ingame\nMod = Mod in discord and ingame\nAdmin = Admin ingame\nVerifyed = Players\nBots = Bots in discord\n' },
)
.setTimestamp()
channel.send({ embeds: [exampleEmbed] });
}
}
thats common sense
no its not
Yes it is. How can you use MessageEmbed() when you import Embed
makes sense
error'
Bot is online!
C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\zod\lib\types.js:175
throw result.error;
^
ZodError: [
{
"code": "invalid_type",
"expected": "number",
"received": "string",
"path": [],
"message": "Expected number, received string"
}
]
at new ZodError (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\zod\lib\ZodError.js:80:28)
at handleResult (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\zod\lib\types.js:115:21)
at ZodNullable.ZodType.safeParse (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\zod\lib\types.js:191:16)
at ZodNullable.ZodType.parse (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\zod\lib\types.js:172:27)
at Embed.setColor (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\@discordjs\builders\dist\index.js:1:5975)
at Object.execute (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\commands\help.js:10:7)
at Client.<anonymous> (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\index.js:51:37)
at Client.emit (node:events:520:28)
at MessageCreateAction.handle (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:23:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\ander\Documents\GitHub\RedLands-Discord-Bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) {
issues: [
{
code: 'invalid_type',
expected: 'number',
received: 'string',
path: [],
message: 'Expected number, received string'
}
],
format: [Function (anonymous)],
addIssue: [Function (anonymous)],
addIssues: [Function (anonymous)],
flatten: [Function (anonymous)]
}
anyone knows this?
const { ApplicationCommandType, ApplicationCommandOptionType, Embed, Util, Modal, TextInputComponent, TextInputStyle} = require('discord.js');
module.exports = {
name: 'modal',
description: 'Bakaa',
type: ApplicationCommandType.ChatInput,
/**
*
* @param {Client} client
* @param {CommandInteraction} interaction
* @param {String[]} args
*/
run: async (client, interaction, args) => {
try{
const modal = new Modal()
.setCustomId('myModal')
.setTitle('My Modal');
// Add components to modal
// Let's create our text inputs
const favoriteColorInput = new TextInputComponent()
.setCustomId('favoriteColorInput')
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle(TextInputStyle.Short);
const hobbiesInput = new TextInputComponent()
.setCustomId('hobbiesInput')
.setLabel("What's your favorites hobbies?")
// Paragraph means multiple lines of text.
.setStyle(TextInputStyle.Paragraph);
// An action row only holds one text input,
// so we need one action row per text input.
const firstActionRow = new ActionRow().addComponents(favoriteColorInput);
const secondActionRow = new ActionRow().addComponents(hobbiesInput);
// Now we need to add our inputs into the modal
modal.addComponents(firstActionRow, secondActionRow);
// Show our modal
await interaction.showModal(modal);
} catch(e) {
return interaction.followUp(`\`\`\`js\n${e}\`\`\``)
}
}
}```
Code of modals^
Read the updated docs
where are they
How are you even coding without reading docs -_-
BRINGS ME BACK TO START
// at the top of your file
const { MessageEmbed } = require('discord.js');
// inside a command, event listener, etc.
const exampleEmbed = new MessageEmbed()
.setColor('#0099ff')
.setTitle('Some title')
.setURL('https://discord.js.org/')
.setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })
.setDescription('Some description here')
.setThumbnail('https://i.imgur.com/AfFp7pu.png')
.addFields(
{ name: 'Regular field title', value: 'Some value here' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Inline field title', value: 'Some value here', inline: true },
{ name: 'Inline field title', value: 'Some value here', inline: true },
)
.addField('Inline field title', 'Some value here', true)
.setImage('https://i.imgur.com/AfFp7pu.png')
.setTimestamp()
.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
channel.send({ embeds: [exampleEmbed] });
code on the website
this is for the stable version
not main (dev)
Yeah.
Anyone got working modals? Or what am I doing wrong here?
but idk how i downloaded the dev i follow turtorial on yt
try to understand what you're doing then
Also ping me when helping with modals
There's a tutorial on YouTube for dev? O_o
probably when passing v12 to v13 ._.
no there is not i cant find them
the deploy preview just has the v13->v14 changes guide, which is also not always up to date
other guide pages are not updated
Shouldn't it be
if (!interaction.isChatInputCommand()) return;
instead of
if (!interaction.isCommand()) return;
Also the latest discord.js dev version is showing this error whenever i start my bot
make sure to install the latest builders dev release. You might have to delete your lockfile for it to prompt you to pick one
ah ok ill try it
can u send what the builders package is? I dont use that so idk
you do use that, it's a dependency on discord.js, just delete your lockfile and reinstall all deps
ohok
what error are u getting?
.
Your error is a dot? ;o
What's your dev version?
the issue is that they're on the latest djs dev but the builders dev is outdated because the repo uses workspace versions, which don't update and require a clean install
const { Client, ActionRow, CommandInteraction, ApplicationCommandType, ApplicationCommandOptionType, Modal, TextInputComponent, TextInputStyle } = require("discord.js");
module.exports = {
name: "modal",
description: "returns websocket ping",
type: ApplicationCommandType.ChatInput,
/**
*
* @param {Client} client
* @param {CommandInteraction} interaction
* @param {String[]} args
*/
run: async (client, interaction, args) => {
const modal = new Modal()
.setCustomId('myModal')
.setTitle('My Modal');
// Add components to modal
// Let's create our text inputs
const favoriteColorInput = new TextInputComponent()
.setCustomId('favoriteColorInput')
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle(TextInputStyle.Short);
const hobbiesInput = new TextInputComponent()
.setCustomId('hobbiesInput')
.setLabel("What's your favorites hobbies?")
// Paragraph means multiple lines of text.
.setStyle(TextInputStyle.Paragraph);
// An action row only holds one text input,
// so we need one action row per text input.
const firstActionRow = new ActionRow().addComponents(favoriteColorInput);
const secondActionRow = new ActionRow().addComponents(hobbiesInput);
// Now we need to add our inputs into the modal
modal.addComponents(firstActionRow, secondActionRow);
// Show our modal
await interaction.showModal(modal);
},
};
code^
You can't reply twice
how am I replying twice?
showModal is a reply
what shud I do then? In docs that is only given
?
does your command handler always defer the interaction?
the only way that could be happening is if it's being deffered or replied somewhere else in your handler
What is the maxiumium length of customId of a BTN?
100 characters
okay
am I missing something?
awaitModalSubmit isn't a thing
Oh I thought it was based on doing some searching
how do I retrieve the modal responses?
It is in v13 not v14 yet
interactionCreate event or construct new InteractionCollector
so something like this?
yes
how come it doesn't collect the response?
Magic numbers oh no
You passed wrong componentType or wrong interactionType in collector options
You can use <Interaction>.isModalSubmit()
Got it, I removed the componentType. Which componentType would it come under anyway?
It's probably like ActionRow or something
Modals aren't components
oh gotcha, explains why it's optional
Responding to an autocomplete interaction with
interaction.respond([
{
name: 'Option 1',
value: 'option1',
},
])
returns
DiscordAPIError[50035]: Invalid Form Body
data.choices[0][MODEL_TYPE_CONVERT]: Only dictionaries may be used in a ModelType
data.choices[1][MODEL_TYPE_CONVERT]: Only dictionaries may be used in a ModelType
I was told that it's still the same as v13 but...?
It takes rest parameters probably instead of array
interaction.respond({
name: 'Option 1',
value: 'option1',
})
``` returns the same error though
How now i know the channel type (String)
If i do channel.type it returns a number
Send full error
use a dictionary
well uuuh read the rest?
AutocompleteInteraction#respond()
Sends results for the autocomplete of this interaction.
the example ^
did you read what i said?
It looks the same
wasn't for you but for this message #djs-in-dev-version message
yeah but going with the docs brings up the same error and that guy was replying to me
does modals has opportunity to check if provided data match some regex pattern
no but you can do it client side
wdym
like send error message ?
you internally check if the data they provide matches your regex pattern, discord doesnt do it
On my code this works:
<Interaction>.respond(["Option 1"].map(choice => ({name: choice, value: choice})));
that sends an array of choices, that is exactly what i did 
Array of objects
yes?
you're contradicting yourself 10 
Strange, don't recall if it was changed or not. Read the source?
Nah they're referring to me
it is planned to be a rest parameter, i'm not sure if it already changed
it wasnt changed, it takes an array
why the sudden change to rest params instead of arrays?
it wasnt changed
no, i meant for other stuff
Heads up everyone, in the next dev release components will be renamed. Instead of having a “Component” suffix they’ll have a “Builder” suffix. For example ButtonComponent -> ButtonBuilder
I’ll try to update the guide later tonight when I get home
whyy
#7584 in discordjs/discord.js by suneettipirneni merged <t:1647110363:R>
refactor: Don't return builders from API data
Yeah
Embed
Read pins
broadcastEval takes a function instead of a string since v13
that wasnt changed
Help Plis
Code
let test = new Discord.ActionRow()
.addComponents(
new Discord.SelectMenuComponent()
.setCustomId("test")
.setPlaceholder('Test')
.setMinValues(1)
.setMaxValues(1)
.addOptions({
label: "test",
description: "test2",
value: "test"
})
)
Error
TypeError: Cannot destructure property 'components' of 'undefined' as it is undefined.
v14 dev
did they make a change?
because it's coming from the discord.js source
cc @velvet jasper
Oh dear lol... I think the import should be from builders now and not discord.js
what
Don't worry it's not relevant to you
alr
but someone explain to me what that is
It's an error x_x
It's because of a bug
uh
from?
Not from you, from discord.js
alr
ok
thanks ig
What vps/application it is may I know?
@uncut kelp srry for ping but whats SelectMenuBuilder etc...
ButtonComponent => ButtonBuilder?
Ya
.
I edited the index.js in the discord.js module to fix it
same
Modals only support TextInputs right?
Yes
looks like it's running pterodactyl
why do i get this error while running the code
ig thats an error from the package's side
const client = require("../index");
client.on("interactionCreate", async (interaction) => {
// Slash Command Handling
if (interaction.isChatInputCommand()) {
await interaction.deferReply({ ephemeral: false }).catch(() => {});
const cmd = client.slashCommands.get(interaction.commandName);
if (!cmd)
return interaction.followUp({ content: "An error has occured " });
const args = [];
for (let option of interaction.options.data) {
if (option.type === "SUB_COMMAND") {
if (option.name) args.push(option.name);
option.options?.forEach((x) => {
if (x.value) args.push(x.value);
});
} else if (option.value) args.push(option.value);
}
interaction.member = interaction.guild.members.cache.get(interaction.user.id);
cmd.run(client, interaction, args);
}
// Context Menu Handling
if (interaction.isContextMenuCommand()) {
await interaction.deferReply({ ephemeral: false });
const command = client.slashCommands.get(interaction.commandName);
try{
if (command) command.run(client, interaction);
} catch(e) {
interaction.followUp({content: `\`\`\`js\n${e}\`\`\``})
}
}
});
My interaction create event