aboutsummaryrefslogtreecommitdiff
path: root/handler/command.js
blob: 3869c6de7b5a3514189304b1b1aa81c20a49faea (plain)
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
const fs = require('fs');
const { MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed } = require('discord.js');

const admin = fs.readFileSync("./config/admin.txt").toString().trim();
const list = Object.keys(JSON.parse(fs.readFileSync("./data/data.json").toString()));

const getResult = require('../modules/result');
const getEmbed = require('../modules/embed');
const getPixel = require("../modules/pixel");

const official = fs.readFileSync("./config/official.txt").toString().replace(/\r\n/g, "\n").split("\n");
const fpserver = fs.readFileSync("./config/fpserver.txt").toString().trim();

const commandRandom = require('../commands/random');
const commandInfo = require('../commands/info');
const commandEval = require('../commands/eval');
const commandConfig = require('../commands/config');
const commandPony = require('../commands/pony');
const commandHelp = require('../commands/help');

module.exports = async (interaction) => {
    console.log(interaction.user.tag + " (" + interaction.user.id + ") used command /" + interaction.commandName);
    if (statsCommands[interaction.commandName] !== undefined) {
        statsCommands[interaction.commandName]++;
    } else {
        statsCommands[interaction.commandName] = 1;
    }
    fs.writeFile("./stats/commands.json", JSON.stringify(statsCommands), () => {});

    if (interaction.commandName === 'random') {
        await commandRandom(interaction);
    }

    if (interaction.commandName === 'help') {
        await commandHelp(interaction);
    }

    if (interaction.commandName === 'info') {
        await commandInfo(interaction);
    }

    if (interaction.commandName === 'eval') {
        await commandEval(interaction);
    }

    if (interaction.commandName === 'config') {
        await commandConfig(interaction);
    }

    if (interaction.commandName === 'pony') {
        await commandPony(interaction);
    }
}