counting-bot / commands /activate.js
pythonSnake5036
Add marshmallow mode
b230fe2
raw
history blame
1.66 kB
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.`)
}
}
}