@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
1 lines • 1.72 kB
Source Map (JSON)
{"version":3,"file":"DMOnly.mjs","names":[],"sources":["../../../src/preconditions/DMOnly.ts"],"sourcesContent":["import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js';\nimport { Identifiers } from '../lib/errors/Identifiers';\nimport { AllFlowsPrecondition } from '../lib/structures/Precondition';\nimport { container } from '@sapphire/pieces';\n\nexport class CorePrecondition extends AllFlowsPrecondition {\n\tpublic messageRun(message: Message): AllFlowsPrecondition.Result {\n\t\treturn message.guild === null ? this.ok() : this.makeSharedError();\n\t}\n\n\tpublic chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.Result {\n\t\treturn interaction.guildId === null ? this.ok() : this.makeSharedError();\n\t}\n\n\tpublic contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.Result {\n\t\treturn interaction.guildId === null ? this.ok() : this.makeSharedError();\n\t}\n\n\tprivate makeSharedError(): AllFlowsPrecondition.Result {\n\t\treturn this.error({\n\t\t\tidentifier: Identifiers.PreconditionDMOnly,\n\t\t\tmessage: 'You cannot run this command outside DMs.'\n\t\t});\n\t}\n}\n\nvoid container.stores.loadPiece({\n\tname: 'DMOnly',\n\tpiece: CorePrecondition,\n\tstore: 'preconditions'\n});\n"],"mappings":";;;;;AAKA,IAAa,mBAAb,cAAsC,qBAAqB;CAC1D,AAAO,WAAW,SAA+C;AAChE,SAAO,QAAQ,UAAU,OAAO,KAAK,IAAI,GAAG,KAAK,iBAAiB;;CAGnE,AAAO,aAAa,aAAuE;AAC1F,SAAO,YAAY,YAAY,OAAO,KAAK,IAAI,GAAG,KAAK,iBAAiB;;CAGzE,AAAO,eAAe,aAAyE;AAC9F,SAAO,YAAY,YAAY,OAAO,KAAK,IAAI,GAAG,KAAK,iBAAiB;;CAGzE,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"}