JaBa/commands/General/hastebin.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js"),
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: [ "pastebin" ],
memberPermissions: [],
botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ],
nsfw: false,
ownerOnly: false,
cooldown: 5000
});
}
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()
.setAuthor(message.translate("general/hastebin:SUCCESS"))
.setDescription(url)
.setColor(data.config.embed.color);
message.channel.send(embed);
2021-12-11 21:08:37 +05:00
} catch(e) {
2021-12-10 21:39:54 +05:00
message.error("misc:ERR_OCCURRED");
};
}
};
module.exports = Hastebin;