JaBa/commands/General/shorturl.js

60 lines
1.6 KiB
JavaScript
Raw Normal View History

const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"),
fetch = require("node-fetch");
class Shorturl extends BaseCommand {
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("shorturl")
.setDescription(client.translate("general/shorturl:DESCRIPTION"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("general/shorturl:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/shorturl:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(true)
2023-07-05 00:58:06 +05:00
.addStringOption(option =>
option
.setName("url")
.setDescription(client.translate("common:URL"))
.setDescriptionLocalizations({
uk: client.translate("common:URL", null, "uk-UA"),
ru: client.translate("common:URL", null, "ru-RU"),
})
.setRequired(true),
),
aliases: [],
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
*/
async onLoad() {
//...
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
2022-08-09 23:48:33 +05:00
* @param {Object} data
*/
async execute(client, interaction) {
const url = interaction.options.getString("url");
2023-11-18 16:30:42 +05:00
const res = await fetch(`https://plsgo.ru/yourls-api.php?signature=${client.config.apiKeys.jababot_yourls}&action=shorturl&url=${encodeURIComponent(url)}&format=json`).then(res => res.json());
interaction.reply({
2023-10-08 13:59:40 +05:00
content: `<${res.shorturl}>`,
ephemeral: true,
});
}
}
2023-07-05 00:58:06 +05:00
module.exports = Shorturl;