mirror of
https://github.com/sern-handler/handler
synced 2026-06-27 18:22:14 +00:00
feat: move name and description out of OptionsData[]
This commit is contained in:
@@ -149,9 +149,7 @@ function autoCmpHandler(mod: Module | undefined, interaction: AutocompleteIntera
|
||||
filterCorrectModule(CommandType.Slash),
|
||||
concatMap(mod => {
|
||||
const choice = interaction.options.getFocused(true);
|
||||
const selectedOption = mod.options?.find(
|
||||
o => o.autocomplete && o.command.name === choice.name,
|
||||
);
|
||||
const selectedOption = mod.options?.find(o => o.autocomplete && o.name === choice.name);
|
||||
if (selectedOption !== undefined && selectedOption.autocomplete) {
|
||||
return of(
|
||||
selectedOption.command.onEvent?.map(e =>
|
||||
|
||||
@@ -67,7 +67,6 @@ type ModuleNoPlugins = ValueOf<{
|
||||
}>;
|
||||
|
||||
//TODO: I WANT BETTER TYPINGS AHHHHHHHHHHHHHHH
|
||||
|
||||
export function sernModule(plugins: CommandPlugin[], mod: ModuleNoPlugins): Module {
|
||||
if (mod.type !== CommandType.Autocomplete)
|
||||
return {
|
||||
|
||||
@@ -111,7 +111,7 @@ export type ModalSubmitCommand = Override<
|
||||
export type AutocompleteCommand = Override<
|
||||
BaseModule,
|
||||
{
|
||||
name : string,
|
||||
name: string;
|
||||
type: CommandType.Autocomplete;
|
||||
onEvent?: EventPlugin<CommandType.Autocomplete>[];
|
||||
execute: (ctx: AutocompleteInteraction) => Awaitable<void>;
|
||||
@@ -143,14 +143,16 @@ export type ModuleDefs = {
|
||||
[CommandType.Autocomplete]: AutocompleteCommand;
|
||||
};
|
||||
|
||||
type OptionsData =
|
||||
export type OptionsData =
|
||||
| Exclude<ApplicationCommandOptionData, ApplicationCommandAutocompleteOption>
|
||||
| {
|
||||
required?: boolean;
|
||||
name: string;
|
||||
description: string;
|
||||
autocomplete: true;
|
||||
required?: boolean;
|
||||
type:
|
||||
| ApplicationCommandOptionType.String
|
||||
| ApplicationCommandOptionType.Number
|
||||
| ApplicationCommandOptionType.Integer;
|
||||
command: AutocompleteCommand;
|
||||
command: Omit<AutocompleteCommand, 'type' | 'name' | 'description'>;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Context from './context';
|
||||
import type { BothCommand, Module, SlashCommand, TextCommand } from './module';
|
||||
import type { BothCommand, Module, SlashCommand, TextCommand, OptionsData } from './module';
|
||||
import type Wrapper from './wrapper';
|
||||
|
||||
export * from './enums';
|
||||
export { Context, SlashCommand, TextCommand, BothCommand, Module, Wrapper };
|
||||
export { Context, SlashCommand, TextCommand, BothCommand, Module, Wrapper, OptionsData };
|
||||
|
||||
Reference in New Issue
Block a user