diff --git a/commands/fun/megamind.ts b/commands/fun/megamind.ts index c7a5414..23cc2e1 100644 --- a/commands/fun/megamind.ts +++ b/commands/fun/megamind.ts @@ -36,8 +36,8 @@ export default commandModule({ context.drawImage(background, 0, 0, canvas.width, canvas.height) const text = `No ${option}?` - context.font = '40px Impact' - context.fillStyle = 'red' + context.font = '50px Impact' + context.fillStyle = 'white' context.textAlign = 'center' context.textBaseline = 'middle' context.fillText(text, canvas.width / 2, canvas.height - 510) diff --git a/commands/handlers/mcform-dm.ts b/commands/handlers/mcform-dm.ts new file mode 100644 index 0000000..99f6231 --- /dev/null +++ b/commands/handlers/mcform-dm.ts @@ -0,0 +1,21 @@ +import { commandModule, CommandType } from '@sern/handler'; + +export default commandModule({ + type: CommandType.Button, + execute: async (ctx) => { + await ctx.deferReply({ ephemeral: true }) + const getUserID = await ctx.client.users.fetch((ctx.message.embeds[0].footer!.text).replace('Discord ID: ', '')) + + await getUserID.send({ + content: `Tu solicitud de entrada al servidor ha sido aceptada correctamente!\nYa puedes entrar al servidor con la IP \`minecraft.maraturing.com\`` + }).catch(async () => { + await ctx.editReply({ + content: `No se ha podido enviar un DM a ${getUserID} <:Sadge:1015764348385382451>`, + }) + }).then(async () => { + await ctx.editReply({ + content: `Se ha podido enviar un DM a ${getUserID} correctamente! <:Pog:1030169609178976346>` + }) + }) + }, +}); \ No newline at end of file diff --git a/commands/handlers/mcform.ts b/commands/handlers/mcform.ts index 37db563..7cccd04 100644 --- a/commands/handlers/mcform.ts +++ b/commands/handlers/mcform.ts @@ -1,26 +1,69 @@ -import { commandModule, CommandType } from '@sern/handler' -import axios from "axios"; -import { GuildBasedChannel, TextChannel } from 'discord.js'; +import { commandModule, CommandType } from '@sern/handler'; +import axios from 'axios'; +import { + ActionRowBuilder, + ButtonBuilder, + ButtonStyle, + EmbedBuilder, + TextChannel, +} from 'discord.js'; export default commandModule({ - type: CommandType.Modal, + type: CommandType.Modal, plugins: [], description: 'Envia el formulario para entrar al servidor.', //alias : [], - async execute (modal) { - const value = modal.fields.getTextInputValue('mcUsernameInput') as any - var specialChars = /[`!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; - if (value > 16 || value < 3 || specialChars.test(value)) { - modal.reply({content: `ERROR: El nombre de usuario no es válido.`, ephemeral: true}); + async execute(modal) { + const value = modal.fields.getTextInputValue('mcUsernameInput'); + const specialChars = /[`!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; + if (value.length > 16 || value.length < 3 || specialChars.test(value)) { + modal.reply({ + content: `ERROR: El nombre de usuario no es válido.`, + ephemeral: true, + }); } else { try { - const request = await axios(`https://api.mojang.com/users/profiles/minecraft/${value}`, {validateStatus: function (status) {return status === 200 || status === 400; }}) - const data = request.data - await modal.reply({content: 'Enviado!, Gracias por utilizar tu Mona Lisa de confianza\n~Sr Izan, 2022', ephemeral: true}); - (modal.client.guilds.cache.get("928018226330337280")!.channels.cache.get("998195363376803850") as TextChannel).send(`Solicitud enviada por ${modal.user}.\nUsername de Minecraft: ${value}`); - } catch (err) { - await modal.reply({content: 'ERROR: No se ha podido enviar ya que eres un usuario no premium o de MC Bedrock.\nAsegúrate que has puesto bien el nombre de usuario.', ephemeral: true}) + const request = await axios + .get(`https://api.mojang.com/users/profiles/minecraft/${value}`, { + validateStatus: function (status) { + return status === 200 || status === 400; + }, + }) + .then((res) => res.data); + await modal.reply({ + content: + 'Enviado!, Gracias por utilizar tu Mona Lisa de confianza\n~Sr Izan, 2022', + ephemeral: true, + }); + const embed = new EmbedBuilder() + .setAuthor({ + name: modal.user.username, + iconURL: modal.user.displayAvatarURL(), + }) + .setColor('Green') + .setTitle('Nueva solicitud de entrada al servidor!') + .setDescription( + `Su nombre de usuario en Minecraft es: \`${value}\`\nSu UUID: \`${request.id}\`` + ) + .setFooter({ text: `Discord ID: ${modal.user.id}` }); + const button = new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId('mcform-dm') + .setLabel('Añadido a la whitelist!') + .setStyle(ButtonStyle.Success) + ); + ( + (await ( + await modal.client.guilds.fetch(process.env.GUILDID!) + ).channels.fetch(process.env.MCFORM_CHANNEL!)) as TextChannel + ).send({ embeds: [embed], components: [button] }); + } catch { + await modal.reply({ + content: + 'ERROR: No se ha podido enviar ya que eres un usuario no premium o de MC Bedrock.\nAsegúrate que has puesto bien el nombre de usuario.', + ephemeral: true, + }); } - } - } -}); \ No newline at end of file + } + }, +}); diff --git a/commands/handlers/role-menu.ts b/commands/handlers/role-menu.ts index 5ec85f3..7039691 100644 --- a/commands/handlers/role-menu.ts +++ b/commands/handlers/role-menu.ts @@ -12,7 +12,6 @@ export default commandModule({ const menuRoles: string[] = ( interaction.message.components[0].components[0] .data as Readonly - // @ts-ignore ).options.map((o: { label: string; value: string }) => o.value); const member = interaction.member as GuildMember;