mirror of
https://github.com/sern-handler/awesome-plugins
synced 2026-06-13 19:32:30 +00:00
chore: Update JavaScript plugins (#47)
chore: update JavaScript plugins Co-authored-by: EvolutionX-10 <EvolutionX-10@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
33416d246d
commit
c7daa476a8
44
JavaScript/serverOnly.js
Normal file
44
JavaScript/serverOnly.js
Normal file
@@ -0,0 +1,44 @@
|
||||
// @ts-nocheck
|
||||
|
||||
/**
|
||||
* Checks if a command is available in a specific server.
|
||||
*
|
||||
* @author @D3ord3NidAm [<@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 { PluginType } from "@sern/handler";
|
||||
export function serverOnly(
|
||||
guildId,
|
||||
failMessage = "I am unable to comply with your command."
|
||||
) {
|
||||
return {
|
||||
type: PluginType.Event,
|
||||
description: "Checks if a command is available in a specific server.",
|
||||
|
||||
async execute([ctx, args], controller) {
|
||||
if (!guildId.includes(ctx.guildId)) {
|
||||
await ctx.reply(failMessage).then(async (m) => {
|
||||
setTimeout(async () => {
|
||||
await m.delete();
|
||||
}, 3000);
|
||||
});
|
||||
return controller.stop();
|
||||
}
|
||||
|
||||
return controller.next();
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user