Skip to content

Commit

Permalink
feat: user apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyko committed Mar 20, 2024
1 parent 4c8ea17 commit 3b8c3d8
Show file tree
Hide file tree
Showing 25 changed files with 103 additions and 48 deletions.
2 changes: 1 addition & 1 deletion apps/bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions apps/bot/src/events/interactionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -80,7 +79,7 @@ export default class implements Event {
}

await command.chatInput(
interaction,
interaction as ChatInputCommandInteraction<'cached'>,
transformApplicationInteraction(interaction.options.data),
interaction.locale,
);
Expand Down
16 changes: 0 additions & 16 deletions apps/bot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,28 +143,12 @@ for await (const file of eventFiles) {
void event_.execute();
}

// const server: FastifyInstance<Server, IncomingMessage, ServerResponse> = 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;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:^",
Expand Down
72 changes: 54 additions & 18 deletions commands.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@
}
]
}
]
],
"contexts": [0],
"integration_types": [0]
},
{
"name": "invite",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -244,7 +250,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "match-word",
Expand Down Expand Up @@ -354,7 +362,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "definition",
Expand Down Expand Up @@ -465,7 +475,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "rhyme",
Expand Down Expand Up @@ -575,7 +587,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "similar-meaning",
Expand Down Expand Up @@ -739,7 +753,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "similar-spelling",
Expand Down Expand Up @@ -849,7 +865,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "hyponyms",
Expand Down Expand Up @@ -959,7 +977,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "word-of-the-day",
Expand Down Expand Up @@ -1014,7 +1034,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "homophones",
Expand Down Expand Up @@ -1124,7 +1146,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "that-follow",
Expand Down Expand Up @@ -1288,7 +1312,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "noun",
Expand Down Expand Up @@ -1398,7 +1424,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "close-rhyme",
Expand Down Expand Up @@ -1508,7 +1536,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "triggers",
Expand Down Expand Up @@ -1618,7 +1648,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "sounds-like",
Expand Down Expand Up @@ -1728,7 +1760,9 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
},
{
"name": "adjective",
Expand Down Expand Up @@ -1838,6 +1872,8 @@
},
"type": 5
}
]
],
"contexts": [0, 1, 2],
"integration_types": [0, 1]
}
]
2 changes: 1 addition & 1 deletion packages/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"author": "Carter Himmel <[email protected]>",
"license": "MIT",
"dependencies": {
"discord-api-types": "^0.37.74",
"discord-api-types": "^0.37.75",
"fs-nextra": "^0.5.1",
"i18next": "^23.10.1"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/interactions/src/commands/general/adjective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const AdjectiveCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default AdjectiveCommand;
2 changes: 2 additions & 0 deletions packages/interactions/src/commands/general/close-rhyme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const CloseRhymeCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default CloseRhymeCommand;
2 changes: 2 additions & 0 deletions packages/interactions/src/commands/general/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const DefinitionCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default DefinitionCommand;
2 changes: 2 additions & 0 deletions packages/interactions/src/commands/general/holonyms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const HolonymsCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default HolonymsCommand;
2 changes: 2 additions & 0 deletions packages/interactions/src/commands/general/homophones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const HomophonesCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default HomophonesCommand;
2 changes: 2 additions & 0 deletions packages/interactions/src/commands/general/hyponyms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const HyponymsCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default HyponymsCommand;
2 changes: 2 additions & 0 deletions packages/interactions/src/commands/general/match-word.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const MatchCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default MatchCommand;
2 changes: 2 additions & 0 deletions packages/interactions/src/commands/general/noun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const NounCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default NounCommand;
2 changes: 2 additions & 0 deletions packages/interactions/src/commands/general/rhyme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const RhymeCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default RhymeCommand;
2 changes: 2 additions & 0 deletions packages/interactions/src/commands/general/similar-meaning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const SimilarMeaningCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default SimilarMeaningCommand;
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const SimilarSpellingCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default SimilarSpellingCommand;
2 changes: 2 additions & 0 deletions packages/interactions/src/commands/general/sounds-like.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const SoundsLikeCommand = {
type: ApplicationCommandOptionType.Boolean,
},
],
contexts: [0, 1, 2],
integration_types: [0, 1],
} as const;

export default SoundsLikeCommand;
Loading

0 comments on commit 3b8c3d8

Please sign in to comment.