const {client, commands} = require("../index")
const { EmbedBuilder, Message, Colors } = require("discord.js")

module.exports.commands = [
    {
        name: "ping",
        run: (ctx, args) => {
            ctx.reply(`Pong! ${args}`)
        },
        hide: false,
        arguments: ["any"],
        description: "Check how fast bot will reply!"
    },

    {
        name: "help",
        run: (ctx, args) => {
            const embed = new EmbedBuilder()
            .setAuthor({name: ctx.author.username, iconURL: ctx.author.avatarURL(), url: "https://git.squog.ru/entar/SquogAdmin"})
            .setColor(Colors.White)
            
            commands.forEach(commandList => {
                commandList.forEach(command => {
                    if (command.hide) {
                        return // Go to next command if this one shouldnt show up
                    }

                    const arguments = command.arguments && command.arguments.slice()
                    
                    if (arguments) {
                        arguments.forEach((argument, index) => {
                            if (typeof argument == "object" || typeof argument == "function") {
                                arguments[index] = argument.name
                            }
                        })
                    }
                    
                    const field = {name: command.name, value: `Description: ${command.description || "None"}\nArguments: ${arguments || "None"}`}
                    embed.addFields(field)
                })
            })
            ctx.reply({embeds: [embed]})
        },
        hide: true,
    }
]