Gavan
Gavan
Explore posts from servers
SIASapphire - Imagine a framework
Created by Gavan on 12/14/2022 in #sapphire-support
Is there a recommended way to split subcommands across multiple files?
Perhaps another way of phrasing this question is: Can I have arbitrary typescript files in the commands directory without breaking things?
6 replies
SIASapphire - Imagine a framework
Created by Gavan on 12/14/2022 in #sapphire-support
How do subcommands work with idHints and guildIds?
How do subcommands work with idHints and guildIds?
5 replies
SIASapphire - Imagine a framework
Created by Gavan on 12/13/2022 in #sapphire-support
Is there a way to prevent fetching information both in the precondition and the command itself?
I need to fetch the same data to resolve a precondition, as I'll need later in the command. Is there a way to prevent fetching this twice?
8 replies
SIASapphire - Imagine a framework
Created by Gavan on 12/5/2022 in #sapphire-support
Autocomplete handler not working
I made a interaction-handlers folder adjacent to my commands folder and have this code as a .ts file inside:
// @ts-nocheck
import { InteractionHandler, InteractionHandlerTypes, PieceContext } from '@sapphire/framework';
import type { AutocompleteInteraction } from 'discord.js';
export class AuthorizationAutocompleteHandler extends InteractionHandler {
public constructor(ctx: PieceContext, options: InteractionHandler.Options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Autocomplete
});
}
public override async run(interaction: AutocompleteInteraction, result: InteractionHandler.ParseResult<this>) {
console.log('hi')
return interaction.respond(result);
}
public override async parse(interaction: AutocompleteInteraction) {
'foo';
console.log('autocompleting')
if (interaction.commandId !== '1049470193220452402' || interaction.commandId !== '1049470194118054061') return this.none();

const focusedOption = interaction.options.getFocused(true);

switch (focusedOption.name) {
case 'topic': {
const typedTopicName = focusedOption.name as string;
const topicId = focusedOption.value as string;
typedTopicName;
topicId;

const searchResult = new Map();
searchResult.set('12345', 'An Entry');
return this.some(Array.from(searchResult).map((k, v) => ({ name: k, value: v })));
}
default:
return this.none();
}
}
}
// @ts-nocheck
import { InteractionHandler, InteractionHandlerTypes, PieceContext } from '@sapphire/framework';
import type { AutocompleteInteraction } from 'discord.js';
export class AuthorizationAutocompleteHandler extends InteractionHandler {
public constructor(ctx: PieceContext, options: InteractionHandler.Options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Autocomplete
});
}
public override async run(interaction: AutocompleteInteraction, result: InteractionHandler.ParseResult<this>) {
console.log('hi')
return interaction.respond(result);
}
public override async parse(interaction: AutocompleteInteraction) {
'foo';
console.log('autocompleting')
if (interaction.commandId !== '1049470193220452402' || interaction.commandId !== '1049470194118054061') return this.none();

const focusedOption = interaction.options.getFocused(true);

switch (focusedOption.name) {
case 'topic': {
const typedTopicName = focusedOption.name as string;
const topicId = focusedOption.value as string;
typedTopicName;
topicId;

const searchResult = new Map();
searchResult.set('12345', 'An Entry');
return this.some(Array.from(searchResult).map((k, v) => ({ name: k, value: v })));
}
default:
return this.none();
}
}
}
` I'm not seeing any console logs. Any thoughts?
14 replies