#djs-in-dev-version

1 messages · Page 31 of 1

regal mason
#

Oh okay, and to display dynamically as the user types what are the methods ?

regal mason
#

I'm not using builders, how can I set it autocomplete ?

#

I just have to add autocomplete: true in the options array, right ?

tame gazelle
#

ah no

dusty otter
#

Turns out embed coloring with EmbedBuilder is case sensitive with color names

#

so you have to type Red not RED

uncut kelp
#

Hm?

dusty otter
#

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.

uncut kelp
#

Is that an issue? I don't see any context

#

Just this message appeared from nowhere

uncut kelp
dusty otter
#

Yeah just wanted to point it out

#

Because in previous discord.js versions it wasn't like this

jaunty comet
scarlet tangle
#

Modal is not a constructor

#

bruh

jaunty comet
scarlet tangle
#

k thz

plain roverBOT
#

class SelectMenuBuilder
Class used to build select menu components to be sent through the API

woven grove
#

thats kinda the point for certain things

open heron
#

is there any major change in v14?

dawn phoenix
#

yes, many

scarlet tangle
#

is it possible to edit a modal already sent ?
editModal ?

keen rivet
#

No

scarlet tangle
#

k thz

subtle pivot
#

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

knotty plover
#

Definitely not days I would think

dusky agate
#

<interaction member>.permissions changed?

hoary fox
plain roverBOT
dusky agate
#

i have this error when using the guildCreate event and apparently it is not an error in my code

knotty plover
#

Known issue in 13.8

#

Not related to guildCreate though, it's with webhooks

dusky agate
#

is the dev version

#

ok

knotty plover
#

Probably the same bug

#

It also got backported

jaunty comet
#

I updated it for the modals

subtle pivot
#

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

jaunty comet
#

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

scarlet tangle
scarlet tangle
green plume
#

I don't why I am getting this error since I upgraded my pakage.
client.channels.cache.get(process.env.ERROR_LOG).send()

plain roverBOT
#

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)

fluid bronze
#

If all was correct you wouldnt get an error

green plume
#

As you see in the eval ss I have used the exactly same code which I use in the main code.

fluid bronze
#

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

green plume
#

Well it used to work previously. But after updating my package I am facing this issue.

modest drum
#

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)
dawn phoenix
#

see pins 13 > 14 guide

plain roverBOT
buoyant ingot
plain roverBOT
scarlet tangle
#

RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: VIEW_CHANNEL
where can i find bitfield flags

vague coyote
scarlet tangle
#

k thz

vague coyote
#

PermissionFlagsBits is reexported in djs

scarlet tangle
#

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"

vague coyote
#

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

scarlet tangle
#

how do i access to <EmbedBuilder>.fields ?

vague coyote
#

embedbuilder.data.fields?

scarlet tangle
#

k

scarlet tangle
#

is it possible to hide or disable a textinput on a modal ?

nocturne kayak
#

no

indigo tide
#

How do you get all members that have a specific role (not only cached)?

uncut kelp
#

Fetch all members the iterate over them and check their roles

mental inlet
#

anyone know how to check if an embed image url is a well formed url so that i don't get errors like this?

neat pier
#

Well formed urls starts by https:// or http:// so verify if it starts with it

mental inlet
#

ah okay then ill do just that

jaunty comet
#

I’ll just look on the discord docs

plain roverBOT
#

Suggestion for @jaunty comet:
guide Interactions: Modals
read more

jaunty comet
#

Wait I meant context menu

#

Mixed them up whoops

brittle robin
jaunty comet
#

User is 2, message is 1 I assume

brittle robin
#

ApplicationCommandTypes? @jaunty comet

discord-api-types have ApplicationCommandType enum

knotty plover
#

Message is 3

jaunty comet
jaunty comet
brittle robin
fierce hatch
#

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'] })

fierce hatch
#

oh, i seem to be using the wrong version. Sorry

pallid peak
#

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.

uncut kelp
#

Where did discord-api-types comes from

pallid peak
#

Its a dependency of discord.js

uncut kelp
#

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?

pallid peak
#

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.

uncut kelp
#

If you want a string just stringify it

pallid peak
#

Regardless of the type of Snowflake, changing the return type for generate() is a breaking change that isn't obvious at first glance.

cinder wraith
#

well, technically, the major version changed between v13 and v14

