aboutsummaryrefslogtreecommitdiff
path: root/handler/autocomplete.js
blob: cf87ef4ba5d517c53071a85fbded174bd773a04b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const getEpisodes = require('../modules/findepisode');
const getPonies = require('../modules/findpony');
const fs = require("fs");
const episodes = JSON.parse(fs.readFileSync("./data/series.json").toString());

module.exports = async (interaction) => {
    try {

        if (interaction.commandName === "episode") {
            let series = interaction.options.getSubcommand();

            await interaction.respond(getEpisodes(episodes.filter(i => i.command.toLowerCase() === series)[0], interaction.options.getFocused()));
        } else if (interaction.commandName === "pony") {
            await interaction.respond(getPonies(interaction.options.getFocused()));
        }
    } catch (e) {
        console.error(e);
    }
}