@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
36 lines (34 loc) • 1.44 kB
JavaScript
import { __name } from '../chunk-PAWJFY3S.mjs';
import { container } from '@sapphire/pieces';
import { ChannelType } from 'discord.js';
import { Identifiers } from '../lib/errors/Identifiers.mjs';
import { AllFlowsPrecondition } from '../lib/structures/Precondition.mjs';
var _CorePrecondition = class _CorePrecondition extends AllFlowsPrecondition {
messageRun(message) {
return message.thread?.type === ChannelType.PublicThread ? this.ok() : this.makeSharedError();
}
async chatInputRun(interaction) {
const channel = await this.fetchChannelFromInteraction(interaction);
return channel.type === ChannelType.PublicThread ? this.ok() : this.makeSharedError();
}
async contextMenuRun(interaction) {
const channel = await this.fetchChannelFromInteraction(interaction);
return channel.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."
});
}
};
__name(_CorePrecondition, "CorePrecondition");
var CorePrecondition = _CorePrecondition;
void container.stores.loadPiece({
name: "GuildPublicThreadOnly",
piece: CorePrecondition,
store: "preconditions"
});
export { CorePrecondition };
//# sourceMappingURL=GuildPublicThreadOnly.mjs.map
//# sourceMappingURL=GuildPublicThreadOnly.mjs.map