{"size": 1268, "ext": "js", "max_stars_repo_path": "commands/internet/ipinfo.js", "max_stars_repo_name": "kitaminka/some-utils-bot", "max_stars_repo_stars_event_min_datetime": "2021-11-03T05:18:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-03T05:18:14.000Z", "max_issues_repo_path": "commands/internet/ipinfo.js", "max_issues_repo_name": "kitaminka/some-utils-bot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "commands/internet/ipinfo.js", "max_forks_repo_name": "kitaminka/some-utils-bot", "max_forks_repo_forks_event_min_datetime": "2021-03-11T09:15:55.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-11T09:15:55.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 40.9032258065, "max_line_length": 119, "alphanum_fraction": 0.5701892744}
const Discord = require('discord.js');
const fetch = require('node-fetch');

module.exports = {
    description: 'Display information about IP address.',
    async execute(client, message, args) {
        if (!args[0]) return message.channel.send(await client.modules.errorEmbed(client, 'No IP address specified.'));
        let embed, ipInfo;

        ipInfo = await fetch(`http://ip-api.com/json/${args[0]}`, {
            method: 'GET',
        }).then((res) => res.json());

        if (ipInfo.status === 'success') {
            embed = new Discord.MessageEmbed()
                .setTitle(`:globe_with_meridians: IP address ${ipInfo.query}`)
                .setColor(client.config.embedColor)
                .addField('Country', ipInfo.country)
                .addField('City', ipInfo.city)
                .addField('Latitude', ipInfo.lat)
                .addField('Longitude', ipInfo.lon)
                .addField('ISP', ipInfo.isp)
                .setImage(`https://static-maps.yandex.ru/1.x/?ll=${ipInfo.lon},${ipInfo.lat}&l=map&z=14&lang=en_GB`)
                .setTimestamp();
        } else {
            embed = await client.modules.errorEmbed(client, 'Entered incorrect IP address.')
        }
        return message.channel.send(embed);
    }
}
