From 3b8c3d89fbce158001635f400c40e9305049339d Mon Sep 17 00:00:00 2001 From: Carter Himmel Date: Wed, 20 Mar 2024 16:12:49 -0600 Subject: [PATCH] feat: user apps --- apps/bot/package.json | 2 +- apps/bot/src/events/interactionCreate.ts | 7 +- apps/bot/src/index.ts | 16 ----- apps/web/package.json | 2 +- commands.lock.json | 72 ++++++++++++++----- packages/interactions/package.json | 2 +- .../src/commands/general/adjective.ts | 2 + .../src/commands/general/close-rhyme.ts | 2 + .../src/commands/general/definition.ts | 2 + .../src/commands/general/holonyms.ts | 2 + .../src/commands/general/homophones.ts | 2 + .../src/commands/general/hyponyms.ts | 2 + .../src/commands/general/match-word.ts | 2 + .../interactions/src/commands/general/noun.ts | 2 + .../src/commands/general/rhyme.ts | 2 + .../src/commands/general/similar-meaning.ts | 2 + .../src/commands/general/similar-spelling.ts | 2 + .../src/commands/general/sounds-like.ts | 2 + .../src/commands/general/that-follow.ts | 2 + .../src/commands/general/triggers.ts | 2 + .../src/commands/general/word-of-the-day.ts | 2 + .../interactions/src/commands/setup/config.ts | 2 + .../interactions/src/commands/util/invite.ts | 2 + .../interactions/src/commands/util/ping.ts | 2 + yarn.lock | 14 ++-- 25 files changed, 103 insertions(+), 48 deletions(-) diff --git a/apps/bot/package.json b/apps/bot/package.json index 00619c31..9ac361fe 100644 --- a/apps/bot/package.json +++ b/apps/bot/package.json @@ -35,7 +35,7 @@ "@yuudachi/framework": "^0.2.10", "bullmq": "^4.17.0", "common-tags": "^1.8.2", - "discord-api-types": "^0.37.74", + "discord-api-types": "^0.37.75", "discord.js": "^14.14.1", "fs-nextra": "^0.5.1", "i18next": "^23.10.1", diff --git a/apps/bot/src/events/interactionCreate.ts b/apps/bot/src/events/interactionCreate.ts index 0dc926ea..bf8d019d 100644 --- a/apps/bot/src/events/interactionCreate.ts +++ b/apps/bot/src/events/interactionCreate.ts @@ -3,6 +3,7 @@ import type { Command } from '@yuudachi/framework'; import { transformApplicationInteraction, kCommands } from '@yuudachi/framework'; import type { Event } from '@yuudachi/framework/types'; import { stripIndents } from 'common-tags'; +import type { AutocompleteInteraction, ChatInputCommandInteraction } from 'discord.js'; import { ApplicationCommandType, Client, EmbedBuilder, Events, WebhookClient } from 'discord.js'; import { Counter, Registry } from 'prom-client'; import { container, inject, injectable } from 'tsyringe'; @@ -42,8 +43,6 @@ export default class implements Event { return; } - if (!interaction.inCachedGuild()) return; - const command = this.commands.get(interaction.commandName.toLowerCase()); const args_ = interaction.options.data.map( // @ts-expect-error i know it works @@ -70,7 +69,7 @@ export default class implements Event { if (autocomplete) { try { if (interaction.commandName === 'definition') { - await definitionAutoComplete(interaction); + await definitionAutoComplete(interaction as AutocompleteInteraction<'cached'>); return; } @@ -80,7 +79,7 @@ export default class implements Event { } await command.chatInput( - interaction, + interaction as ChatInputCommandInteraction<'cached'>, transformApplicationInteraction(interaction.options.data), interaction.locale, ); diff --git a/apps/bot/src/index.ts b/apps/bot/src/index.ts index dfa0d39d..e2acc317 100644 --- a/apps/bot/src/index.ts +++ b/apps/bot/src/index.ts @@ -143,28 +143,12 @@ for await (const file of eventFiles) { void event_.execute(); } -// const server: FastifyInstance = fastify(); - -// server.get('/metrics', async (_req, res) => { -// const metrics = await register.metrics(); -// res.header('Content-Type', register.contentType); -// res.send(metrics); -// }); -// server.get('/terms', (_req, res) => res.redirect(301, process.env.TERMS_URL)); -// server.get('/privacy', (_req, res) => res.redirect(301, process.env.PRIVACY_URL)); -// server.get('/health', (_req, res) => res.send({ status: 'ok' })); -// rewrite the above to use the native node http server - const server = new App(); - server.get('/metrics', async (_req, res) => { const metrics = await register.metrics(); res.setHeader('Content-Type', register.contentType); res.send(metrics); }); - -server.get('/terms', (_req, res) => res.redirect(process.env.TERMS_URL, 301)); -server.get('/privacy', (_req, res) => res.redirect(process.env.PRIVACY_URL, 301)); server.get('/health', (_req, res) => res.send({ status: 'ok' })); const port = process.env.PORT ? Number.parseInt(process.env.PORT, 10) : 2_399; diff --git a/apps/web/package.json b/apps/web/package.json index 6e36de29..a8e3a43b 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -23,7 +23,7 @@ "@widgetbot/message-renderer": "^2.2.0", "astro": "^3.6.5", "astro-i18next": "1.0.0-beta.21", - "discord-api-types": "^0.37.74", + "discord-api-types": "^0.37.75", "i18next": "^23.10.1", "i18next-fs-backend": "^2.3.1", "locales": "workspace:^", diff --git a/commands.lock.json b/commands.lock.json index 9cdee1dc..da5c9d24 100644 --- a/commands.lock.json +++ b/commands.lock.json @@ -82,7 +82,9 @@ } ] } - ] + ], + "contexts": [0], + "integration_types": [0] }, { "name": "invite", @@ -108,7 +110,9 @@ "pl": "Returns an invite link to add Thoth to your server.", "zh-CN": "Returns an invite link to add Thoth to your server.", "zh-TW": "Returns an invite link to add Thoth to your server." - } + }, + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "ping", @@ -134,7 +138,9 @@ "pl": "Ensures the bot is responding to commands.", "zh-CN": "Ensures the bot is responding to commands.", "zh-TW": "Ensures the bot is responding to commands." - } + }, + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "holonyms", @@ -244,7 +250,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "match-word", @@ -354,7 +362,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "definition", @@ -465,7 +475,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "rhyme", @@ -575,7 +587,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "similar-meaning", @@ -739,7 +753,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "similar-spelling", @@ -849,7 +865,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "hyponyms", @@ -959,7 +977,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "word-of-the-day", @@ -1014,7 +1034,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "homophones", @@ -1124,7 +1146,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "that-follow", @@ -1288,7 +1312,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "noun", @@ -1398,7 +1424,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "close-rhyme", @@ -1508,7 +1536,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "triggers", @@ -1618,7 +1648,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "sounds-like", @@ -1728,7 +1760,9 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] }, { "name": "adjective", @@ -1838,6 +1872,8 @@ }, "type": 5 } - ] + ], + "contexts": [0, 1, 2], + "integration_types": [0, 1] } ] diff --git a/packages/interactions/package.json b/packages/interactions/package.json index 5fff1303..b5779428 100644 --- a/packages/interactions/package.json +++ b/packages/interactions/package.json @@ -55,7 +55,7 @@ "author": "Carter Himmel ", "license": "MIT", "dependencies": { - "discord-api-types": "^0.37.74", + "discord-api-types": "^0.37.75", "fs-nextra": "^0.5.1", "i18next": "^23.10.1" }, diff --git a/packages/interactions/src/commands/general/adjective.ts b/packages/interactions/src/commands/general/adjective.ts index 0cf4f6b6..96ee678c 100644 --- a/packages/interactions/src/commands/general/adjective.ts +++ b/packages/interactions/src/commands/general/adjective.ts @@ -31,6 +31,8 @@ const AdjectiveCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default AdjectiveCommand; diff --git a/packages/interactions/src/commands/general/close-rhyme.ts b/packages/interactions/src/commands/general/close-rhyme.ts index 5dd5906b..f85d3a2d 100644 --- a/packages/interactions/src/commands/general/close-rhyme.ts +++ b/packages/interactions/src/commands/general/close-rhyme.ts @@ -31,6 +31,8 @@ const CloseRhymeCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default CloseRhymeCommand; diff --git a/packages/interactions/src/commands/general/definition.ts b/packages/interactions/src/commands/general/definition.ts index 96f78c2d..11363bdc 100644 --- a/packages/interactions/src/commands/general/definition.ts +++ b/packages/interactions/src/commands/general/definition.ts @@ -32,6 +32,8 @@ const DefinitionCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default DefinitionCommand; diff --git a/packages/interactions/src/commands/general/holonyms.ts b/packages/interactions/src/commands/general/holonyms.ts index f601cae8..7f98d549 100644 --- a/packages/interactions/src/commands/general/holonyms.ts +++ b/packages/interactions/src/commands/general/holonyms.ts @@ -31,6 +31,8 @@ const HolonymsCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default HolonymsCommand; diff --git a/packages/interactions/src/commands/general/homophones.ts b/packages/interactions/src/commands/general/homophones.ts index dfd9c22a..2f948955 100644 --- a/packages/interactions/src/commands/general/homophones.ts +++ b/packages/interactions/src/commands/general/homophones.ts @@ -31,6 +31,8 @@ const HomophonesCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default HomophonesCommand; diff --git a/packages/interactions/src/commands/general/hyponyms.ts b/packages/interactions/src/commands/general/hyponyms.ts index 9b837018..3899959d 100644 --- a/packages/interactions/src/commands/general/hyponyms.ts +++ b/packages/interactions/src/commands/general/hyponyms.ts @@ -31,6 +31,8 @@ const HyponymsCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default HyponymsCommand; diff --git a/packages/interactions/src/commands/general/match-word.ts b/packages/interactions/src/commands/general/match-word.ts index ce32e0f7..d232cb1d 100644 --- a/packages/interactions/src/commands/general/match-word.ts +++ b/packages/interactions/src/commands/general/match-word.ts @@ -31,6 +31,8 @@ const MatchCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default MatchCommand; diff --git a/packages/interactions/src/commands/general/noun.ts b/packages/interactions/src/commands/general/noun.ts index 0e414e9c..22ae121c 100644 --- a/packages/interactions/src/commands/general/noun.ts +++ b/packages/interactions/src/commands/general/noun.ts @@ -31,6 +31,8 @@ const NounCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default NounCommand; diff --git a/packages/interactions/src/commands/general/rhyme.ts b/packages/interactions/src/commands/general/rhyme.ts index 7a50fead..97a5ca30 100644 --- a/packages/interactions/src/commands/general/rhyme.ts +++ b/packages/interactions/src/commands/general/rhyme.ts @@ -31,6 +31,8 @@ const RhymeCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default RhymeCommand; diff --git a/packages/interactions/src/commands/general/similar-meaning.ts b/packages/interactions/src/commands/general/similar-meaning.ts index 61d292e7..eb1f4b04 100644 --- a/packages/interactions/src/commands/general/similar-meaning.ts +++ b/packages/interactions/src/commands/general/similar-meaning.ts @@ -45,6 +45,8 @@ const SimilarMeaningCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default SimilarMeaningCommand; diff --git a/packages/interactions/src/commands/general/similar-spelling.ts b/packages/interactions/src/commands/general/similar-spelling.ts index 49490095..5312e084 100644 --- a/packages/interactions/src/commands/general/similar-spelling.ts +++ b/packages/interactions/src/commands/general/similar-spelling.ts @@ -31,6 +31,8 @@ const SimilarSpellingCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default SimilarSpellingCommand; diff --git a/packages/interactions/src/commands/general/sounds-like.ts b/packages/interactions/src/commands/general/sounds-like.ts index fb7d177f..93321efe 100644 --- a/packages/interactions/src/commands/general/sounds-like.ts +++ b/packages/interactions/src/commands/general/sounds-like.ts @@ -31,6 +31,8 @@ const SoundsLikeCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default SoundsLikeCommand; diff --git a/packages/interactions/src/commands/general/that-follow.ts b/packages/interactions/src/commands/general/that-follow.ts index 6bc65fd8..247e7111 100644 --- a/packages/interactions/src/commands/general/that-follow.ts +++ b/packages/interactions/src/commands/general/that-follow.ts @@ -45,6 +45,8 @@ const ThatFollowCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default ThatFollowCommand; diff --git a/packages/interactions/src/commands/general/triggers.ts b/packages/interactions/src/commands/general/triggers.ts index 73493fbf..cf7e574c 100644 --- a/packages/interactions/src/commands/general/triggers.ts +++ b/packages/interactions/src/commands/general/triggers.ts @@ -31,6 +31,8 @@ const TriggersCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default TriggersCommand; diff --git a/packages/interactions/src/commands/general/word-of-the-day.ts b/packages/interactions/src/commands/general/word-of-the-day.ts index 6cbc9862..29c6059e 100644 --- a/packages/interactions/src/commands/general/word-of-the-day.ts +++ b/packages/interactions/src/commands/general/word-of-the-day.ts @@ -16,6 +16,8 @@ const WordOfTheDayCommand = { type: ApplicationCommandOptionType.Boolean, }, ], + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default WordOfTheDayCommand; diff --git a/packages/interactions/src/commands/setup/config.ts b/packages/interactions/src/commands/setup/config.ts index 98848dce..9177aecc 100644 --- a/packages/interactions/src/commands/setup/config.ts +++ b/packages/interactions/src/commands/setup/config.ts @@ -28,6 +28,8 @@ const ConfigCommand = { ], }, ], + contexts: [0], + integration_types: [0], } as const; export default ConfigCommand; diff --git a/packages/interactions/src/commands/util/invite.ts b/packages/interactions/src/commands/util/invite.ts index 6f1f3f2e..e1e101c7 100644 --- a/packages/interactions/src/commands/util/invite.ts +++ b/packages/interactions/src/commands/util/invite.ts @@ -6,6 +6,8 @@ const InviteCommand = { name_localizations: fetchDataLocalizations('commands.invite.meta.name'), description: i18n.t('commands.invite.meta.description'), description_localizations: fetchDataLocalizations('commands.invite.meta.description'), + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default InviteCommand; diff --git a/packages/interactions/src/commands/util/ping.ts b/packages/interactions/src/commands/util/ping.ts index 606025d9..9be029a4 100644 --- a/packages/interactions/src/commands/util/ping.ts +++ b/packages/interactions/src/commands/util/ping.ts @@ -6,6 +6,8 @@ const PingCommand = { name_localizations: fetchDataLocalizations('commands.ping.meta.name'), description: i18n.t('commands.ping.meta.description'), description_localizations: fetchDataLocalizations('commands.ping.meta.description'), + contexts: [0, 1, 2], + integration_types: [0, 1], } as const; export default PingCommand; diff --git a/yarn.lock b/yarn.lock index c1e6310a..bd35f007 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1994,7 +1994,7 @@ __metadata: version: 0.0.0-use.local resolution: "@thoth/interactions@workspace:packages/interactions" dependencies: - discord-api-types: "npm:^0.37.74" + discord-api-types: "npm:^0.37.75" eslint: "npm:^8.57.0" eslint-config-neon: "npm:^0.1.59" eslint-formatter-pretty: "npm:^5.0.0" @@ -3711,7 +3711,7 @@ __metadata: bullmq: "npm:^4.17.0" common-tags: "npm:^1.8.2" cpy-cli: "npm:^5.0.0" - discord-api-types: "npm:^0.37.74" + discord-api-types: "npm:^0.37.75" discord.js: "npm:^14.14.1" dotenv: "npm:^16.4.5" eslint: "npm:^8.57.0" @@ -4851,10 +4851,10 @@ __metadata: languageName: node linkType: hard -"discord-api-types@npm:^0.37.74": - version: 0.37.74 - resolution: "discord-api-types@npm:0.37.74" - checksum: 10/0ee299b13a32181e1aa16e9034cb0884597eeb8784a1a13e85b701b3575f44e8af284390b22b154ec95e446bffd8d147c53f554cfc11acb5d2d6f5f3abe17779 +"discord-api-types@npm:^0.37.75": + version: 0.37.75 + resolution: "discord-api-types@npm:0.37.75" + checksum: 10/555597e4e95c58b7d3d296a690351c51456d80e6b53bcb3f88d1640e20799a27ea2017ae9763a991a161a2eaafbba863d066a8e364d701135b67a2983c7f117a languageName: node linkType: hard @@ -14676,7 +14676,7 @@ __metadata: "@widgetbot/message-renderer": "npm:^2.2.0" astro: "npm:^3.6.5" astro-i18next: "npm:1.0.0-beta.21" - discord-api-types: "npm:^0.37.74" + discord-api-types: "npm:^0.37.75" eslint: "npm:^8.57.0" eslint-config-neon: "npm:^0.1.59" eslint-formatter-pretty: "npm:^5.0.0"