#djs-in-dev-version
35223 messages · Page 23 of 36
Ok where I can suggest?
They have their own website for suggestions/feature requests
Any links?
The last link
Why is this happening?
No reaction with that id on the message
Resolved to null
but it is there
and i even use that same line of code in another file and i have no issues
Well that's all that can throw an error on that line. Sure it's the right message?
i'll check again
oh wow, i apologize, it wasn't
no wonder
I am above the bot, still the bot say me I must be above. Is this a bug of djs?
if (ctx.interaction.member.roles.highest.position < ctx.interaction.guild.members.me.roles.highest.position || ctx.interaction.member.user?.id !== ctx.interaction.guild.ownerId) return ctx.interaction.reply({ content: `${process.env.FAILURE_EMOJI} | You must be above me to use this command.`, ephemeral: true });
Do you have a higher role than it
yep
guild.members.me is the bot itself I assume right
yes
are you the guild owner?
no
Thats why it’s not working
I want the cmd to work if a user have higher role than bot as well as if the user is guild owner
Well the way you did it doesnt work
Cause ur using an or operator
Can I use like this?
if (ctx.interaction.member.user?.id !== ctx.interaction.guild.ownerId && ctx.interaction.member.roles.highest.position <= ctx.interaction.guild.members.me.roles.highest.position) return ctx.interaction.reply({ content: `${process.env.FAILURE_EMOJI} | You must be above me to use this command.`, ephemeral: true });
using an && should work
Yeah an && would work
okay
Actually @green plume what if the owner has like no roles
actually that why I have added ctx.interaction.member.user?.id !== ctx.interaction.guild.ownerId
cause owner doesn't require roles to ban someone
Yes but the && means both have to be true
Or false actually
Exactly
the first one is false but the 2nd one is true technically cause the owner has no roles
He wants them both false
Owner can have roles
You could flip it to be a positive pass on owner
But it's fine with them both false
I want anyone of them to be false, that's why I used ||
But the || wouldn’t work for you, the person who’s not an owner
Doesn't work like that
That's why you use &&
Is there a thing where the owner is already classified as the “highest role”
No
well that means both have to be false. right?
No, both have to be true
Oh okay
Oh wait I see why itd work now
Nvm I was thinking it the other way around
Because if one condition isn't true, it won't return
Yeah exactly
ya
I was thinking as if both had to be false
So wait since the builders are gonna be in the actual api
How would I be able to access the builders
wdym
Just import them
Oh so its the same package name?
for the re-exported ones yeah
doesn't discord.js export builders now? or am I tripping
So I could get the SlashCommandBuilder from discord.js
no idea myself, I'm asking
it seemed to work when I tried it
I see
should probably take a look at source
From the looks of it SlashCommandBuilder is in discord.js, but the course isnt updated
course or guide?
guide I meant
guide still uses builders
oh nevermind
I think I checked the wrong one
Hi, can sb help me?
(05.06.2022 10:06:03) [ERROR]: TypeError: TypeError: component.toJSON is not a function
import { ColorResolvable, Message, Util } from 'discord.js';
import { ActionRowBuilder, ButtonBuilder, EmbedBuilder } from '@discordjs/builders';
import { Client } from '../../classes/client';
import { ButtonStyle } from 'discord-api-types/v10';
export default async (bot: Client, message: Message) => {
if (message.channel.isDM() && !message.author.bot) {
const buttonHelp = new ButtonBuilder()
.setCustomId(`ticket-${message.author.id}`)
.setLabel('Potrzebuję pomocy!')
.setStyle(ButtonStyle.Success);
const buttonCancel = new ButtonBuilder()
.setCustomId(`ticket-${message.author.id}`)
.setLabel('Anuluj!')
.setStyle(ButtonStyle.Danger);
const buttonHelpRow = new ActionRowBuilder()
.addComponents([buttonHelp]);
const buttonCancelRow = new ActionRowBuilder()
.addComponents([buttonCancel]);
const helloEmbed = new EmbedBuilder()
.setColor(Util.resolveColor(<ColorResolvable>bot.colors.green))
.setDescription(`Witaj ${message.author}!.`)
.setFooter({ text: `Ticket - ${message.author.id}`, iconURL: message.author.displayAvatarURL() });
await message.channel.send({
embeds: [helloEmbed],
components: [buttonHelpRow, buttonCancelRow],
});
}
};
full error?
Try passing just the button on the addComponents, not an array
Also i don't think your bot can be sent a dm by your bot, right?
They seem to take an array on the latest commit. You sure this is updated?
okay, I deleted an array and it works
Make sure it's updated then.
but is it possible to put buttons inline?
Add them to the same row instead of seperate action rows
okay
Thanks

