mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-23 05:34:58 +05:00
42 lines
No EOL
1 KiB
JavaScript
42 lines
No EOL
1 KiB
JavaScript
const Command = require("../../base/Command"),
|
|
Discord = require("discord.js"),
|
|
fetch = require("node-fetch");
|
|
|
|
class ShortURL extends Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: "shorturl",
|
|
dirname: __dirname,
|
|
enabled: true,
|
|
guildOnly: false,
|
|
aliases: ["minimize"],
|
|
memberPermissions: [],
|
|
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
|
|
nsfw: false,
|
|
ownerOnly: false,
|
|
cooldown: 1000
|
|
});
|
|
}
|
|
|
|
async run(message, args, data) {
|
|
const url = args[0];
|
|
if (!url) return message.error("general/shorturl:MISSING_URL");
|
|
|
|
const res = await fetch(`https://is.gd/create.php?format=simple&url=${encodeURI(url)}`);
|
|
const body = await res.text();
|
|
|
|
if (body === "Error: Please enter a valid URL to shorten") return message.error("general/shorturl:MISSING_URL");
|
|
|
|
const embed = new Discord.MessageEmbed()
|
|
.setColor(data.config.embed.color)
|
|
.setFooter({
|
|
text: data.config.embed.footer
|
|
})
|
|
.setDescription(body);
|
|
message.channel.send({
|
|
embeds: [embed]
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = ShortURL; |