-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
59 lines (52 loc) · 1.32 KB
/
bot.js
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
const { Client, Intents } = require("discord.js");
const {
listPlants,
plantInfo,
setPlant,
editPlant,
removePlant,
waterPlant,
lightPlant,
} = require("./commandService");
require("dotenv").config();
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.once("ready", () => {
console.log("Bot Ready!");
});
client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand()) return;
const command = interaction.commandName;
const options = interaction.options;
let response = null;
switch (command) {
case "list-plants":
response = await listPlants();
await interaction.reply(response);
break;
case "plant-info":
response = await plantInfo(options);
await interaction.reply(response);
break;
case "set-plant":
response = await setPlant(options);
await interaction.reply(response);
break;
case "edit-plant":
response = await editPlant(options);
await interaction.reply(response);
break;
case "remove-plant":
response = await removePlant(options);
await interaction.reply(response);
break;
case "water":
response = await waterPlant(options);
await interaction.reply(response);
break;
case "light":
response = await lightPlant(options);
await interaction.reply(response);
break;
}
});
client.login(process.env.TOKEN);