Conflicting types

I use the latest version of djs (14.14.1) and it seems like it has different types for taking the result from parsing.
No description
Solution:
anyway if I write the code like this then it works fine: ```ts import { ApplyOptions } from '@sapphire/decorators'; import { Awaitable, InteractionHandler, InteractionHandlerTypes, Option } from '@sapphire/framework'; import { AutocompleteInteraction, type ApplicationCommandOptionChoiceData } from 'discord.js';...
Jump to solution
6 Replies
Kito
KitoOP10mo ago
And as a result, Auto Completions are broken
No description
Favna
Favna10mo ago
Please share your package.json and lock file so the issue can be reproduced and analysed.
Favna
Favna10mo ago
are you sure that's your packge.json entirely? you dont have typescript in there at all.
Solution
Favna
Favna10mo ago
anyway if I write the code like this then it works fine:
import { ApplyOptions } from '@sapphire/decorators';
import { Awaitable, InteractionHandler, InteractionHandlerTypes, Option } from '@sapphire/framework';
import { AutocompleteInteraction, type ApplicationCommandOptionChoiceData } from 'discord.js';

@ApplyOptions<InteractionHandler.Options>({
interactionHandlerType: InteractionHandlerTypes.Autocomplete
})
export class AutocompleteHandler extends InteractionHandler {
public override async run(interaction: AutocompleteInteraction, result: InteractionHandler.ParseResult<this>) {
return interaction.respond(result);
}

public override parse(interaction: AutocompleteInteraction): Awaitable<Option<ApplicationCommandOptionChoiceData[]>> {
// Only run this interaction for the command with ID '1000000000000000000'
if (interaction.commandId !== '1000000000000000000') return this.none();

return this.some([
{
name: 'a',
value: 'b'
}
]);
}
}
import { ApplyOptions } from '@sapphire/decorators';
import { Awaitable, InteractionHandler, InteractionHandlerTypes, Option } from '@sapphire/framework';
import { AutocompleteInteraction, type ApplicationCommandOptionChoiceData } from 'discord.js';

@ApplyOptions<InteractionHandler.Options>({
interactionHandlerType: InteractionHandlerTypes.Autocomplete
})
export class AutocompleteHandler extends InteractionHandler {
public override async run(interaction: AutocompleteInteraction, result: InteractionHandler.ParseResult<this>) {
return interaction.respond(result);
}

public override parse(interaction: AutocompleteInteraction): Awaitable<Option<ApplicationCommandOptionChoiceData[]>> {
// Only run this interaction for the command with ID '1000000000000000000'
if (interaction.commandId !== '1000000000000000000') return this.none();

return this.some([
{
name: 'a',
value: 'b'
}
]);
}
}
That said, the explicit return type for parse is only required because of pnpm. When I install dependencies with npm or yarn then having it implicit is enough. This is just one more of the quirks of pnpm's way of doing pnp that isn't really compatible with the NodeJS ecosystem. If you use pnpm for its speed over npm we recommend looking into Yarn v4 which is just as fast if not faster. You can use /tag query: yarnv4 from @Spinel to get a copypasta about installing yarn v4. At its core this problem probably stems from that pnpm does wacky stuff with how it puts dependencies in node_modules without patching typescript to ensure that it can properly process this. If you compare that to yarn's PnP mode (optional!!), there you HAVE to use a custom typescript wrapper otherwise it just straight up doesn't work. pnpm should do that same but I doubt they ever will
Kito
KitoOP10mo ago
I have ts installed globally. I won't share my project anywhere cuz it's just for me personally, a kind of a test development bot process. hm Thanks, this way actually solved that issue.
Want results from more Discord servers?
Add your server