@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
32 lines (30 loc) • 1.28 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/GuildPublicThreadOnly.ts
var CorePrecondition = class extends AllFlowsPrecondition {
messageRun(message) {
return message.thread?.type === ChannelType.PublicThread ? this.ok() : this.makeSharedError();
}
async chatInputRun(interaction) {
return (await this.fetchChannelFromInteraction(interaction)).type === ChannelType.PublicThread ? this.ok() : this.makeSharedError();
}
async contextMenuRun(interaction) {
return (await this.fetchChannelFromInteraction(interaction)).type === ChannelType.PublicThread ? this.ok() : this.makeSharedError();
}
makeSharedError() {
return this.error({
identifier: Identifiers.PreconditionGuildPublicThreadOnly,
message: "You can only run this command in public server thread channels."
});
}
};
container.stores.loadPiece({
name: "GuildPublicThreadOnly",
piece: CorePrecondition,
store: "preconditions"
});
//#endregion
export { CorePrecondition };
//# sourceMappingURL=GuildPublicThreadOnly.mjs.map