pallid peak
#

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.

cinder wraith
#

that's fair

slate mango
#

You should always use bigint for DB, if you're using it for it, btw

cinder wraith
#

How is that relevant

slate mango
#

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

pallid peak
#

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.

slate mango
#

The change in return was intentional, yes

pallid peak
#

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?

slate mango
#

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

cinder wraith
#

so why does it matter what do they store it as

slate mango
#

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

pallid peak
#

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.

slate mango
#

And the return type of the utility won't change either

pallid peak
#

Separate question: Is v13's Permissions.resolve() now PermissionsBitField.resolve() in v14?

forest elm
#

Permissions is PermissionsBitField

pallid peak
#

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?

cyan jewel
#

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.

uncut kelp
#

That error is from Discord, not discord.js

cyan jewel
#

That's fair. I guess I should ask on Discord Devs then.

#

I wish it would tell me which permission was missing. Crying

jagged marsh
#
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)

unreal stump
#

Also it needs to be an array

hexed tapir
#

When was the last update for dev version?

vague coyote
#

6 hours ago

plain roverBOT
vague coyote
forest mulch
#

nvm

scarlet tangle
#

What's the problem in this?It says invalid bitfield flag or number

rain bramble
scarlet tangle
rain bramble
scarlet tangle
#

It was my handler issue and I fixed it

rain reef
#

since modals got released in v13.7.0 what are new features in v14 other than renamed stuff

rain reef
#

thx

jagged marsh
#

wait so arrays of Attachments can't be used anymore?

tame gazelle
#

I think you just can’t build it

jagged marsh
buoyant ingot
#

djs v14 is coming shall i keep learning v13 or wait for v14

slow storm
#

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.

split fulcrum
#

did it change name??

uncut kelp
#

It was removed

split fulcrum
#

What

#

What is it now then ;-;

uncut kelp
#

Just check the type of interaction instead

split fulcrum
#

Breh

#

How should i check for the type then

#

nvm fixed it

merry sigil
#

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?

quasi dew
#

How many TextInputs i can add on modal? is it 5 or 25 like other interaction

jaunty vault
#

5

quasi dew
#

well rip

forest elm
#

if you're using the interactionCreate event, it should be AnyInteraction

uncut kelp
#

Yeah exactly what Almeida said

merry sigil
#

oh yeah, using AnyInteraction fixes it, thank you! I was handling the interaction in a separate utility function where I passed it as Interaction

grim sigil
#

I just updated the discord.js and it throws me this
something changed?

mental inlet
#

i set the client type to the Client you can import from djs and i get this error, anyone know why?

sacred eagle
#

If it's meant to be a ready client, type it to be Client<true>

mental inlet
grim sigil
#

I think the preview needs to be updated

forest elm
#

8027

mental inlet
#

has interaction.isChatInputCommand() been removed?

#

and interaction.isModalSubmit()?

#

if so ill change those

forest elm
#

yes

mental inlet
#

ight

forest elm
#

wait no

#

only isModalSubmit

#

isChatInputCommand is still around

grim sigil
#

I confirm

#

but... what replaces the isModalSubmit?

forest elm
#

interaction.type === InteractionType.ModalSubmit

grim sigil
#

ty

shut comet
#

uhm what am I supposed to use now that interaction.isAutocomplete() is removed?

mental inlet
#

not sure if its a problem on my side but interaction.options.getSubcommand() isn't working, is it removed or something?

mental inlet
uncut kelp
#

What does "isn't working" mean

shut comet
#

oh thanks

mental inlet
#

hold on let me check if its an error on my side

uncut kelp
#

undefined is definitely a developer issue

mental inlet
#

okay yeah its an error on my side

#

fixed it 👍

cyan jewel
#

Is InteractionType.ApplicationCommand the proper replacement for isChatCommand()?

uncut kelp
#

That never existed

cyan jewel
mental inlet
#

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?

uncut kelp
#

...don't?

velvet jasper
mental inlet
cyan jewel
uncut kelp
#

I don't understand how that will affect your bot

cyan jewel
#

I see. Well... I guess I could use it, but now my code is inconsistent. lol

marble barn
#

I miss the method type guards tbh, they looked cleaner

cyan jewel
#

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.

uncut kelp
velvet jasper
#

isChatInput for example was kept bc it checks type and commandType

cyan jewel
#

