UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

1 lines 2.13 kB
{"version":3,"file":"GuildNewsThreadOnly.mjs","names":[],"sources":["../../../src/preconditions/GuildNewsThreadOnly.ts"],"sourcesContent":["import { container } from '@sapphire/pieces';\nimport { ChannelType, ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js';\nimport { Identifiers } from '../lib/errors/Identifiers';\nimport { AllFlowsPrecondition } from '../lib/structures/Precondition';\n\nexport class CorePrecondition extends AllFlowsPrecondition {\n\tpublic messageRun(message: Message): AllFlowsPrecondition.Result {\n\t\treturn message.thread?.type === ChannelType.AnnouncementThread ? this.ok() : this.makeSharedError();\n\t}\n\n\tpublic async chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.AsyncResult {\n\t\tconst channel = await this.fetchChannelFromInteraction(interaction);\n\t\treturn channel.type === ChannelType.AnnouncementThread ? this.ok() : this.makeSharedError();\n\t}\n\n\tpublic async contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.AsyncResult {\n\t\tconst channel = await this.fetchChannelFromInteraction(interaction);\n\t\treturn channel.type === ChannelType.AnnouncementThread ? this.ok() : this.makeSharedError();\n\t}\n\n\tprivate makeSharedError(): AllFlowsPrecondition.Result {\n\t\treturn this.error({\n\t\t\tidentifier: Identifiers.PreconditionGuildNewsThreadOnly,\n\t\t\tmessage: 'You can only run this command in server announcement thread channels.'\n\t\t});\n\t}\n}\n\nvoid container.stores.loadPiece({\n\tname: 'GuildNewsThreadOnly',\n\tpiece: CorePrecondition,\n\tstore: 'preconditions'\n});\n"],"mappings":";;;;;;AAKA,IAAa,mBAAb,cAAsC,qBAAqB;CAC1D,AAAO,WAAW,SAA+C;AAChE,SAAO,QAAQ,QAAQ,SAAS,YAAY,qBAAqB,KAAK,IAAI,GAAG,KAAK,iBAAiB;;CAGpG,MAAa,aAAa,aAA4E;AAErG,UADgB,MAAM,KAAK,4BAA4B,YAAY,EACpD,SAAS,YAAY,qBAAqB,KAAK,IAAI,GAAG,KAAK,iBAAiB;;CAG5F,MAAa,eAAe,aAA8E;AAEzG,UADgB,MAAM,KAAK,4BAA4B,YAAY,EACpD,SAAS,YAAY,qBAAqB,KAAK,IAAI,GAAG,KAAK,iBAAiB;;CAG5F,AAAQ,kBAA+C;AACtD,SAAO,KAAK,MAAM;GACjB,YAAY,YAAY;GACxB,SAAS;GACT,CAAC;;;AAIC,UAAU,OAAO,UAAU;CAC/B,MAAM;CACN,OAAO;CACP,OAAO;CACP,CAAC"}