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