Ah I see. OK, that makes sense.

#

I'll live with my command handler looking a bit odd.

mental inlet
velvet jasper
#

You can still do it manually if you want consistency

mental inlet
#

and I get an invalid form body api error

uncut kelp
#

But that's just a client issue

#

What's that gotta do with discord.js

#

o,o

cyan jewel
mental inlet
#

or my issue?

uncut kelp
#

Where did you get that error from?

mental inlet
#

discord api

uncut kelp
#

Was it sent to your bot?

mental inlet
uncut kelp
#

wat

velvet jasper
#
if (
  interaction.type === InteractionType.ApplicationCommand &&
  interaction.commandType === ApplicationCommandType.ChatInput
) { ... }

@cyan jewel

jaunty vault
# mental inlet

I'm thinking you were sending a message that was too long, and didn't handle it
harder to know without the full error

uncut kelp
#

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

cyan jewel
velvet jasper
#

Well chatinput is a method as well

mental inlet
#
  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?

uncut kelp
#

YES

#

That is it

jaunty vault
#

knew it

mental inlet
#

how can I prevent this?

jaunty vault
#

by checking the length
or catching

uncut kelp
#

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

mental inlet
#

ah okay

mental inlet
uncut kelp
#

Well, now you know

cyan jewel
uncut kelp
#

Bots can only send 2,000 character messages, but embed descriptions can have up to 4,096 characters

mental inlet
#

still sending the same error even after i check the length, could be my problem

uncut kelp
#

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

small light
#

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

uncut kelp
#

I believe the type of activity is a number

small light
uncut kelp
#

Documentation

small light
#

ty

uncut kelp
#

You would do import { ActivityType } from "discord.js" then in your type put ActivityType.Listening

small light
#

aight ty

jolly pike
#

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?

velvet jasper
#

Hmmm, it definitely seems unintended

uncut kelp
#

Shouldn't it be AnyInteraction

#

@velvet jasper

velvet jasper
#

Yeah, are you on the latest dev version?

jolly pike
#

yeah I just updated

#

what's the difference between Interaction and AnyInteraction?

#

oh it's just a union of every interaction lol

velvet jasper
#

Yeah class hierarchies are open, unions are closed

noble kernel
#

TypeError: Cannot read properties of undefined (reading 'resolve') when dealing with webhooks..?

outer bane
#

known issue

uncut kelp
noble kernel
#

what's the recommended fix for now?

outer bane
#

don't deal with webhooks for now or use an earlier commit

noble kernel
#

alr

digital sequoia
white nebula
#

Flags are PascalCase in v14, not SCREAMING_SNAKE_CASE

digital sequoia
#

How can I access them?

white nebula
#

PermissionsBitField.Flags.ViewChannel

#

or PermissionFlagsBits.ViewChannel

digital sequoia
#

ok

digital sequoia
#

and from SEND_MESSAGES SendMessages?

slow storm
#

Yup

digital sequoia
#

ok

slow storm
#

global? 🤔

dark minnow
#
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

uncut kelp
#

Yea, we're aware

dark minnow
#

Oh, I didn't know, sorry for bothering

uncut kelp
#

No, you're not bothering

#

You're actually the first person I've seen to talk about this lol

#

We welcome things like this ^^

dark minnow
#

🙂

#

I will downgrade my version, do you know any that works?

uncut kelp
#

Anything before commit c7391db

dark minnow
#

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

uncut kelp
dark minnow
#

Nice!

#

The method <Interaction>.isAutocomplete() has been removed?

dark minnow
#

Oh, got it, thanks

scarlet tangle
#

<guild>.me is depreciated in the dev build?

#

Is it <guild>.members.me now?

idle galleon
#

Yea

scarlet tangle
#

thanks

half pine
manic lynx
half pine
#

ok, i found answer, tysm

nocturne kayak
manic lynx
nocturne kayak
#

no... downgrade your djs

manic lynx
nocturne kayak
scarlet tangle
cinder bane
#

receiving this error when using AttachmentBuilder

#

assuming that AttachmentBuilder is the v14 version of MessageAttachment of v13

cinder bane
#

ah thanks

#

right i updated the version before using it

hardy wind
#

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.

half pine
hardy wind
#

Also I'm getting bigint serialisation errors when trying to create commands with default member permissions, whether I stringify the permissions or not.

dawn phoenix
#

