Skip to content

Commit

Permalink
Merge branch 'web'
Browse files Browse the repository at this point in the history
  • Loading branch information
devcayed committed Feb 28, 2024
2 parents d287bf0 + 392dc2e commit 71d44a8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions server/src/discord/commands/QuoteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>('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)
Expand All @@ -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] })
}
}
6 changes: 3 additions & 3 deletions server/src/discord/commands/RandomQuoteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Quote } from '../../common/Quote'

export default class RandomQuoteCommand implements ICommand {
async execute(interaction: CommandInteraction<CacheType>): Promise<void> {
const quote = (await Database.getInstance().getRandom('quote')) as Quote
const quote = await Database.getInstance().getRandom<Quote>('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)
Expand All @@ -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] })
}
}
2 changes: 1 addition & 1 deletion server/src/discord/tasks/CakeDayTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>('quote')
if (!quotes) {
return null
}
Expand Down
6 changes: 4 additions & 2 deletions server/src/elysia/Setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

0 comments on commit 71d44a8

Please sign in to comment.