aboutsummaryrefslogtreecommitdiff
path: root/src/api/Commands.ts
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-10-12 05:34:39 +0200
committerVendicated <vendicated@riseup.net>2022-10-12 05:34:39 +0200
commit8e93c5cb43fc8f375f91a44dc665ddc573435f84 (patch)
tree7f82268113d768d8ee25500942f0504bd76ef8da /src/api/Commands.ts
parent66f8fde353076180276ba79d984bde60df57ab29 (diff)
downloadVencord-8e93c5cb43fc8f375f91a44dc665ddc573435f84.tar.gz
Vencord-8e93c5cb43fc8f375f91a44dc665ddc573435f84.tar.bz2
Vencord-8e93c5cb43fc8f375f91a44dc665ddc573435f84.zip
CommandsApi: fix accidently overwriting inputType BUILT_IN
Diffstat (limited to 'src/api/Commands.ts')
-rw-r--r--src/api/Commands.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/api/Commands.ts b/src/api/Commands.ts
index 907a65d..f7f42e9 100644
--- a/src/api/Commands.ts
+++ b/src/api/Commands.ts
@@ -45,7 +45,9 @@ export function generateId() {
* @param fallbackValue Fallback value in case this option wasn't passed
* @returns Value
*/
-export function findOption<T extends string | undefined>(args: Argument[], name: string, fallbackValue?: T): T extends undefined ? T : string {
+export function findOption<T>(args: Argument[], name: string): T & {} | undefined;
+export function findOption<T>(args: Argument[], name: string, fallbackValue: T): T & {};
+export function findOption(args: Argument[], name: string, fallbackValue?: any) {
return (args.find(a => a.name === name)?.value || fallbackValue) as any;
}
@@ -64,10 +66,10 @@ export function registerCommand(command: Command, plugin: string) {
if (BUILT_IN.some(c => c.name === command.name))
throw new Error(`Command '${command.name}' already exists.`);
- command.id ||= generateId();
- command.applicationId ||= "-1"; // BUILT_IN;
- command.type ||= ApplicationCommandType.CHAT_INPUT;
- command.inputType ||= ApplicationCommandInputType.BUILT_IN_TEXT;
+ command.id ??= generateId();
+ command.applicationId ??= "-1"; // BUILT_IN;
+ command.type ??= ApplicationCommandType.CHAT_INPUT;
+ command.inputType ??= ApplicationCommandInputType.BUILT_IN_TEXT;
command.plugin ||= plugin;
modifyOpt(command);
@@ -155,5 +157,5 @@ export interface Command {
options?: Option[];
predicate?(ctx: CommandContext): boolean;
- execute(args: Argument[], ctx: CommandContext): CommandReturnValue | void;
+ execute(args: Argument[], ctx: CommandContext): CommandReturnValue | void | Promise<CommandReturnValue | void>;
}