there is something wrong with the typings
Is this a typings error?
No? I don't understand the question
What's wrong here
Oh it doesn't match the jsdoc
Well one of them is wrong I guess
A modal is not an action row
It's a Modal / ModalBuilder
oh, ok thx
I want to send an embed in the voice text channel when a new voice channel is created but I don't know how to send it
would be good
which one? jsdoc or typings? 
<VoiceChannel>.send
like in a TextChannel
can I use select menu in modal ?
no
You can but is not supported by discord.js yet
oh, ok
I hope it will be in new version
iirc you can send them
when selectMenu in modal will be announced by Discord yes
idk, but you need to catch error when you send a message in voice channel because is not activated in all servers
It's a private bot for a unique server so i don't need I think
How can i show a modal?
<Interaction>.showModal()
thx
is it possible to use Attachment for create an attachment or we have to use AttachmentBuilder ?
the latter, that's why it exists
why we can contruct Attachment if AttachmentBuilder is a thing i dont understand it
the constructor is private
can I keep it if Attachment still work?
idk if it works or not, but the constructor is private, so you should not be using it
but its showing in the docs i have show privates option disabled
it might work now, but it might not work at a later stage
#8009 in discordjs/discord.js by almeidx opened <t:1654435245:R> (review required)
docs(Attachment): remove constructor doc
📥 npm i almeidx/discord.js#attachment-constructor
good job
this.client.on("ready", async () => {
const commands = this.client.commands.map((command) => ({
name: command.name,
description: command.description,
options: command.options,
type: command.type
}))
await this.client.guilds.cache.get("960547412567539763").commands.set(commands);
})
Don't refresh commands
Are you using the correct ID?
yes

try client.application.commands.set(commands)
it work for single guilds?
works globally, but if only one guild is used, there should be no problem.
const applyModal = new Modal()
Error:
TypeError: Modal is not a constructor
huh?
ModalBuilder