if you manually provide it as a string, how would that error out on json serialisation for bigints?

hardy wind
#

After making changes to the command transformer I was able to make it work, I'll submit a PR.

upper stirrup
#

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 });
                }
            });
steel haven
steel haven
upper stirrup
plain roverBOT
#

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

upper stirrup
#

error referencing this line:
await i.update({ content: 'Select roles from the menu below', components: [menuShop], ephemeral: true });

noble kernel
#

any update on webhook bug?

upper stirrup
#

DiscordAPIError[40060]: Interaction has already been acknowledged referencing this line await i.update({ content: 'Select roles from the menu below', components: [menuShop], ephemeral: true });

rain bramble
upper stirrup
steel haven
steel haven
civic topaz
#

hi

#

I cannot install @discordjs/opus on replit

split fulcrum
#

what does it mean with Path??

tame gazelle
split fulcrum
#

i Replace this with that??

civic topaz
#

hi
I cannot install @discordjs/opus on replit

tame gazelle
#

new AttachmentBuilder('url', { name: 'attachment.jpg' }) for example

split fulcrum
#

Ok Thanks

unreal stump
manic lynx
#

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?

steel haven
#

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

half pine
white nebula
#

Is there a reason that the type isn't getting narrowed to AutocompleteInteraction, or can I just assume that this is a vscode issue?

white nebula
#

so probably just an issue with the IDE, got it

forest elm
white nebula
#

Ah, I had it as just normal Interaction
That fixed it, thanks!

forest elm
scarlet tangle
#

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),
                        ])```
forest elm
#

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

plain roverBOT
#

class Role (extends Base)
Represents a role on Discord.

slow storm
#

How can I check if a user has permission to run a command in perms v2?

sonic moth
nocturne kayak
slow storm
forest elm
#

discord hides commands for those without the required permission

slow storm
#

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

slow storm
#

?

uncut kelp
#

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

slow storm
uncut kelp
slow storm
#

You aren't getting what I mean

uncut kelp
slow storm
#

no lol

slow storm
# uncut kelp But this is exactly what I said

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

dawn phoenix
#

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

slow storm
#

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

regal mason
#

There's an error when sending dynamique autocomplete with Integer argument

#

The interaction is not received on the event interactionCreate

undone yew
#

how to fix?

uncut kelp
# regal mason

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

undone yew
#

2 bots won't login

#

help me

dusk heath
#

Dont ask every few minutes the same question repeatedly Madge

small light
#

hi how can i check if the user that ran the interaction is alone in a vc

steel haven
plain roverBOT
#

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?

undone yew
undone yew
#

i said everything

#

no errors

dawn phoenix
#

attach a listener to debug (client) and rateLimited (client.rest)

plain roverBOT
undone yew
#

I'm added rest.on

#

no changes

#

what should I do?

dawn phoenix
#

good question, so it's just stuck at preparing and never gets past that?

steel haven
noble kernel
#

any updates on the webhook fix?

undone yew
#

i updated discordjs latest version

#

no changes

plain roverBOT
undone yew
#

Do I need to throw away the client definitions?

#

?

kind carbon
#

Is there a reason why the message.content is empty, when it's not??

dark light
#

do you have the message content intent enabled?

steel haven
# undone yew ?

Attach to the restDebug event of client.rest too please and try again

undone yew
#

i will try tomorrow

dark light
#

in the dev portal and in your code?

kind carbon
#

yes

digital sequoia
#

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?

kind carbon
dark light
#

hmm that shouldn't happen if you have it enabled

steel haven
uncut kelp
#

Without code, we cannot tell either what the issue may really be

digital sequoia
#

Yeah all good I post the code now I had the hope that there was a change or something xd

#

client.sendE is a function to send a embed (reply with editReply check)

kind carbon
steel haven
steel haven
kind carbon
steel haven
#

Very weird indeed then…

kind carbon
#

Yeah, message content is empty when I log it

brittle robin
kind carbon
#
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
brittle robin
#

Did you already show how you receive and log the message anywhere? @kind carbon

kind carbon
#

No

#
    if (message.author.bot) return;
    console.log(message.content)
})``` Rn just testing to see why it isn't working
brittle robin
#

yeah yeah

hoary fox
kind carbon
steel haven
hoary fox
kind carbon
#

Alright, fixed. Thanks

digital sequoia
steel haven
digital sequoia
#

