Archived
getParam to fetch parameter values
This commit is contained in:
1 parent
d37015a617
commit
12e0a247db
1 file changed
+22
-3
+22
-3
@@ -7,7 +7,11 @@ import {
|
|||||||
GuildMember,
|
GuildMember,
|
||||||
ReplyMessageOptions,
|
ReplyMessageOptions,
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import { CommandBuilder, PermissionCheckTypes } from "./types.js";
|
import {
|
||||||
|
CommandBuilder,
|
||||||
|
ParameterResolvable,
|
||||||
|
PermissionCheckTypes,
|
||||||
|
} from "./types.js";
|
||||||
import { PermissionsError } from "./errors.js";
|
import { PermissionsError } from "./errors.js";
|
||||||
import { DefaultParameter, InputParameter, Parameter } from "./Parameter.js";
|
import { DefaultParameter, InputParameter, Parameter } from "./Parameter.js";
|
||||||
|
|
||||||
@@ -97,7 +101,11 @@ export class Command {
|
|||||||
? memberPermissions.has(this.permissions, true)
|
? memberPermissions.has(this.permissions, true)
|
||||||
: memberPermissions.any(this.permissions, true))
|
: memberPermissions.any(this.permissions, true))
|
||||||
) {
|
) {
|
||||||
const fnResult = await this.function(interaction, cmdParams);
|
const fnResult = await this.function.call(
|
||||||
|
this,
|
||||||
|
interaction,
|
||||||
|
cmdParams
|
||||||
|
);
|
||||||
if (
|
if (
|
||||||
"content" in (fnResult as ReplyMessageOptions) ||
|
"content" in (fnResult as ReplyMessageOptions) ||
|
||||||
"embeds" in (fnResult as ReplyMessageOptions) ||
|
"embeds" in (fnResult as ReplyMessageOptions) ||
|
||||||
@@ -134,7 +142,8 @@ export class Command {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
const fnResult = await this.function(
|
const fnResult = await this.function.call(
|
||||||
|
this,
|
||||||
interaction,
|
interaction,
|
||||||
cmdParams
|
cmdParams
|
||||||
);
|
);
|
||||||
@@ -242,6 +251,16 @@ export class Command {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getParam(
|
||||||
|
query: string,
|
||||||
|
list: InputParameter[],
|
||||||
|
returnType?: "value" | "object"
|
||||||
|
): ParameterResolvable | InputParameter | null {
|
||||||
|
return returnType === "object"
|
||||||
|
? list.find((p) => p.name === query) || null
|
||||||
|
: list.find((p) => p.name === query)?.value || null;
|
||||||
|
}
|
||||||
|
|
||||||
private static processPhrase(
|
private static processPhrase(
|
||||||
phrase?: string | string[]
|
phrase?: string | string[]
|
||||||
): string[] | undefined {
|
): string[] | undefined {
|
||||||
|
|||||||
Reference in new issue
Block a user