From 1b55774ed260d7b0147f8f3fccef48d7913f9d3a Mon Sep 17 00:00:00 2001 From: SrIzan10 <66965250+SrIzan10@users.noreply.github.com> Date: Thu, 29 Dec 2022 12:23:21 +0100 Subject: [PATCH] feat: change to sern 2.0 --- commands/fun/8ball.ts | 8 +- commands/fun/a.ts | 2 +- commands/fun/animal.ts | 6 +- commands/fun/cursivify.ts | 8 +- commands/fun/gogoanime.ts | 6 +- commands/fun/joke.ts | 2 +- commands/fun/megamind.ts | 8 +- commands/fun/rps.ts | 2 +- commands/fun/tictactoe.ts | 4 +- commands/handlers/role-menu.ts | 2 +- commands/minecraft/ip.ts | 8 +- commands/minecraft/mcform.ts | 4 +- commands/misc/askjavi.ts | 8 +- commands/misc/askjavi_disabled.ts | 4 +- commands/misc/credits.ts | 2 +- commands/misc/cumple.ts | 10 +- commands/misc/radio.ts | 6 +- commands/misc/roleMenu.ts | 4 +- commands/misc/shorten.ts | 2 +- commands/misc/stats.ts | 4 +- commands/misc/sugerencias.ts | 4 +- commands/misc/traducir.ts | 8 +- commands/misc/uptime.ts | 2 +- commands/moderation/ban.ts | 4 +- commands/moderation/deleteMessage.ts | 10 +- commands/moderation/kick.ts | 4 +- commands/moderation/prune.ts | 4 +- commands/moderation/slowmode.ts | 4 +- commands/moderation/timeoutUser.ts | 8 +- commands/moderation/warn.ts | 4 +- commands/ping.ts | 8 +- index.ts | 21 +- package-lock.json | 298 ++++++++++++------ package.json | 9 +- {src/plugins => plugins}/acceptingBirthday.ts | 2 +- plugins/index.ts | 4 + {src/plugins => plugins}/ownerOnly.ts | 0 {src/plugins => plugins}/publish.ts | 121 ++++--- {src/plugins => plugins}/srIzanOnly.ts | 2 +- tsconfig.json | 11 +- 40 files changed, 378 insertions(+), 250 deletions(-) rename {src/plugins => plugins}/acceptingBirthday.ts (98%) create mode 100644 plugins/index.ts rename {src/plugins => plugins}/ownerOnly.ts (100%) rename {src/plugins => plugins}/publish.ts (61%) rename {src/plugins => plugins}/srIzanOnly.ts (94%) diff --git a/commands/fun/8ball.ts b/commands/fun/8ball.ts index f7fff66..ca558df 100644 --- a/commands/fun/8ball.ts +++ b/commands/fun/8ball.ts @@ -1,10 +1,10 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; import { ApplicationCommandOptionType } from "discord.js"; /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ diff --git a/commands/fun/a.ts b/commands/fun/a.ts index b41b418..213b40a 100644 --- a/commands/fun/a.ts +++ b/commands/fun/a.ts @@ -1,7 +1,7 @@ import { commandModule, CommandType } from '@sern/handler' import { Context } from "@sern/handler"; import { ApplicationCommandOptionType, AttachmentBuilder, AutocompleteInteraction, EmbedBuilder } from "discord.js"; -import { publish } from "../../src/plugins/publish.js"; +import { publish } from "#plugins"; const choices = ['XaviXE', 'Paula', 'William', 'Espejito2500', 'Wheelook', 'MarioCabrera', 'Paticama', 'Vinci', 'SrIzan', 'ItsAdrian', 'ByHGT', 'Irene', 'Boniato64']; export default commandModule({ diff --git a/commands/fun/animal.ts b/commands/fun/animal.ts index b2148b3..74c1aa2 100644 --- a/commands/fun/animal.ts +++ b/commands/fun/animal.ts @@ -1,10 +1,10 @@ import { commandModule, CommandType } from '@sern/handler' import axios from "axios"; import { ActionRowBuilder, ApplicationCommandOptionType, ButtonBuilder, ButtonStyle, ComponentType, EmbedBuilder } from "discord.js"; -import { publish } from "../../src/plugins/publish.js"; +import { publish } from "#plugins"; /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ diff --git a/commands/fun/cursivify.ts b/commands/fun/cursivify.ts index d003746..936e37b 100644 --- a/commands/fun/cursivify.ts +++ b/commands/fun/cursivify.ts @@ -1,13 +1,13 @@ import { commandModule, CommandType } from '@sern/handler'; -import { publish } from '../../src/plugins/publish.js'; +import { publish } from '../../plugins/publish.js'; /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ name: 'cursivify', - type: CommandType.MenuMsg, + type: CommandType.CtxMsg, plugins: [publish()], execute: async (ctx) => { await ctx.deferReply() diff --git a/commands/fun/gogoanime.ts b/commands/fun/gogoanime.ts index d2daeb2..deef853 100644 --- a/commands/fun/gogoanime.ts +++ b/commands/fun/gogoanime.ts @@ -1,5 +1,5 @@ import { commandModule, CommandType } from '@sern/handler'; -import { publish } from '../../src/plugins/publish.js'; +import { publish } from '../../plugins/publish.js'; import { ANIME } from '@consumet/extensions'; import { ActionRowBuilder, @@ -10,8 +10,8 @@ import { EmbedBuilder, } from 'discord.js'; /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ diff --git a/commands/fun/joke.ts b/commands/fun/joke.ts index c5772b0..43713b2 100644 --- a/commands/fun/joke.ts +++ b/commands/fun/joke.ts @@ -1,6 +1,6 @@ import { commandModule, CommandType } from '@sern/handler' import axios from "axios"; -import { publish } from "../../src/plugins/publish.js"; +import { publish } from "#plugins"; export default commandModule({ name: 'chiste', diff --git a/commands/fun/megamind.ts b/commands/fun/megamind.ts index 23cc2e1..b7d7e55 100644 --- a/commands/fun/megamind.ts +++ b/commands/fun/megamind.ts @@ -1,11 +1,11 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; import Canvas from '@napi-rs/canvas'; import { ApplicationCommandOptionType, AttachmentBuilder } from 'discord.js'; /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ diff --git a/commands/fun/rps.ts b/commands/fun/rps.ts index 98fc015..bd8810d 100644 --- a/commands/fun/rps.ts +++ b/commands/fun/rps.ts @@ -1,6 +1,6 @@ import { commandModule, CommandType } from '@sern/handler' import { ActionRowBuilder, ApplicationCommandOptionType, ButtonBuilder, ButtonStyle, ComponentType, EmbedBuilder, GuildMember } from "discord.js"; -import { publish } from "../../src/plugins/publish.js"; +import { publish } from "#plugins"; import rockpaperscissors from "rockpaperscissors-checker"; export default commandModule({ diff --git a/commands/fun/tictactoe.ts b/commands/fun/tictactoe.ts index 5d13193..641db48 100644 --- a/commands/fun/tictactoe.ts +++ b/commands/fun/tictactoe.ts @@ -1,7 +1,7 @@ import TicTacToe from 'discord-tictactoe'; import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; import { ApplicationCommandOptionType } from "discord.js"; const game = new TicTacToe({language: 'en'}) diff --git a/commands/handlers/role-menu.ts b/commands/handlers/role-menu.ts index d098131..cc5b7e2 100644 --- a/commands/handlers/role-menu.ts +++ b/commands/handlers/role-menu.ts @@ -2,7 +2,7 @@ import { commandModule, CommandType } from "@sern/handler"; import type { APISelectMenuComponent, GuildMember } from "discord.js"; export default commandModule({ - type: CommandType.MenuSelect, + type: CommandType.StringSelect, name: 'role-menu', async execute(interaction) { await interaction.deferReply({ ephemeral: true }); diff --git a/commands/minecraft/ip.ts b/commands/minecraft/ip.ts index c1fda9f..4c00f84 100644 --- a/commands/minecraft/ip.ts +++ b/commands/minecraft/ip.ts @@ -1,10 +1,10 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; import { ApplicationCommandOptionType } from "discord.js"; /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ diff --git a/commands/minecraft/mcform.ts b/commands/minecraft/mcform.ts index 0da076b..3532844 100644 --- a/commands/minecraft/mcform.ts +++ b/commands/minecraft/mcform.ts @@ -1,7 +1,7 @@ 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" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; export default commandModule({ diff --git a/commands/misc/askjavi.ts b/commands/misc/askjavi.ts index dff94a3..4036688 100644 --- a/commands/misc/askjavi.ts +++ b/commands/misc/askjavi.ts @@ -1,10 +1,10 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; import { ApplicationCommandOptionType } from "discord.js"; /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ diff --git a/commands/misc/askjavi_disabled.ts b/commands/misc/askjavi_disabled.ts index ba8c4dd..229e058 100644 --- a/commands/misc/askjavi_disabled.ts +++ b/commands/misc/askjavi_disabled.ts @@ -11,8 +11,8 @@ import { ModalSubmitInteraction, ApplicationCommandOptionType, } from 'discord.js'; -import { publish } from '../../src/plugins/publish.js'; -import { ownerOnly } from '../../src/plugins/ownerOnly.js'; +import { publish } from '../../plugins/publish.js'; +import { ownerOnly } from '../../plugins/ownerOnly.js'; import padyama from '../../schemas/padyama.js'; import { randomnumbergen } from '../../util/randomnumbergen.js'; diff --git a/commands/misc/credits.ts b/commands/misc/credits.ts index 79664f0..9401332 100644 --- a/commands/misc/credits.ts +++ b/commands/misc/credits.ts @@ -1,7 +1,7 @@ import { commandModule, CommandType } from '@sern/handler' import { Context, SlashOptions } from "@sern/handler"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js"; -import { publish } from "../../src/plugins/publish.js"; +import { publish } from "#plugins"; export default commandModule({ name: 'creditos', diff --git a/commands/misc/cumple.ts b/commands/misc/cumple.ts index f74c462..42e4c8f 100644 --- a/commands/misc/cumple.ts +++ b/commands/misc/cumple.ts @@ -1,18 +1,18 @@ import { commandModule, CommandType } from "@sern/handler"; -import { publish } from "../../src/plugins/publish.js"; +import { publish } from "#plugins"; import { ApplicationCommandOptionType } from "discord.js"; import { readFileSync } from "node:fs"; import birthdays from "../../schemas/birthdays.js"; -import { confirmation } from "../../src/plugins/acceptingBirthday.js"; +import { acceptingBirthday } from "#plugins"; /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ name: "cumple", type: CommandType.Slash, - plugins: [publish(), confirmation()], + plugins: [publish(), acceptingBirthday()], description: "Pon tu cumpleaƱos en la base de datos para ser felicitado!", //alias : [], options: [ diff --git a/commands/misc/radio.ts b/commands/misc/radio.ts index 285721d..6c8654d 100644 --- a/commands/misc/radio.ts +++ b/commands/misc/radio.ts @@ -1,11 +1,11 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; +import { publish } from "#plugins"; import { createAudioPlayer, createAudioResource, DiscordGatewayAdapterCreator, joinVoiceChannel } from "@discordjs/voice"; import got from "got"; import { ApplicationCommandOptionType, EmbedBuilder } from "discord.js"; /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ diff --git a/commands/misc/roleMenu.ts b/commands/misc/roleMenu.ts index cb0c997..159183f 100644 --- a/commands/misc/roleMenu.ts +++ b/commands/misc/roleMenu.ts @@ -1,6 +1,6 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; import { ActionRowBuilder, ApplicationCommandOptionType, ChannelType, Collection, EmbedBuilder, Role, SelectMenuBuilder, TextChannel } from "discord.js"; import { Resolver } from "../../util/resolver.js"; diff --git a/commands/misc/shorten.ts b/commands/misc/shorten.ts index 2c100ea..5137a97 100644 --- a/commands/misc/shorten.ts +++ b/commands/misc/shorten.ts @@ -1,7 +1,7 @@ import { commandModule, CommandType } from "@sern/handler"; import axios, { AxiosError, AxiosResponse } from "axios"; import { ApplicationCommandOptionType } from "discord.js"; -import { publish } from "../../src/plugins/publish.js"; +import { publish } from "#plugins"; export default commandModule({ name: "acortar", diff --git a/commands/misc/stats.ts b/commands/misc/stats.ts index 99619b6..f8cbf74 100644 --- a/commands/misc/stats.ts +++ b/commands/misc/stats.ts @@ -1,6 +1,6 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; import { EmbedBuilder } from "discord.js"; import axios from "axios"; import prettySeconds from 'pretty-seconds-spanish' diff --git a/commands/misc/sugerencias.ts b/commands/misc/sugerencias.ts index 0b883e3..e241fb9 100644 --- a/commands/misc/sugerencias.ts +++ b/commands/misc/sugerencias.ts @@ -1,7 +1,7 @@ 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" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; export default commandModule({ diff --git a/commands/misc/traducir.ts b/commands/misc/traducir.ts index 295d5d7..a197e0e 100644 --- a/commands/misc/traducir.ts +++ b/commands/misc/traducir.ts @@ -1,13 +1,13 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; import axios from 'axios'; import { readFileSync } from 'node:fs' import { ActionRowBuilder, ApplicationCommandOptionType, ButtonBuilder, ButtonStyle, ComponentType, EmbedBuilder } from 'discord.js'; const choices = ['es', 'en', 'fr', 'de', 'hi', 'it', 'ja', 'ko', 'pl'] /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ diff --git a/commands/misc/uptime.ts b/commands/misc/uptime.ts index 4547db2..74de11f 100644 --- a/commands/misc/uptime.ts +++ b/commands/misc/uptime.ts @@ -1,5 +1,5 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; +import { publish } from "#plugins"; import prettySeconds from 'pretty-seconds-spanish' export default commandModule({ diff --git a/commands/moderation/ban.ts b/commands/moderation/ban.ts index 38cae5d..748b610 100644 --- a/commands/moderation/ban.ts +++ b/commands/moderation/ban.ts @@ -1,6 +1,6 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js"; +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins";; import { ApplicationCommandOptionType, EmbedBuilder, GuildMember, TextChannel } from 'discord.js' export default commandModule({ diff --git a/commands/moderation/deleteMessage.ts b/commands/moderation/deleteMessage.ts index 3f6b583..77243ec 100644 --- a/commands/moderation/deleteMessage.ts +++ b/commands/moderation/deleteMessage.ts @@ -1,10 +1,10 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "../../plugins/index.js"; +import { ownerOnly } from "#plugins"; import { ApplicationCommandOptionType, TextChannel } from "discord.js"; /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ @@ -30,7 +30,7 @@ export default commandModule({ execute: async (ctx, options) => { try { const idMensaje = options[1].getString('id', true); - const guildId = ctx.guild.id + const guildId = ctx.guild!.id const guild = await ctx.client.guilds.fetch(guildId); const channel = await guild.channels.fetch(ctx.channel!.id); (await (channel as TextChannel).messages.fetch(idMensaje)).delete(); diff --git a/commands/moderation/kick.ts b/commands/moderation/kick.ts index cef02ae..5089d90 100644 --- a/commands/moderation/kick.ts +++ b/commands/moderation/kick.ts @@ -1,6 +1,6 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js"; +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins";; import { ApplicationCommandOptionType, EmbedBuilder, GuildMember, TextChannel } from 'discord.js' export default commandModule({ diff --git a/commands/moderation/prune.ts b/commands/moderation/prune.ts index 7ba326d..47f55c1 100644 --- a/commands/moderation/prune.ts +++ b/commands/moderation/prune.ts @@ -1,6 +1,6 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js"; +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins";; import { ApplicationCommandOptionType, TextChannel } from 'discord.js' export default commandModule({ diff --git a/commands/moderation/slowmode.ts b/commands/moderation/slowmode.ts index f595bab..571e189 100644 --- a/commands/moderation/slowmode.ts +++ b/commands/moderation/slowmode.ts @@ -1,6 +1,6 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; import { ApplicationCommandOptionType, TextChannel } from "discord.js"; export default commandModule({ diff --git a/commands/moderation/timeoutUser.ts b/commands/moderation/timeoutUser.ts index 1f288ea..530ccd9 100644 --- a/commands/moderation/timeoutUser.ts +++ b/commands/moderation/timeoutUser.ts @@ -1,10 +1,10 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins"; import { ApplicationCommandOptionType, GuildMember, TextChannel } from "discord.js"; /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ diff --git a/commands/moderation/warn.ts b/commands/moderation/warn.ts index 6a9edc2..9e68718 100644 --- a/commands/moderation/warn.ts +++ b/commands/moderation/warn.ts @@ -1,6 +1,6 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js"; +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins";; import { ActionRowBuilder, ApplicationCommandOptionType, ButtonBuilder, ButtonInteraction, ButtonStyle, ComponentType, EmbedBuilder, GuildMember } from "discord.js"; import db from '../../schemas/warn.js'; diff --git a/commands/ping.ts b/commands/ping.ts index 924ce18..ab74a65 100644 --- a/commands/ping.ts +++ b/commands/ping.ts @@ -1,9 +1,9 @@ import { commandModule, CommandType } from '@sern/handler' -import { publish } from "../src/plugins/publish.js"; -import { ownerOnly } from "../src/plugins/ownerOnly.js" +import { publish } from "../plugins/publish.js"; +import { ownerOnly } from "../plugins/ownerOnly.js" /* -import { publish } from "../../src/plugins/publish.js"; -import { ownerOnly } from "../../src/plugins/ownerOnly.js" +import { publish } from "#plugins"; +import { ownerOnly } from "#plugins" */ export default commandModule({ diff --git a/index.ts b/index.ts index d9c5259..f7810f2 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,4 @@ -import { SernEmitter } from '@sern/handler'; +import { DefaultLogging, Dependencies, single, Singleton } from '@sern/handler'; import { ActivityType } from 'discord.js'; import { Client, GatewayIntentBits } from 'discord.js'; import { Sern } from '@sern/handler'; @@ -36,12 +36,22 @@ mongoose.connect(process.env.MONGODB!).then(() => { console.log('Connected to MongoDB'); }); +interface MyDependencies extends Dependencies { + '@sern/client' : Singleton; + '@sern/logger' : Singleton +} +export const useContainer = Sern.makeDependencies({ + build: root => root + .add({ '@sern/client': single(client) }) + .add({ '@sern/logger': single(new DefaultLogging()) }) +}); Sern.init({ - client, - commands: './dist/commands', - sernEmitter: new SernEmitter(), - events: './dist/events', + commands: 'dist/commands', + events: 'dist/events', defaultPrefix: process.env.PREFIX, + containerConfig: { + get: useContainer + } }); client.on('ready', async () => { @@ -80,6 +90,7 @@ client.on('ready', async () => { await giveawaychecker(client) }, 10000); */ } + (await (await client.application!.fetch()).commands.fetch('1045375985815654511')).delete().then(() => console.log('ok')) }); client.on('rateLimit', async () => { diff --git a/package-lock.json b/package-lock.json index 1f6b31f..195dcbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,13 +13,13 @@ "@discordjs/opus": "^0.9.0", "@discordjs/voice": "^0.14.0", "@napi-rs/canvas": "^0.1.30", - "@sern/handler": "^1.2.1", + "@sern/handler": "^2.0.0", "axios": "^1.1.3", "country-flag-emoji": "^1.0.3", "dayjs": "^1.11.6", "discord-bot-youtube-notifications": "^1.1.4", "discord-tictactoe": "^4.0.0", - "discord.js": "^14.5.0", + "discord.js": "^14.7.1", "dotenv": "^16.0.1", "express": "^4.18.1", "got": "^11.8.5", @@ -71,28 +71,30 @@ } }, "node_modules/@discordjs/builders": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.2.0.tgz", - "integrity": "sha512-ARy4BUTMU+S0ZI6605NDqfWO+qZqV2d/xfY32z3hVSsd9IaAKJBZ1ILTZLy87oIjW8+gUpQmk9Kt0ZP9bmmd8Q==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.4.0.tgz", + "integrity": "sha512-nEeTCheTTDw5kO93faM1j8ZJPonAX86qpq/QVoznnSa8WWcCgJpjlu6GylfINTDW6o7zZY0my2SYdxx2mfNwGA==", "dependencies": { - "@sapphire/shapeshift": "^3.5.1", - "discord-api-types": "^0.37.3", + "@discordjs/util": "^0.1.0", + "@sapphire/shapeshift": "^3.7.1", + "discord-api-types": "^0.37.20", "fast-deep-equal": "^3.1.3", - "ts-mixer": "^6.0.1", - "tslib": "^2.4.0" + "ts-mixer": "^6.0.2", + "tslib": "^2.4.1" }, "engines": { "node": ">=16.9.0" } }, "node_modules/@discordjs/builders/node_modules/discord-api-types": { - "version": "0.37.12", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.12.tgz", - "integrity": "sha512-SMBP4V6/A9mE7shBQAiTxNWnQlYTdiKMGvc7G23neayxaTJeFYh5FviJSWUa0BTdXcph1h/jT03Nbyv5XgZkzw==" + "version": "0.37.24", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.24.tgz", + "integrity": "sha512-1+Fb4huJCihdbkJLcq2p7nBmtlmAryNwjefT8wwJnL8c7bc7WA87Oaa5mbLe96QvZyfwnwRCDX40H0HhcVV50g==" }, "node_modules/@discordjs/collection": { - "version": "1.1.0", - "license": "Apache-2.0", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.3.0.tgz", + "integrity": "sha512-ylt2NyZ77bJbRij4h9u/wVy7qYw/aDqQLWnadjvDqW/WoWCxrsX6M3CIw9GVP5xcGCDxsrKj5e0r5evuFYwrKg==", "engines": { "node": ">=16.9.0" } @@ -190,26 +192,35 @@ } }, "node_modules/@discordjs/rest": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.2.0.tgz", - "integrity": "sha512-WX79uzMdnBzFNgsDdA440Ia2q7SMk6F8bNaPMmV4i6qcUNJpg+Sgb2spKuQmQPlNTX4HCntR609xHqUkK1tnVQ==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.5.0.tgz", + "integrity": "sha512-lXgNFqHnbmzp5u81W0+frdXN6Etf4EUi8FAPcWpSykKd8hmlWh1xy6BmE0bsJypU1pxohaA8lQCgp70NUI3uzA==", "dependencies": { - "@discordjs/collection": "^1.1.0", + "@discordjs/collection": "^1.3.0", + "@discordjs/util": "^0.1.0", "@sapphire/async-queue": "^1.5.0", "@sapphire/snowflake": "^3.2.2", - "discord-api-types": "^0.37.10", + "discord-api-types": "^0.37.23", "file-type": "^18.0.0", - "tslib": "^2.4.0", - "undici": "^5.10.0" + "tslib": "^2.4.1", + "undici": "^5.13.0" }, "engines": { "node": ">=16.9.0" } }, "node_modules/@discordjs/rest/node_modules/discord-api-types": { - "version": "0.37.12", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.12.tgz", - "integrity": "sha512-SMBP4V6/A9mE7shBQAiTxNWnQlYTdiKMGvc7G23neayxaTJeFYh5FviJSWUa0BTdXcph1h/jT03Nbyv5XgZkzw==" + "version": "0.37.24", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.24.tgz", + "integrity": "sha512-1+Fb4huJCihdbkJLcq2p7nBmtlmAryNwjefT8wwJnL8c7bc7WA87Oaa5mbLe96QvZyfwnwRCDX40H0HhcVV50g==" + }, + "node_modules/@discordjs/util": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-0.1.0.tgz", + "integrity": "sha512-e7d+PaTLVQav6rOc2tojh2y6FE8S7REkqLldq1XF4soCx74XB/DIjbVbVLtBemf0nLW77ntz0v+o5DytKwFNLQ==", + "engines": { + "node": ">=16.9.0" + } }, "node_modules/@discordjs/voice": { "version": "0.14.0", @@ -460,11 +471,12 @@ } }, "node_modules/@sapphire/shapeshift": { - "version": "3.7.0", - "license": "MIT", + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.8.1.tgz", + "integrity": "sha512-xG1oXXBhCjPKbxrRTlox9ddaZTvVpOhYLmKmApD/vIWOV1xEYXnpoFs68zHIZBGbqztq6FrUPNPerIrO1Hqeaw==", "dependencies": { "fast-deep-equal": "^3.1.3", - "lodash.uniqwith": "^4.5.0" + "lodash": "^4.17.21" }, "engines": { "node": ">=v14.0.0", @@ -472,23 +484,23 @@ } }, "node_modules/@sapphire/snowflake": { - "version": "3.2.2", - "license": "MIT", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.4.0.tgz", + "integrity": "sha512-zZxymtVO6zeXVMPds+6d7gv/OfnCc25M1Z+7ZLB0oPmeMTPeRWVPQSS16oDJy5ZsyCOLj7M6mbZml5gWXcVRNw==", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" } }, "node_modules/@sern/handler": { - "version": "1.2.1", - "license": "MIT", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@sern/handler/-/handler-2.0.0.tgz", + "integrity": "sha512-i9BbUxwOYX1rn1FUfVFT+c8ltAloEfIMUznOt2T4h1xbWyXm/aKocmcgt5DkBHRU8yGoCfDiFF3E3I1mHln3UQ==", "dependencies": { + "iti": "^0.5.0", "rxjs": "^7.5.6", "ts-pattern": "^4.0.2", "ts-results-es": "^3.5.0" - }, - "peerDependencies": { - "discord.js": "^14.5.x" } }, "node_modules/@sindresorhus/is": { @@ -513,7 +525,8 @@ }, "node_modules/@tokenizer/token": { "version": "0.3.0", - "license": "MIT" + "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz", + "integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==" }, "node_modules/@tsconfig/node10": { "version": "1.0.9", @@ -775,6 +788,8 @@ }, "node_modules/busboy": { "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", "dependencies": { "streamsearch": "^1.1.0" }, @@ -1223,29 +1238,31 @@ } }, "node_modules/discord.js": { - "version": "14.5.0", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.5.0.tgz", - "integrity": "sha512-Kd5OqdeiXe3t9eHUHCzf1r3LmKpeJJ7lKqwlWX1qdC0WfsbO2K3kucIDLfe0INnZVZaErUQ6/U6kGbTDnGgwZg==", + "version": "14.7.1", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.7.1.tgz", + "integrity": "sha512-1FECvqJJjjeYcjSm0IGMnPxLqja/pmG1B0W2l3lUY2Gi4KXiyTeQmU1IxWcbXHn2k+ytP587mMWqva2IA87EbA==", "dependencies": { - "@discordjs/builders": "^1.2.0", - "@discordjs/collection": "^1.1.0", - "@discordjs/rest": "^1.2.0", + "@discordjs/builders": "^1.4.0", + "@discordjs/collection": "^1.3.0", + "@discordjs/rest": "^1.4.0", + "@discordjs/util": "^0.1.0", "@sapphire/snowflake": "^3.2.2", "@types/ws": "^8.5.3", - "discord-api-types": "^0.37.10", + "discord-api-types": "^0.37.20", "fast-deep-equal": "^3.1.3", "lodash.snakecase": "^4.1.1", - "tslib": "^2.4.0", - "undici": "^5.10.0", - "ws": "^8.9.0" + "tslib": "^2.4.1", + "undici": "^5.13.0", + "ws": "^8.11.0" }, "engines": { "node": ">=16.9.0" } }, "node_modules/discord.js/node_modules/discord-api-types": { - "version": "0.37.12", - "license": "MIT" + "version": "0.37.24", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.24.tgz", + "integrity": "sha512-1+Fb4huJCihdbkJLcq2p7nBmtlmAryNwjefT8wwJnL8c7bc7WA87Oaa5mbLe96QvZyfwnwRCDX40H0HhcVV50g==" }, "node_modules/dom-serializer": { "version": "2.0.0", @@ -1507,7 +1524,8 @@ }, "node_modules/file-type": { "version": "18.0.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-18.0.0.tgz", + "integrity": "sha512-jjMwFpnW8PKofLE/4ohlhqwDk5k0NC6iy0UHAJFKoY1fQeGMN0GDdLgHQrvCbSpMwbqzoCZhRI5dETCZna5qVA==", "dependencies": { "readable-web-to-node-stream": "^3.0.2", "strtok3": "^7.0.0", @@ -1900,6 +1918,17 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, + "node_modules/iti": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/iti/-/iti-0.5.0.tgz", + "integrity": "sha512-ZiwdEIhXAxyb6/+j2didONRa3q73y9h8oHMRXAIkXv7k851cm8H7fyZZyszr514TdzgoVQl7Z6hvsdTogjgc0w==", + "dependencies": { + "utility-types": "^3.10.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/json-buffer": { "version": "3.0.1", "license": "MIT" @@ -1936,10 +1965,6 @@ "version": "4.1.1", "license": "MIT" }, - "node_modules/lodash.uniqwith": { - "version": "4.5.0", - "license": "MIT" - }, "node_modules/lowercase-keys": { "version": "2.0.0", "license": "MIT", @@ -2409,7 +2434,8 @@ }, "node_modules/peek-readable": { "version": "5.0.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-5.0.0.tgz", + "integrity": "sha512-YtCKvLUOvwtMGmrniQPdO7MwPjgkFBtFIrmfSbYmYuq3tKDV/mcfAhBth1+C3ru7uXIZasc/pHnb+YDYNkkj4A==", "engines": { "node": ">=14.16" }, @@ -2593,7 +2619,8 @@ }, "node_modules/readable-web-to-node-stream": { "version": "3.0.2", - "license": "MIT", + "resolved": "https://registry.npmjs.org/readable-web-to-node-stream/-/readable-web-to-node-stream-3.0.2.tgz", + "integrity": "sha512-ePeK6cc1EcKLEhJFt/AebMCLL+GgSKhuygrZ/GLaKZYEecIgIECf4UaUuaByiGtzckwR4ain9VzUh95T1exYGw==", "dependencies": { "readable-stream": "^3.6.0" }, @@ -2901,6 +2928,8 @@ }, "node_modules/streamsearch": { "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", "engines": { "node": ">=10.0.0" } @@ -2961,7 +2990,8 @@ }, "node_modules/strtok3": { "version": "7.0.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-7.0.0.tgz", + "integrity": "sha512-pQ+V+nYQdC5H3Q7qBZAz/MO6lwGhoC2gOAjuouGf/VO0m7vQRh8QNMl2Uf6SwAtzZ9bOw3UIeBukEGNJl5dtXQ==", "dependencies": { "@tokenizer/token": "^0.3.0", "peek-readable": "^5.0.0" @@ -3059,7 +3089,8 @@ }, "node_modules/token-types": { "version": "5.0.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/token-types/-/token-types-5.0.1.tgz", + "integrity": "sha512-Y2fmSnZjQdDb9W4w4r1tswlMHylzWIeOKpx0aZH9BgGtACHhrk3OkT52AzwcuqTRBZtvvnTjDBh8eynMulu8Vg==", "dependencies": { "@tokenizer/token": "^0.3.0", "ieee754": "^1.2.1" @@ -3083,8 +3114,9 @@ } }, "node_modules/ts-mixer": { - "version": "6.0.1", - "license": "MIT" + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.2.tgz", + "integrity": "sha512-zvHx3VM83m2WYCE8XL99uaM7mFwYSkjR2OZti98fabHrwkjsCvgwChda5xctein3xGOyaQhtTeDq/1H/GNvF3A==" }, "node_modules/ts-node": { "version": "10.9.1", @@ -3226,8 +3258,9 @@ } }, "node_modules/undici": { - "version": "5.11.0", - "license": "MIT", + "version": "5.14.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.14.0.tgz", + "integrity": "sha512-yJlHYw6yXPPsuOH0x2Ib1Km61vu4hLiRRQoafs+WUgX1vO64vgnxiCEN9dpIrhZyHFsai3F0AEj4P9zy19enEQ==", "dependencies": { "busboy": "^1.6.0" }, @@ -3246,6 +3279,14 @@ "version": "1.0.2", "license": "MIT" }, + "node_modules/utility-types": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", + "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==", + "engines": { + "node": ">= 4" + } + }, "node_modules/utils-merge": { "version": "1.0.1", "license": "MIT", @@ -3393,26 +3434,29 @@ } }, "@discordjs/builders": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.2.0.tgz", - "integrity": "sha512-ARy4BUTMU+S0ZI6605NDqfWO+qZqV2d/xfY32z3hVSsd9IaAKJBZ1ILTZLy87oIjW8+gUpQmk9Kt0ZP9bmmd8Q==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.4.0.tgz", + "integrity": "sha512-nEeTCheTTDw5kO93faM1j8ZJPonAX86qpq/QVoznnSa8WWcCgJpjlu6GylfINTDW6o7zZY0my2SYdxx2mfNwGA==", "requires": { - "@sapphire/shapeshift": "^3.5.1", - "discord-api-types": "^0.37.3", + "@discordjs/util": "^0.1.0", + "@sapphire/shapeshift": "^3.7.1", + "discord-api-types": "^0.37.20", "fast-deep-equal": "^3.1.3", - "ts-mixer": "^6.0.1", - "tslib": "^2.4.0" + "ts-mixer": "^6.0.2", + "tslib": "^2.4.1" }, "dependencies": { "discord-api-types": { - "version": "0.37.12", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.12.tgz", - "integrity": "sha512-SMBP4V6/A9mE7shBQAiTxNWnQlYTdiKMGvc7G23neayxaTJeFYh5FviJSWUa0BTdXcph1h/jT03Nbyv5XgZkzw==" + "version": "0.37.24", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.24.tgz", + "integrity": "sha512-1+Fb4huJCihdbkJLcq2p7nBmtlmAryNwjefT8wwJnL8c7bc7WA87Oaa5mbLe96QvZyfwnwRCDX40H0HhcVV50g==" } } }, "@discordjs/collection": { - "version": "1.1.0" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.3.0.tgz", + "integrity": "sha512-ylt2NyZ77bJbRij4h9u/wVy7qYw/aDqQLWnadjvDqW/WoWCxrsX6M3CIw9GVP5xcGCDxsrKj5e0r5evuFYwrKg==" }, "@discordjs/node-pre-gyp": { "version": "0.4.5", @@ -3484,26 +3528,32 @@ } }, "@discordjs/rest": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.2.0.tgz", - "integrity": "sha512-WX79uzMdnBzFNgsDdA440Ia2q7SMk6F8bNaPMmV4i6qcUNJpg+Sgb2spKuQmQPlNTX4HCntR609xHqUkK1tnVQ==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.5.0.tgz", + "integrity": "sha512-lXgNFqHnbmzp5u81W0+frdXN6Etf4EUi8FAPcWpSykKd8hmlWh1xy6BmE0bsJypU1pxohaA8lQCgp70NUI3uzA==", "requires": { - "@discordjs/collection": "^1.1.0", + "@discordjs/collection": "^1.3.0", + "@discordjs/util": "^0.1.0", "@sapphire/async-queue": "^1.5.0", "@sapphire/snowflake": "^3.2.2", - "discord-api-types": "^0.37.10", + "discord-api-types": "^0.37.23", "file-type": "^18.0.0", - "tslib": "^2.4.0", - "undici": "^5.10.0" + "tslib": "^2.4.1", + "undici": "^5.13.0" }, "dependencies": { "discord-api-types": { - "version": "0.37.12", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.12.tgz", - "integrity": "sha512-SMBP4V6/A9mE7shBQAiTxNWnQlYTdiKMGvc7G23neayxaTJeFYh5FviJSWUa0BTdXcph1h/jT03Nbyv5XgZkzw==" + "version": "0.37.24", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.24.tgz", + "integrity": "sha512-1+Fb4huJCihdbkJLcq2p7nBmtlmAryNwjefT8wwJnL8c7bc7WA87Oaa5mbLe96QvZyfwnwRCDX40H0HhcVV50g==" } } }, + "@discordjs/util": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-0.1.0.tgz", + "integrity": "sha512-e7d+PaTLVQav6rOc2tojh2y6FE8S7REkqLldq1XF4soCx74XB/DIjbVbVLtBemf0nLW77ntz0v+o5DytKwFNLQ==" + }, "@discordjs/voice": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@discordjs/voice/-/voice-0.14.0.tgz", @@ -3630,18 +3680,25 @@ "version": "1.5.0" }, "@sapphire/shapeshift": { - "version": "3.7.0", + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.8.1.tgz", + "integrity": "sha512-xG1oXXBhCjPKbxrRTlox9ddaZTvVpOhYLmKmApD/vIWOV1xEYXnpoFs68zHIZBGbqztq6FrUPNPerIrO1Hqeaw==", "requires": { "fast-deep-equal": "^3.1.3", - "lodash.uniqwith": "^4.5.0" + "lodash": "^4.17.21" } }, "@sapphire/snowflake": { - "version": "3.2.2" + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.4.0.tgz", + "integrity": "sha512-zZxymtVO6zeXVMPds+6d7gv/OfnCc25M1Z+7ZLB0oPmeMTPeRWVPQSS16oDJy5ZsyCOLj7M6mbZml5gWXcVRNw==" }, "@sern/handler": { - "version": "1.2.1", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@sern/handler/-/handler-2.0.0.tgz", + "integrity": "sha512-i9BbUxwOYX1rn1FUfVFT+c8ltAloEfIMUznOt2T4h1xbWyXm/aKocmcgt5DkBHRU8yGoCfDiFF3E3I1mHln3UQ==", "requires": { + "iti": "^0.5.0", "rxjs": "^7.5.6", "ts-pattern": "^4.0.2", "ts-results-es": "^3.5.0" @@ -3657,7 +3714,9 @@ } }, "@tokenizer/token": { - "version": "0.3.0" + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz", + "integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==" }, "@tsconfig/node10": { "version": "1.0.9", @@ -3870,6 +3929,8 @@ }, "busboy": { "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", "requires": { "streamsearch": "^1.1.0" } @@ -4173,25 +4234,28 @@ } }, "discord.js": { - "version": "14.5.0", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.5.0.tgz", - "integrity": "sha512-Kd5OqdeiXe3t9eHUHCzf1r3LmKpeJJ7lKqwlWX1qdC0WfsbO2K3kucIDLfe0INnZVZaErUQ6/U6kGbTDnGgwZg==", + "version": "14.7.1", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.7.1.tgz", + "integrity": "sha512-1FECvqJJjjeYcjSm0IGMnPxLqja/pmG1B0W2l3lUY2Gi4KXiyTeQmU1IxWcbXHn2k+ytP587mMWqva2IA87EbA==", "requires": { - "@discordjs/builders": "^1.2.0", - "@discordjs/collection": "^1.1.0", - "@discordjs/rest": "^1.2.0", + "@discordjs/builders": "^1.4.0", + "@discordjs/collection": "^1.3.0", + "@discordjs/rest": "^1.4.0", + "@discordjs/util": "^0.1.0", "@sapphire/snowflake": "^3.2.2", "@types/ws": "^8.5.3", - "discord-api-types": "^0.37.10", + "discord-api-types": "^0.37.20", "fast-deep-equal": "^3.1.3", "lodash.snakecase": "^4.1.1", - "tslib": "^2.4.0", - "undici": "^5.10.0", - "ws": "^8.9.0" + "tslib": "^2.4.1", + "undici": "^5.13.0", + "ws": "^8.11.0" }, "dependencies": { "discord-api-types": { - "version": "0.37.12" + "version": "0.37.24", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.24.tgz", + "integrity": "sha512-1+Fb4huJCihdbkJLcq2p7nBmtlmAryNwjefT8wwJnL8c7bc7WA87Oaa5mbLe96QvZyfwnwRCDX40H0HhcVV50g==" } } }, @@ -4394,6 +4458,8 @@ }, "file-type": { "version": "18.0.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-18.0.0.tgz", + "integrity": "sha512-jjMwFpnW8PKofLE/4ohlhqwDk5k0NC6iy0UHAJFKoY1fQeGMN0GDdLgHQrvCbSpMwbqzoCZhRI5dETCZna5qVA==", "requires": { "readable-web-to-node-stream": "^3.0.2", "strtok3": "^7.0.0", @@ -4644,6 +4710,14 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, + "iti": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/iti/-/iti-0.5.0.tgz", + "integrity": "sha512-ZiwdEIhXAxyb6/+j2didONRa3q73y9h8oHMRXAIkXv7k851cm8H7fyZZyszr514TdzgoVQl7Z6hvsdTogjgc0w==", + "requires": { + "utility-types": "^3.10.0" + } + }, "json-buffer": { "version": "3.0.1" }, @@ -4675,9 +4749,6 @@ "lodash.snakecase": { "version": "4.1.1" }, - "lodash.uniqwith": { - "version": "4.5.0" - }, "lowercase-keys": { "version": "2.0.0" }, @@ -4997,7 +5068,9 @@ } }, "peek-readable": { - "version": "5.0.0" + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-5.0.0.tgz", + "integrity": "sha512-YtCKvLUOvwtMGmrniQPdO7MwPjgkFBtFIrmfSbYmYuq3tKDV/mcfAhBth1+C3ru7uXIZasc/pHnb+YDYNkkj4A==" }, "prebuild-install": { "version": "7.1.1", @@ -5117,6 +5190,8 @@ }, "readable-web-to-node-stream": { "version": "3.0.2", + "resolved": "https://registry.npmjs.org/readable-web-to-node-stream/-/readable-web-to-node-stream-3.0.2.tgz", + "integrity": "sha512-ePeK6cc1EcKLEhJFt/AebMCLL+GgSKhuygrZ/GLaKZYEecIgIECf4UaUuaByiGtzckwR4ain9VzUh95T1exYGw==", "requires": { "readable-stream": "^3.6.0" } @@ -5306,7 +5381,9 @@ } }, "streamsearch": { - "version": "1.1.0" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==" }, "string_decoder": { "version": "1.3.0", @@ -5348,6 +5425,8 @@ }, "strtok3": { "version": "7.0.0", + "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-7.0.0.tgz", + "integrity": "sha512-pQ+V+nYQdC5H3Q7qBZAz/MO6lwGhoC2gOAjuouGf/VO0m7vQRh8QNMl2Uf6SwAtzZ9bOw3UIeBukEGNJl5dtXQ==", "requires": { "@tokenizer/token": "^0.3.0", "peek-readable": "^5.0.0" @@ -5408,6 +5487,8 @@ }, "token-types": { "version": "5.0.1", + "resolved": "https://registry.npmjs.org/token-types/-/token-types-5.0.1.tgz", + "integrity": "sha512-Y2fmSnZjQdDb9W4w4r1tswlMHylzWIeOKpx0aZH9BgGtACHhrk3OkT52AzwcuqTRBZtvvnTjDBh8eynMulu8Vg==", "requires": { "@tokenizer/token": "^0.3.0", "ieee754": "^1.2.1" @@ -5420,7 +5501,9 @@ } }, "ts-mixer": { - "version": "6.0.1" + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.2.tgz", + "integrity": "sha512-zvHx3VM83m2WYCE8XL99uaM7mFwYSkjR2OZti98fabHrwkjsCvgwChda5xctein3xGOyaQhtTeDq/1H/GNvF3A==" }, "ts-node": { "version": "10.9.1", @@ -5507,7 +5590,9 @@ "dev": true }, "undici": { - "version": "5.11.0", + "version": "5.14.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.14.0.tgz", + "integrity": "sha512-yJlHYw6yXPPsuOH0x2Ib1Km61vu4hLiRRQoafs+WUgX1vO64vgnxiCEN9dpIrhZyHFsai3F0AEj4P9zy19enEQ==", "requires": { "busboy": "^1.6.0" } @@ -5518,6 +5603,11 @@ "util-deprecate": { "version": "1.0.2" }, + "utility-types": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", + "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==" + }, "utils-merge": { "version": "1.0.1" }, diff --git a/package.json b/package.json index decc984..7207a61 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,11 @@ "type": "git", "url": "git+https://github.com/SrIzan10/vinci.git" }, + "imports": { + "#plugins": [ + "./dist/plugins/index.js" + ] + }, "keywords": [ "discord-bot" ], @@ -31,13 +36,13 @@ "@discordjs/opus": "^0.9.0", "@discordjs/voice": "^0.14.0", "@napi-rs/canvas": "^0.1.30", - "@sern/handler": "^1.2.1", + "@sern/handler": "^2.0.0", "axios": "^1.1.3", "country-flag-emoji": "^1.0.3", "dayjs": "^1.11.6", "discord-bot-youtube-notifications": "^1.1.4", "discord-tictactoe": "^4.0.0", - "discord.js": "^14.5.0", + "discord.js": "^14.7.1", "dotenv": "^16.0.1", "express": "^4.18.1", "got": "^11.8.5", diff --git a/src/plugins/acceptingBirthday.ts b/plugins/acceptingBirthday.ts similarity index 98% rename from src/plugins/acceptingBirthday.ts rename to plugins/acceptingBirthday.ts index 5c98bf0..a2a1bd2 100644 --- a/src/plugins/acceptingBirthday.ts +++ b/plugins/acceptingBirthday.ts @@ -27,7 +27,7 @@ import { ComponentType, } from "discord.js"; -export function confirmation( +export function acceptingBirthday( options?: Partial ): EventPlugin { return { diff --git a/plugins/index.ts b/plugins/index.ts new file mode 100644 index 0000000..7ecf887 --- /dev/null +++ b/plugins/index.ts @@ -0,0 +1,4 @@ +export * from './publish.js' +export * from './ownerOnly.js' +export * from './srIzanOnly.js' +export * from './acceptingBirthday.js' diff --git a/src/plugins/ownerOnly.ts b/plugins/ownerOnly.ts similarity index 100% rename from src/plugins/ownerOnly.ts rename to plugins/ownerOnly.ts diff --git a/src/plugins/publish.ts b/plugins/publish.ts similarity index 61% rename from src/plugins/publish.ts rename to plugins/publish.ts index 76d9832..95a4a97 100644 --- a/src/plugins/publish.ts +++ b/plugins/publish.ts @@ -1,9 +1,9 @@ // @ts-nocheck /** - * This is publish plugin, it allows you to publish your application commands with ease. + * This is publish plugin, it allows you to publish your application commands using the discord.js library with ease. * * @author @EvolutionX-10 [<@697795666373640213>] - * @version 1.3.0 + * @version 2.0.0 * @example * ```ts * import { publish } from "../plugins/publish"; @@ -29,20 +29,27 @@ import { ApplicationCommandType, PermissionResolvable, } from "discord.js"; +/** + * This is the dependency getter that is created from Sern.makeDependencies. + * import it here so that this plugin has access to your bot's dependencies + */ +import { useContainer } from "../index.js"; export function publish( options?: PublishOptions ): CommandPlugin< | CommandType.Slash | CommandType.Both - | CommandType.MenuMsg - | CommandType.MenuUser + | CommandType.CtxUser + | CommandType.CtxMsg > { return { type: PluginType.Command, - description: "Manage Slash Commands", + description: "Manage Application Commands", name: "slash-auto-publish", - async execute({ client }, { mod: module }, controller) { + async execute({ mod: module }, controller) { + // Users need to provide their own useContainer function. + const [client] = useContainer("@sern/client"); const defaultOptions = { guildIds: [], dmPermission: undefined, @@ -55,55 +62,69 @@ export function publish( options as unknown as ValidPublishOptions; function c(e: unknown) { - console.error("publish command didnt work for", module.name!); + console.error("publish command didnt work for", module.name); console.error(e); } - try { - const commandData = { - type: CommandTypeRaw[module.type], - name: module.name!, - description: [CommandType.Slash, CommandType.Both].includes( - module.type - ) - ? module.description - : "", - options: [CommandType.Slash, CommandType.Both].includes( - module.type - ) - ? optionsTransformer( - (module as SlashCommand).options ?? [] - ) - : [], + const log = + (...message: any[]) => + () => + console.log(...message); + const logged = (...message: any[]) => log(message); + /** + * a local function that returns either one value or the other, + * depending on {t}'s CommandType. If the commandtype of + * this module is CommandType.Both or CommandType.Text or CommandType.Slash, + * return 'is', else return 'els' + * @param t + * @returns S | T + */ + const appCmd = (t: V) => { + return (is: S, els: T) => + (t & CommandType.Both) !== 0 ? is : els; + }; + const curAppType = CommandTypeRaw[module.type]; + const createCommandData = () => { + const cmd = appCmd(module.type); + return { + name: module.name, + type: curAppType, + description: cmd(module.description, ""), + options: cmd( + optionsTransformer( + (module as SlashCommand).options ?? [] + ), + [] + ), defaultMemberPermissions, dmPermission, } as ApplicationCommandData; + }; + + try { + const commandData = createCommandData(); if (!guildIds.length) { const cmd = ( await client.application!.commands.fetch() ).find( - (c) => - c.name === module.name && - c.type === CommandTypeRaw[module.type] + (c) => c.name === module.name && c.type === curAppType ); if (cmd) { if (!cmd.equals(commandData, true)) { - console.log( + logged( `Found differences in global command ${module.name}` ); - cmd.edit(commandData).then(() => { - console.log( + cmd.edit(commandData).then( + log( `${module.name} updated with new data successfully!` - ); - }); + ) + ); } return controller.next(); } client .application!.commands.create(commandData) - .then(() => { - console.log("Command created", module.name!); - }) + .then(log("Command created", module.name)) .catch(c); return controller.next(); } @@ -111,20 +132,18 @@ export function publish( for (const id of guildIds) { const guild = await client.guilds.fetch(id).catch(c); if (!guild) continue; - const guildcmd = (await guild.commands.fetch()).find( - (c) => - c.name === module.name && - c.type === CommandTypeRaw[module.type] + const guildCmd = (await guild.commands.fetch()).find( + (c) => c.name === module.name && c.type === curAppType ); - if (guildcmd) { - if (!guildcmd.equals(commandData, true)) { - console.log( + if (guildCmd) { + if (!guildCmd.equals(commandData, true)) { + logged( `Found differences in command ${module.name}` ); - guildcmd + guildCmd .edit(commandData) - .then(() => - console.log( + .then( + log( `${module.name} updated with new data successfully!` ) ) @@ -135,10 +154,10 @@ export function publish( } guild.commands .create(commandData) - .then(() => - console.log( + .then( + log( "Guild Command created", - module.name!, + module.name, guild.name ) ) @@ -146,8 +165,8 @@ export function publish( } return controller.next(); } catch (e) { - console.log("Command did not register" + module.name!); - console.log(e); + logged("Command did not register" + module.name); + logged(e); return controller.stop(); } }, @@ -162,8 +181,8 @@ export function optionsTransformer(ops: Array) { export const CommandTypeRaw = { [CommandType.Both]: ApplicationCommandType.ChatInput, - [CommandType.MenuMsg]: ApplicationCommandType.Message, - [CommandType.MenuUser]: ApplicationCommandType.User, + [CommandType.CtxUser]: ApplicationCommandType.Message, + [CommandType.CtxMsg]: ApplicationCommandType.User, [CommandType.Slash]: ApplicationCommandType.ChatInput, } as const; diff --git a/src/plugins/srIzanOnly.ts b/plugins/srIzanOnly.ts similarity index 94% rename from src/plugins/srIzanOnly.ts rename to plugins/srIzanOnly.ts index c0a29be..d6d296f 100644 --- a/src/plugins/srIzanOnly.ts +++ b/plugins/srIzanOnly.ts @@ -16,7 +16,7 @@ import { CommandType, EventPlugin, PluginType } from "@sern/handler"; const ownerIDs = ['703974042700611634']; //! Fill your ID -export function ownerOnly(): EventPlugin { +export function srIzanOnly(): EventPlugin { return { type: PluginType.Event, description: "Allows only bot owner to run command", diff --git a/tsconfig.json b/tsconfig.json index 5e96867..595f6c3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ /* Language and Environment */ - "target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ // "lib": ["ES2022"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ // "jsx": "preserve", /* Specify what JSX code is generated. */ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ @@ -98,10 +98,9 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - }, - "ts-node": { - "esm": true, - "experimentalSpecifierResolution": "node", + "skipLibCheck": true, /* Skip type checking all .d.ts files. */ + "paths": { + "#plugins": ["./plugins/index.js"], + } } } \ No newline at end of file