PeterKrooni / dailydle-bot

Discord bot that tracks daily stats from various Wordle-like online games, such as NYT's Connections, Gamedle and Wordle.
5 stars 1 forks source link

laste inn en debug util modul for dev build #26

Open PeterKrooni opened 8 months ago

PeterKrooni commented 8 months ago
export const dropEntriesCommand = {
  data: new SlashCommandBuilder()
    .setName('drop')
    .setDescription('Drops entries from the database.')
    .addStringOption((option) =>
      option
        .setName('mode')
        .setDescription('The mode to drop entries for.')
        .addChoices(
          { name: 'Wordle', value: 'Wordle' },
          { name: 'Connections', value: 'Connections' },
          { name: 'Mini Crossword', value: 'Mini Crossword' },
          { name: 'Gamedle', value: 'Gamedle' },
          { name: 'All', value: 'All' }
        )
        .setRequired(true),
    )
    .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
  async execute(interaction) {
    console.info('Delete command received')
    const mode = interaction.options.getString('mode')
    options = { game: mode }
    if (mode === 'All') {
      console.warn('Deleting all entries')
    } else {
      console.info(`Deleting entries for mode ${mode}`)
    }

    await Entry.deleteMany(options)
      .then((result) => {
        console.info(`Deleted ${result.deletedCount} entries`)
        interaction.reply({ content: `Deleted ${result.deletedCount} entries.`, ephemeral: true })
      })
      .catch((err) => {
        console.error(err)
        interaction.reply({ content: 'There was an error while deleting the entries.', ephemeral: true })
      })
  },
}