@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
31 lines (29 loc) • 1.05 kB
JavaScript
import { Identifiers } from "../lib/errors/Identifiers.mjs";
import { AllFlowsPrecondition } from "../lib/structures/Precondition.mjs";
import { container } from "@sapphire/pieces";
//#region src/preconditions/GuildThreadOnly.ts
var CorePrecondition = class extends AllFlowsPrecondition {
messageRun(message) {
return message.thread ? this.ok() : this.makeSharedError();
}
async chatInputRun(interaction) {
return (await this.fetchChannelFromInteraction(interaction)).isThread() ? this.ok() : this.makeSharedError();
}
async contextMenuRun(interaction) {
return (await this.fetchChannelFromInteraction(interaction)).isThread() ? this.ok() : this.makeSharedError();
}
makeSharedError() {
return this.error({
identifier: Identifiers.PreconditionThreadOnly,
message: "You can only run this command in server thread channels."
});
}
};
container.stores.loadPiece({
name: "GuildThreadOnly",
piece: CorePrecondition,
store: "preconditions"
});
//#endregion
export { CorePrecondition };
//# sourceMappingURL=GuildThreadOnly.mjs.map