mirror of
https://github.com/sern-handler/awesome-plugins
synced 2026-06-19 14:22:21 +00:00
* feat!: update ownerOnly * feat!: update permCheck * feat!: update publish * feat!: update serverOnly * feat!: update nsfwOnly * feat!: update requirePermission * feat!: update dmOnly * feat!: update cooldown * feat!: update confirmation * feat!: update channelType * feat!: update buttonConfirmation * feat: addAssertFields (#67) feat: add assertFields
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
// @ts-nocheck
|
|
/**
|
|
* Checks if a command is available in a specific server.
|
|
*
|
|
* @author @Peter-MJ-Parker [<@1017182455926624316>]
|
|
* @version 1.0.0
|
|
* @example
|
|
* ```ts
|
|
* import { commandModule, CommandType } from "@sern/handler";
|
|
* import { serverOnly } from "../plugins/serverOnly";
|
|
* export default commandModule({
|
|
* type: CommandType.Both,
|
|
* plugins: [serverOnly(["guildId"], failMessage)], // fail message is the message you will see when the command is ran in the wrong server.
|
|
* description: "command description",
|
|
* execute: async (ctx, args) => {
|
|
* // your code here
|
|
* },
|
|
* });
|
|
* ```
|
|
*/
|
|
|
|
import { CommandType, controller, CommandControlPlugin } from "@sern/handler";
|
|
|
|
export function serverOnly(
|
|
guildId: string[],
|
|
failMessage = "This command is not available in this guild. \nFor permission to use in your server, please contact my developer."
|
|
) {
|
|
return CommandControlPlugin<CommandType.Both>(async ( ctx, _) => {
|
|
if(ctx.guildId == null) {
|
|
return controller.stop()
|
|
}
|
|
if (!guildId.includes(ctx.guildId)) {
|
|
ctx.reply(failMessage).then(async (m) => {
|
|
setTimeout(async () => {
|
|
await m.delete();
|
|
}, 3000);
|
|
});
|
|
return controller.stop();
|
|
}
|
|
return controller.next();
|
|
})
|
|
}
|