ok

kind carbon
#

When sending a message through a webhook, I'm getting this error. return this.client.channels.resolve(this.channelId);

hoary fox
steel haven
kind carbon
steel haven
kind carbon
#

nvm that was the first thing that came up in the error lmao

steel haven
kind carbon
steel haven
zealous otter
#

yeah, webhooks are broken

steel haven
#

Oh, okay that explains it

signal carbon
digital sequoia
signal carbon
digital sequoia
#

thx

plain roverBOT
proud creek
#

Plas help how to display the number of deleted messages and how to delete a message after a certain time has passed.

plain roverBOT
#

The timeout option has been removed from the Message#delete method.

- message.delete(5000)
- message.delete({ timeout: 5000 })
+ setTimeout(() => { message.delete() }, 5000)
hoary fox
proud creek
forest elm
#

so... from bulk delete?

cinder topaz
#

I surely can't be the only one with some weird issue like this, can I

cinder topaz
#

downgrading typescript worked somehow

digital sequoia
uncut kelp
digital sequoia
#

So I need to wait? or what?

uncut kelp
#

:eyes:

#

It needs to be merged. Then released. Then you install it. Then all's good with the world

unreal stump
#

or downgrade (to pre 7917)

digital sequoia
#

Wouldent that fucks my whole code?

uncut kelp
#

It's dev. Anything will fuck with your code

digital sequoia
#

xD

uncut kelp
#

Downgrade or manually implement that pull request's fix - up to you

digital sequoia
#

I mean thats currently the only problem I got with dev

#

And a collector bug but thats something diffrent

plain roverBOT
#

We do not provide any help with third party libraries
Buttons and Modals are supported natively.
• Buttons: learn more
• Modals: learn more

split fulcrum
#

why does this not work? it just return as a file.jpg file

idle galleon
#

You should set the name of the attachment

digital sequoia
outer bane
#

you passed 10 as a number to an embed field value without stringifying it

digital sequoia
#

Ahh ok thx

#

Is there a way to check this cuz its a user config value?

idle galleon
digital sequoia
#

Okay thank you

manic lynx
#

Any suggestion how do I convert the Enums to String? Because I want string in my slash cmd type instead an Enums

knotty plover
#

Enums aren't strings though and it doesn't accept strings anymore

manic lynx
#

IDK if that works

knotty plover
#

i guess?

#

But thats string to enum/number, not enum to string

slow storm
#

u r using replace instead of assigning

fluid summit
exotic rain
#

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?

manic lynx
#

And also please help

slow storm
# manic lynx Yes why not?

U want to replace string with enum right? If u use replace, It'll be a string ('1') and not a number (1).

exotic rain
#

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

#

I see so the second check is not needed

#

Yup but I'm further narrowing more down

nocturne kayak
#

not sure why this didnt narrow the type

