mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
fix message commands
This commit is contained in:
parent
6d47f6ee17
commit
add53be029
@ -95,6 +95,7 @@ export async function onMessageCreate(
|
|||||||
};
|
};
|
||||||
const args = (self.options?.commands?.argsParser ?? defaultArgsParser)(content, command);
|
const args = (self.options?.commands?.argsParser ?? defaultArgsParser)(content, command);
|
||||||
const { options, errors } = await parseOptions(self, command, rawMessage, args, resolved);
|
const { options, errors } = await parseOptions(self, command, rawMessage, args, resolved);
|
||||||
|
console.log({ options, errors });
|
||||||
const optionsResolver = new OptionResolver(self, options, parent as Command, message.guildId, resolved);
|
const optionsResolver = new OptionResolver(self, options, parent as Command, message.guildId, resolved);
|
||||||
const context = new CommandContext(self, message, optionsResolver, shardId, command);
|
const context = new CommandContext(self, message, optionsResolver, shardId, command);
|
||||||
const extendContext = self.options?.context?.(message) ?? {};
|
const extendContext = self.options?.context?.(message) ?? {};
|
||||||
@ -364,6 +365,11 @@ async function parseOptions(
|
|||||||
value,
|
value,
|
||||||
} as APIApplicationCommandInteractionDataOption);
|
} as APIApplicationCommandInteractionDataOption);
|
||||||
}
|
}
|
||||||
|
if (i.required && value === undefined)
|
||||||
|
errors.push({
|
||||||
|
error: 'Option is required but returned undefined',
|
||||||
|
name: i.name,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return { errors, options };
|
return { errors, options };
|
||||||
|
@ -130,15 +130,14 @@ class BaseCommand {
|
|||||||
ctx: CommandContext<{}, never>,
|
ctx: CommandContext<{}, never>,
|
||||||
resolver: OptionResolver,
|
resolver: OptionResolver,
|
||||||
): Promise<[boolean, OnOptionsReturnObject]> {
|
): Promise<[boolean, OnOptionsReturnObject]> {
|
||||||
const command = resolver.getCommand();
|
if (!this?.options?.length) {
|
||||||
if (!command?.options?.length) {
|
|
||||||
return [false, {}];
|
return [false, {}];
|
||||||
}
|
}
|
||||||
const data: OnOptionsReturnObject = {};
|
const data: OnOptionsReturnObject = {};
|
||||||
let errored = false;
|
let errored = false;
|
||||||
for (const i of command.options ?? []) {
|
for (const i of this.options ?? []) {
|
||||||
try {
|
try {
|
||||||
const option = command.options!.find(x => x.name === i.name) as __CommandOption;
|
const option = this.options!.find(x => x.name === i.name) as __CommandOption;
|
||||||
const value =
|
const value =
|
||||||
resolver.getHoisted(i.name)?.value !== undefined
|
resolver.getHoisted(i.name)?.value !== undefined
|
||||||
? await new Promise(
|
? await new Promise(
|
||||||
@ -147,7 +146,6 @@ class BaseCommand {
|
|||||||
res(resolver.getValue(i.name)),
|
res(resolver.getValue(i.name)),
|
||||||
)
|
)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
if (option.required) {
|
if (option.required) {
|
||||||
errored = true;
|
errored = true;
|
||||||
|
@ -46,6 +46,10 @@ export class BaseMessage extends DiscordBase {
|
|||||||
this.patch(data);
|
this.patch(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get user() {
|
||||||
|
return this.author;
|
||||||
|
}
|
||||||
|
|
||||||
createComponentCollector(options?: ListenerOptions) {
|
createComponentCollector(options?: ListenerOptions) {
|
||||||
return this.client.components.createComponentCollector(this.id, options);
|
return this.client.components.createComponentCollector(this.id, options);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user