#djs-in-dev-version
1 messages · Page 31 of 1
I'm not using builders, how can I set it autocomplete ?
I just have to add autocomplete: true in the options array, right ?
I think they’re talking about it in the guide I sent
ah no
yes
Turns out embed coloring with EmbedBuilder is case sensitive with color names
so you have to type Red not RED
Hm?
For v14 currently in the dev build
when you use new EmbedBuilder.setColor()
if you want to use a color name like RED or BLUE you have to make it Red or Blue, its case sensitive
Not sure if this is considered a bug just a slight annoyance.
Enumerables are like that
Yeah just wanted to point it out
Because in previous discord.js versions it wasn't like this
I mean they can just do a .toUpperCase()
Yeah cause it’s ModalBuilder
k thz
SelectMenuBuilder
Class used to build select menu components to be sent through the API
in previous discord.js versions a lot of things weren't the way they are now
thats kinda the point for certain things
is there any major change in v14?
yes, many
is it possible to edit a modal already sent ?
editModal ?
No
k thz
v14 is a matter of days or weeks?
im planning to write a new bot and im trying to figure out if i should wait for a couple more days or just use 13.8.0
Definitely not days I would think
<interaction member>.permissions changed?
no, but u can also use
CommandInteraction#memberPermissions
The permissions of the member, if one exists, in the channel this interaction was executed in
i have this error when using the guildCreate event and apparently it is not an error in my code
I mean v14 works pretty well currently
I updated it for the modals
dev version shouldn't be used in production 😶
...and i'll be too lazy to change my code later if anything in dev will change
well its a private bot for a few servers anyway
so im fine with it
Also
is the discordjs/builders context menu different from the djs one
cause when using djs I have to set the type as 2, referring to a user type
that's for v13, in v14 you probably need to use the enum instead
I am on v14
the guide has not been updated for v14 yet
alr
I don't why I am getting this error since I upgraded my pakage.
client.channels.cache.get(process.env.ERROR_LOG).send()
Tag suggestion for @green plume:
• The provided id is incorrect (copy role ids from context menus, not message mentions)
• The client does not have this structure cached (try fetching instead)
• The client is not yet ready (move the code into any event listener callback)
Every thing is correct.
If all was correct you wouldnt get an error
As you see in the eval ss I have used the exactly same code which I use in the main code.
Read the third statement of the tag
Just because it works in an eval doesnt mean that it will work everywhere in your code, the client needs to be logged in
Well it used to work previously. But after updating my package I am facing this issue.
Did v14 change the embed?
TypeError: MessageEmbed is not a constructor
at Object.embed (C:\Users\whes1015\Desktop\B-MPR\B-MPR-Release\core\structure.js:22:30)
at Object.main (C:\Users\whes1015\Desktop\B-MPR\B-MPR-Release\core\console.js:35:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
see pins 13 > 14 guide
NewsChannel (extends BaseGuildTextChannel)
Represents a guild news channel on Discord.
shall i learn v13 of djs now or v14 later
CategoryChannel#children
A manager of the channels belonging to this category
CategoryChannelChildManager#create()
Creates a new channel within this category. (more...)
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: VIEW_CHANNEL
where can i find bitfield flags
@ dev uses PascalCase, so ViewChannel
(or use the enums)
https://discord-api-types.dev/api/discord-api-types-payloads/common#PermissionFlagsBits
k thz
PermissionFlagsBits is reexported in djs
CombinedPropertyError (6)
Received one or more errors
input.guild
| UnknownPropertyError > guild
| Received unexpected property
|
| Received:
| | Guild {
| | id: '80....',
etc
at js ButtonBuilder.setEmoji(client.emojis.resolve("852246257366990878"))
the emoji should be a "APIMessageComponentEmoji"
it expects an object with name, id and animated
if its a default emoji, only name is required, if its a custom emoji id is required, if its animated, id and animated are required
how do i access to <EmbedBuilder>.fields ?
embedbuilder.data.fields?
k
is it possible to hide or disable a textinput on a modal ?
no
How do you get all members that have a specific role (not only cached)?
Fetch all members the iterate over them and check their roles
anyone know how to check if an embed image url is a well formed url so that i don't get errors like this?
Well formed urls starts by https:// or http:// so verify if it starts with it
ah okay then ill do just that
That has nothing about context menu types
I’ll just look on the discord docs
two types
MESSAGE
USER
No like enums
User is 2, message is 1 I assume
ApplicationCommandTypes? @jaunty comet
discord-api-types have ApplicationCommandType enum
Message is 3
Thanks
It has ones for context menus?
if only he bothered to google what he was already answered
here if u want to make sure https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types
Alr
have intents changed? i am getting this following error: ```
throw new RangeError('BITFIELD_INVALID', bit);
^
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: Guilds.
at Function.resolve (C:\Users\HiTech\Desktop\hjs\node_modules\discord.js\src\util\BitField.js:152:11)
at C:\Users\HiTech\Desktop\hjs\node_modules\discord.js\src\util\BitField.js:147:54
at Array.map (<anonymous>)
at Function.resolve (C:\Users\HiTech\Desktop\hjs\node_modules\discord.js\src\util\BitField.js:147:40)
at Client._validateOptions (C:\Users\HiTech\Desktop\hjs\node_modules\discord.js\src\client\Client.js:550:33)
at new Client (C:\Users\HiTech\Desktop\hjs\node_modules\discord.js\src\client\Client.js:76:10)
at Object.<anonymous> (C:\Users\HiTech\Desktop\hjs\index.js:20:13)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
[Symbol(code)]: 'BITFIELD_INVALID'
}
```from this code: new discord.Client({ intents: ['Guilds', 'GuildMessages', 'MessageContent'] })
npm ls discord.js
oh, i seem to be using the wrong version. Sorry
I tried giving v14 a spin today and the first thing I noticed is that the return type of SnowflakeUtil.generate() no longer matches the declared type of Snowflake.
The type of Snowflake in discord-api-types@0.33.5 is type Snowflake = string, however SnowflakeUtil.generate() in @sapphire/snowflake@3.2.2 returns a bigint.
Where did discord-api-types comes from
Its a dependency of discord.js
I just don't understand how it affects your problem
You're trying to use a generated snowflake in one of discord.js's methods?
No, I was using SnowflakeUtil.generate() to generate ids for related information in a database. In v13, this method returns a string. In v14, it now returns a bigint.
If you want a string just stringify it
Regardless of the type of Snowflake, changing the return type for generate() is a breaking change that isn't obvious at first glance.
well, technically, the major version changed between v13 and v14
Yes, you can .toString() it, but I had to go back and verify that the return value from SnowflakeUtil.generate() in v13 returned a decimal formatted number to ensure I just needed to do SnowflakeUtil.generate().toString() and not SnowflakeUtil.generate().toString(16) for hexadecimal (or something else). And that was to verify the result matched the format I would expect in my database.
That's fair, but It seems arbitrarily inconsistent to have SnowflakeUtil.generate() return something else. At the very least I would hope that would be called out in a breaking changes document somewhere (assuming you have something like that, I couldn't find one for v14 so far).
It's not a major issue, just an inconvenience and I wanted to clarify whether it was an intentional change or just overlooked.
that's fair
You should always use bigint for DB, if you're using it for it, btw
How is that relevant
But if you want a string, you can just do so with bigint.toString() or String(bigint), the utility just outputs the raw result from the operations, so if you want to use bigint, you can do so without further perf impact
as I said, it just boils down to intent. Was the change in return value intentional or overlooked? I was able to catch it quickly because I use TypeScript and was warned at compile time. If you're using this from JS you might only find out if/when something breaks.
The change in return was intentional, yes
Is it expected that all Snowflake values in discord.js and discord-api-types (or any other related packages) will remain as string, or will those also eventually become bigint to match?
Doesn't matter
It's @sapphire/snowflake, a third-party package, not discord.js nor any @discordjs/ package
And it represents better with the internal representation of snowflakes after all, Discord stores snowflakes as bigints
They just send them as strings because JSON doesn't support bigint
so why does it matter what do they store it as
And we don't convert them back to bigints because that requires a lot of extra steps
So no, it's going to be a numeric string
Yes, but it replaced the built-in SnowflakeUtil and wasn't exactly a drop-in replacement. I'm just pointing out the inconsistency that exists now, and only asking whether that inconsistency will be addressed or left as is.
And the return type of the utility won't change either
Hopefully it won't forever, assuming https://github.com/tc39/proposal-json-parse-with-source is standardized.
Separate question: Is v13's Permissions.resolve() now PermissionsBitField.resolve() in v14?
Permissions is PermissionsBitField
Thanks
Hmm. In the TS types there doesn't appear to be anything that satisfies JSONEncodable<AtachmentPayload>, which is the type expected for MessageOptions.attachments. Both Attachment and AttachmentBuilder have toJSON(): unknown. Possibly a bug in the definitions?
Not sure if this is a v14 thing or not: I'm coding a command that restricts permissions for regular members, but my bot gets the Missing Permissions error when attempting to execute channel.permissionOverwrites.set(). My bot has Manage Roles and is not trying to edit overwrites for a role higher than its own. I followed the v14 upgrade guide as well, so I'm using the latest syntax.
That error is from Discord, not discord.js
That's fair. I guess I should ask on Discord Devs then.
I wish it would tell me which permission was missing. 
TypeError: Cannot read properties of undefined (reading 'path')
at findName (/app/node_modules/discord.js/src/structures/MessagePayload.js:240:17)
at Function.resolveFile (/app/node_modules/discord.js/src/structures/MessagePayload.js:254:31)
at /app/node_modules/discord.js/src/structures/MessagePayload.js:221:85
at Array.map (<anonymous>)
at MessagePayload.resolveFiles (/app/node_modules/discord.js/src/structures/MessagePayload.js:221:56)
at TextChannel.send (/app/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:174:50)
at logEmbed (file:///app/util/functions.js:52:46)
at Object.execute (file:///app/events/loggers/messageUpdate.js:36:68)
at Client.<anonymous> (file:///app/structures/handlers/events.js:24:67)
at Client.emit (node:events:527:28)
what could be causing this issue?
all I'm doing is running:
client.channels.cache.get(targetChannel).send({ embeds: [embed], files: attachments });
(targetChannel is a string of the channel ID)
related to https://github.com/discordjs/discord.js/issues/8031 possibly?
note that this issue only appeared very recently, after some update (unsure which)
it only happens when sending an attachment from what I can tell
How are you defining attachments
Also it needs to be an array
When was the last update for dev version?
6 hours ago
new AttachmentBuilder(…)
AutocompleteInteraction (extends Interaction)
Represents an autocomplete interaction.
@regal mason #app-commands
nvm
What's the problem in this?It says invalid bitfield flag or number
Can you show the full error?
Can you show line 13? The error is from there.
It was my handler issue and I fixed it
since modals got released in v13.7.0 what are new features in v14 other than renamed stuff
pins
thx
ah thanks!
wait so arrays of Attachments can't be used anymore?
I think you just can’t build it
at least looking at https://discord.js.org/#/docs/discord.js/main/typedef/BaseMessageOptions seems you can, but that might be outdated I'm not sure
alright after more digging I assume it has something to do with this commit: https://github.com/discordjs/discord.js/commit/dfadcbc2fd50be64c8a0c1cae3be10f83678c5ee
so I will use new AttachmentBuilder() instead, thanks!
djs v14 is coming shall i keep learning v13 or wait for v14
You just need to learn logic and js. V13, v14 doesn't matter u just need to rename some stuff and change some logics. So just learn v13 now and migrate to v14 when it comes.
It was removed
Just check the type of interaction instead
I'm trying to narrow down an Interaction to be either a AutocompleteInteraction or CommandInteraction. Before I used to do this with two typeguards: if(!interaction.isCommand() && !interaction.isAutocomplete()) return;, but #8027 removed both of these. What I got from the other PR mentioned in #8027 is that you can just typecheck by comparing the type field, but that doesn't seem to work:
if (
interaction.type !== InteractionType.ApplicationCommand &&
interaction.type !== InteractionType.ApplicationCommandAutocomplete
)
return;
const { commandName } = interaction; // TS Err: Property 'commandName' does not exist on type 'Interaction<CacheType>'
// 'interaction' is still of type Interaction
So, how do I now typeguard interactions?
How many TextInputs i can add on modal? is it 5 or 25 like other interaction
5
well rip
cant replicate
but actually why is the type "Interaction"
if you're using the interactionCreate event, it should be AnyInteraction
Yeah exactly what Almeida said
oh yeah, using AnyInteraction fixes it, thank you! I was handling the interaction in a separate utility function where I passed it as Interaction
I just updated the discord.js and it throws me this
something changed?
i set the client type to the Client you can import from djs and i get this error, anyone know why?
If it's meant to be a ready client, type it to be Client<true>
ty! that fixed it
I think the preview needs to be updated
8027
has interaction.isChatInputCommand() been removed?
and interaction.isModalSubmit()?
if so ill change those
yes
ight
interaction.type === InteractionType.ModalSubmit
uhm what am I supposed to use now that interaction.isAutocomplete() is removed?
not sure if its a problem on my side but interaction.options.getSubcommand() isn't working, is it removed or something?
interaction.type === InteractionType.ApplicationCommandAutocomplete
What does "isn't working" mean
oh thanks
showing an error: interaction.options.getSubcommand() is undefined
hold on let me check if its an error on my side
undefined is definitely a developer issue
Is InteractionType.ApplicationCommand the proper replacement for isChatCommand()?
That never existed
Is that directed at me?
what? if you enter something bigger than 2000 characters in the slash command option you get an api error
is there a way to prevent this?
...don't?
isChatInputCommand still exists
what if a user does the same? you know what ill try to put it in a try catch block
Sorry, that's the one I meant. So that isn't one of the typeguards that was removed?
I don't understand how that will affect your bot
Nope
I see. Well... I guess I could use it, but now my code is inconsistent. lol
I miss the method type guards tbh, they looked cleaner
I liked them, too. I'm sure there is a good reason for removing them, but I wonder why some were removed and not others.
What are you even doing here? I don't understand how you get this error if someone just passes 2,000 characters in an option. You must be doing something
The ones removed were the ones that just checked for one single type
isChatInput for example was kept bc it checks type and commandType
okay here's what i do to recreate: copy and paste a paragraph or something that's more than 2000 characters like this
You can still do it manually if you want consistency
and I get an invalid form body api error
Yeah I'm considering it, heh.
Where did you get that error from?
discord api
Was it sent to your bot?
wat
if (
interaction.type === InteractionType.ApplicationCommand &&
interaction.commandType === ApplicationCommandType.ChatInput
) { ... }
@cyan jewel
I'm thinking you were sending a message that was too long, and didn't handle it
harder to know without the full error
Discord just doesn't send you errors like that, you're doing something with the data that is
If a user can send it, so be it
Probably looks like you just tried to resend the message
Yeah that's what I was thinking. A lot more verbose, though. Autocomplete is the only outlier that needs the new syntax, so I think I'll just leave it for now. Don't want to bikeshed this when I'm so close to shipping. 😅
Well chatinput is a method as well
interaction.reply(`**${interaction.options.getString('message')}** has been translated to: **${res.data.binary}**.`);
Is it because I'm getting past the message character limit due to the user sending a long option?
knew it
how can I prevent this?
by checking the length
or catching
what? if you enter something bigger than 2000 characters in the slash command option you get an api error
This message was missing a LOT of context in what you were doing for your error, hence the confusion
ah okay
sorry about the confusion, english isn't my first language lol
Well, now you know
I meant autocomplete is the only check in my command handler that no longer has a method. All the rest still have methods.
Bots can only send 2,000 character messages, but embed descriptions can have up to 4,096 characters
still sending the same error even after i check the length, could be my problem
Probably checking in the wrong place
Also look what you sent above
#djs-in-dev-version message
You're sending whatever the user puts alongside text already. You need to check for a number less than 2,000
did the presence stuff change bcs my bot isnt setting the presence js client.user.setPresence({ activities: [{ name: "your favorite vibes • /help", type: "LISTENING" }], status: "idle", });
it only sets that its idle
I believe the type of activity is a number
and where do i get that number from
Documentation
ty
https://discord-api-types.dev/api/discord-api-types-v10/enum/ActivityType
Or use this enumerable
You would do import { ActivityType } from "discord.js" then in your type put ActivityType.Listening
aight ty
how do I get an interaction's customId?
Property 'customId' does not exist on type 'Interaction<"cached"> & InteractionResponseFields<"cached">'
@velvet jasper shouldn't this narrow the type or am i just missing something really obvious?
Hmmm, it definitely seems unintended
Yeah, are you on the latest dev version?
yeah I just updated
what's the difference between Interaction and AnyInteraction?
oh it's just a union of every interaction lol
Yeah class hierarchies are open, unions are closed
TypeError: Cannot read properties of undefined (reading 'resolve') when dealing with webhooks..?
known issue
what's the recommended fix for now?
don't deal with webhooks for now or use an earlier commit
alr
https://sean.does-co.de/QTwxAKF6 whats that?
Flags are PascalCase in v14, not SCREAMING_SNAKE_CASE
How can I access them?
ok
ok so its from VIEW_CHANNEL to ViewChannel?
and from SEND_MESSAGES SendMessages?
Yup
ok
Okay I did this now like this?
https://sean.does-co.de/J3f4rTLM
is this right?
global? 🤔
Uncaught Error Error: Cannot find module './INTEGRATION_CREATE'
Require stack:
- c:\Users\jpedr\Desktop\Visual Code\Node.js\Botter V4.1\node_modules\discord.js\src\client\websocket\handlers\index.js
- c:\Users\jpedr\Desktop\Visual Code\Node.js\Botter V4.1\node_modules\discord.js\src\client\websocket\WebSocketManager.js
- c:\Users\jpedr\Desktop\Visual Code\Node.js\Botter V4.1\node_modules\discord.js\src\client\Client.js
- c:\Users\jpedr\Desktop\Visual Code\Node.js\Botter V4.1\node_modules\discord.js\src\index.js
So this error keeps the discord js library to load at all, djs version: discord.js@14.0.0-dev.1654906231-c7391db
Yea, we're aware
Oh, I didn't know, sorry for bothering
No, you're not bothering
You're actually the first person I've seen to talk about this lol
We welcome things like this ^^
Anything before commit c7391db
Okk, I will look for it, thanks
This version works 14.0.0-dev.1654862727-0415300, for anybody seeing that error: npm i discord.js@14.0.0-dev.1654862727-0415300
Oh, got it, thanks
Yea
thanks
How to use isModalSubmit() and isAutocomplete() after https://github.com/discordjs/discord.js/pull/8027 ?
Help
ok, i found answer, tysm
read like several messages above
interaction.type === InteractionType.ApplicationCommand?? Did I need to import the InteractionType?
no... downgrade your djs
wdym?
^
or wait till https://github.com/discordjs/discord.js/pull/8065 get merged
BTW wdym downgrade?
install a lower version of djs which doesn't has the bug, see what Jiralite said
How do I install it?
receiving this error when using AttachmentBuilder
assuming that AttachmentBuilder is the v14 version of MessageAttachment of v13
Look this
Hi guys, with the latest dev release the integration event handlers are missing from /src/client/websocket/handlers.
I have to comment out the requirements in order to successfully start my bot.
wait till https://github.com/discordjs/discord.js/pull/8065 get merged
Also I'm getting bigint serialisation errors when trying to create commands with default member permissions, whether I stringify the permissions or not.
if you manually provide it as a string, how would that error out on json serialisation for bigints?
I have no idea at all.
After making changes to the command transformer I was able to make it work, I'll submit a PR.
Interaction has already been acknowledged.
await interaction.deferReply({ fetchReply: true });
await interaction.editReply({ embeds: [embed], components: [menu] });
const msg = await interaction.fetchReply();
const collectorMenu = msg.createMessageComponentCollector({ componentType: ComponentType.SelectMenu, time: 180000 });
collectorMenu.on('collect', async i => {
if (i.user.id === interaction.user.id) {
if (i.customId === 'menu') {
switch (i.values[0]) {
case 'shop_option': {
const menuShop = new ActionRowBuilder().addComponents([
new SelectMenuBuilder()
.setCustomId('menuShop')
.setPlaceholder('Select roles')
.addOptions(Components),
]);
await i.update({ content: 'Select roles from the menu below', components: [menuShop], ephemeral: true });
const msg1 = await i.fetchReply();
const collectorMenuShop = msg1.createMessageComponentCollector({ componentType: ComponentType.SelectMenu, time: 180000 });
collectorMenuShop.on('collect', async shop => {
if (shop.user.id === interaction.user.id) {
for (const value of Components) {
if (shop.values[0] === value.values[0]) {
await shop.update({ content: 'Like a successful purchase :)', embeds: [], components: [], ephemeral: true });
}
}
} else {
shop.update({ content: 'This menu does not belong to you!', ephemeral: true });
}
});
} break;
}
}
} else {
i.reply({ content: 'This menu does not belong to you!', ephemeral: true });
}
});
You should stop collectorMenu when updating, since it’s still the same Message and both collectors will collect the next SelectMenuInteraction
didn't help, same error
Which of those many lines gets you the error though? Hard to determine with three different interactions in your code… Show full error stack
DiscordAPIError[40060]: Interaction has already been acknowledged.
Tag suggestion for @upper stirrup:
• DiscordAPIError: Interaction has already been acknowledged
• [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
You have already replied to the interaction.
• Use <Interaction>.followUp() to send a new message
• If you deferred reply it's better to use <Interaction>.editReply()
• Responding to slash commands / buttons / select menus
error referencing this line:
await i.update({ content: 'Select roles from the menu below', components: [menuShop], ephemeral: true });
any update on webhook bug?
DiscordAPIError[40060]: Interaction has already been acknowledged referencing this line await i.update({ content: 'Select roles from the menu below', components: [menuShop], ephemeral: true });
collectorMenu and collectorMenuShop collects the same select menu interaction and both replies to it.
well, I need to have another menu in one menu, how can I do this so that there is no error
Guess you acknowledge that interaction somewhere else (maybe in your interactionCreate event?)
Oh, you don’t check customId in second collector…
what does it mean with Path??
new AttachmentBuilder(…)
i Replace this with that??
hi
I cannot install @discordjs/opus on replit
yep
new AttachmentBuilder('url', { name: 'attachment.jpg' }) for example
Ok Thanks
not something we can fix, replit is just bad
Its merged now
const { InteractionType } = require('discord.js');
client.on('interactionCreate', async interaction => {
if (interaction.type === InteractionType.Autocomplete) {
if (interaction.commandName === 'sourcebin') {
const focusedValue = interaction.options.getFocused();
const choices = ['JavaScript', 'TypeScript', 'HTML', 'CSS', 'Text', 'Java', 'Ruby', 'Phyton', 'C#', 'C+', 'C', 'JSON'];
const filtered = choices.filter(choice => choice.startsWith(focusedValue));
await interaction.respond(
filtered.map(choice => ({ name: choice, value: choice })),
);
}
}
});```Why its not working?
And also what is InteractionType.Ping for?
It’s an interaction discord sends to make sure the client is still responding. Djs responds to it internally only HTTP interaction handlers get it so it never fires in interactionCreate event
Ok
Already fixed my lib :)
Is there a reason that the type isn't getting narrowed to AutocompleteInteraction, or can I just assume that this is a vscode issue?
mine its working
so probably just an issue with the IDE, got it
is interaction typed as AnyInteraction?
Ah, I had it as just normal Interaction
That fixed it, thanks!
InteractionType.ApplicationCommandAutocomplete
components[0].components[1][COMPONENT_LAYOUT_WIDTH_EXCEEDED]: The specified component exceeds the maximum width
const row = new ActionRowBuilder()
.addComponents([
new ButtonBuilder()
.setLabel("Modifier")
.setStyle("Primary")
.setCustomId("edit_product-" + res.id),
new SelectMenuBuilder()
.setPlaceholder("Modifier le statut")
.setCustomId("edit_status-" + res.id)
.addOptions([
{
label: "Public",
value: "publish"
},
{
label: "Brouillon",
value: "draft"
}
]),
new ButtonBuilder()
.setLabel("Images")
.setStyle("Primary")
.setCustomId("add_images-" + res.id),
])```
an action row can only have 1 select menu
or 5 buttons
you cant have buttons and a select menu in the same action row
How can I check if a user has permission to run a command in perms v2?
const { MessageEmbed, Permissions } = require('discord.js')
if (!message.guild.me.permissions.has([Permissions.FLAGS.SEND_MESSAGES])) {
return message.reply({
embeds: [
new MessageEmbed()
.setTitle("***You don't have the permission to do that!***")
.setColor("#cc0000")
]
});
} ```
you specify default_member_permissions field on your command and discord will hide those cmd from those who doesnt have perms (unless server admins overwrite that)
No I want to check if a user have permission to use the command which is set by an admin
discord hides commands for those without the required permission
ik but I want to use it for other purpose
like if a member uses my message cmd, I want to check if they've perms to use my slash cmd
if they've only then run the command
/check-perms command?
?
There is literally no answer to your question other than what Almeida said? :thinking:
Discord hides it from people who don't have permission, so how were you expecting to test them running the command
run my message cmd (prefix cmd) with the same name. And I want to see if they've perms to use my slash cmd (with that name) then run the prefix cmd
Yeah, exactly, this would be the workaround. Make a command that checks the permission of the command they want to use but that sounds ugly imo
You aren't getting what I mean
But this is exactly what I said
no lol
see I'm giving an example.
like I've a cmd a. This command can be used from/a or using my prefix like !a. Now an admin can set permission for the slash cmd. And that command will be hidden. But that user can still use my message command. So before running my message command, I want to see if the slash command is available to that user then run the message command else don't
easy, delete your message command and tell your users to not disable slash command suggestions instead, that way they will get /a if they type !a or ~a or really any other common or uncommon prefix
well I also don't want to use a lot's of extra lines of code to make my command message and slash compitible but my users don't uses slash command lol. But nvm I'll figure out
There's an error when sending dynamique autocomplete with Integer argument
The interaction is not received on the event interactionCreate
how to fix?
That's way too big. If you really think there's an error, make a minimal reproduction sample. You're also on an old dev verison
hey
how to fix?
Dont ask every few minutes the same question repeatedly 
hi how can i check if the user that ran the interaction is alone in a vc
interaction.member.voice.channel.members.size would be 1 (add some checks or optional chaining to make sure they actually are in a VC before)
ty
no look what should i do?
Tag suggestion for @undone yew:
To help you we need more information:
• What are you trying to do?
• What is your code?
• What errors and debug logs do you have?
my code?
attach a listener to debug (client) and rateLimited (client.rest)
Client#rest
The REST manager of the client
debug
I'm added rest.on
no changes
what should I do?
good question, so it's just stuck at preparing and never gets past that?
What exact version are you on?
any updates on the webhook fix?
"discord.js": "14.0.0-dev.1654689812-1afae90",
i updated discordjs latest version
no changes
yes
ModalSubmitFields
Represents the serialized fields from a modal submit interaction
Is there a reason why the message.content is empty, when it's not??
do you have the message content intent enabled?
Attach to the restDebug event of client.rest too please and try again
i will try tomorrow
yes
in the dev portal and in your code?
yes
Guys I have a page system with buttons from v13 and It dont work in the current dev version + dont drop errors before I post code here Is there a change between v13 and v14 with collectors?
the bot receives the message from the api, but then when I console log it, it's empty.
hmm that shouldn't happen if you have it enabled
Only that an ignore event was added, but no breaking changes in collectors itself that I‘m aware of
Without code, we cannot tell either what the issue may really be
Yeah all good I post the code now I had the hope that there was a change or something xd
Thats my code (a snippet from the actual event) https://sourceb.in/GywBj9MKll
client.sendE is a function to send a embed (reply with editReply check)
Yeah, that's why I'm confused.
So you have GuildMessages and MessageContent intent?
yes
And is your bot verified?
no
Very weird indeed then…
Yeah, message content is empty when I log it
did u save after fixing the intents "typo"? :P
const client = new Discord.Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences
],
})``` I think so
Did you already show how you receive and log the message anywhere? @kind carbon
No
if (message.author.bot) return;
console.log(message.content)
})``` Rn just testing to see why it isn't working
yeah yeah
do u have message content intent?
Yes, it's enabled on the dashboard
So no MessageContent intent here
it also must be in client constructor
Alright, fixed. Thanks
Anyone know why this dont response?
Add some console.log and find out what part gets or doesn’t get called
ok
When sending a message through a webhook, I'm getting this error. return this.client.channels.resolve(this.channelId);
does the bot have permissions to see this channel?
yes
What error? I only see a line of code
that line is the error
How is that an error
TypeError: Cannot read properties of undefined (reading 'resolve')
nvm that was the first thing that came up in the error lmao
Are you sending the webhook message before the client is ready?
nope, the webhook message is sent in the messageDelete event
Mind showing the full errorstack?
yeah, webhooks are broken
Oh, okay that explains it
uh how di i fix that lol
https://c.lunish.nl/95Fc.png
I dont find anything for that in the guide is there a change? or why this dont work?
https://sean.does-co.de/1AlfLVtS

AttachmentBuilder
thx
AttachmentBuilder
Represents an attachment builder
Plas help how to display the number of deleted messages and how to delete a message after a certain time has passed.
The timeout option has been removed from the Message#delete method.
- message.delete(5000)
- message.delete({ timeout: 5000 })
+ setTimeout(() => { message.delete() }, 5000)
deleted messages from bulk delete?
No, deleting messages in a specific chat, with a specific value
so... from bulk delete?
downgrading typescript worked somehow
When I try to send a saved webhook this error comes?
https://sean.does-co.de/1zpo0i4E
That's a discord.js bug. This will fix it: https://github.com/discordjs/discord.js/pull/8038
So I need to wait? or what?
:eyes:
It needs to be merged. Then released. Then you install it. Then all's good with the world
or downgrade (to pre 7917)
Wouldent that fucks my whole code?
It's dev. Anything will fuck with your code
xD
Downgrade or manually implement that pull request's fix - up to you
I mean thats currently the only problem I got with dev
And a collector bug but thats something diffrent
We do not provide any help with third party libraries
Buttons and Modals are supported natively.
• Buttons: learn more
• Modals: learn more
why does this not work? it just return as a file.jpg file
That’s the default name
You should set the name of the attachment
What is this?
https://sean.does-co.de/8zL2MBxG
you passed 10 as a number to an embed field value without stringifying it
Ahh ok thx
And whats with that?
https://sean.does-co.de/sxsxJqLZ
Is there a way to check this cuz its a user config value?
Call parseInt on it manually
Okay thank you
Any suggestion how do I convert the Enums to String? Because I want string in my slash cmd type instead an Enums
Enums aren't strings though and it doesn't accept strings anymore
I mean js if (file.type === 'ChatInput') file.type.replace('ChatInput', 1)
IDK if that works
u r using replace instead of assigning
I'm attempting to update my old canvas code and have been testing by following this:
https://discordjs.guide/popular-topics/canvas.html#basic-image-loading
For some reason, line #15 is returning attachment: undefined
I have replaced MessagedAttachment with Attachment
Any ideas what my mistake is?
How would I achieve something similar in the dev version?
Like alternative to BaseCommand / ContextMenu interaction
Thanks! What about the ContextMenu one?
Ah seems to be ContextMenuCommandInteraction
Why was this done? How can I use getBoolean now 🤔
I see, I try to differentiate using the type property but I guess this type error is blocking:
All fixed now 👌
How do you use these now?
Yes why not?
And also please help
U want to replace string with enum right? If u use replace, It'll be a string ('1') and not a number (1).
So what do I need to do?
Thanks for this, do you have a example for the interactionCreate event by any chance or would you be able to help rewriting my old one? https://sourceb.in/aZxpeKPMf2 I can rewrite the type guard parts like isCommand but for the other stuff I have no clue, there's also no type alternative to isContextMenu
Seems like it was isContextMenuCommand, I rewrote it to this now: https://sourceb.in/XB7y4JwKmE
I see so the second check is not needed
Yup but I'm further narrowing more down
Currently I have this: https://sourceb.in/gbbh9DqMlE and I only get errors wherever I refer to interaction in my try block
not sure why this didnt narrow the type
Any idea how to check for this properly?
Smaller version ```ts
const isSlashCommand =
interaction.type === InteractionType.ApplicationCommand &&
command.type === ApplicationCommandType.ChatInput
try {
if (isSlashCommand) {
if (command.conditions) {
const conditionsResults = await Promise.all(
// condition: (interaction: ChatInputCommandInteraction<"cached">) => Promise<boolean>
command.conditions.map((condition) => condition(interaction))
)
Argument of type 'ChatInputCommandInteraction<"cached"> | MessageContextMenuCommandInteraction<"cached"> | UserContextMenuCommandInteraction<"cached">' is not assignable to parameter of type 'ChatInputCommandInteraction<"cached">'.
Type 'MessageContextMenuCommandInteraction<"cached">' is not assignable to type 'ChatInputCommandInteraction<"cached">'.
Types of property 'commandType' are incompatible.
Type 'ApplicationCommandType.Message' is not assignable to type 'ApplicationCommandType.ChatInput'
```
ChatInput is an application, but not a slash command
How can I check if it's a slash command properly?
are you already checking this
I may be wrong, but you need to assign the type CommandInteraction
// condition: (interaction: CommandInteraction<"cached">) => Promise<boolean>
CommandInteraction (extends Interaction) (implements InteractionResponses)
Represents a command interaction.
Thanks, not sure why that is the case though. This errors too:
await command.execute(interaction, interaction.locale)
Argument of type 'ChatInputCommandInteraction<"cached"> | MessageContextMenuCommandInteraction<"cached"> | UserContextMenuCommandInteraction<"cached">' is not assignable to parameter of type 'ChatInputCommandInteraction<"cached">'.
Type 'MessageContextMenuCommandInteraction<"cached">' is not assignable to type 'ChatInputCommandInteraction<"cached">'.
Types of property 'commandType' are incompatible.
Type 'ApplicationCommandType.Message' is not assignable to type 'ApplicationCommandType.ChatInput'.
The else if (isContextMenuCommand) { part does work, for some reason it's not narrowing properly in the if block
Okay I had to change the check to
const isSlashCommand =
interaction.isChatInputCommand() &&
command.type === ApplicationCommandType.ChatInput
```Let me know if I can refactor / improve something 😅 https://sourceb.in/yz3LJB1OD3
help js .addRoleOption(option => option.setName('role') .setDescription('The role that will become the dj role') .setRequired(true) .addChoices({ name: 'role', value: 'role' })),
im unable to disable a select menu
I dont think you can add choises ro role options
Only integer, number and string iirc
ok ty
[
SelectMenuBuilder {
data: { type: 3, custom_id: 'info', max_values: 1, disabled: true },
options: [
[UnsafeSelectMenuOptionBuilder],
]
}
]
this is the select menu builder data after i disable it, it still does not get disabled even though it says disabled: true
Did you edit the message with the edited components?
return interaction.editReply({ components: [InfoEmbedComponents, InfoButtonComponents] }).catch(() => null);
yes
oh
my bad, i didnt defer
nvm
defer isnt needed as long as i have replied within 3 seconds right?
i can still edit after i have replied to it
You can edit after reply yes
Remove the .catch and see if it errors
ok found the error
[
ButtonBuilder {
data: { type: 1, components: [Array], emoji: undefined, disabled: true }
}
]
in here emoji is undefined
RangeError: Buttons must have a label and/or an emoji
but i have given an emoji
Why is that ButtonBuilder of type ActionRow?🤔
Then it shouldn’t show ButtonBuilder anymore though
yeah i just realised that but i cant do InfoButtonComponents.components since it doesnt take an array
and i have 2 emojis so i can do InfoButtonComponents.components[0] either
InfoEmbedComponents = new ActionRowBuilder()
.addComponents([
SelectMenuBuilder.from(InfoEmbedComponents.components ? InfoEmbedComponents.components[0] : InfoEmbedComponents).setDisabled(true)
]);
InfoButtonComponents = new ActionRowBuilder()
.addComponents([
ButtonBuilder.from(InfoButtonComponents.components ? InfoButtonComponents.toJSON : InfoButtonComponents).setDisabled(true)
]);
toJSON**()**
Because you access the whole ActionRow there, not a button inside of it
then tell me, what can I do to access two buttons
Maybe not build a row and rebuild it from that row later on but build it once you know what you need?
i only need to disable the buttons of that row, so..
see, I have two buttons, it works perfectly fine if i do InfoButtonComponents.components[0] but that would only disable 1 button of that ActionRow and I have two buttons instead of 1 so how do I disable both at once?
OH
i could just add another .addComponents
nvm, thanks
no changes
how to fix this issue?
what's the problem here? I don't see her yet
I fixed it here: #djs-in-dev-version message
Needed a isChatInputCommand() check to check if it's a slash command
Look, ChatInput is not a command, but a message or user interaction, you need to use the checks provided by the library and then everything will work for you
Does the hook send the information though?
But this is from the library?
And the check works, besides that I trust TS which didn't give me any error so should be fine now
no channel is empty
apologize. I just got something mixed up. to check that the interaction came from the slash command, use .isChatInputCommand(), and if you have an interaction from the application, then use .isMessageContextMenuCommand() or .isUserContextMenuCommand()
Yup that's what I applied in the end
I'm not sure if I can improve the code https://github.com/daniellwdb/akira/blob/development/src/events/interaction-create.ts, I have a duplicate if / else-if block only to satisfy TS :/
So REST isn’t sending anything from your host apparently
could you open a network monitoring tool of some kind to find out if the REST requests do even get send and/or if something is blocking them or their responses from arriving at its destination? Because at this point I‘m unsure if it’s your network or a djs bug. @undone yew
aaaaaaaaa how to check now that the interaction is Autocomplete
interaction.isAutocomplete() there used to be this function, where did it go?
Let me check the firewall, maybe it's blocking it.
compare its type property to InteractionType.Autocomplete
@exotic rain do you need help with something else or did you succeed?
So?
alright then
It's all good now, thanks, if you have any code improvements I sent the full file above
Is there any solution to my problem?
What did your research regarding firewall/network traffic show?
i thought there was no nodejs ni authorization on the firewall but there is
I will run netstat -an in cmd for 1 minute
I couldn't find any results. Is it okay if we ask the Contributors for help?
not much they can do either
if you are listening to debug and aren't even getting here "Fetched Gateway Information":
https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/client/websocket/WebSocketManager.js#L132-L144
there isn't much we can do - you could attempt to put logs or breakpoints in the source code to find out where exactly it's stuck, following it all the way from Client#login
from what i saw you got here https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/client/Client.js#L229-L234
at "Preparing to connect to the gateway..."
and the next thing that happens, is this #connect call
so you must be stuck somewhere inbetween there
so the only line that i could imagine feasibly hanging is https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/client/websocket/WebSocketManager.js#L138
what exactly do i need to do?
set breakpoints or logs around that area, see where execution reaches, what the values are, etc.
so how do i set the breakpoint?
#resources > debugging, we can't teach you how to use your IDE here
as said, you can also set console.logs
I run it with VSC's debug mode and still no details :|
In my eyes the most important next step would be to find out if the node process sends any network packets at all. I still think there might be something blocking the rest call to reach discord‘s API. VSC should have a way to monitor network traffic from the debug process
At least tell what the source of your error was. In case others get the same
I added listener with process.on, I couldn't solve this resolve issue
Webhooks are broken
How do I do that???
Is it not any docs about it??
new AttachmentBuilder(...).setName
Hmm ok
or new AttachmentBuilder('url', { name: 'attachment.jpg' })
I did that
It still said file.jpg
Ahh now it works weird i forgot to change it But thanks
help
i have the following type error. What can I do to only get the GuildMemberRoleManager?
you want to use the interaction.inCachedGuild() typeguard to narrow the interaction to be on a cached guild
since on raw member objects, .roles would be an array of ids
on a cached guild, interaction.member would be a djs GuildMember and .roles on that would be the manager
does djs automatically cache the guild?
if you have the Guilds intent then yeah
okay. thanks
does someone know about this problem?
I have a silly question
I left coding 3 Months Back, So Did Anything Get a Major Change
I have Discord.js version discord.js@14.0.0-dev.1646914074.dcd4797
read the pinned messages to find the guide
kk
This is the 3 months old djs version
where is the discord.js v14 guide
check pins
Well, ApplicationCommandData is no export from djs. Where do you want to use it?
@manic lynx
how to dismiss a modal after clicked on submit
if you submit a modal that will cause another interaction, respond to it
dismissing it is on the user, nothing you can do about that
Oh wait, it is actually, but only in typings. Doesn’t make much sense in CommonJS import
~~Hey,
I'm trying to create a webhook in a TextChannel https://c.lunish.nl/a8DH.png
But I'm getting this error https://c.lunish.nl/EB8A.png~~
nvm I fixed it
https://c.lunish.nl/VAzz.png
Type is a not an option btw
TextChannel#awaitMessages()
Similar to createMessageCollector but in promise form. Resolves with a collection of messages that pass the specified filter.
Is the permission now like this or is it different?
they now use the flags from PermissionBitFields
I got it
const filter =
/**
*
* @param {Message} m
* @returns {Boolean}
*/
(m) => m.author.id == member.user.id;
const msgs = await channel.awaitMessages({
filter,
max: 1,
time: 6_000,
errors: ["time"]
})
console.log(msgs);
const images = msgs.first().attachments.map(a => a.url);
console.log(images)```
Output :
Collection(0) [Map] {}
Are you sure that you're logging the correct thing? .map(...) returns an array, not a collection
Ah, I thought that was images
Do you have the GuildMessages intent?
hmm, ill check
no 😅
i just added
ok so now i have the msg, but there is not attachments ...
should i add MessageContent intent ?
yes
Error [DisallowedIntents]: Privileged intent provided is not enabled or whitelisted.
when i add MessageContent
you need to enable the intent in your application panel
Are you sure that's the right application, and the error is still the Disallowed Intents one?
no wait
TypeError [COLOR_CONVERT]: Unable to convert color to a number.
The line: .setColor("RANDOM")
Try "Random" instead
It worked. Thanks!
let role = interaction.options.getRole('role')
``` is not a function
what is interaction.options then?
data: new SlashCommandBuilder()
.setName("dj")
.setDescription("Sets the new DJ role")
.addRoleOption(option =>
option.setName('role')
.setDescription('Loop mode')
.setRequired(true)),```
Where are you declaring interaction
async execute(interaction, guildQueue, discord, client){```
Tag suggestion for @small light:
The order of function parameters must match between definition and function call.
function execute(client, message, args) { ... };
execute(message, client, args);
• mismatch! you pass a Message where the client is expected
• mismatch! you pass the Client where a Message is expected
Wherever you run execute from a different file, you need to pass parameters in the same order
ok ty
const images = msgs.first().attachments.map(a => a.url);
await client.put("products/" + productId + "/images", {
images: images
}).then(async (res) => {
message.embeds[0].data.thumbnail = images[0]
await message.edit({
embeds: [message.embeds[0]]
})
channel.send({
content: "**Les images ont été ajoutées avec succès !**"
})
})```
embeds[0].thumbnail[MODEL_TYPE_CONVERT]: Only dictionaries may be used in a ModelType
works
Are you trying to get an embed from a message?
tysm
in raw embed data thumbnail is not a string
Then it'll be much easier if you just use the EmbedBuilder
k
EmbedBuilder.from(message.embeds[0]) I believe, then you can use .setThumbnail(url)
thz
EmbedBuilder.from(message.embeds[0])
TypeError: (intermediate value).from is not a function
but when i go to EmbedBuilder i see that
.
const e = new EmbedBuilder().from(message.embeds[0])
nope
Attachment
Represents an attachment
so. found something with the discord.js@14.0.0-dev.1654949087-96053ba
// Require the necessary discord.js classes
const { Client, Collection, Intents } = require('discord.js');
const { token } = require('./config.json');
// Create a new client instance
const teamBotIntents = new Intents();
teamBotIntents.add(Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES);
const client = new Client({ intents: teamBotIntents, partials: ['CHANNEL'] });
module.exports = client;
PS C:\Users\A1CBe\Documents\realm_bot> node .
C:\Users\A1CBe\Documents\realm_bot\index.js:8
const teamBotIntents = new Intents();
^
TypeError: Intents is not a constructor
at Object.<anonymous> (C:\Users\A1CBe\Documents\realm_bot\index.js:8:24)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Why is typescript saying EmbedBuilder, Colors, SlashCommandBuilder, etc. aren't an export module of discord.js? I'm using discord.js@14.0.0-dev.1654949087-96053ba
Read pins
Cannot reproduce on the same version. Is it your IDE that is saying it or really TypeScript?
Step 1. Go to pinned messages in this chan
Step 2. Open guide "changing in v14"
Step 3.
They've already been told that, look above
thanks! 🙂
ah, see, alright
src/commands/Info/help.ts:2:10 - error TS2305: Module '"discord.js"' has no exported member 'Colors'.
Have you tried reinstalling
So idk what the issue is
Works fine on my end
Maybe you have multiple discord.js packages somehow with different versions, I've seen people have that for some reason...
Ok I fixed it by completely reinstalling discordjs and restarting my IDE
@tidal quest Unrelated ||I saw your rpc when you were playing Roblox, who were you? In my laptop, it shows that Roblox is in maintenance (website)||
beta client prob
so im trying to send a message to a specific channel id but i am kind of new to discordjs and i have tried so many examples on forums but none of them work at all and im kinda in need of it
Tag suggestion for @civic badge:
const channel = client.channels.cache.get("222086648706498562");
const channel = client.channels.cache.find(channel => channel.name === "general");
• Caches in discord.js are Collections which extend the native Map structure.
• learn more
then channel.send("Hello There!")
❤️
no errors still doesnt work
i can send whole commands'
Alert messy code
const { SlashCommandBuilder, channelMention, SlashCommandSubcommandBuilder} = require('@discordjs/builders');
const { MessageEmbed, Permissions, memberPermissions } = require('discord.js');
const { TextChannel } = require('discord.js')
const KickPermissionEmbed = new MessageEmbed()
.setTitle('Insufficient permissions')
.setDescription('You do not have enough permissions to kick someone')
.setFooter({ text: 'Bot made by TheSwedishMeatball!' });
const KickUnableEmbed = new MessageEmbed()
.setTitle('Unable to kick')
.setDescription('You are unable to kick this user')
.setFooter({ text: 'Bot made by TheSwedishMeatball!' });
const KickWrongEmbed = new MessageEmbed()
.setTitle('Unable to kick')
.setDescription('This member has a higher or equal rank as you so u cannot kick them!')
.setFooter({ text: 'Bot made by TheSwedishMeatball!' });
module.exports = {
data: new SlashCommandBuilder()
.setName('kick')
.setDescription('you are able to kick users')
.addUserOption((option) =>
option
.setName("user")
.setDescription("Who you want to kick")
.setRequired(true)
)
.addStringOption((option) =>
option
.setName("reason")
.setDescription("The reason you want to kick for")
.setRequired(true)
),
async execute(interaction) {
if (!interaction.memberPermissions?.has(Permissions.FLAGS.KICK_MEMBERS))
return interaction.channel.send({ embeds: [KickPermissionEmbed]})
const user = interaction.options.getUser('user')
const member = interaction.guild.members.cache.get(user.id) || await interaction.guild.members.fetch(user.id).cache
const reason = interaction.options.getString('reason')
const { client } = interaction
if(!member.bannable || member.user.id === client.user.id)
return interaction.reply({ embeds: [BanUnableEmbed]})
if(interaction.member.roles.highest.position <= member.roles.highest.position)
return interaction.reply({ embeds: BanWrongEmbed})
const banned = new MessageEmbed()
.setTitle('Kicked')
.setDescription(`**${member.user.tag}** was kicked from the server for the reason **${reason}**`)
.setColor('RED')
.setTimestamp()
.setFooter({ text: 'Bot made by TheSwedishMeatball!' });
await member.user.send({ embeds: [banned]})
member.kick({ reason })
return interaction.reply({embeds: [banned]})
const channel = client.channels.cache.get("985537873342234624");
channel.send({ embeds: [banned]})
},
};```
Less talking more looking
not sure what im not seeing
If you return the code after return wont run
so i put it before?
Yes
💀 💀 💀
https://thumbsnap.com/i/M3xwWkuU.png What am I doing wrong?
Pins
After updating my djs package to latest dev version I am getting this error.
My code:
if (interaction?.isAutocomplete()) {
if (interaction?.commandName === "help") {
const focused = interaction.options.getFocused(true);
let choices;
if (focused?.name === "command") {
choices = [...new Set(client.slashCommands.map((cmd) => cmd.name))]
}
const filtered = choices.filter((choice) => choice.startsWith(focused?.value)).slice(0, 24).sort();
await interaction.respond(
filtered.map((choice) => ({
name: choice,
value: choice
})),
).catch(console.error)
}
}
I am getting this error now.
My option in help interaction
options: [
{
name: "command",
description: "Provide the command you want to get more information on!",
type: 3,
required: false,
autocomplete: true
}
]
did u get option in autocomplete interaction
you used .getFocused() but it says there is no focused option
yes, idk why
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: SEND_MESSAGES.
SendMessages
Thanks
I'm not sure but should defaultMemberPermissions be a boolean?
export interface BaseApplicationCommandData {
name: string;
nameLocalizations?: LocalizationMap;
dmPermission?: boolean;
defaultMemberPermissions?: PermissionResolvable;
}```
No
So how do i set default permissions to false now?
"0"
You mean defaultMemberPermissions: ['0'] ?
defaultMemberPermissions tells discord what Permissions a member should have to use that command (until the admins set it to something else)
But i don't see that feature on discord. It's not configurable from the client?
Any PermissionResolvable
PermissionResolvable
Data that can be resolved to give a permission number. This can be: (more...)
Sure is. Integrations tab in server settings
Yes but i can't set permissions like ('Manage servers') in the ssettings of an application command
This is where i'm lost
The defaultMemberPermissions are what the developer sets as a recommendation for the application command. You can choose MANAGE_GUILD for example and the command will only be viewable to those with that permission. This is not reflected in the UI and you cannot change that
Alright. That is the answer i was looking for. It's now possible to see it in the UI. I guess that it will be available later as it's not cool to not see the required permissions of a command xD
But kinda curious on how overwrites works on that
If i set 'Administrator' only and the server owner changes the permission for everyong to true
Which will be used?
Well, for the above example, you can toggle it so that @everyone can view it. It supersedes it, it's like a default configuration
Discord doesn't show that in the UI, don't know why, it's been called a bug and in the backlog, and lol
And if i want to create my command with everyone to false, should i just use Syjalo example of ['0']?
Admins can always see your command though
Yea
So if you want no one to see your command but them, specify just them
Hoo, i see
You can just set it to "0" without an array
Right
Dunno if 0n or 8n has the same effect though. 0n sounds like it'd work
I'll use Admin instead
is it for the current version like this?\\
you can also check i.type === InteractionType.MessageComponent
Hello. I've seen the past answer before but can't remember when. How do I put characters that are not normally allowed in a text channel name (like discord.js@dev)?
It was due to an API bug. It's not possible
was it possible recently?
Yes it was due to an API bug
I am looking at building slash commands with permissions, but I cannot find it in the guide yet, but I know it had a github pr to do so. Is this still being looked at or is the guide outdated for slash commands?
With the latest update, how can i identify ModalSubmit and AutoComplete from an interaction as .isModalSubmit() and .isAutoComplete() have been removed?
Check the type
Ok. So no plan to bring back those getters? Is there a reason why they have been removed?
TypeScript don't like just comparing the type
I seriously doubt that
TypeError: interaction.isModalSubmit is not a function
xd
So they were eliminated?
To the messages above:
- interaction.isModalSubmit()
+ interaction.type === InteractionType.ModalSubmit
A ok
But for TypeScript, this is not the way to go
As it will still provide an error.
With Typescript, it gives me errors
did you type interaction as AnyInteraction?
incorrect. i use typescript and i don't get any of these errors
Hmm
that doesnt answer my question
when using .setDefaultMemberPermissions(permissions) would it accept 8 as the value for administrator or do I have to actually use the full bitfield value from the discord dev portal?
8 is administrator, why wouldn't it accept that o_O
It works with
if (!interaction.ModalSubmit) return;
I don't know if it works in typescript
wat
interaction.ModalSubmit is a thing??
Wtf
because the portal says the following
what?? what version of discord.js are you using?
yeah... you don't see the 8 right there?
It worked for me so now I'm left with a xd
14.0.0-dev.1654949087-96053ba
Just asking if I have to use the full value.
just use 8..
oh man, never knew it existed!
I installed it a while ago
??
TSError: ⨯ Unable to compile TypeScript:
events/interactionCreate.ts:15:8 - error TS2367: This condition will always return 'false' since the types 'ChannelType.GuildText | ChannelType.GuildVoice | ChannelType.GuildNews | ChannelType.GuildNewsThread | ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread' and 'ChannelType.DM' have no overlap.
15 if (interaction.channel?.type === ChannelType.DM) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gasps
i'm trying to check if the type of the channel is a DM, however I get ts complaining
anyone know why?
did you use a guild typeguard
like inGuild() or .inCachedGuild()?
Use this interaction.channel?.isDMBased()
no
alright, ill try that
I can't reproduce that so I'm keen on saying you're doing something you don't know you're doing then
I have it different I have it as
if(interaction.channel.type === 1)
interaction is typed as AnyInteraction
this fixed it ty, however i'm not sure if it'll stay long since typeguards like that might be removed
(iirc)
mean I replace both with this?
🤞
It shouldn't fix it
Because it's removed
I'm on the latest version, still there
Oh wait, on the channel
You can also use this if (interaction.channel instanceof DMChannel)
Yes
yes
But I'm not getting your TypeScript error
message.content is undefined although i have the intents are enabled ( under 75 servers ) and the partials?
the intent
You need more than 1 intent
Don't you need the message content intent and the guild messages intent
These are the intents that im using if that helps
Need the MessageContent one
ohhh thanks
allowedMentions: {
parse: [
"roles",
"users",
"everyone"
],
repliedUser: false
},
partials: [
Partials.User,
Partials.Channel,
Partials.GuildMember,
Partials.Message,
Partials.Reaction,
Partials.GuildScheduledEvent,
Partials.ThreadMember
],
intents: [
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessageTyping,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildScheduledEvents,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent
]
});```
const { GatewayIntentBits, Partials } = require("discord.js");
Object.keys(IntentsBitField.Flags).filter(f => f.startsWith("Guild")).concat("MessageContent")
i just use this, saves space
yes it's up to you which one you want to use
I just want to give you what I use

When sending a webhook message, djs tries to get the message from the function new (getMessage())(this.client, d); which returns an error on js get channel() { return this.client.channels.resolve(this.channelId); }
Known bug
Is there a temp workaround?
Don't use the version the bug is on
😦
it is in use but not labeled in any way
Can you rephrase that? Do you have a question of any kind?
The allowed mention part doesn't work so it doesn't throw tags.
The guide still says to use SlashCommandBuilder from DiscordJS/Builders is this now part of Discord.js and I dont need to import builders for v14?
yes, all builders from @discordjs/builders are now included in discord.js
Did you console.log that config['whitelist-role'] and make sure it’s the roleId for the role you try to ping?
In djs v13, we had DMPermission which used to disable slash cmds in DM, how to do that in v14? same question about DefaultMemberPermissions
dmPermission still exists, so does defaultMemberPermissions
defaultMemberPermissions are only for new guilds the bot joins afaik, and the permissions can be overwritten by guild owners anyway, so I wouldn’t use it for eval commands. IMHO if you need to have an eval command you should definitely make it a Guild command and only deploy to guilds you own yourself
Verified bots aren't allowed to register guild commands. Also I have added this, so it's won't be a problem. But I wanted it to get disabled as many places I getif ```js
(!ctx.client.owners.includes(ctx.interaction.user?.id)) return ctx.interaction.reply({
content: ${process.env.FAILURE_EMOJI} | The command is only for the developers of ${ctx.client.user?.username} bot,
ephemeral: true
})
Verified bots definitely shouldn’t have an eval slashcommand in my eyes
ya, I think I should put it in text commands
thanks
was MessageEmbed() removed? I am being told new MessageEmbed() isnt a constructor.
EmbedBuilder
What about MessageActionRow and MessageSelectMenu? I get the same error on this two also
yep, they've been changed to ActionRowBuilder and SelectMenuBuilder
👍🏻
Ok but why is .setPresence not working to set the activity? Was it changed to not be activities anymore?
Maybe you're doing it wrong
whats the difference between PermissionBitFlags & PermissionsBitField?
I’ve used this way since v13 and I can’t see any documentation that it was changed other than using bitfield values instead of playing etc.
Where did PermissionBitFlags come from
This is your screenshot right
https://cdn.discordapp.com/attachments/937420598383108167/985954561481146448/unknown.png
Yes
Isn't that wrong
As you can see here
Works fine for me
sry i meant PermissionsBitField
So your question is what is the difference between PermissionsBitField and PermissionsBitField? 
hmm thanksk
Could just be a delay in it being updated. The gateway be like that
Interactions: Modals

