From 490a06d7225baecceb443694ce45b6fef979e987 Mon Sep 17 00:00:00 2001 From: SrIzan10 <66965250+SrIzan10@users.noreply.github.com> Date: Sat, 13 Aug 2022 18:15:13 +0200 Subject: [PATCH] feat: nuevo comando: /eliminarmensaje --- commands/moderation/deleteMessage.ts | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 commands/moderation/deleteMessage.ts diff --git a/commands/moderation/deleteMessage.ts b/commands/moderation/deleteMessage.ts new file mode 100644 index 0000000..5797d22 --- /dev/null +++ b/commands/moderation/deleteMessage.ts @@ -0,0 +1,39 @@ +const { commandModule, CommandType } = require('@sern/handler'); +import { publish } from "../../src/plugins/publish"; +import { ownerOnly } from "../../src/plugins/ownerOnly" +import { ApplicationCommandOptionType, TextChannel } from "discord.js"; +/* +import { publish } from "../../src/plugins/publish"; +import { ownerOnly } from "../../src/plugins/ownerOnly" +*/ + +export default commandModule({ + name: 'eliminarmensaje', + type: CommandType.Both, + plugins: [publish(['1000400148289036298', '928018226330337280']), ownerOnly()], + description: 'ADMIN: Elimina comandos por su ID.', + //alias : [], + options: [ + { + name: 'canal', + type: ApplicationCommandOptionType.Channel, + description: 'El canal de texto.', + required: true + }, + { + name: 'id', + type: ApplicationCommandOptionType.String, + description: 'El ID del mensaje.', + required: true + } + ], + execute: async (ctx, options) => { + const idMensaje = options[1].getString('id', true); + const channelID = options[1].getChannel('canal', true).id || ctx.channel.id + const guildId = ctx.guild.id + const guild = await ctx.client.guilds.fetch(guildId); + const channel = await guild.channels.fetch(channelID); + (await channel.messages.fetch(idMensaje)).delete(); + await ctx.reply({content: 'Mensaje eliminado correctamente.', ephemeral: true}); + }, +}); \ No newline at end of file