UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

1 lines 2.6 kB
{"version":3,"file":"NSFW.cjs","names":["AllFlowsPrecondition","Identifiers","container"],"sources":["../../../src/preconditions/NSFW.ts"],"sourcesContent":["import { container } from '@sapphire/pieces';\nimport type { 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\t// `nsfw` is undefined in DMChannel, doing `=== true`\n\t\t// will result on it returning `false`.\n\t\treturn Reflect.get(message.channel, 'nsfw') === true\n\t\t\t? this.ok()\n\t\t\t: this.error({ identifier: Identifiers.PreconditionNSFW, message: 'You cannot run this message command outside NSFW channels.' });\n\t}\n\n\tpublic async chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.AsyncResult {\n\t\tconst channel = await this.fetchChannelFromInteraction(interaction);\n\n\t\t// `nsfw` is undefined in DMChannel, doing `=== true`\n\t\t// will result on it returning `false`.\n\t\treturn Reflect.get(channel, 'nsfw') === true\n\t\t\t? this.ok()\n\t\t\t: this.error({ identifier: Identifiers.PreconditionNSFW, message: 'You cannot run this chat input command outside NSFW channels.' });\n\t}\n\n\tpublic async contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.AsyncResult {\n\t\tconst channel = await this.fetchChannelFromInteraction(interaction);\n\n\t\t// `nsfw` is undefined in DMChannel, doing `=== true`\n\t\t// will result on it returning `false`.\n\t\treturn Reflect.get(channel, 'nsfw') === true\n\t\t\t? this.ok()\n\t\t\t: this.error({ identifier: Identifiers.PreconditionNSFW, message: 'You cannot run this command outside NSFW channels.' });\n\t}\n}\n\nvoid container.stores.loadPiece({\n\tname: 'NSFW',\n\tpiece: CorePrecondition,\n\tstore: 'preconditions'\n});\n"],"mappings":";;;;;;AAKA,IAAa,mBAAb,cAAsCA,yDAAqB;CAC1D,AAAO,WAAW,SAA+C;AAGhE,SAAO,QAAQ,IAAI,QAAQ,SAAS,OAAO,KAAK,OAC7C,KAAK,IAAI,GACT,KAAK,MAAM;GAAE,YAAYC,2CAAY;GAAkB,SAAS;GAA8D,CAAC;;CAGnI,MAAa,aAAa,aAA4E;EACrG,MAAM,UAAU,MAAM,KAAK,4BAA4B,YAAY;AAInE,SAAO,QAAQ,IAAI,SAAS,OAAO,KAAK,OACrC,KAAK,IAAI,GACT,KAAK,MAAM;GAAE,YAAYA,2CAAY;GAAkB,SAAS;GAAiE,CAAC;;CAGtI,MAAa,eAAe,aAA8E;EACzG,MAAM,UAAU,MAAM,KAAK,4BAA4B,YAAY;AAInE,SAAO,QAAQ,IAAI,SAAS,OAAO,KAAK,OACrC,KAAK,IAAI,GACT,KAAK,MAAM;GAAE,YAAYA,2CAAY;GAAkB,SAAS;GAAsD,CAAC;;;AAIvHC,4BAAU,OAAO,UAAU;CAC/B,MAAM;CACN,OAAO;CACP,OAAO;CACP,CAAC"}