diff --git a/.gitignore b/.gitignore index 620801e..78416ab 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ node_modules/ json.sqlite dist/ -*giveaway* -*manga.ts* \ No newline at end of file +*giveaway* \ No newline at end of file diff --git a/commands/misc/afk.ts b/commands/misc/afk.ts new file mode 100644 index 0000000..5c76225 --- /dev/null +++ b/commands/misc/afk.ts @@ -0,0 +1,60 @@ +import { commandModule, CommandType } from '@sern/handler' +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" +import db from '../../schemas/afk.js'; +import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js'; +/* +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" +*/ + +export default commandModule({ + type: CommandType.Slash, + plugins: [publish()], + description: 'afk command', + //alias : [], + options: [ + { + name: 'añadir', + description: 'Di que estás AFK o inactivo por la razón que quieras.', + type: ApplicationCommandOptionType.Subcommand, + options: [ + { + name: 'motivo', + description: 'El motivo por el que estarás AFK', + type: ApplicationCommandOptionType.String, + required: true, + } + ] + }, + { + name: 'eliminar', + description: 'Elimina tu AFK', + type: ApplicationCommandOptionType.Subcommand + } + ], + execute: async (ctx, options) => { + switch (options[1].getSubcommand()) { + case 'añadir': { + if (await db.exists({ id: ctx.user.id })) return ctx.reply({ content: 'Ya existes en la base de datos!', ephemeral: true }) + const reason = options[1].getString('motivo', true); + + await (new db({ id: ctx.user.id, reason: reason })).save() + const embed = new EmbedBuilder() + .setAuthor({ name: ctx.user.username, iconURL: ctx.user.displayAvatarURL() }) + .setTitle('AFK añadido!') + .setColor('Green') + .setDescription(`AFK añadido!\nRazón: ${reason}`) + + await ctx.reply({ embeds: [embed] }) + } break; + case 'eliminar': { + if (!await db.exists({ id: ctx.user.id })) return ctx.reply({ content: 'No existes en la base de datos!', ephemeral: true }) + + await db.deleteOne({ id: ctx.user.id }) + + await ctx.reply('Ok, has sido eliminado correctamente de la base de datos.') + } break; + } + }, +}); \ No newline at end of file diff --git a/events/afknotify.ts b/events/afknotify.ts new file mode 100644 index 0000000..bcdf6f7 --- /dev/null +++ b/events/afknotify.ts @@ -0,0 +1,24 @@ +import { EventType, eventModule } from '@sern/handler'; +import { EmbedBuilder, Message } from 'discord.js'; +import db from '../schemas/afk.js'; + +export default eventModule({ + type: EventType.Discord, + name: 'messageCreate', + execute: async (message: Message) => { + const dbEntries = await db.find() + + dbEntries.forEach(async (doc) => { + if (!message.content.includes(`<@${doc.id}`)) return; + const username = (await message.client.users.fetch(doc.id)).username + const embed = new EmbedBuilder() + .setColor('Red') + .setTitle(`Usuario ${username} está AFK`) + .setDescription(`El usuario que has mencionado en tu mensaje ha marcado su estado como AFK\nRazón: ${doc.reason}`) + .setFooter({ text: 'Este mensaje se eliminará en 10 segundos (wepa, como una bomba!)' }) + + const sentMessage = await message.reply({ embeds: [embed] }) + setTimeout(async () => { await sentMessage.delete() }, 10_000) + }) + }, +}); diff --git a/package-lock.json b/package-lock.json index 7bfd72e..d60ff90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@consumet/extensions": "^1.2.8", + "@consumet/extensions": "^1.3.5", "@discordjs/opus": "^0.9.0", "@discordjs/voice": "^0.14.0", "@napi-rs/canvas": "^0.1.30", @@ -40,16 +40,15 @@ } }, "node_modules/@consumet/extensions": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@consumet/extensions/-/extensions-1.2.8.tgz", - "integrity": "sha512-peswGT0bs60uNBFffP6FIc3WmaGBxgpBCksEp4l2nD8kO4QXTMIQU8or7vDa8ThVAwReeoSYWg1+A38d7K/HoA==", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@consumet/extensions/-/extensions-1.3.5.tgz", + "integrity": "sha512-Dy8Cb4jgzzZ5ItBCMUPgMaaaIVXbhBiENbHF8NlklHW6fD3u3KUd0UgPI0GvqyhAtVoMeI15TsoVOSr4PriPbA==", "dependencies": { "ascii-url-encoder": "^1.2.0", "axios": "^0.27.2", "cheerio": "^1.0.0-rc.11", "crypto-js": "^4.1.1", - "form-data": "^4.0.0", - "ws": "^8.8.1" + "form-data": "^4.0.0" } }, "node_modules/@consumet/extensions/node_modules/axios": { @@ -3520,16 +3519,15 @@ }, "dependencies": { "@consumet/extensions": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@consumet/extensions/-/extensions-1.2.8.tgz", - "integrity": "sha512-peswGT0bs60uNBFffP6FIc3WmaGBxgpBCksEp4l2nD8kO4QXTMIQU8or7vDa8ThVAwReeoSYWg1+A38d7K/HoA==", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@consumet/extensions/-/extensions-1.3.5.tgz", + "integrity": "sha512-Dy8Cb4jgzzZ5ItBCMUPgMaaaIVXbhBiENbHF8NlklHW6fD3u3KUd0UgPI0GvqyhAtVoMeI15TsoVOSr4PriPbA==", "requires": { "ascii-url-encoder": "^1.2.0", "axios": "^0.27.2", "cheerio": "^1.0.0-rc.11", "crypto-js": "^4.1.1", - "form-data": "^4.0.0", - "ws": "^8.8.1" + "form-data": "^4.0.0" }, "dependencies": { "axios": { diff --git a/package.json b/package.json index 932ebc0..b0b520e 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ }, "homepage": "https://github.com/SrIzan10/vinci#readme", "dependencies": { - "@consumet/extensions": "^1.2.8", + "@consumet/extensions": "^1.3.5", "@discordjs/opus": "^0.9.0", "@discordjs/voice": "^0.14.0", "@napi-rs/canvas": "^0.1.30", diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 39a2b6e..0000000 --- a/renovate.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base" - ] -} diff --git a/schemas/afk.js b/schemas/afk.js new file mode 100644 index 0000000..34f53e4 --- /dev/null +++ b/schemas/afk.js @@ -0,0 +1,7 @@ +import mongoose from 'mongoose' +const schema = new mongoose.Schema({ + id: {type: String, required: true}, + reason: {type: String, required: true}, +}); +const db = mongoose.model('afk', schema, 'afk'); +export default db \ No newline at end of file