Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

laste inn en debug util modul for dev build #26

Open
PeterKrooni opened this issue Mar 14, 2024 · 1 comment
Open

laste inn en debug util modul for dev build #26

PeterKrooni opened this issue Mar 14, 2024 · 1 comment
Labels
enhancement New feature or request infra db/discord/hosting - alt koderelatert som ikke har med features eller kode å gjøre

Comments

@PeterKrooni
Copy link
Owner

No description provided.

@PeterKrooni
Copy link
Owner Author

PeterKrooni commented Mar 14, 2024

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 })
      })
  },
}

@PeterKrooni PeterKrooni added enhancement New feature or request infra db/discord/hosting - alt koderelatert som ikke har med features eller kode å gjøre labels Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request infra db/discord/hosting - alt koderelatert som ikke har med features eller kode å gjøre
Projects
None yet
Development

No branches or pull requests

1 participant