JaBa/commands/General/hastebin.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

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()
.setAuthor({
name: message.translate("general/hastebin:SUCCESS")
})
2022-01-04 02:18:28 +05:00
.setDescription(url)
.setColor(data.config.embed.color);
message.reply({
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;