JaBa/commands/General/hastebin.js

50 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 {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "hastebin",
dirname: __dirname,
enabled: true,
guildOnly: false,
2021-12-26 19:29:37 +05:00
aliases: ["pastebin"],
2021-12-10 21:39:54 +05:00
memberPermissions: [],
2021-12-26 19:29:37 +05:00
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 3000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
2021-12-10 21:39:54 +05:00
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,
2021-12-26 19:29:37 +05:00
headers: {
"Content-Type": "text/plain"
}
2021-12-10 21:39:54 +05:00
});
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-26 19:29:37 +05:00
} catch (e) {
2021-12-10 21:39:54 +05:00
message.error("misc:ERR_OCCURRED");
};
}
};
module.exports = Hastebin;