@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
36 lines (34 loc) • 1.15 kB
JavaScript
import { Identifiers } from "../lib/errors/Identifiers.mjs";
import { resolveDate } from "../lib/resolvers/date.mjs";
import { Argument } from "../lib/structures/Argument.mjs";
import { container } from "@sapphire/pieces";
//#region src/arguments/CoreDate.ts
var CoreArgument = class extends Argument {
constructor(context) {
super(context, { name: "date" });
this.messages = {
[Identifiers.ArgumentDateTooEarly]: ({ minimum }) => `The given date must be after ${new Date(minimum).toISOString()}.`,
[Identifiers.ArgumentDateTooFar]: ({ maximum }) => `The given date must be before ${new Date(maximum).toISOString()}.`,
[Identifiers.ArgumentDateError]: () => "The argument did not resolve to a date."
};
}
run(parameter, context) {
return resolveDate(parameter, {
minimum: context.minimum,
maximum: context.maximum
}).mapErrInto((identifier) => this.error({
parameter,
identifier,
message: this.messages[identifier](context),
context
}));
}
};
container.stores.loadPiece({
name: "date",
piece: CoreArgument,
store: "arguments"
});
//#endregion
export { CoreArgument };
//# sourceMappingURL=CoreDate.mjs.map