exotic rain
exotic rain
#

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'
```
thorny haven
#

ChatInput is an application, but not a slash command

exotic rain
#

How can I check if it's a slash command properly?

thorny haven
#

are you already checking this

#

I may be wrong, but you need to assign the type CommandInteraction

#

// condition: (interaction: CommandInteraction<"cached">) => Promise<boolean>

plain roverBOT
exotic rain
# thorny haven I may be wrong, but you need to assign the type CommandInteraction

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
small light
#

help js .addRoleOption(option => option.setName('role') .setDescription('The role that will become the dj role') .setRequired(true) .addChoices({ name: 'role', value: 'role' })),

cinder bane
#

im unable to disable a select menu

flat ice
cinder bane
#
[
  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

flat ice
cinder bane
#
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

flat ice
#

Remove the .catch and see if it errors

cinder bane
#

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

steel haven
cinder bane
#

because i did, InfoButtonComponents.toJSON()

#

so basically JSON of ActionRowBuilder

steel haven
#

Then it shouldn’t show ButtonBuilder anymore though

cinder bane
#

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)
    ]);
cinder bane
#

it was .toJSON() already, i was editing the code

#

toJSON gives undefined in emoji

steel haven
#

Because you access the whole ActionRow there, not a button inside of it

cinder bane
#

then tell me, what can I do to access two buttons

steel haven
#

Maybe not build a row and rebuild it from that row later on but build it once you know what you need?

cinder bane
#

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

undone yew
#

how to fix this issue?

thorny haven
exotic rain
#

Needed a isChatInputCommand() check to check if it's a slash command

thorny haven
steel haven
exotic rain
#

And the check works, besides that I trust TS which didn't give me any error so should be fine now

undone yew
thorny haven
# exotic rain But this is from the library?

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()

exotic rain
#

Yup that's what I applied in the end

steel haven
#

So REST isn’t sending anything from your host apparently Thonk 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

thorny haven
#

aaaaaaaaa how to check now that the interaction is Autocomplete

#

interaction.isAutocomplete() there used to be this function, where did it go?

undone yew
steel haven
zealous otter
#

construct a WebhookClient instead

undone yew
#

._.

thorny haven
#

@exotic rain do you need help with something else or did you succeed?

zealous otter
undone yew
zealous otter
#

alright then

undone yew
#

and the problem is not the webhook

#

2 bots not logging in

exotic rain
undone yew
#

Is there any solution to my problem?

steel haven
undone yew
#

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?

dawn phoenix
dawn phoenix
undone yew
#

what exactly do i need to do?

dawn phoenix
#

set breakpoints or logs around that area, see where execution reaches, what the values are, etc.

undone yew
#

so how do i set the breakpoint?

dawn phoenix
#

#resources > debugging, we can't teach you how to use your IDE here
as said, you can also set console.logs

undone yew
#

I run it with VSC's debug mode and still no details :|

steel haven
#

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

undone yew
#

wow

#

working but error

#

how to fix?

#

I'm fixed

#

👍🏽

#

thank you for your help

steel haven
#

At least tell what the source of your error was. In case others get the same

undone yew
zealous otter
#

Webhooks are broken

undone yew
#

most likely yes, they are sending a message to the channel with this error

split fulcrum
#

Is it not any docs about it??

zealous otter
split fulcrum
#

Hmm ok

tame gazelle
split fulcrum
#

It still said file.jpg

split fulcrum
manic lynx
median junco
#

i have the following type error. What can I do to only get the GuildMemberRoleManager?

urban belfry
#

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

median junco
#

does djs automatically cache the guild?

scarlet tangle
#

if you have the Guilds intent then yeah

median junco
#

okay. thanks

lusty cairn
#

does someone know about this problem?

dire rover
#

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

scarlet tangle
#

read the pinned messages to find the guide

dire rover
#

kk

dire rover
coarse imp
#

where is the discord.js v14 guide

urban belfry
steel haven
#

Well, ApplicationCommandData is no export from djs. Where do you want to use it?

scarlet tangle
#

how to dismiss a modal after clicked on submit

dawn phoenix
#

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

steel haven
#

Oh wait, it is actually, but only in typings. Doesn’t make much sense in CommonJS import

empty urchin
zealous otter
plain roverBOT
#

method TextChannel#awaitMessages()
Similar to createMessageCollector but in promise form. Resolves with a collection of messages that pass the specified filter.

lusty cairn
#

Is the permission now like this or is it different?

scarlet tangle
lusty cairn
scarlet tangle
#
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] {}
white nebula
scarlet tangle
#

console.log(msgs);

#

its a collection of messages

#

but there is no msgs :/

white nebula
#

Ah, I thought that was images
Do you have the GuildMessages intent?

scarlet tangle
#

hmm, ill check

#

no 😅

#

i just added

#

ok so now i have the msg, but there is not attachments ...

#

should i add MessageContent intent ?

obtuse crater
#

yes

scarlet tangle
# obtuse crater yes

Error [DisallowedIntents]: Privileged intent provided is not enabled or whitelisted.

#

when i add MessageContent

obtuse crater
#

you need to enable the intent in your application panel

scarlet tangle
#

k

#

nope

#

thats not work -_-

#

so what can i do ...?

white nebula
#

Are you sure that's the right application, and the error is still the Disallowed Intents one?

scarlet tangle
#

no wait

hard robin
#

TypeError [COLOR_CONVERT]: Unable to convert color to a number.
The line: .setColor("RANDOM")

white nebula
#

Try "Random" instead

scarlet tangle
#

how can i be so dumb 😑, it was the wrong app

#

worked thz vry much

hard robin
small light
#
            let role = interaction.options.getRole('role')
``` is not a function
tardy cobalt
#

what is interaction.options then?

small light
zealous otter
small light
plain roverBOT
#

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

zealous otter
#

