feat: move name and description out of OptionsData[]

This commit is contained in:
Jacob Nguyen
2022-05-23 20:55:02 -05:00
parent ac8a2f4c86
commit 93942bd0e7
4 changed files with 9 additions and 10 deletions

View File

@@ -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 =>

View File

@@ -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 {

View File

@@ -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'>;
};

View File

@@ -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 };