From 0d1100e580e90d27248542c2c3a6326534fd5eeb Mon Sep 17 00:00:00 2001 From: SrIzan10 <66965250+SrIzan10@users.noreply.github.com> Date: Sat, 4 Mar 2023 17:25:27 +0100 Subject: [PATCH] feat: nickname command --- commands/misc/nick.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 commands/misc/nick.ts diff --git a/commands/misc/nick.ts b/commands/misc/nick.ts new file mode 100644 index 0000000..ccdf542 --- /dev/null +++ b/commands/misc/nick.ts @@ -0,0 +1,33 @@ +import { commandModule, CommandType } from '@sern/handler'; +import { ApplicationCommandOptionType, GuildMember } from 'discord.js'; +import { publish } from '../../plugins/publish.js'; + +export default commandModule({ + type: CommandType.Slash, + plugins: [publish()], + description: 'Cambiale el nickname a randoms', + //alias : [], + options: [ + { + name: 'usuario', + description: 'El usuario', + type: ApplicationCommandOptionType.User, + required: true, + }, + { + name: 'nick', + description: 'El nickname que ponerle al usuario', + type: ApplicationCommandOptionType.String, + required: true, + } + ], + execute: async (ctx, args) => { + const user = args[1].getMember('usuario') as GuildMember + const nick = args[1].getString('nick', true) + const oldNick = user.nickname || user.user.username + if (user.user.bot) return await ctx.reply({ content: 'No puedes cambiarle el nick a un bot...', ephemeral: true }) + + await user.setNickname(nick) + await ctx.reply({ content: `El nickname de ${user} ha sido cambiado por ${ctx.user}\nAntiguo nickname: ${oldNick}\nNuevo nickname: ${nick}` }) + }, +});