module.exports = {
    name: "status",
    description: "Changes your Discord Account's status.",
    category: "Account",
    guildOnly: false,
    dmOnly: false,
    usage: `{prefix}{commandName} "dnd/idle/offline/online"`,
    requiredPermissions: "EMBED_LINKS",
    run: (message, args) => {
        const type = args[0]
        const colors = {
            dnd: "#9b4242",
            idle: "#ddbd5a",
            online: "#4e9b42",
            offline: "#989f97"
        }

        const Config = require("../../../Data/options.json")
        const Lang = require("../../Lang/" + Config.language || "en" + ".json")

        const types = {
            dnd: Lang.statusCommand.doNotDisturb,
            idle: Lang.statusCommand.idle,
            online: Lang.statusCommand.online,
            invisible: Lang.statusCommand.offline
        }

        const { Client } = require("../Structures/Client.js")
        const Discord = require("discord.js")

        if(type) {
            if(type.toLowerCase() == "dnd" || type.toLowerCase() == "idle" || type.toLowerCase() == "online" || type.toLowerCase() == "invisible") {
                Client.user.setStatus(type.toLowerCase())
                let embed = new Discord.RichEmbed()
                embed.setDescription(Lang.statusCommand.yourStatus.replace("{status}", types[type.toLowerCase()]))
                embed.setColor(colors[type.toLowerCase()])
                try {
                    message.channel.send(embed)
                } catch(e) {
                    try {
                        message.channel.send(Lang.statusCommand.yourStatus.replace("{status}", types[type.toLowerCase()]))
                    } catch(e) {
                        return
                    }
                }
            } else {
                let embed = new Discord.RichEmbed()
                embed.setDescription(Lang.statusCommand.invalidType)
                embed.setColor("#65429b")
                try {
                    message.channel.send(embed)
                } catch(e) {
                    try {
                        message.channel.send(Lang.statusCommand.invalidType)
                    } catch(e) {
                        return
                    }
                }
            }
        } else {
            let embed = new Discord.RichEmbed()
            embed.setDescription(Lang.statusCommand.invalidUsage)
            embed.setColor("#65429b")
            try {
                message.channel.send(embed)
            } catch(e) {
                try {
                    message.channel.send(Lang.statusCommand.invalidUsage)
                } catch(e) {
                    return
                }
            }
        }
    }
}