Random errors after running `npm update`

I accidentally ran npm update in one of the repositories I'm working on (I'm using nodejs v18) and now I just get a bunch of errors on all my slash command builders. I quite frankly don't understand them so I'm hoping someone here could.
No description
28 Replies
d.js toolkit
d.js toolkit3mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
cody
cody3mo ago
Djs version is 14.13.0
Svitkona
Svitkona3mo ago
can you show your code?
cody
cody3mo ago
Which part? The builders or the function?
Svitkona
Svitkona3mo ago
well, let's start with the definition for SlashCommandSubcommandsOnlyBuilder i have something which i assume is close to what you have and it seems to work https://tsplay.dev/NloQlw ugh sorry ,wrong link https://tsplay.dev/wXLzQw
cody
cody3mo ago
export function data<M extends 'slash' | 'context' = 'slash'>(
data: M extends 'slash' ? Partial<SlashCommandBuilder> : Partial<ContextMenuCommandBuilder>
) {
return function <T extends { new (...args: any[]): {} }>(constructor: T) {
return class extends constructor {
data = data;
};
};
}
export function data<M extends 'slash' | 'context' = 'slash'>(
data: M extends 'slash' ? Partial<SlashCommandBuilder> : Partial<ContextMenuCommandBuilder>
) {
return function <T extends { new (...args: any[]): {} }>(constructor: T) {
return class extends constructor {
data = data;
};
};
}
This is the function that handles the slash command creation ^
export default abstract class Command<IsMsg extends boolean = false> {
public readonly data: IsMsg extends false ? Partial<SlashCommandBuilder> | Partial<ContextMenuCommandBuilder> : null =
null!;
public clientPermissions: PermissionsBitField | null = null;

// only present in slash commands
public id: If<IsMsg, null, string> = null!;
// not present in slash commands
public name: If<IsMsg, string> = null!;
public description: If<IsMsg, string> = null!;
public aliases: If<IsMsg, string[]> = null!;
public args: If<IsMsg, string[] | null> = null!;
// Not Available - Redirect to slash command
public slashOnly: If<IsMsg, boolean> = null!;

public allowDM = false;
public guildResolve = false;
public client = client;
public flags: string[] | null = null!;

abstract run(
interaction: ChatInputCommandInteraction | Message | ContextMenuCommandInteraction,
args?: string[] | null,
guild?: Guild
): unknown;
}
export default abstract class Command<IsMsg extends boolean = false> {
public readonly data: IsMsg extends false ? Partial<SlashCommandBuilder> | Partial<ContextMenuCommandBuilder> : null =
null!;
public clientPermissions: PermissionsBitField | null = null;

// only present in slash commands
public id: If<IsMsg, null, string> = null!;
// not present in slash commands
public name: If<IsMsg, string> = null!;
public description: If<IsMsg, string> = null!;
public aliases: If<IsMsg, string[]> = null!;
public args: If<IsMsg, string[] | null> = null!;
// Not Available - Redirect to slash command
public slashOnly: If<IsMsg, boolean> = null!;

public allowDM = false;
public guildResolve = false;
public client = client;
public flags: string[] | null = null!;

abstract run(
interaction: ChatInputCommandInteraction | Message | ContextMenuCommandInteraction,
args?: string[] | null,
guild?: Guild
): unknown;
}
This is the class ^
@data<'slash'>(
new SlashCommandBuilder()
.setName('appeal')
.setDescription('Create a new appeal for an infraction.')
.addIntegerOption(option =>
option
.setName('id')
.setDescription('The infraction ID for the infraction you are appealing.')
)
)
@data<'slash'>(
new SlashCommandBuilder()
.setName('appeal')
.setDescription('Create a new appeal for an infraction.')
.addIntegerOption(option =>
option
.setName('id')
.setDescription('The infraction ID for the infraction you are appealing.')
)
)
And this is a random command that will throw the error ^
Svitkona
Svitkona3mo ago
i don't see SlashCommandSubcommandsOnlyBuilder there
cody
cody3mo ago
exactly
Svitkona
Svitkona3mo ago
oh my bad, it's a djs thing this might just be a type issue in the package aha it's a known issue, i think? https://github.com/discordjs/discord.js/issues/10256 https://github.com/discordjs/discord.js/pull/10255 for now i'd suggest reverting to the previous version
cody
cody3mo ago
The thing is im on discord.js v14.13 according to npm list, but it seems to think that im on 14.15.2
Svitkona
Svitkona3mo ago
try removing node_modules
cody
cody3mo ago
i did, it installs 14.13 as its supposed to but it still gives me that error
Svitkona
Svitkona3mo ago
hmm... try removing package-lock.json as well, then ideally you wouldn't, but your dependencies are kinda messed up oh, keep a backup of it first
cody
cody3mo ago
I did some messing around lets see if it works now I honestly don't even understand anymore Now I'm getting like 30k errors in the console when using npm install
Svitkona
Svitkona3mo ago
😢 what did you do?
cody
cody3mo ago
I just deleted every trace of all my node modules and now this is happening So confusd
cody
cody3mo ago
No description
cody
cody3mo ago
???? I don't use these packages at all
Svitkona
Svitkona3mo ago
they're probably transitive dependencies check your package-lock.json
cody
cody3mo ago
not a trace of them there either for whatever reason discordjs doesn't wanna go back to 14.13.0 Fuck it i gotta force it then YES THAT WORKED WOO
Svitkona
Svitkona3mo ago
what did you do?
cody
cody2mo ago
I just force installed djs v14 npm i discord.js@14.13.0 Hopefully they fix the issue soon so I can update to 15.2 I'll try when I get home and confirm if it is or not. Really hoping it is bc I could use the polls feature Updated to the latest version last night and was still getting the error. I don't think it's fixed
Akerck ⏚
Akerck ⏚2mo ago
@dan You can use npm uninstall discord.js and install a specific version of the package (older and stable version) with npm install discord.js@the.version.you.want Hoping it can help 😅
cody
cody2mo ago
Oh yeah, i know lol. This Is what I did I don't remember. I'll check again when I'm back home But discordjs showed 14.15.2 from what I remember Most of my packages got messed up during the update so I'm just gonna re configure them all. They're all due updates cuz I'm running some old versions
cody
cody2mo ago
@Qjuh
No description
cody
cody2mo ago
The error still presists So it hasn't been fixed in 15.2 It's alright. Guess I'll stick to 14.13.0 for now for whatever reason that also wants to give me the error... my node modules are severely fucked from what it's telling me its on 1.7.0
cody
cody2mo ago
@Qjuh
No description
No description
cody
cody2mo ago
Yeah Wait I think I have an idea give me a sec Okay even though it shows up as 1.7.0 it's actually downloading 1.8 for whatever reason Yeah Oh well, I don't mind staying on 14.13.0 it works fine for me Gotta wait till its fixed to utilize polls
Want results from more Discord servers?
Add your server
More Posts