Wherever you run execute from a different file, you need to pass parameters in the same order

small light
#

ok ty

scarlet tangle
#
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
small light
#

works

zealous otter
small light
#

tysm

scarlet tangle
#

shouldn't ?

dawn phoenix
#

in raw embed data thumbnail is not a string

zealous otter
scarlet tangle
#

k

zealous otter
# scarlet tangle k

EmbedBuilder.from(message.embeds[0]) I believe, then you can use .setThumbnail(url)

scarlet tangle
#

thz

forest elm
#

EmbedBuilder.from(message.embeds[0])

scarlet tangle
#

TypeError: (intermediate value).from is not a function

#

but when i go to EmbedBuilder i see that

forest elm
scarlet tangle
#

const e = new EmbedBuilder().from(message.embeds[0])

forest elm
#

nope

scarlet tangle
#

oh ok

#

works thz

plain roverBOT
thick schooner
#

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
tidal quest
#

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

uncut kelp
ruby void
uncut kelp
#

They've already been told that, look above

ruby void
#

ah, see, alright

tidal quest
uncut kelp
#

Dunno what's wrong. Reinstall or something

#

Are you sure you're on version 14?

tidal quest
uncut kelp
#

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

tidal quest
#

Ok I fixed it by completely reinstalling discordjs and restarting my IDE

haughty stump
#

@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)||

civic badge
#

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

plain roverBOT
#

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

hoary fox
civic badge
#

❤️

#

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]})
    },
};```
uncut kelp
civic badge
#

2 different channels

#

the second one is logs

uncut kelp
#

Less talking more looking

civic badge
#

not sure what im not seeing

copper jetty
#

If you return the code after return wont run

civic badge
#

so i put it before?

copper jetty
#

Yes

civic badge
#

💀 💀 💀

thorny haven
green plume
#

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)
            }
        }
green plume
hoary fox
green plume
jaunty vault
green plume
#

yes, idk why

hard robin
#

RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: SEND_MESSAGES.

jaunty vault
#

SendMessages

hard robin
#

Thanks

cerulean bay
#

I'm not sure but should defaultMemberPermissions be a boolean?

export interface BaseApplicationCommandData {
  name: string;
  nameLocalizations?: LocalizationMap;
  dmPermission?: boolean;
  defaultMemberPermissions?: PermissionResolvable;
}```
cerulean bay
#

So how do i set default permissions to false now?

rain bramble
#

"0"

cerulean bay
#

You mean defaultMemberPermissions: ['0'] ?

steel haven
cerulean bay
rain bramble
plain roverBOT
steel haven
cerulean bay
#

Yes but i can't set permissions like ('Manage servers') in the ssettings of an application command

#

This is where i'm lost

rain bramble
cerulean bay
#

Yea

#

I can only set members, roles or channels

uncut kelp
#

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

cerulean bay
#

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?

uncut kelp
#

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

cerulean bay
#

And if i want to create my command with everyone to false, should i just use Syjalo example of ['0']?

uncut kelp
#

Admins can always see your command though

cerulean bay
#

Yea

uncut kelp
#

So if you want no one to see your command but them, specify just them

cerulean bay
#

Hoo, i see

rain bramble
#

You can just set it to "0" without an array

cerulean bay
#

Right

uncut kelp
#

Dunno if 0n or 8n has the same effect though. 0n sounds like it'd work

cerulean bay
#

I'll use Admin instead

lusty cairn
#

is it for the current version like this?\\

forest elm
#

you can also check i.type === InteractionType.MessageComponent

proven wolf
#

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)?

uncut kelp
#

It was due to an API bug. It's not possible

proven wolf
#

was it possible recently?

uncut kelp
#

Yes it was due to an API bug

copper nymph
#

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?

cerulean bay
#

With the latest update, how can i identify ModalSubmit and AutoComplete from an interaction as .isModalSubmit() and .isAutoComplete() have been removed?

uncut kelp
#

Check the type

cerulean bay
#

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

uncut kelp
cerulean bay
#

Ho nvm

#

I'm dumb

novel notch
#

TypeError: interaction.isModalSubmit is not a function

cerulean bay
#

Just asked that

#

Read last messages xD

novel notch
#

xd

novel notch
mental inlet
#

To the messages above:

- interaction.isModalSubmit()
+ interaction.type === InteractionType.ModalSubmit
novel notch
#

