diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ed785b5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotenv.enableAutocloaking": false +} \ No newline at end of file diff --git a/commands/fun/8ball.ts b/commands/fun/8ball.ts index 3544e6c..742e020 100644 --- a/commands/fun/8ball.ts +++ b/commands/fun/8ball.ts @@ -9,7 +9,7 @@ import { ownerOnly } from "../../src/plugins/ownerOnly" export default commandModule({ name: '8ball', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })], description: 'Preguntale a la 8-ball cosas.', //alias : [], diff --git a/commands/fun/a.ts b/commands/fun/a.ts index db1bcfa..7ec1263 100644 --- a/commands/fun/a.ts +++ b/commands/fun/a.ts @@ -1,29 +1,67 @@ const { commandModule, CommandType } = require('@sern/handler'); +import { Context } from "@sern/handler"; +import { ApplicationCommandOptionType, AttachmentBuilder, EmbedBuilder } from "discord.js"; import { publish } from "../../src/plugins/publish"; +const choices = ['XaviXE', 'Paula', 'William', 'Espejito2500', 'Wheelook', 'MarioCabrera', 'Paticama', 'Vinci', 'SrIzan', 'ItsAdrian', 'ByHGT']; export default commandModule({ name: 'a', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })], description: 'A', //alias : [], + options: [ + { + name: 'usuario', + description: 'Usuario que debería aparecer', + type: ApplicationCommandOptionType.String, + autocomplete: true, + command: { + onEvent: [], + async execute(ctx){ + const focusedValue = ctx.options.getFocused(); + const filtered = choices.filter(choice => choice.startsWith(focusedValue)); + await ctx.respond( + filtered.map(choice => ({ name: choice, value: choice })), + ); + } + } + } + ], execute: async (ctx, options) => { - const imagesArray = [ - './images/XaviXE.png', - './images/Paula.png', - './images/William.png', - './images/Espejito2500.png', - './images/Paula.png', - './images/Wheelook.png', - './images/MarioCabrera.png', - './images/Paticama.png', - './images/Vinci.png', - './images/SrIzan.png', - './images/ItsAdrian.png', - './images/ByHGT.png' - ] - const images = imagesArray[Math.floor(Math.random() * imagesArray.length)]; + try { + if (choices.indexOf(options[1].getString('usuario', true)) > -1) { + const attachmentbuilder = new AttachmentBuilder(`./images/${options[1].getString('usuario', true)}.png`) + const embed = new EmbedBuilder() + .setTitle("A") + .setImage(`attachment://${options[1].getString('usuario', true)}.png`) + .setColor("Random") + await ctx.reply({embeds: [embed], files: [attachmentbuilder]}) + } else { + const embed = new EmbedBuilder() + .setTitle("A no encontrado!") + .setDescription(`Qué raro, no se ha encontrado ese /a...\nPorqué no pruebas a poner uno del autocompletado?`) + .setColor("Red") + await ctx.reply({embeds: [embed], ephemeral: true}) + } + if (!options[1].getString('usuario', true)) { + const imagesArray = [ + './images/XaviXE.png', + './images/Paula.png', + './images/William.png', + './images/Espejito2500.png', + './images/Wheelook.png', + './images/MarioCabrera.png', + './images/Paticama.png', + './images/Vinci.png', + './images/SrIzan.png', + './images/ItsAdrian.png', + './images/ByHGT.png' + ] + const images = imagesArray[Math.floor(Math.random() * imagesArray.length)]; - await ctx.reply({content: 'A', files: [images]}); + await ctx.reply({content: 'A', files: [images]}); + } + } catch (err) {} }, }); \ No newline at end of file diff --git a/commands/fun/cat.ts b/commands/fun/cat.ts new file mode 100644 index 0000000..8588f78 --- /dev/null +++ b/commands/fun/cat.ts @@ -0,0 +1,59 @@ +const { commandModule, CommandType } = require('@sern/handler'); +import { Context } from "@sern/handler"; +import axios from "axios"; +import { ActionRowBuilder, APIMessageActionRowComponent, ButtonBuilder, ButtonStyle, ComponentType, EmbedBuilder } from "discord.js"; +import { publish } from "../../src/plugins/publish"; +/* +import { publish } from "../../src/plugins/publish"; +import { ownerOnly } from "../../src/plugins/ownerOnly" +*/ + +export default commandModule({ + name: 'gato', + type: CommandType.Slash, + plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })], + description: 'QUIEN HA DICHO GATOS?!?!?!', + //alias : [], + options: [], + execute: async (ctx: Context, options) => { + const request = await axios.get(`https://api.thecatapi.com/v1/images/search?api_key=${process.env.CATAPI}`).then(res => res.data) + const embed = new EmbedBuilder() + .setAuthor({name: ctx.user.username, iconURL: ctx.user.displayAvatarURL()}) + .setColor("Random") + .setImage(request[0].url) + .setFooter({text: `ID: ${request[0].id}`}) + .setTitle('Gato') + const row = new ActionRowBuilder() + .addComponents( + new ButtonBuilder() + .setCustomId("cat-upvote") + .setEmoji("⬆️") + .setStyle(ButtonStyle.Success), + new ButtonBuilder() + .setCustomId("cat-downvote") + .setEmoji("⬇️") + .setStyle(ButtonStyle.Danger), + ) + const message = await ctx.reply({embeds: [embed], components: [row]}) + const collector = message.createMessageComponentCollector({time: 30000, componentType: ComponentType.Button}) + collector.on('collect', async (i) => { + await i.deferReply({ephemeral: true}) + if (i.customId === "cat-upvote") { + await axios.post(`https://api.thecatapi.com/v1/votes?api_key=${process.env.CATAPI}`, { + "image_id": request[0].id, + "sub_id": i.user.id, + "value": 1 + }) + i.editReply({content: "Has votado positivamente al gato con ID " + "`" + request[0].id + "`"}) + } + if (i.customId === "cat-downvote") { + await axios.post(`https://api.thecatapi.com/v1/votes?api_key=${process.env.CATAPI}`, { + "image_id": request[0].id, + "sub_id": i.user.id, + "value": -1 + }) + i.editReply({content: "Has votado negativamente al gato con ID " + "`" + request[0].id + "`"}) + } + }) + }, +}); \ No newline at end of file diff --git a/commands/fun/joke.ts b/commands/fun/joke.ts index b136f44..ea6c249 100644 --- a/commands/fun/joke.ts +++ b/commands/fun/joke.ts @@ -4,7 +4,7 @@ import { publish } from "../../src/plugins/publish"; export default commandModule({ name: 'chiste', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })], description: 'Enseña un chiste en inglés.', alias : ['joke'], diff --git a/commands/minecraft/ip.ts b/commands/minecraft/ip.ts index 0c29ff9..936c4ef 100644 --- a/commands/minecraft/ip.ts +++ b/commands/minecraft/ip.ts @@ -9,7 +9,7 @@ import { ownerOnly } from "../../src/plugins/ownerOnly" export default commandModule({ name: 'ip', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })], // description: 'La IP del servidor de Minecraft', diff --git a/commands/minecraft/mcform_modal.ts b/commands/minecraft/mcform_modal.ts index 5c54861..16d6659 100644 --- a/commands/minecraft/mcform_modal.ts +++ b/commands/minecraft/mcform_modal.ts @@ -6,7 +6,7 @@ import { ownerOnly } from "../../src/plugins/ownerOnly" export default commandModule({ name: 'mcform', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })], description: 'Envia el formulario para entrar al servidor.', //alias : [], diff --git a/commands/misc/radio.ts b/commands/misc/radio.ts index 02a5de6..c08c4bf 100644 --- a/commands/misc/radio.ts +++ b/commands/misc/radio.ts @@ -10,7 +10,7 @@ import { ownerOnly } from "../../src/plugins/ownerOnly" export default commandModule({ name: 'radio', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })], description: 'Reproduce la radio', options: [ diff --git a/commands/misc/roleMenu.ts b/commands/misc/roleMenu.ts index 2238885..f2e5c45 100644 --- a/commands/misc/roleMenu.ts +++ b/commands/misc/roleMenu.ts @@ -6,7 +6,7 @@ import { Resolver } from "../../resolver"; export default commandModule({ name: 'rolemenu', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] }), ownerOnly()], description: 'ADMIN: Spawnea un menú de roles', //alias : [], diff --git a/commands/misc/shorten.ts b/commands/misc/shorten.ts index 394da42..25786f7 100644 --- a/commands/misc/shorten.ts +++ b/commands/misc/shorten.ts @@ -5,7 +5,7 @@ import { publish } from "../../src/plugins/publish"; export default commandModule({ name: 'acortar', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })], description: 'Acorta una URL a vinci.tk', options: [ diff --git a/commands/misc/sugerencias_modal.ts b/commands/misc/sugerencias_modal.ts index 5eec692..77ec2cf 100644 --- a/commands/misc/sugerencias_modal.ts +++ b/commands/misc/sugerencias_modal.ts @@ -6,7 +6,7 @@ import { ownerOnly } from "../../src/plugins/ownerOnly" export default commandModule({ name: 'sugerencias', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })], description: 'Envia una sugerencia.', //alias : [], diff --git a/commands/misc/uptime.ts b/commands/misc/uptime.ts index 19a88a7..0c9a341 100644 --- a/commands/misc/uptime.ts +++ b/commands/misc/uptime.ts @@ -4,7 +4,7 @@ const prettySeconds = require('pretty-seconds-spanish') export default commandModule({ name: 'uptime', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] })], description: 'Enseña el tiempo que ha estado encendido el bot.', //alias : [], diff --git a/commands/moderation/ban.ts b/commands/moderation/ban.ts index 8b65787..5765fad 100644 --- a/commands/moderation/ban.ts +++ b/commands/moderation/ban.ts @@ -5,7 +5,7 @@ import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js' export default commandModule({ name: 'ban', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] }), ownerOnly()], description: 'ADMIN: Banea usuarios.', options: [{ diff --git a/commands/moderation/deleteMessage.ts b/commands/moderation/deleteMessage.ts index c4d5b06..d135392 100644 --- a/commands/moderation/deleteMessage.ts +++ b/commands/moderation/deleteMessage.ts @@ -9,7 +9,7 @@ import { ownerOnly } from "../../src/plugins/ownerOnly" export default commandModule({ name: 'eliminarmensaje', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] }), ownerOnly()], description: 'ADMIN: Elimina comandos por su ID.', //alias : [], diff --git a/commands/moderation/kick.ts b/commands/moderation/kick.ts index 2b45d96..e115512 100644 --- a/commands/moderation/kick.ts +++ b/commands/moderation/kick.ts @@ -5,7 +5,7 @@ import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js' export default commandModule({ name: 'kick', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] }), ownerOnly()], description: 'ADMIN: Expulsa usuarios.', options: [ diff --git a/commands/moderation/prune.ts b/commands/moderation/prune.ts index b6bdaf0..5016738 100644 --- a/commands/moderation/prune.ts +++ b/commands/moderation/prune.ts @@ -5,7 +5,7 @@ import { ApplicationCommandOptionType } from 'discord.js' export default commandModule({ name: 'prune', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] }), ownerOnly()], description: 'ADMIN: Elimina hasta 100 mensajes', options: [{ diff --git a/commands/moderation/slowmode.ts b/commands/moderation/slowmode.ts index 69edd1e..7e26134 100644 --- a/commands/moderation/slowmode.ts +++ b/commands/moderation/slowmode.ts @@ -5,7 +5,7 @@ import { ApplicationCommandOptionType } from "discord.js"; export default commandModule({ name: 'slowmode', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] }), ownerOnly()], description: 'ADMIN: Pon modo lento a canales de texto', options: [ diff --git a/commands/moderation/timeoutUser.ts b/commands/moderation/timeoutUser.ts index 06690f0..7a49dbf 100644 --- a/commands/moderation/timeoutUser.ts +++ b/commands/moderation/timeoutUser.ts @@ -9,7 +9,7 @@ import { ownerOnly } from "../../src/plugins/ownerOnly" export default commandModule({ name: 'timeout', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298', '928018226330337280'] }), ownerOnly()], description: 'ADMIN: Silencia a usuarios.', options: [ diff --git a/commands/ping.ts b/commands/ping.ts index d65cbe4..c31a2cd 100644 --- a/commands/ping.ts +++ b/commands/ping.ts @@ -8,7 +8,7 @@ import { ownerOnly } from "../../src/plugins/ownerOnly" export default commandModule({ name: 'ping', - type: CommandType.Both, + type: CommandType.Slash, plugins: [publish({ guildIds: ['1000400148289036298'] })], // , '928018226330337280' description: 'A ping command', diff --git a/events/guildMemberAdd.ts b/events/guildMemberAdd.ts index e181314..152b030 100644 --- a/events/guildMemberAdd.ts +++ b/events/guildMemberAdd.ts @@ -6,13 +6,12 @@ export default eventModule({ type: EventType.Discord, name: 'guildMemberAdd', execute(member: GuildMember) { - // member.guild.channels.cache.get("968572106952560670").send(`${member.user} has joined the server!`); const newMemberEmbed = new EmbedBuilder() - .setColor("Random") - .setTitle("Nuevo miembro!") - .setDescription(`${member.user} acaba de entrar al servidor!`) - .setThumbnail(member.user.displayAvatarURL()) - .setTimestamp(); + .setColor("Random") + .setTitle("Nuevo miembro!") + .setDescription(`${member.user} acaba de entrar al servidor!`) + .setThumbnail(member.user.displayAvatarURL()) + .setTimestamp(); const channel = member.client.guilds.cache.get('928018226330337280')!.channels.cache.get('993599947364634694') as TextChannel channel.send({embeds: [newMemberEmbed]}) diff --git a/index.ts b/index.ts index d394898..8990907 100644 --- a/index.ts +++ b/index.ts @@ -18,7 +18,6 @@ export const db = mongoose.connect(process.env.MONGODB, {useNewUrlParser: true,u Sern.init({ client, - sernPrefix, commands : './commands', sernEmitter : new SernEmitter(), events: './events' diff --git a/package-lock.json b/package-lock.json index 2fea02f..577949d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@discordjs/opus": "^0.8.0", "@discordjs/voice": "^0.11.0", - "@sern/handler": "^1.2.0", + "@sern/handler": "^1.2.1", "@xmldom/xmldom": "^0.8.2", "axios": "^0.27.2", "discord-bot-youtube-notifications": "^1.1.4", @@ -212,9 +212,9 @@ } }, "node_modules/@sern/handler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@sern/handler/-/handler-1.2.0.tgz", - "integrity": "sha512-yXPwzuacYN+65hvf8VI16isw4Cy7Uo4TX5BgIA1dLaaAE7Fmxv6LvhQZjQQj/bw2gQdEY7XMoPlnggV7EpIlTw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@sern/handler/-/handler-1.2.1.tgz", + "integrity": "sha512-ElXlJC/tS5T++QCUCXw1uCCfMu4sVSg6UN6uD+Y9TigynpQsFpzHAKuOtyQwUcwIBbiB+NZ2xAbOiyVy0YpPvw==", "dependencies": { "rxjs": "^7.5.6", "ts-pattern": "^4.0.2", @@ -3010,9 +3010,9 @@ "integrity": "sha512-ula2O0kpSZtX9rKXNeQMrHwNd7E4jPDJYUXmEGTFdMRfyfMw+FPyh04oKMjAiDuOi64bYgVkOV3MjK+loImFhQ==" }, "@sern/handler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@sern/handler/-/handler-1.2.0.tgz", - "integrity": "sha512-yXPwzuacYN+65hvf8VI16isw4Cy7Uo4TX5BgIA1dLaaAE7Fmxv6LvhQZjQQj/bw2gQdEY7XMoPlnggV7EpIlTw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@sern/handler/-/handler-1.2.1.tgz", + "integrity": "sha512-ElXlJC/tS5T++QCUCXw1uCCfMu4sVSg6UN6uD+Y9TigynpQsFpzHAKuOtyQwUcwIBbiB+NZ2xAbOiyVy0YpPvw==", "requires": { "rxjs": "^7.5.6", "ts-pattern": "^4.0.2", diff --git a/package.json b/package.json index 3a90d96..d55e381 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "@discordjs/opus": "^0.8.0", "@discordjs/voice": "^0.11.0", - "@sern/handler": "^1.2.0", + "@sern/handler": "^1.2.1", "@xmldom/xmldom": "^0.8.2", "axios": "^0.27.2", "discord-bot-youtube-notifications": "^1.1.4",