diff --git a/server/src/discord/commands/QuoteCommand.ts b/server/src/discord/commands/QuoteCommand.ts index 70e66ad..5235ad6 100644 --- a/server/src/discord/commands/QuoteCommand.ts +++ b/server/src/discord/commands/QuoteCommand.ts @@ -13,7 +13,7 @@ export default class QuoteCommand implements ICommand { let stringQuote = (quote.value as string).replaceAll('\\n', '\n') const quoteObject = new Quote(null, stringQuote, interaction.user.id, Date.now(), [], 0) const quoteCreator = interaction.guild?.members.cache.find((member) => member.id === interaction.user.id) - Database.getInstance().insert('quote', quoteObject) // this usually never takes more than 3 seconds, so we don't need to defer + await Database.getInstance().insert('quote', quoteObject) // this usually never takes more than 3 seconds, so we don't need to defer const quoteEmbed = new EmbedBuilder() .setColor('Random') .setDescription(quoteObject.content) @@ -22,6 +22,7 @@ export default class QuoteCommand implements ICommand { iconURL: quoteCreator?.displayAvatarURL() ?? undefined, }) .setTimestamp(quoteObject.timestamp) - interaction.reply({ embeds: [quoteEmbed] }) + + await interaction.reply({ embeds: [quoteEmbed] }) } } diff --git a/server/src/discord/commands/RandomQuoteCommand.ts b/server/src/discord/commands/RandomQuoteCommand.ts index 48728ae..d920696 100644 --- a/server/src/discord/commands/RandomQuoteCommand.ts +++ b/server/src/discord/commands/RandomQuoteCommand.ts @@ -5,9 +5,9 @@ import { Quote } from '../../common/Quote' export default class RandomQuoteCommand implements ICommand { async execute(interaction: CommandInteraction): Promise { - const quote = (await Database.getInstance().getRandom('quote')) as Quote + const quote = await Database.getInstance().getRandom('quote') if (!quote) { - interaction.reply({ content: 'Could not fetch quote' }) + await interaction.reply({ content: 'Could not fetch quote' }) return } const quoteCreator = interaction.guild?.members.cache.find((member) => member.id === quote.creator) @@ -19,6 +19,6 @@ export default class RandomQuoteCommand implements ICommand { iconURL: quoteCreator?.displayAvatarURL() ?? undefined, }) .setTimestamp(quote.timestamp) - interaction.reply({ embeds: [quoteEmbed] }) + await interaction.reply({ embeds: [quoteEmbed] }) } } diff --git a/server/src/discord/tasks/CakeDayTask.ts b/server/src/discord/tasks/CakeDayTask.ts index 4d43cd1..a765987 100644 --- a/server/src/discord/tasks/CakeDayTask.ts +++ b/server/src/discord/tasks/CakeDayTask.ts @@ -35,7 +35,7 @@ export default class CakeDayTask implements ITextChannelTask { } async getCakeQuotes(): Promise<[Quote, number][] | null> { - let quotes = (await Database.getInstance().all('quote')) as Quote[] + let quotes = await Database.getInstance().all('quote') if (!quotes) { return null } diff --git a/server/src/elysia/Setup.ts b/server/src/elysia/Setup.ts index 03f232d..46847af 100644 --- a/server/src/elysia/Setup.ts +++ b/server/src/elysia/Setup.ts @@ -2,8 +2,10 @@ import { Elysia } from 'elysia' import { Database } from '../common/Database' import { client } from '../discord/Client' -const databaseDecorator = new Elysia({ name: 'DatabaseDecorator' }).decorate('database', Database.getInstance()) +const databaseDecorator = new Elysia({ name: 'DatabaseDecorator' }) + .decorate('database', Database.getInstance()) -const discordClientDecorator = new Elysia({ name: 'DiscordClientDecorator' }).decorate('discordClient', client) +const discordClientDecorator = new Elysia({ name: 'DiscordClientDecorator' }) + .decorate('discordClient', client) export { databaseDecorator, discordClientDecorator }