A ok

cerulean bay
#

As it will still provide an error.

forest elm
#

thats incorrect

#

that is the way to go

cerulean bay
#

With Typescript, it gives me errors

forest elm
#

did you type interaction as AnyInteraction?

mental inlet
cerulean bay
#

Hmm

mental inlet
#

i'm using AnyInteraction

#

as the type of interaction

cerulean bay
forest elm
#

that doesnt answer my question

cerulean bay
#

You are right

#

About the AnyInteraction

#

My bad!!! This fixes it

copper nymph
#

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?

uncut kelp
#

8 is administrator, why wouldn't it accept that o_O

novel notch
#

It works with
if (!interaction.ModalSubmit) return;

#

I don't know if it works in typescript

jaunty vault
#

wat
interaction.ModalSubmit is a thing??

cerulean bay
#

Wtf

copper nymph
#

because the portal says the following

mental inlet
jaunty vault
novel notch
novel notch
copper nymph
jaunty vault
#

just use 8..

mental inlet
novel notch
#

I installed it a while ago

mental inlet
#

??

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) {
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uncut kelp
#

Gasps

mental inlet
#

i'm trying to check if the type of the channel is a DM, however I get ts complaining

#

anyone know why?

jaunty vault
cerulean bay
mental inlet
uncut kelp
# mental inlet no

I can't reproduce that so I'm keen on saying you're doing something you don't know you're doing then

novel notch
mental inlet
uncut kelp
#

Wym see if that changes anything

#

What would it be if not AnyInteraction

mental inlet
#

(iirc)

lusty cairn
cerulean bay
#

🤞

uncut kelp
#

Because it's removed

cerulean bay
#

Not removed yet

#

Just updated and it's still there

mental inlet
uncut kelp
#

Oh wait, on the channel

cerulean bay
uncut kelp
#

Yes

forest elm
uncut kelp
#

But I'm not getting your TypeScript error

boreal kraken
#

message.content is undefined although i have the intents are enabled ( under 75 servers ) and the partials?

uncut kelp
#

the intent
You need more than 1 intent

#

Don't you need the message content intent and the guild messages intent

boreal kraken
#

These are the intents that im using if that helps

cerulean bay
#

Need the MessageContent one

boreal kraken
#

ohhh thanks

cerulean bay
lusty cairn
# boreal kraken These are the intents that im using if that helps
            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");
boreal kraken
lusty cairn
#

I just want to give you what I use

boreal kraken
cerulean bay
#

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); }

uncut kelp
#

Known bug

cerulean bay
#

Is there a temp workaround?

uncut kelp
#

Don't use the version the bug is on

cerulean bay
#

😦

frank moss
#

it is in use but not labeled in any way

steel haven
frank moss
copper nymph
#

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?

mental inlet
steel haven
green plume
#

In djs v13, we had DMPermission which used to disable slash cmds in DM, how to do that in v14? same question about DefaultMemberPermissions

steel haven
green plume
#

👍🏻

#

The slash didn't get disabled

steel haven
# green plume The slash didn't get disabled

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

green plume
# steel haven defaultMemberPermissions are only for new guilds the bot joins afaik, and the pe...

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
})

steel haven
green plume
#

ya, I think I should put it in text commands

copper nymph
#

Why is interaction.IsCommand() not working?

#

Like what was it replaced by?

jaunty vault
#

it doesn't exist anymore

#

you have to compare interaction type

copper nymph
#

thanks

#

was MessageEmbed() removed? I am being told new MessageEmbed() isnt a constructor.

forest elm
#

EmbedBuilder

copper nymph
#

thanks

#

This is just setting to DND

green plume
mental inlet
green plume
#

👍🏻

copper nymph
#

Ok but why is .setPresence not working to set the activity? Was it changed to not be activities anymore?

uncut kelp
#

Maybe you're doing it wrong

forest mulch
#

whats the difference between PermissionBitFlags & PermissionsBitField?

copper nymph
uncut kelp
copper nymph
#

Yes

uncut kelp
#

Isn't that wrong

copper nymph
#

That’s old commenting.

#

I am using the bitfield

copper nymph
uncut kelp
#

Works fine for me

forest mulch
uncut kelp
#

So your question is what is the difference between PermissionsBitField and PermissionsBitField? Thonk

copper nymph
uncut kelp