-
Notifications
You must be signed in to change notification settings - Fork 4
/
boardCommand.js
37 lines (34 loc) · 1.41 KB
/
boardCommand.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
const {
SlashCommandBuilder
} = require('discord.js');
const fs = require('fs');
const config = require('./config.json');
const Boards = require('./boards.js');
module.exports = {
data: new SlashCommandBuilder()
.setName((config.nestBoardCommand).toLowerCase().replaceAll(/[^a-z0-9]/gi, '_'))
.setDescription('Create nest board')
.addStringOption(option =>
option.setName('area')
.setDescription('Select nest area')
.setRequired(true)
.setAutocomplete(true)),
async execute(client, interaction, config, master, shinies) {
await interaction.reply({
content: 'Generating nest board...'
}).catch(console.error);
let nestEmbedInfo = await Boards.fetchAreaNests(client, interaction.options.getString('area'), config, master, shinies);
await interaction.deleteReply().catch(console.error);
await interaction.channel.send({
embeds: [nestEmbedInfo[0]]
})
.then(msg => {
var nestBoards = JSON.parse(fs.readFileSync('./nestBoards.json'));
nestBoards[msg.id] = {
channelId: msg.channelId,
areaName: interaction.options.getString('area')
}
fs.writeFileSync('./nestBoards.json', JSON.stringify(nestBoards));
}).catch(console.error);
}, //End of execute()
};