Why does typescript complain when I try to define client.commands, I have a discord.d.ts file to silence it..
discord.d.ts file:
import { Collection } from 'discord.js';
interface ExtraData {
commands: Collection<unknown, any>
}
declare module 'discord.js' {
export interface Client extends ExtraData {}
}
is that .d.ts file included in the tsconfig
🤦♂️ i completely forgot. tysm lol never knew all I had to do was just that.
what's the problem here?
*using dev version ^14.0.0-dev.1654430643-7a1095b
can i use discord.js to write a serverless bot?
No
anyone?
new ActionRowBuilder<ButtonBuilder>() iirc
Whats wrong with that?
TypeError: components.map is not a function
Code:
const applyModal = new ModalBuilder()
.setCustomId(`${client.user.id}_apply_${interaction.guild.id}`)
.setTitle(`${interaction.guild.name} Application`)
.addComponents(
new ActionRowBuilder()
.addComponents(
comps // Array of TextInputs
)
)
addComponents takes an array
Both?
yes
thank you!
New error
Expected the value to be one of the following enum values:
| Short or 1
| Paragraph or 2
at NativeEnumValidator.handle (/root/cloepremium/node_modules/@sapphire/shapeshift/dist/index.js:1666:66)
what is comps
an array of textInputBuilders
can you show the code for them?
let comps = []
guildDB.application.questions.forEach(entry => {
comps.push(
new TextInputBuilder()
.setCustomId(`${entry.ID}`)
.setLabel(`${entry.question}`)
.setStyle(`${entry.type}`)
.setMinLength(entry.min)
.setMaxLength(entry.max)
.setPlaceholder(`${entry.placeholder}`)
.setRequired(entry.required),
)
})
How can I implement a new description to a Message's embed
EmbedBuilder.from(firstLog.embeds[0]).setDescription()
damn, thank you
well entry.type needs to be a TextInputStyle
For context components returned from the api aren’t mutable anymore, they need to be converted to a builder
can I still do this:
<fetchedEmbed>.description = "test";
return <channel>.send({
embeds: fetchedEmbed
})
```?
If TS allows that it’s unintentional and needs to be fixed
I dont use ts
It doesn't
Ok well considering js allows you to do anything unsafe, there’s nothing we can do about that
Okay so this should still work?
const Embed = message.embeds[0];
Embed.fields[1].value = `**Approved** by ${modal.user.tag}!\n**Reason from ${modal.user.username}:** ${reason}`;
Embed.color = "#098A09";
Embed.author.name = `Approved ${Embed.author.name}`;
let error;
await message.edit({
embeds: [Embed],
}).catch(err => {
error = true;
})
Or do I need <Embed>.from()
It would but you shouldn’t be modifying the cache like that
why?
Bc if you modify the cache it’s no longer in sync. The cache should only be managed internally by djs
It’s like changing the .content of a recieved message
name: 'channel',
description: 'The channel to link the event log to',
required: true,
type: ApplicationCommandOptionType.Channel,
channelTypes: [ChannelType.GuildText]
}```
can some1 lmk why this is showing all channels instead of just text channels
If you're sending raw requests, you're using camel case
are u referring to me
yes
is it meant to be channeltypes
ahh ok
Is there anyway to get a property from a Builder? Like the opposite?
No
oops, ok
another thing I was wondering, why is log.target a type of never?
No idea, can you please make a bug ticket for that?
Which one is correct?
message.author.id or message.author.Id
id
👍🏻
I wish I could, but I don't currently have access to github on phone. Can you?
Can you paste that code here
I'm lazy
how am I supposed to paste it when im on phone :/
ok imma just go on laptop one sec
wat
const auditLogs = await ban.guild.fetchAuditLogs({
limit: 10,
type: AuditLogEvent.MemberBanAdd,
});
const findCase = auditLogs.entries.find((log) => log.target.id === ban.user.id);
do u mean this
It says log.target is possibly null
That's why it won't work
hmm how can I fix that
so it's not a bug?
Just noticed it's the same for every auditLogEvent
Now it sounds more like an issue with your TS server
So what I do is this
is there a way to limit a user to only 1 option from something like this?
those arent even valid option names
its an example
either use subcommands or a single option with choices or something
im asking something else
ok
choices dont take user input right?
not sure what that means
what's the modal fields limit
idk what you're asking exactly, but if you're asking the max amount of components in a modal, its 5
You can have the max amount of 4000 characters in a field
thanks
thats not exactly what I was asking but anyway thanks
Is a Modal just an ActionRow
Oh I see
Looks cool
why is that
how to fix error?
Ok so I just got the dev build
but the GatewayIntentBits are not part of discord.js
theyre part of the discord-api-types
@forest elm do you look?
that's right, and they are re-exported in discord.js
what if Im using just regular JS
one or more of those emojis you're passing in the values was not found
is it fine to use discordapitypes then
yes
alright thx
you can just import the enum from discord.js and use it normally
in the final build will it be in discord.js by default?
oh wait nvm they appear in discord.js now
I just needed to refresh my vs code window
@velvet jasper Why AttachmentBuilder and Attachment have unknown toJSON type?
So I was going to the buttons page on the new guide
doesnt work
app.f3e620f8.js:7 TypeError: Failed to fetch dynamically imported module: https://deploy-preview-1011--discordjs-guide.netlify.app/assets/buttons.html.263d8360.js
That’s how it was set before so I just kept it
Message#attachments
A collection of attachments in the message - e.g. Pictures - mapped by their ids
With the latest dev releases, I'm unable to send attachments, with the following error:
at findName (/srv/cosmic_goat/node_modules/discord.js/src/structures/MessagePayload.js:240:17)
at Function.resolveFile (/srv/cosmic_goat/node_modules/discord.js/src/structures/MessagePayload.js:254:31)
at /srv/cosmic_goat/node_modules/discord.js/src/structures/MessagePayload.js:221:85
at Array.map (<anonymous>)
at MessagePayload.resolveFiles (/srv/cosmic_goat/node_modules/discord.js/src/structures/MessagePayload.js:221:56)
at TextChannel.send (/srv/cosmic_goat/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:174:50)
at leveling.update (/srv/cosmic_goat/modules/leveling.js:247:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
AttachmentBuilder
would client.users.fetch() work the same way as client.api.users(person.id).get()?
the latter would not work, but if you mean from previous versions, yes
the different is the former returns a User instance and the latter returns raw api data
the latter didnt work so I just tried client.users.fetch()
and it seemed to work
because client.api was removed
yeah I assumed so
and it was a private thing anyway, which you shouldnt be using
oh I didnt know that
Lol I'm an idiot.
If I wanted to use the raw api I would prob be using the actual rest api I assume
so now it isn't necessary to set the fetchReply option to true for get a Message object?
from the interaction reply
Let me try without it cause I didnt know that
didn't work ._.
Same here
ah ok I read the PR bad
now we only get a Message object not an APIMessage
How would I be able to pop up a Modal
Documentation suggestion for @jaunty comet:
ChatInputCommandInteraction#showModal()
Shows a modal component
Guys what can I do against this?
https://i.imgur.com/opo6pZz.png
pass 0x<hex value> instead of a string
or import the builder from discord.js instead
ok thx
let component = new ModalBuilder()
.addComponents([
new TextInputBuilder()
.setCustomId("hello")
.setValue("TextInputStyle")
])
anyone know whats wrong with this
Error?
ValidationError > s.string
Expected a string primitive
Received:
| undefined
you didnt set the label of the textinput
however, you must wrap the textinput component in an actionrow
Ohhh
well I did this
let component = new ModalBuilder()
.addComponents([
new ActionRowBuilder().addComponents([
new TextInputBuilder()
.setCustomId("hello")
.setValue("TextInputStyle")
.setLabel("something")
])
])
didnt work
same error as last time
after some digging
I found the customId was the problem
I still dont know how to fix it so imma just find one
don't you need to set a style?
Didnt know what the options were
But I found SHORT
DiscordAPIError[50035]: Invalid Form Body
data.components[0].components[1][COMPONENT_LAYOUT_WIDTH_EXCEEDED]: The specified component exceeds the maximum width
for what in the modal is this?
max 1 text input per row
lol
you can't put action rows into other action rows
huh?
that are 2 diffrent action rows
scratch that, yes
ok thx
Is there a way to make a forEach or something like that with <modal>.fields ?
I need to forEach the inputs
yeah why not
Just add rows to the modal inside your forEach
Wait, do you mean the submitted fields?
[...<ModalSubmitInteraction>.fields.fields.values()]
Tc39 Iterator helpers proposal can’t come soon enough
yes
thx
Found the error
is it supposed to say this
cause I can grab the info the person submitted
but it says something went wrong
Not responding to the modal submit
do I have to do like
an interaction.reply
or something else
You can do that
Also heads up if you're using the latest dev version the channel-based typeguards methods are removed instead you should just check the type of the channel:
-if (channel.isText()) { }
+if (channel.type === ChannelType.GuildText) { }
Is there anything for Direct Messages
Channel#type
The type of the channel
alr
channel.isDMBased()
ChannelType.DM works too it seems
it does too
@crude valley, Hi, what kind of font do you use?
It's a paid font, sorry
but the name is this if you want
Noooo
I used these methods
I used to use just regular text lol
How to check if a member is banned or not?
<Guild>.bans.fetch(<UserResolvable>) and catch the promise rejection
👍🏻
builder's new dev version wasn't released along with djs dev which imports RestOrArray from builder
The releases are automated, you need to wait
- Attachment('url', 'filename.jpg')
+ AttachmentBuilder('url', { filename: 'filename.jpg' })
right?
+ AttachmentBuilder('url', { name: 'filename.jpg' })
The typing is wrong in current dev version and the pr is merged
That's APIAttachment
ah ok
thanks
when will the next dev version be released?
ah didn't see ._.
const { ActionRowBuilder, SelectMenuBuilder } = require('discord.js');
const row = new ActionRowBuilder()
.addComponents(
new SelectMenuBuilder()
.setCustomId('select')
.setPlaceholder('Nothing selected')
.addOptions([
{
label: 'Select me',
description: 'This is a description',
value: 'first_option',
},
{
label: 'You can select me too',
description: 'This is also a description',
value: 'second_option',
},
]),
);
console.log(row.toJSON());
``````js
TypeError: Found non-callable @@iterator
addComponents takes an array
there is something wrong with the typings of this commit: https://github.com/discordjs/discord.js/commit/349766dd6925e2d5e5597cc78c73e46f17c56eab#diff-cf0f0bd1759a85d7814ba3e340ab7d7a4e093ca44420c108e0888ef117ed910d
Shouldn't it be GuildMemberManager#fetchMe that instead of Guild#fetchMe?

hello excuse me 
how do i can fix this problem which suddenly came after I updated the discord.js@dev package??
this is solved now
Is there any ETA on this update release?
When it's ready™️ :)
What type of release even
Dev releases are there
why is interaction.guild.me undefined??
Cause it doesn't exist
It’s guild.members.me now
ah
may i have a full list of changes?
Check the guide in pins
i'm trying to create a select menu however typescript keeps showing an error, anyone know why?
Not getting that error
hmm, not sure why
(im on the latest dev version btw)
Which is?
14.0.0-dev.1654519696-fba9710
could it be due to this discord.d.ts file?
import { Collection } from 'discord.js';
interface ExtraData {
commands: Collection<unknown, any>
}
declare module 'discord.js' {
export interface Client extends ExtraData {}
}
fba9710 is not published to npm
How are you using it?
i updated it because i heard there was a new update
so if it isn't published, i'm not sure
To be pedantic, it's not the version on npm nor the latest commit, which would be 86d8fbc
I don't know what you have... but it's probably why I can't reproduce this
Reinstall discord.js from npm and try again
alright ill try that indeed
nope gave me the same version, is there a way to downgrade to the version you mentioned above?
Hmm now I reinstalled it and I'm getting fba9710... that's from /builders it seems
hmm
But I still can't reproduce the error
i managed to downgrade to this version, and the error isn't happening
so i don't know my issue there
ty lol
no longer supported?
so you're telling me fba9710 did get published??
Old dev versions are deprecated
ah okay
You probably just installed the latest dev version again, not sure how all that works
all i did was this lol
Yeah I dunno, I can't reproduce your error
hmm
All is fine
i went back to fba9710 and the error is gone
not sure how this happened i guess
Welp
don't merge this please https://github.com/discordjs/discord.js/pull/8027
care to elaborate?
That would be too logical a move
So wait is a text input builder the only component I can add to a modal currently
help
Is there a change log for v14, if so where can I find it
Your footer needs to be an object
deal ty
guide in pins
yes
Do they plan on adding more in the future
yes
Ok good
yo so like i have slash commands, when i run one of them, the others wont work and it says application did not respond here is my handler: ```js
const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v9");
const fs = require("fs");
const ascii = require("ascii-table");
// Create a new Ascii table
let table = new ascii("(/) Commands");
table.setHeading("Command", "Load status");
module.exports = async (client) => {
const commands = [];
const commandFiles = fs
.readdirSync("./slashCommands")
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(../slashCommands/${file});
commands.push(command.data.toJSON());
client.slashCommands.set(command.data.name, command);
if (command.data.toJSON().name) {
table.addRow(file, "✅");
} else {
table.addRow(file, ❌ -> Not able to load);
continue;
}
}
const token = process.env.TOKEN;
const rest = new REST({ version: "10" }).setToken(token);
try {
console.log("Started refreshing application (/) commands.");
const {clientId} = require(../config.json)
await rest.put(Routes.applicationCommands(clientId), { body: commands });
console.log("Successfully reloaded application (/) commands.");
} catch (error) {
console.error(error);
}
// Log the table
console.log(table.toString());
};
Why not it’s not needed
how are you executing your commands
let row = new ActionRowBuilder()
.addComponents([
new ButtonBuilder()
.setCustomId('bang1')
.setLabel('Bang')
.setStyle(1)
.setEmoji('🔫'),
new ButtonBuilder()
.setCustomId('bang2')
.setLabel('Bang')
.setStyle(1)
.setEmoji('🔫'),
new ButtonBuilder()
.setCustomId('bang3')
.setLabel('Bang')
.setStyle(1)
.setEmoji('🔫'),
new ButtonBuilder()
.setCustomId('hunting-info')
.setLabel('What is Hunting?')
.setStyle(2)
.setEmoji('🤔')
])
I have an action row with buttons. How can I take a button from the action row, disable the button, and edit the action row into a message?
is there a specific button you need to edit
that like you know beforehand
I'm editing the button within a collector that's below.
Though, the button that needs to be edited depends on which of the first three is clicked.
The last one isn't relevant for what I want to do.
@velvet jasper
can you show your collector code?
for the record builders is kinda in flux there's probably going to be major changes soon
collector.on('collect', async (i) => {
row = ButtonBuilder.from(row.components[row.components.findIndex((c) => c.custom_id === i.customId)]).setDisabled(true)
await i.update({ compontents: [row] })
})
@velvet jasper
here is the confusing part
oh wait a minute wow
"compontents"
Xddd
Do you really need to access the array finding the index?
Isn't array.find just enough
i forget that some methods exist sometimes
Not to mention you're assigning a button to "row" which should be an action row correct?
i already changed ButtonBuilder to ActionRowBuilder
Okay is it all good now? Does it work?
hold on i was about to see
Hmm try without from, calling a constructor instead
It most certainly is, update and show the definition for it
Make sure it is imported from discord.js
ok
oh, would it be c.data.custom_id?
Maybe. Try it. Also split it up. Everything after the from call, move it to another line
now i'm getting this error
Did you move it to another line?
oh, i didn't
move everthing after find()?
Also if you still have issues, just describe it with as much detail as needed
Goodnight
oh, goodnight
anyway to acknowledge interaction.reply without actually replying
deferReply
Then you can editReply later
oh yea ended up using deferUpdate as deferReply ended up endlessly . . . waiting
er anyway to close modal automatically?
i.awaitModalSubmit({filter2, time: 10000}).then(modal => {
// some code
}).catch(e => {
// fail, close modal automatically
})```
you cannot close a modal
and you are not passing the filter to awaitModalSubmit correctly
it expects a filter option, and not filter2
rip
let Discord = require('discord.js')
require('../client.js')
module.exports = {
name: "interactionCreate",
once: true,
async execute(interaction){
const { client } = interaction;
let guildQueue = client.player.getQueue(interaction.guildId)
if (!interaction.isCommand()) return;
const command = client.slashCommands.get(interaction.commandName, interaction);
if (!command) return;
try {
await command.execute(client, interaction, Discord, guildQueue);
}catch (error) {
console.log(error);
await interaction.followUp({
content: "There was an error while executing this command!",
ephemeral: true,
});
}
}
}
InteractionCreate needs to be a .on
Otherwise it’ll only execute once, which happened to you
Np
When v14 will release?
when its ready
When it's ready™️
Okay
Why can't I edit reply after answering the modal, like when I reply to button interaction I can edit last reply, but when I'm trying to answer to modal and edit last reply message I cant
Are you calling update on the modal?
no editReply
there is no update method available
Documentation suggestion for @prisma kiln:
ModalSubmitInteraction#update()
Updates the original message of the component on which the interaction was received on.
oh, wait
It should work since the modal originated from a message component interaction
editReply requires that you alr called reply, update, or the defer variant of either
but the interface not contain update method for ModalSubmitInteraction
It’s documented
maybe I should update the package
Oof, it’s not in the ts types
lmao
Oh, it’s a different class name
ModalMessageModalSubmitInteraction
You get it by checking .isFromMessage()
oh, ok thank you very much
where can i find djs 14 docs?
and the changes between v13 and v14
Refer to pins
ty
if(message.member.roles.cache.has("971537773444100146")) {
TypeError: Cannot read properties of null (reading 'roles')
message.member is null, which most commonly happens when the message was sent in DMs
but i have if(!message.guild) return;
what triggered that error? It may be that an application was added without the bot scope, so it's not technically a member of the guild
it's in the messageCreate event
am i definitely on the correct version?
a lot of changes to be honest. how do I get СomponentType now?
const { ComponentType } = require('discord-api-types/v10')
``` this path does not give me anything
import it from discord.js even if this should work
ComponentType is there, what do you mean it doesn't give you anything?
found a bug in GuildInviteManager
when you try to force fetch guild invites it won't really work as force option does not really exist
only cache option does exists in fetch method
guild.invites.fetch({ force: true });
this code gives the error in the SS
docs says there is a force option while it does not work and as i reviewed the source of the method i couldn't seem to find any option with the name 'force'
guild.invites.fetch({ force: true }); I'm pretty sure this is not a correct overload anyway, there is no force option when fetching all invites
Because it's always forced
So it probably thinks you're fetching a singular invite but you didn't supply a code
Yep, if you provide force, for the FetchInviteOptions, code isn't optional
It's also not documented here
if its always forced why is there force option in the docs
What your code is doing and what you are looking at are both completely different
You're looking at the documentation to fetch a singular invite, but your code is fetching all invites
This is the fetch all one
https://discord.js.org/#/docs/discord.js/main/typedef/FetchInvitesOptions
oh wait got it there is literally 1 character difference
Yea, the plural
so if i do invites.fetch() without any options its already forced
What does it mean?? ModelType??
you did something wrong with an embed, can I see the code
don't you need to toJSON() an EmbedBuilder before sending it
No?
the label for buttons maybe?
they use Emojis
ah yeah
then it wouldn't point to data.embeds[0]
How to give donations?
why not
For it has not been a problem befor
wdym?
donations to discord.js or donations for your own bot?
and i don't json my embeds for i use the same way on other commands and it works fine
Looks like djs already does it for you?
i use array
doesn't look like it takes Array<EmbedBuilder>
:/
no need to call .toJSON()
just try
it's not going to explode your machine
at worst the error won't go away
EmbedBuilder should support Array
what?
that is not what that says
nor that's not how that works
docs seem to be outdated, types are correct embeds?: (JSONEncodable<APIEmbed> | APIEmbed)[]
interesting given how they refresh every time i open them, but sure

I can "reproduce" the error if I try to send embeds: [undefined], seems like your loop isn't working as intended
Hmm ok weird
So it's a discord.js error or is it on my side??
it's on you for providing an invalid payload
Let me check that out 
yea you had right its undefined weird
Name theme?
Aren't you importing directly from Discordjs? So you don't need the Util.resolveColor, right?
Perhaps they need to convert it
To a color resolvable
setColor(color) {
return super.setColor(color && Util.resolveColor(color));
}```no, it calls it internally
I see
What does that even return
It means that internally, Util.resolveColor is called
you don't need to call it yourself and pass it
And it returns the Embed Builder, and the resolveColor returns a number
I see
Well yeah Ik the resolve color is a number
The EmbedBuilder in the builders package only takes a number or an rgb tuple
the extended djs class takes in a color-resolvable, it resolves it internally to make it work for the builders' setColor
I installed the dev version when this channel has been created, so a lot of changes since his creation
Andromeda Colorizer
I added descriptionLocalizations to my Slash Commands but when I change the locale of Discord to this language ("fr") the descriptions are still in english
do u have localizations build?
I guess, because VSC suggested nameLocalizations
Idk if this build has localizations:
"discord.js": "^14.0.0-dev.1650931749-df64d3e",
They mean the discord build override to show localizations in the client
What is that ?
OH I see now
I haven't the override
How I can get it. I forgot where I got it
The override is invalid
maybe remove this from pins? ^
Did the rest thing get merged
Heh nice
The pin hath gone then
also a new builders version https://github.com/discordjs/discord.js/releases/tag/%40discordjs%2Fbuilders%400.15.0
The fetch returns a Collection if there’s no id passed
But doesn’t seems wrong, do you have the GUILD_MEMBERS intent?
there is
And member returns what?
when receiving a message component interaction in a guild, when can member be an APIInteractionGuildMember?
I don't think it can?
also why can't a GuildMember object be constructed since the docs say ** member is sent when the interaction is invoked in a guild, and user is sent when invoked in a DM, so shouldn't a full guild member object be received?
@velvet jasper ^ :eyes:
you get the raw object when the guild isn't cached afaik
Actually looks like that wasn't updated
https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/structures/Interaction.js#L60-L64
So yeah if it's in an uncached guild, it's the raw object
I'm pretty sure there was a pull request to always return discord.js instances though
only for messages
Oh
guild members have a direct reference to a guild, no getter
though that could probably be changed too
it looks like GuildMember relies heavily on the guild not being null so I'll just make sure its in a cached guild instead
someone renamed this channel
#analyse
Is there currently an issue with the messageCreate event? It's not firing on my bot right now.
AttachmentBuilder
Represents an attachment builder
How do you make dynamic choices like in /docs ?
its autocomplete
not choices
but it looks like choices
Do you have the guild messages and guilds intent?
I fixed the issue, it was my own fault after all.
Excuse me, everyone. I would like to ask for help, what function should I use? The expectation of this should be that the previous objects won't add up or stack up with each other but it should only display what the objects would only be. Here's a source code. Hope someone could help me with my problem.
const colsheads = () => {
let tempArray = [];
tableData.map((head) => {
head.list_attributes.map((columnheaders) => {
const tempObj = { field: "", headerName: "" };
tempObj["field"] = columnheaders.list_attr_data_key;
tempObj["headerName"] = columnheaders.list_attr_data_key;
tempArray.push(tempObj);
});
});
return tempArray;
};
However the outcome of this in my display would be like this.
How is this discord.js related
if any message is deleted in a voice channel then does it not emit the messageDelete event?
It should... why?
i tried doing so but it didnt work
when i did the same on a normal text channel it got emitted
I am unable to reproduce that. I deleted a message in a text-in-voice channel and the event got emitted.
do i need some intent or smth
ah, wait maybe i need to update to the latest v14
"discord.js": "^14.0.0-dev.1651147765-679dcda",
im on this one rn
yup it worked after updating the package.
what is the alternate for Guild#me ? since its removed in v14
iirc its now guild.members.me
okay thanks
Am I doing something wrong? I can't seem to tell whether a message is edited. I'm sending a message and storing it
const message = await channel.send({content: 'Hello world!'});
and later on (many seconds later), I edit it
message.edit({content: 'Good morning, world!'});
However, afterwards (many seconds later), editedAt and editedTimestamp are null, even after fetching it (even with force: true)
await message.fetch(true);
console.log(message.editedTimestamp); // => null
const message = await channel.send({content: 'Hello world!'});
setTimeout(async () => {
message.edit({content: 'Good morning, world!'});
}, 2000);
setTimeout(async () => {
await message.fetch(true);
console.log(message.editedTimestamp);
}, 6000);
try resolve Message#edit promise, await it
Ok, that seems to work...is there no other way to tell if a message was edited?
compare content, embeds, components with old message maybe? if you want other tricky way. the best to do is check for editedAt and editedTimestamp
awaiting edit only works if I can actually keep the return value of await message.edit(...)
if that was done in another context, editedTimestamp will still be null on the original message
const content = 'Hello world!';
const message = await channel.send({content});
setTimeout(async () => {
const editedMessage = await message.edit({content: 'Good morning, world!'});
console.log(`after edit: ${editedMessage.editedTimestamp}`);
}, 2000);
setTimeout(async () => {
await message.fetch(true);
console.log(`later: ${message.editedTimestamp}`);
}, 6000);
after edit: 1654663077932
later: null
Ahhh- message.fetch might not do what I think it does.
nope. I thought message.fetch might return a new message object, but the return value still has null for editedTimestamp
message = await message.fetch(true);
console.log(`later: ${message.editedTimestamp}`); // later: null
I have added this code in my bot to stop error when we try to unban someone who is not banned. But this I get this error
if (!ctx.interaction.guild.bans.fetch(user?.id)) return ctx.interaction.reply({ content: `${process.env.FAILURE_EMOJI} | The given user is not banned!` });
catch the rejection
huh?
#resources #useful-servers if you dont know them
cant you do a .then on the message
you need to catch the rejection, not resolving em
bans.fetch return a pending promise. This promise throw error when ban doesn't exists
👍🏻
i do await the fetch before attempting to access editedTimestamp, if that's what you're suggesting
No I meant after message is sent, you do a .then(), and then inside of it you do a setInterval that edits the message
ah, so the actual use case is that when someone clicks a button, the message is edited. The bot later needs to know if the message was edited or not, ideally without having to manually keep track of that myself
so the send and edit won't be done together, unlike the repro
In the .then you could add the event in it
And then make it so that if they click the button it edits it
I appreciate your input. I could, but I would consider that a workaround. I was hoping I could use the library for what I expected it to do
My first thought would be using the api but thats probably not ideal
So you can do something like:
let msg = await message.channel.send(message)
And then check if msg.editedAt exists
probably not what ur looking for but yea
yeah, that's pretty much what I'm doing right now, but editedAt and editedTimestamp are null even though the message was edited 😦
What if you yourself set a timestamp
like msg.editedTimestamp = Date.now()
Hello! And where can I see permissions in string?
PermissionsBitField.Flags outputs only bigint, and I want to see them in string
Are you using GatewayBitIntents
oh wait nvm ur doing perms
Documentation suggestion for @thorny haven:
PermissionsBitField#toArray()
Gets an Array of bitfield names based on the permissions available.
Would that get you what you want?
oh, you're trying to print out every permission? Try using PermissionsBigField.Flags
not too sure what you expected with a "new" permission bitfield
ofc that's gonna be 0
he said he wants to see the permissions as a string
pretty sure
You can take the keys of that object if you want just the strings
Just do Object.keys(Discord.PermissionsBitField.Flags)
actually if u wanted to do that
no, I understand that it is possible to do this, but before discord.js itself printed out the flags beautifully. by MANAGE_MESSAGES type
beauty lies in the eyes of the beholder
news = ""
for i = 0, i < len(flag) - 1, i++:
if isUpper(flag[i]) && i != 0:
news += "_" + flag[i]
else
news += upper(flag[i])
or sth like that
I understand that when creating a channel, string permissions from discord dev portal are supported
👏
I mean you have the option to create a channel using the api
permissionOverwrites supports allow with string type permissions?
dont think so
actually idk lol
this.permissions = [
{
id: "798867454205231124",
deny: ["VIEW_CHANNEL"]
}
]```I wanted to do something like this
You can just do new Discord.PermissionsBitField[deny[0]]
or something along the lines of that
use static flags lel
in your code, just use the enum
I believe strings are going away in v14
they still work for me if you do it like that
as in they give me the permissions bitfield
PermissionFlagBits.ViewChannel - clean and efficient
looks good to me
well, yes, it gave an error
wait I did it wrong
new Discord.PermissionsBitField(deny[0])
supposed to be a function
read what souji said
or just do this honestly
it is possible, but it takes a lot of lines if you change more permissions
what?
if you put each permission on one line, it would be the same amount of lines
you needed flag strings, now you need flag enum properties, i don't see the big difference, tbh
alternatively you can just one-time compute the thing and pass the bigint
but that's obv. less readable
should prob. | those anyways
I just wish it was like before, but apparently it's no longer available
then write your own util function to make it happen
like, programming, extend things to fit what you want them to do
well
function, pass in strings, return a single bigint with the combined perms
I was thinking of making it something like "ViewChannel", and then applying a .map on the array
can prob. even do that with dynamic property accessors
haven't tried yet, i usually use enums as enums, because they're great and verbose
but for other people lines of code is an issue, for some reason
for me I just read the stuff after the .
I prefer enums just in case the underlying value ever changes
for example that funny person that said eris is better because it has less lines of code
- but i'm getting off topic here
I used to like that discord.js gave 2 options, either bigint or string permissions. and option 2 suited me, but right now it was removed. and it became somehow dreary
okay, I'll try to make a bicycle so that the strings are converted into bits
As I said this would work:
new Discord.PermissionsBitField(string)
But up to you
I told you, it gave an error
https://thumbsnap.com/i/cLWMruut.png I will use this option.
That was cause I made it an array, not a function
But the other method is better anyway so use that
Wait nvm
@thorny haven https://discord.js.org/#/docs/discord.js/main/class/BitField?scrollTo=s-resolve
map the flags with that, should do the job
for some reason it doesn't show on PermissionsBitField but is directly inherited
-ev Discord.PermissionsBitField.resolve("BanMembers")
4n```• d.js `14.0.0-dev.1651493371-4ba0f56` • Type: `bigint` • time taken: `0.122831ms`
I think its cause he was doing VIEW_CHANNEL, which probably isnt on Discord.PermissionsBitField
Either way he’d have to use a different string format
Does anyone know how to get modal interactions custom id to work?
f(interaction.customId === "banappealModal"){
const reasonofappeal = interaction.fields.getTextInputValue("appealtext")
const emailofuser = interaction.fields.getTextInputValue("emailofuser")
console.log(interaction.customId)
as this dosent work
doesnt work how
Like it dosent do anything
I also tried putting interaction.customId in
Show the code above it, how do you get to here
™️
hmm well if i dont use v14 is it fine
it's fine til we drop support for v13, then you will have to update at some point 

how to force someone
WAIT WHAT! I JUST STARTED LEARNING USING DISCORD JS.GUIDE AND V14
nvm
updated version to v14 and dint even updated code

u bad bad

everything you need to know in regards of updating to v14 is pinned
help! i cant get
^ read
: >
^
ReferenceError: Client is not defined
at Object.<anonymous> (D:\aayush\skeyush bot\index.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157: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```
sir you gave me alot of error
now help me :>
learn js #useful-servers
:> yeah i was thinking to learn js again
Hmm lets wait for v14 to realease again
till what time to wait
til its done
spoiler: you should learn js before making the bot :)
bruh i know js
if(interaction.isModalSubmit()) {
if(interaction.customId === "suggestionModal") {
const suggestionstitle = interaction.fields.getTextInputValue('suggestiontitle')
const suggestion = interaction.fields.getTextInputValue("suggestion")
const row = new ActionRowBuilder().addComponents([
Is there anything above that causing it to return
Nope
OO
i think i found out why
I think i did it on the wrong }
am i supposed to be able to re-fetch a message in order to update properties such as editedTimestamp?
What are your intents?
That was the reason
It works now
but do you know how to change the 16234324 timestamp thing to real time stamp, like 8. Juny 2022 11:42 am?
Some time (up to five minutes) after sending a message, determine whether or not said message was edited
Do you know what a gateway intent is?
Oh, those
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
Well from the list of intents, you are not looking for guild messages. Therefore, you are not receiving any updates
Yep
Jiralite, u know how to make so it dosent send out timestamp numbers, but shows the real timestamp?
These , i want em like 8. Juny 2022 11:46 Am
Like that instead of what it said
Ahh, so I'm missing GuildMessages then arent I
Yep
is that intent required to forcibly refetch a message too?
Think so
@uncut kelp (Sorry for piiinggg)
you could use native js date objects, but keep in mind that it will always use the system's tz
Yeah
but can it display the timezone then?
Documentation suggestion for @granite yacht:
Date.prototype.toLocaleDateString()
The toLocaleDateString() method returns a string with a language sensitive representation of the date portion of the specified date in the user agent's timezone.
check out Intl.DateTimeFormat as well
What?
Message formatting (mentions, timestamps, emoji, etc.): learn more
Whats intl?
nvm, just saw the screenshot
is it interaction.DateTimeFormat?
@hasty beacon
Documentation suggestion for @granite yacht:
Intl
The Intl object is the namespace for the ECMAScript Internationalization API, which provides language sensitive string comparison, number formatting, and date and time formatting. The Intl object provides access to several constructors as well as functionality common to the internationalization constructors and other language sensitive functions.
Intl.DateTimeFormat
The Intl.DateTimeFormat object enables language-sensitive date and time formatting.
how do i use it?
im really confused rn
by reading the docs. not djs related.
Fixed
can someone explain the error to me? It seems like I'm doing something wrong with the action row, because when I send the message without the components it works
doesnt look like you set customId for your selectmenu
oh
now it works! thanks
const member = interaction.options.getMember("user");
if(member.roles.highest.position >= interaction.guild.members.me.roles.highest.position) {}
Cannot read properties of undefined (reading 'roles')
i've been getting this error for a while now and i've never had issues with it
Try logging member and guild.members.me
Q: Am I correct that Channel#type is gonna get removed?
no
What made you think that
Thought I heard about it somewhere on djs' github
nvm them, crisis averted
How can I get total count of users who have administrator permission in a server?
filter members by permission
👀 Okay, I will try
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS], partials: ['MESSAGE', 'CHANNEL', 'REACTION']});
^
TypeError: Cannot read properties of undefined (reading 'FLAGS')
at Object.<anonymous> (C:\Users\whes1015\Desktop\B-MPR\index.js:3:47)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Module._load (node:internal/modules/cjs/loader:827:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Node.js v18.3.0```
Is this correct in v14?
No
You use gatewaybitintents
What's correct in v14?
check pins
Is this correct for v14???
no
look at the guide in the pins
Where is v14 Documentation?
pins
I was directed to the v13 documentation
use main branch
the link in the pins takes you to the main branch documentation
pls help
did you import gatewayintentbits from djs?
either import GatewayIntentBits from discord-api-types or use IntentsBitField
IntentsBitField (extends BitField)
Data structure that makes it easy to calculate intents.
no
you can import it from d.js as well
everything from dapi-types is re-exported
Then i suggest you do it, it doesnt magically get imported
what is better to use? gatewayintentbits or intentsbitfield?
doesn't matter, IntentsBitFields.Flags is GatewayIntentBits
ah okay
ok, thx
bumping
just has some extra methods
Hi, how I can use autocomplete interactions ?
Wdym by “auto complete”
@jaunty comet
setAutocomplete(true) if you're using builders, in your slash command options. Though note not all accept autocomplete. Then just handle the interaction as usual in your interactionCreate event
Oh okay, and to display dynamically as the user types what are the methods ?
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.
Is that an issue? I don't see any context
Just this message appeared from nowhere
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()
Modal is not a constructor
bruh
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
Known issue in 13.8
Not related to guildCreate though, it's with webhooks
is the dev version
ok
Probably the same bug
It also got backported
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
Suggestion for @jaunty comet:
Interactions: Modals
read more
Wait I meant context menu
Mixed them up whoops
two types
MESSAGE
USER
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