mirror of
https://github.com/sern-handler/handler
synced 2026-06-11 10:22:14 +00:00
feat: finishing autocomplete!!
This commit is contained in:
@@ -201,7 +201,7 @@ export function onInteractionCreate(wrapper: Wrapper) {
|
||||
return modalHandler(modul, interaction);
|
||||
}
|
||||
if (interaction.isAutocomplete()) {
|
||||
const modul = Files.ApplicationCommands[1].get(interaction.commandName);
|
||||
const modul = Files.ApplicationCommands['1'].get(interaction.commandName);
|
||||
return autoCmpHandler(modul, interaction);
|
||||
}
|
||||
return of();
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
import { concat, concatMap, from, fromEvent, map, Observable, of, skip, take, throwError } from 'rxjs';
|
||||
import {
|
||||
concat,
|
||||
concatMap,
|
||||
from,
|
||||
fromEvent,
|
||||
map,
|
||||
Observable,
|
||||
of,
|
||||
skip,
|
||||
take,
|
||||
throwError,
|
||||
} from 'rxjs';
|
||||
import { basename } from 'path';
|
||||
import * as Files from '../utilities/readFile';
|
||||
import type Wrapper from '../structures/wrapper';
|
||||
@@ -27,8 +38,12 @@ export const onReady = (wrapper: Wrapper) => {
|
||||
);
|
||||
const processPlugins$ = processCommandFiles$.pipe(
|
||||
concatMap(mod => {
|
||||
if(mod.type === CommandType.Autocomplete) {
|
||||
return throwError(() => SernError.NonValidModuleType + `. You cannot use command plugins and Autocomplete.`);
|
||||
if (mod.type === CommandType.Autocomplete) {
|
||||
return throwError(
|
||||
() =>
|
||||
SernError.NonValidModuleType +
|
||||
`. You cannot use command plugins and Autocomplete.`,
|
||||
);
|
||||
}
|
||||
const cmdPluginsRes =
|
||||
mod.plugins?.map(plug => {
|
||||
@@ -89,6 +104,7 @@ function registerModule(mod: DefinitelyDefined<Module, { name: string }>): Resul
|
||||
return Ok.EMPTY;
|
||||
})
|
||||
.with({ type: CommandType.Slash }, mod => {
|
||||
console.log(mod);
|
||||
Files.ApplicationCommands[ApplicationCommandType.ChatInput].set(name, mod);
|
||||
return Ok.EMPTY;
|
||||
})
|
||||
@@ -113,7 +129,7 @@ function registerModule(mod: DefinitelyDefined<Module, { name: string }>): Resul
|
||||
Files.MessageCompCommands[ComponentType.SelectMenu].set(name, mod);
|
||||
return Ok.EMPTY;
|
||||
})
|
||||
.with({ type : CommandType.Modal }, mod => {
|
||||
.with({ type: CommandType.Modal }, mod => {
|
||||
Files.ModalSubmitCommands.set(name, mod);
|
||||
return Ok.EMPTY;
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type {
|
||||
ApplicationCommandAutocompleteOption,
|
||||
ApplicationCommandAttachmentOption,
|
||||
ApplicationCommandChannelOptionData,
|
||||
ApplicationCommandChoicesData,
|
||||
ApplicationCommandNonOptionsData,
|
||||
@@ -173,8 +173,8 @@ export type BaseOptions =
|
||||
| ApplicationCommandChoicesData
|
||||
| ApplicationCommandNonOptionsData
|
||||
| ApplicationCommandChannelOptionData
|
||||
| ApplicationCommandAutocompleteOption
|
||||
| ApplicationCommandNumericOptionData
|
||||
| ApplicationCommandAttachmentOption
|
||||
| SernAutocompleteData;
|
||||
|
||||
export type SernSubCommandData = Override<
|
||||
|
||||
@@ -1,6 +1,28 @@
|
||||
import Context from './context';
|
||||
import type { BothCommand, Module, SlashCommand, TextCommand, OptionsData } from './module';
|
||||
import type {
|
||||
BothCommand,
|
||||
Module,
|
||||
SlashCommand,
|
||||
TextCommand,
|
||||
SernOptionsData,
|
||||
BaseOptions,
|
||||
SernAutocompleteData,
|
||||
SernSubCommandData,
|
||||
SernSubCommandGroupData,
|
||||
} from './module';
|
||||
import type Wrapper from './wrapper';
|
||||
|
||||
export * from './enums';
|
||||
export { Context, SlashCommand, TextCommand, BothCommand, Module, Wrapper, OptionsData };
|
||||
export {
|
||||
Context,
|
||||
SlashCommand,
|
||||
TextCommand,
|
||||
BothCommand,
|
||||
Module,
|
||||
Wrapper,
|
||||
SernOptionsData,
|
||||
BaseOptions,
|
||||
SernAutocompleteData,
|
||||
SernSubCommandData,
|
||||
SernSubCommandGroupData,
|
||||
};
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import type { SernOptionsData } from '../structures/module';
|
||||
import type { ApplicationCommandOptionData } from 'discord.js';
|
||||
|
||||
class OptionsBuilder {
|
||||
public constructor(private options: ApplicationCommandOptionData[] = []) {
|
||||
this.options = options;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,6 @@
|
||||
import type {
|
||||
Awaitable,
|
||||
ClientEvents,
|
||||
CommandInteractionOptionResolver,
|
||||
MessageOptions,
|
||||
MessagePayload,
|
||||
} from 'discord.js';
|
||||
import type { Awaitable, ClientEvents, CommandInteractionOptionResolver } from 'discord.js';
|
||||
import type { EventEmitter } from 'events';
|
||||
// Anything that can be sent in a `<TextChannel>#send` or `<CommandInteraction>#reply`
|
||||
export type possibleOutput<T = string> = T | (MessagePayload & MessageOptions);
|
||||
export type Nullish<T> = T | undefined | null;
|
||||
// Thanks @cursorsdottsx
|
||||
export type ParseType<T> = {
|
||||
@@ -16,8 +9,14 @@ export type ParseType<T> = {
|
||||
|
||||
export type Args = ParseType<{ text: string[]; slash: SlashOptions }>;
|
||||
|
||||
export type DiscordEvent = ParseType<{ [K in keyof ClientEvents]: (...args: ClientEvents[K]) => Awaitable<void> }>;
|
||||
export type EventEmitterRegister = [emitter: EventEmitter, k: string, cb: (...args: unknown[]) => Awaitable<void>];
|
||||
export type DiscordEvent = ParseType<{
|
||||
[K in keyof ClientEvents]: (...args: ClientEvents[K]) => Awaitable<void>;
|
||||
}>;
|
||||
export type EventEmitterRegister = [
|
||||
emitter: EventEmitter,
|
||||
k: string,
|
||||
cb: (...args: unknown[]) => Awaitable<void>,
|
||||
];
|
||||
|
||||
export type SlashOptions = Omit<CommandInteractionOptionResolver, 'getMessage' | 'getFocused'>;
|
||||
|
||||
@@ -25,3 +24,10 @@ export type SlashOptions = Omit<CommandInteractionOptionResolver, 'getMessage' |
|
||||
export type Override<T1, T2> = Omit<T1, keyof T2> & T2;
|
||||
|
||||
export type DefinitelyDefined<T, K> = T & Override<T, K>;
|
||||
export type Expand<T> = T extends object ? { [K in keyof T]: Expand<T[K]> } : T;
|
||||
|
||||
type Reconstruct<T> = T extends Omit<infer O, infer _> ? O & Reconstruct<O> : T;
|
||||
|
||||
type IsOptional<T> = {
|
||||
[K in keyof T]-?: T[K] extends Required<T>[K] ? false : true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user