diff --git a/JavaScript/publish.js b/JavaScript/publish.js index 2f7092b..f343fa4 100644 --- a/JavaScript/publish.js +++ b/JavaScript/publish.js @@ -4,13 +4,14 @@ * This is publish plugin, it allows you to publish your slash commands with ease. * * @author @EvolutionX-10 [<@697795666373640213>] - * @version 1.2.0 + * @version 1.2.1 * @example * ```ts * import { publish } from "../plugins/publish"; * import { commandModule } from "@sern/handler"; * export default commandModule({ * plugins: [ publish() ], // put an object containing permissions, ids for guild commands, boolean for dmPermission + * // plugins: [ publish({ guildIds: [], dmPermission: true})] * execute: (ctx) => { * //your code here * } @@ -19,19 +20,18 @@ */ import { CommandType, PluginType } from "@sern/handler"; import { ApplicationCommandType } from "discord.js"; -export function publish( - options = { - guildIds: [], - dmPermission: true, - defaultMemberPermissions: null, - } -) { +export function publish(options) { return { type: PluginType.Command, description: "Manage Slash Commands", name: "slash-auto-publish", async execute({ client }, { mod: module }, controller) { + const defaultOptions = { + guildIds: [], + dmPermission: true, + }; + options = { ...defaultOptions, ...options }; let { defaultMemberPermissions, dmPermission, guildIds } = options; function c(e) { diff --git a/TypeScript/publish.ts b/TypeScript/publish.ts index 452431e..262037a 100644 --- a/TypeScript/publish.ts +++ b/TypeScript/publish.ts @@ -17,7 +17,7 @@ * }) * ``` */ - import { +import { CommandPlugin, CommandType, PluginType, @@ -60,12 +60,14 @@ export function publish( if (!Array.isArray(guildIds)) guildIds = [guildIds!]; if (!guildIds.length) { - const cmd = (await client.application!.commands.fetch()).find( - (c) => c.name === module.name - ); + const cmd = ( + await client.application!.commands.fetch() + ).find((c) => c.name === module.name); if (cmd) { if (!cmd.equals(commandData, true)) { - console.log(`Found differences in global command ${module.name}`); + console.log( + `Found differences in global command ${module.name}` + ); cmd.edit(commandData).then(() => { console.log( `${module.name} updated with new data successfully!` @@ -91,7 +93,9 @@ export function publish( ); if (guildcmd) { if (!guildcmd.equals(commandData, true)) { - console.log(`Found differences in command ${module.name}`); + console.log( + `Found differences in command ${module.name}` + ); guildcmd .edit(commandData) .then(() => @@ -107,7 +111,11 @@ export function publish( guild.commands .create(commandData) .then(() => - console.log("Guild Command created", module.name!, guild.name) + console.log( + "Guild Command created", + module.name!, + guild.name + ) ) .catch(c); }