File size: 1,660 Bytes
db1810b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b230fe2
 
 
 
db1810b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const { SlashCommandBuilder } = require('discord.js');
const { getFirestore } = require('firebase-admin/firestore');

module.exports = {
  data: new SlashCommandBuilder()
    .setName('activate')
    .setDescription("Activates counting")
    .addStringOption(option =>
      option.setName("mode")
        .setDescription("The mode for counting")
        .setRequired(true)
        .addChoices(
          {
            name: "Normal",
            value: "normal"
          },
          {
            name: "Fizz Buzz",
            value: "fizzbuzz"
          },
          {
            name: "Roman Numerals",
            value: "roman"
          },
          {
            name: "Hexadecimals",
            value: "hex"
          },
          {
            name: "Binary",
            value: "bin"
          },
          {
            name: "Marshmallow",
            value: "marshmallow"
          }
        )),
  async execute(interaction) {
    const db = getFirestore();
    const channel = interaction.channelId;
    const id = `${interaction.guildId}-${channel}`;
    
    const doc = db.doc(`channels/${id}`);
    const exists = (await doc.get()).exists;

    if (exists) {
      await interaction.reply(`Channel <#${channel}> has already been activated for counting. To view info, run /info. To change mode, deactivate, then activate with the new mode.`)
    } else {
      const mode = interaction.options.getString("mode");
      const data = {
        mode: mode,
        num: 0,
        lastUser: ""
      };

      await doc.set(data);

      await interaction.reply(`Activated channel <#${channel}> with mode ${mode} for counting.`)
    }
  }
}