UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

1 lines 2.19 kB
{"version":3,"file":"GuildPrivateThreadOnly.cjs","names":["AllFlowsPrecondition","ChannelType","Identifiers","container"],"sources":["../../../src/preconditions/GuildPrivateThreadOnly.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.PrivateThread ? 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.PrivateThread ? 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.PrivateThread ? this.ok() : this.makeSharedError();\n\t}\n\n\tprivate makeSharedError(): AllFlowsPrecondition.Result {\n\t\treturn this.error({\n\t\t\tidentifier: Identifiers.PreconditionGuildPrivateThreadOnly,\n\t\t\tmessage: 'You can only run this command in private server thread channels.'\n\t\t});\n\t}\n}\n\nvoid container.stores.loadPiece({\n\tname: 'GuildPrivateThreadOnly',\n\tpiece: CorePrecondition,\n\tstore: 'preconditions'\n});\n"],"mappings":";;;;;;;AAKA,IAAa,mBAAb,cAAsCA,yDAAqB;CAC1D,AAAO,WAAW,SAA+C;AAChE,SAAO,QAAQ,QAAQ,SAASC,uBAAY,gBAAgB,KAAK,IAAI,GAAG,KAAK,iBAAiB;;CAG/F,MAAa,aAAa,aAA4E;AAErG,UADgB,MAAM,KAAK,4BAA4B,YAAY,EACpD,SAASA,uBAAY,gBAAgB,KAAK,IAAI,GAAG,KAAK,iBAAiB;;CAGvF,MAAa,eAAe,aAA8E;AAEzG,UADgB,MAAM,KAAK,4BAA4B,YAAY,EACpD,SAASA,uBAAY,gBAAgB,KAAK,IAAI,GAAG,KAAK,iBAAiB;;CAGvF,AAAQ,kBAA+C;AACtD,SAAO,KAAK,MAAM;GACjB,YAAYC,2CAAY;GACxB,SAAS;GACT,CAAC;;;AAICC,4BAAU,OAAO,UAAU;CAC/B,MAAM;CACN,OAAO;CACP,OAAO;CACP,CAAC"}