xyter/src/plugins/utility/modules/lookup.ts
deepsource-autofix[bot] 8eec235dfd
Format code with standardjs and prettier
This commit fixes the style issues introduced in 9dbe6a8 according to the output
from standardjs and prettier.

Details: https://deepsource.io/gh/ZynerOrg/xyter/transform/ea47e9d9-074f-4db5-af76-2dc328f01aed/
2022-05-17 09:32:40 +00:00

118 lines
3.6 KiB
TypeScript

import axios from "axios";
import { CommandInteraction } from "discord.js";
import { successColor, errorColor } from "@config/embed";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import embedBuilder from "@root/helpers/embedBuilder";
export default {
meta: { guildOnly: false, ephemeral: false },
data: (command: SlashCommandSubcommandBuilder) => {
return command
.setName("lookup")
.setDescription(
"Lookup a domain or ip. (Request sent over HTTP, proceed with caution!)"
)
.addStringOption((option) =>
option
.setName("query")
.setDescription("The query you want to look up.")
.setRequired(true)
);
},
execute: async (interaction: CommandInteraction) => {
const embedTitle = "[:hammer:] Utility (Lookup)";
embedBuilder.setTitle(embedTitle);
const { options } = interaction;
const query = options.getString("query");
await axios
.get(`http://ip-api.com/json/${query}`)
.then(async (response) => {
if (response.data.status !== "success") {
await interaction.editReply({
embeds: [
embedBuilder
.setColor(errorColor)
.setDescription(
`${response?.data?.message}: ${response?.data?.query}`
),
],
});
return;
}
await interaction.editReply({
embeds: [
embedBuilder.setColor(successColor).setFields([
{
name: ":classical_building: AS",
value: `${response.data.as || "Unknown"}`,
inline: true,
},
{
name: ":classical_building: ISP",
value: `${response.data.isp || "Unknown"}`,
inline: true,
},
{
name: ":classical_building: Organization",
value: `${response.data.org || "Unknown"}`,
inline: true,
},
{
name: ":compass: Latitude",
value: `${response.data.lat || "Unknown"}`,
inline: true,
},
{
name: ":compass: Longitude",
value: `${response.data.lon || "Unknown"}`,
inline: true,
},
{
name: ":clock4: Timezone",
value: `${response.data.timezone || "Unknown"}`,
inline: true,
},
{
name: ":globe_with_meridians: Country",
value: `${response.data.country || "Unknown"}`,
inline: true,
},
{
name: ":globe_with_meridians: Region",
value: `${response.data.regionName || "Unknown"}`,
inline: true,
},
{
name: ":globe_with_meridians: City",
value: `${response.data.city || "Unknown"}`,
inline: true,
},
{
name: ":globe_with_meridians: Country Code",
value: `${response.data.countryCode || "Unknown"}`,
inline: true,
},
{
name: ":globe_with_meridians: Region Code",
value: `${response.data.region || "Unknown"}`,
inline: true,
},
{
name: ":globe_with_meridians: ZIP",
value: `${response.data.zip || "Unknown"}`,
inline: true,
},
]),
],
});
});
},
};