fix: slice message content argsParser

This commit is contained in:
MARCROCK22 2024-05-11 15:31:09 -04:00
parent 6a63178846
commit b44e7d456a
2 changed files with 7 additions and 2 deletions

View File

@ -219,7 +219,7 @@ export interface ClientOptions extends BaseClientOptions {
prefix?: (message: Message) => Promise<string[]> | string[];
deferReplyResponse?: (ctx: CommandContext) => Parameters<Message['write']>[0];
reply?: (ctx: CommandContext) => boolean;
argsParser?: (content: string, command: SubCommand | Command) => Record<string, string>;
argsParser?: (content: string, command: SubCommand | Command, message: Message) => Record<string, string>;
};
handlePayload?: ShardManagerOptions['handlePayload'];
}

View File

@ -113,7 +113,12 @@ export async function onMessageCreate(
members: {},
attachments: {},
};
const args = (self.options?.commands?.argsParser ?? defaultArgsParser)(content, command);
const args = (self.options?.commands?.argsParser ?? defaultArgsParser)(
content.slice(fullCommandName.length + 1),
command,
message,
);
const { options, errors } = await parseOptions(self, command, rawMessage, args, resolved);
const optionsResolver = new OptionResolver(self, options, parent as Command, message.guildId, resolved);
const context = new CommandContext(self, message, optionsResolver, shardId, command);