feat: more beautiful mcform

This commit is contained in:
2022-12-28 13:09:31 +01:00
parent 9ead07d208
commit 31fabf024f
4 changed files with 84 additions and 21 deletions

View File

@@ -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)

View File

@@ -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>`
})
})
},
});

View File

@@ -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<ButtonBuilder>().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,
});
}
}
}
});
}
},
});

View File

@@ -12,7 +12,6 @@ export default commandModule({
const menuRoles: string[] = (
interaction.message.components[0].components[0]
.data as Readonly<APISelectMenuComponent>
// @ts-ignore
).options.map((o: { label: string; value: string }) => o.value);
const member = interaction.member as GuildMember;