2022-01-13 00:56:24 +05:00
|
|
|
const Command = require("../../base/Command"),
|
2022-01-04 02:18:28 +05:00
|
|
|
Discord = require("discord.js"),
|
|
|
|
fetch = require("node-fetch");
|
|
|
|
|
|
|
|
class Hastebin extends Command {
|
|
|
|
constructor(client) {
|
|
|
|
super(client, {
|
|
|
|
name: "hastebin",
|
|
|
|
dirname: __dirname,
|
|
|
|
enabled: true,
|
|
|
|
guildOnly: false,
|
|
|
|
aliases: ["hb"],
|
|
|
|
memberPermissions: [],
|
|
|
|
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
|
|
|
|
nsfw: false,
|
|
|
|
ownerOnly: false,
|
|
|
|
cooldown: 1000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async run(message, args, data) {
|
|
|
|
const content = args.join(" ");
|
|
|
|
if (!content) return message.error("general/hastebin:MISSING_TEXT");
|
|
|
|
|
|
|
|
try {
|
|
|
|
const res = await fetch("https://hastebin.com/documents", {
|
|
|
|
method: "POST",
|
|
|
|
body: content,
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "text/plain"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const json = await res.json();
|
|
|
|
if (!json.key) return message.error("misc:ERR_OCCURRED");
|
|
|
|
|
|
|
|
const url = `https://hastebin.com/${json.key}.js`;
|
|
|
|
|
|
|
|
const embed = new Discord.MessageEmbed()
|
2022-01-05 00:24:57 +05:00
|
|
|
.setAuthor({
|
|
|
|
name: message.translate("general/hastebin:SUCCESS")
|
|
|
|
})
|
2022-01-04 02:18:28 +05:00
|
|
|
.setDescription(url)
|
|
|
|
.setColor(data.config.embed.color);
|
2022-02-13 17:26:12 +05:00
|
|
|
message.reply({
|
2022-01-05 00:24:57 +05:00
|
|
|
embeds: [embed]
|
|
|
|
});
|
2022-01-04 02:18:28 +05:00
|
|
|
} catch (e) {
|
|
|
|
message.error("misc:ERR_OCCURRED");
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
}
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
module.exports = Hastebin;
|