Linter errors in command options after upgrade

Hey there, After upgrading to the freshest Sapphire and Discord.js versions I've got error in every command where I parse the options. For example:
const channel = interaction.options.getChannel('channel');
const messageId = interaction.options.getString('messageid')!;
const channel = interaction.options.getChannel('channel');
const messageId = interaction.options.getString('messageid')!;
Here I got two errors in my linter: Inside .getChannel()
Expected 0 arguments, but got 1
And at .getString()
Property 'getString' does not exist on type 'Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused">'
The interesting thing is the errors are only inside my linter and in CLI it builds without any warns or errors. Did I forgot to add something or remove something from my package.json?
Solution:
I had to reinstall the IDE and now it seems to work
Jump to solution
11 Replies
UndiedGFX
UndiedGFX12mo ago
have you tried reinstalling node_modules or regenerating your lockfile? and its not the linter, its the typescript which is warning you, also try to restart the TS server in your IDE
Feralheart
FeralheartOP12mo ago
I've tried to reinstall node_modules, but haven't tried to regenerate the lock file Now I've tried with - deleting node_modules - deleting yarn.lock - restarting the TS server - restarting the IDE completely but the error is still there
UndiedGFX
UndiedGFX12mo ago
quite weird because #getChannel requires one argument (3 in total) and the same for getString are you sure by any chance the interaction type is not ChatInputCommandInteraction? @Feralheart @Feralheart iirc there is a difference in types between ChatInputCommandInteraction and CommandInteraction
Spinel
Spinel12mo ago
<::898645160248897586> ChatInputCommandInteraction#options The options passed to the command. <::898645160336977960> CommandInteractionOption Represents an option of a received command interaction.
UndiedGFX
UndiedGFX12mo ago
you sure typeof <interaction> is ChatInputCommandInteraction?
Feralheart
FeralheartOP12mo ago
I've declared the method like this:
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// command logic
}
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// command logic
}
But if I change the typing to ChatInputCommandInteraction or to CommandInteraction the error remains
UndiedGFX
UndiedGFX12mo ago
the issue should not persist at this point...considering you dont have any issues on build time as well
Feralheart
FeralheartOP12mo ago
yes, I don't have any errors buildtime
UndiedGFX
UndiedGFX12mo ago
delete node modules yarn cache yarn.lock and try again
Feralheart
FeralheartOP12mo ago
tried it, but the error is still there
Solution
Feralheart
Feralheart12mo ago
I had to reinstall the IDE and now it seems to work
Want results from more Discord servers?
Add your server