@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
40 lines (38 loc) • 1.54 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 {
constructor() {
super(...arguments);
this.allowedTypes = [ChannelType.GuildText, ChannelType.PublicThread, ChannelType.PrivateThread];
}
messageRun(message) {
return this.allowedTypes.includes(message.channel.type) ? this.ok() : this.makeSharedError();
}
async chatInputRun(interaction) {
const channel = await this.fetchChannelFromInteraction(interaction);
return this.allowedTypes.includes(channel.type) ? this.ok() : this.makeSharedError();
}
async contextMenuRun(interaction) {
const channel = await this.fetchChannelFromInteraction(interaction);
return this.allowedTypes.includes(channel.type) ? this.ok() : this.makeSharedError();
}
makeSharedError() {
return this.error({
identifier: Identifiers.PreconditionGuildTextOnly,
message: "You can only run this command in server text channels."
});
}
};
__name(_CorePrecondition, "CorePrecondition");
var CorePrecondition = _CorePrecondition;
void container.stores.loadPiece({
name: "GuildTextOnly",
piece: CorePrecondition,
store: "preconditions"
});
export { CorePrecondition };
//# sourceMappingURL=GuildTextOnly.mjs.map
//# sourceMappingURL=GuildTextOnly.mjs.map