feat: organize more stuff in the bot

This commit is contained in:
2022-10-30 22:52:46 +01:00
parent a5228f99f5
commit 661d746c05
7 changed files with 66 additions and 55 deletions

View File

@@ -14,6 +14,6 @@ vinci bot
<!--<img src="https://srizan.s-ul.eu/RddzT2f9">-->
<img src="https://cdn.discordapp.com/attachments/928230817673641995/1036390945945559140/makesweet-hbt4h3.gif">
by [Oliverlg8](https://osu.ppy.sh/users/Oliverlg8)
by @Oliverlg8
9 stars! tysm!

View File

@@ -0,0 +1,26 @@
import { commandModule, CommandType } from '@sern/handler'
import axios from "axios";
import { GuildBasedChannel, TextChannel } from 'discord.js';
export default commandModule({
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});
} 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})
}
}
}
});

View File

@@ -0,0 +1,14 @@
// import everything
import { commandModule, CommandType } from '@sern/handler'
import { EmbedBuilder } from 'discord.js';
import { publish } from "../../src/plugins/publish.js";
import { ownerOnly } from "../../src/plugins/ownerOnly.js"
import { TextChannel, ThreadAutoArchiveDuration, ThreadManager } from "discord.js";
export default commandModule({
type: CommandType.Modal,
//alias : [],
async execute (modal) {
}
});

View File

@@ -6,10 +6,7 @@ import { ownerOnly } from "../../src/plugins/ownerOnly.js"
import { TextChannel, ThreadAutoArchiveDuration, ThreadManager } from "discord.js";
export default commandModule({
// using CommandType.Modal to get the answers
type: CommandType.Modal,
plugins: [],
description: 'Envia sugerencias.',
//alias : [],
async execute (modal) {
// first we get the value

View File

@@ -1,26 +1,32 @@
import { commandModule, CommandType } from '@sern/handler'
import axios from "axios";
import { GuildBasedChannel, TextChannel } from 'discord.js';
import { ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ModalActionRowComponentBuilder } from 'discord.js'
import { publish } from "../../src/plugins/publish.js";
import { ownerOnly } from "../../src/plugins/ownerOnly.js"
export default commandModule({
type: CommandType.Modal,
plugins: [],
name: 'mcform',
type: CommandType.Slash,
plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })],
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});
} 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})
}
}
execute: async (ctx) => {
const modal = new ModalBuilder()
.setCustomId('mcform')
.setTitle('Formulario para entrar al servidor');
// Create the text input components
const input = new TextInputBuilder()
.setCustomId('mcUsernameInput')
// The label is the prompt the user sees for this input
.setLabel("Cuál es tu nombre de usuario de Minecraft?")
// Short means only a single line of text
.setStyle(TextInputStyle.Short);
// An action row only holds one text input,
// so you need one action row per text input.
const usernameActionRow = new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(input);
// Add inputs to the modal
modal.addComponents(usernameActionRow);
await ctx.interaction.showModal(modal);
}
});

View File

@@ -1,32 +0,0 @@
import { commandModule, CommandType } from '@sern/handler'
import { ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ModalActionRowComponentBuilder } from 'discord.js'
import { publish } from "../../src/plugins/publish.js";
import { ownerOnly } from "../../src/plugins/ownerOnly.js"
export default commandModule({
name: 'mcform',
type: CommandType.Slash,
plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })],
description: 'Envia el formulario para entrar al servidor.',
//alias : [],
execute: async (ctx) => {
const modal = new ModalBuilder()
.setCustomId('mcform')
.setTitle('Formulario para entrar al servidor');
// Create the text input components
const input = new TextInputBuilder()
.setCustomId('mcUsernameInput')
// The label is the prompt the user sees for this input
.setLabel("Cuál es tu nombre de usuario de Minecraft?")
// Short means only a single line of text
.setStyle(TextInputStyle.Short);
// An action row only holds one text input,
// so you need one action row per text input.
const usernameActionRow = new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(input);
// Add inputs to the modal
modal.addComponents(usernameActionRow);
await ctx.interaction.showModal(modal);
}
});