char-slop/city-role-bot

discord auto role applicator bot for charlotte polycule city

git clone https://git.t4t.associates/char-slop/city-role-bot

Charlotte Somadd starboarda4093f0

main
1.3 KiB36 linesraw
1import { guard, slash, slashSub } from '../rosepack.ts'
2import { STARBOARD_GUILD } from '../starboard.ts'
3
4const adminOnly = [
5  guard.guild({ message: 'this command only works in a server.' }),
6  guard.userPermissions('MANAGE_GUILD', { message: 'you need manage server to do that.' }),
7  guard((context) => context.interaction.guildID === STARBOARD_GUILD
8    ? guard.allow()
9    : guard.deny('the starboard is not configured for this server.'))
10]
11
12export default slash({
13  name: 'starboard',
14  description: 'manage the starboard and its full-history scan',
15  subcommands: {
16    status: slashSub({
17      description: 'show starboard settings and backfill progress',
18      guards: adminOnly,
19      async execute(context) {
20        await context.defer({ ephemeral: true })
21        await context.reply(context.app.starboard.status())
22      }
23    }),
24    backfill: slashSub({
25      description: 'resume backfill, or rescan all history if the previous scan finished',
26      guards: adminOnly,
27      async execute(context) {
28        await context.defer({ ephemeral: true })
29        const started = context.app.starboard.startBackfill()
30        await context.reply(started
31          ? 'full-history backfill started/resumed. use /starboard status to check progress.'
32          : 'backfill is already running. use /starboard status to check progress.')
33      }
34    })
35  }
36})