2024-09-14 19:52:56 +05:00
|
|
|
const { SlashCommandBuilder, InteractionContextType } = require("discord.js");
|
2022-08-04 19:26:17 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand"),
|
|
|
|
fetch = require("node-fetch");
|
|
|
|
|
|
|
|
class Whois extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../base/Client")} client
|
2022-08-04 19:26:17 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("whois")
|
|
|
|
.setDescription(client.translate("general/whois:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("general/whois:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("general/whois:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2024-09-14 19:52:56 +05:00
|
|
|
.setContexts([InteractionContextType.BotDM, InteractionContextType.PrivateChannel, InteractionContextType.Guild])
|
2023-07-05 00:58:06 +05:00
|
|
|
.addStringOption(option =>
|
|
|
|
option
|
|
|
|
.setName("ip")
|
|
|
|
.setDescription(client.translate("common:IP"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("common:IP", null, "uk-UA"),
|
|
|
|
ru: client.translate("common:IP", null, "ru-RU"),
|
|
|
|
})
|
|
|
|
.setRequired(true),
|
|
|
|
),
|
2022-08-04 19:26:17 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-04 19:26:17 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-08-04 19:26:17 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-04 19:26:17 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
|
|
|
await interaction.deferReply();
|
2022-11-18 16:04:04 +05:00
|
|
|
|
2023-06-15 19:46:27 +05:00
|
|
|
const ip = interaction.options.getString("ip"),
|
|
|
|
whois = await fetch(`http://ip-api.com/json/${ip}?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,zip,timezone,currency,isp,org,as,mobile,proxy,hosting,query`).then(response => response.json());
|
|
|
|
|
2022-08-05 18:18:43 +05:00
|
|
|
if (whois.status === "fail") return interaction.editReply({ content: interaction.translate("general/whois:ERROR", { ip }) });
|
2023-06-15 19:46:27 +05:00
|
|
|
|
2024-02-06 21:45:53 +05:00
|
|
|
const embed = client.embed({
|
|
|
|
title: interaction.translate("general/whois:INFO_ABOUT", {
|
|
|
|
ip,
|
|
|
|
}),
|
|
|
|
fields: [
|
2022-08-04 19:26:17 +05:00
|
|
|
{ name: interaction.translate("common:IP"), value: whois.query, inline: true },
|
|
|
|
{ name: interaction.translate("general/whois:COUNTRY"), value: `${whois.country || interaction.translate("common:UNKNOWN")} (${whois.countryCode || interaction.translate("common:UNKNOWN")})`, inline: true },
|
|
|
|
{ name: interaction.translate("general/whois:REGION"), value: `${whois.regionName || interaction.translate("common:UNKNOWN")} (${whois.region || interaction.translate("common:UNKNOWN")})`, inline: true },
|
|
|
|
{ name: interaction.translate("general/whois:CITY"), value: `${whois.city || interaction.translate("common:UNKNOWN")}`, inline: true },
|
|
|
|
{ name: interaction.translate("general/whois:ZIP"), value: `${whois.zip || interaction.translate("common:UNKNOWN")}`, inline: true },
|
|
|
|
{ name: interaction.translate("general/whois:TIMEZONE"), value: `${whois.timezone || interaction.translate("common:UNKNOWN")}`, inline: true },
|
|
|
|
{ name: interaction.translate("general/whois:CONTINENT"), value: `${whois.continent || interaction.translate("common:UNKNOWN")} (${whois.continentCode || interaction.translate("common:UNKNOWN")})`, inline: true },
|
|
|
|
{ name: interaction.translate("general/whois:CURRENCY"), value: `${whois.currency || interaction.translate("common:UNKNOWN")}`, inline: true },
|
2022-12-15 21:02:38 +05:00
|
|
|
{ name: interaction.translate("general/whois:ISP"), value: `${whois.isp || interaction.translate("common:UNKNOWN")}`, inline: true },
|
2024-02-06 21:45:53 +05:00
|
|
|
],
|
|
|
|
});
|
2022-08-04 19:26:17 +05:00
|
|
|
|
2024-02-06 21:45:53 +05:00
|
|
|
if (whois.proxy) embed.data.fields.push({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:PROXY") });
|
|
|
|
if (whois.mobile) embed.data.fields.push({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:MOBILE") });
|
|
|
|
if (whois.hosting) embed.data.fields.push({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:HOSTING") });
|
2022-08-04 19:26:17 +05:00
|
|
|
|
|
|
|
interaction.editReply({
|
2022-12-15 21:02:38 +05:00
|
|
|
embeds: [embed],
|
2022-08-04 19:26:17 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Whois;
|