@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
43 lines (41 loc) • 1.57 kB
JavaScript
;
const require_lib_errors_Identifiers = require('../lib/errors/Identifiers.cjs');
const require_lib_structures_Precondition = require('../lib/structures/Precondition.cjs');
let __sapphire_pieces = require("@sapphire/pieces");
let discord_js = require("discord.js");
//#region src/preconditions/GuildTextOnly.ts
var CorePrecondition = class extends require_lib_structures_Precondition.AllFlowsPrecondition {
constructor(..._args) {
super(..._args);
this.allowedTypes = [
discord_js.ChannelType.GuildText,
discord_js.ChannelType.PublicThread,
discord_js.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: require_lib_errors_Identifiers.Identifiers.PreconditionGuildTextOnly,
message: "You can only run this command in server text channels."
});
}
};
__sapphire_pieces.container.stores.loadPiece({
name: "GuildTextOnly",
piece: CorePrecondition,
store: "preconditions"
});
//#endregion
exports.CorePrecondition = CorePrecondition;
//# sourceMappingURL=GuildTextOnly.cjs.map