Skip to content

Commit

Permalink
Update paste.js
Browse files Browse the repository at this point in the history
  • Loading branch information
saiteja-madha committed Sep 21, 2021
1 parent 5a87919 commit 24a832e
Showing 1 changed file with 38 additions and 42 deletions.
80 changes: 38 additions & 42 deletions src/commands/utility/paste.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,42 @@
const fetch = require('node-fetch');
const fetch = require("node-fetch");
const { Command } = require("@src/structures");
const { MessageEmbed } = require("discord.js");
const { MessageEmbed, Message } = require("discord.js");

module.exports = class CatCommand extends Command {
constructor(client) {
super(client, {
name: "paste",
description: "Paste something in sourceb.in",
cooldown: 5,
command: {
enabled: true,
category: "UTILITY",
botPermissions: ["EMBED_LINKS"],
},
slashCommand: {
enabled: false,
},
});
}

/**
* @param {Message} message
* @param {string[]} args
*/

async messageRun(message, args) {

if (!args || args.length < 3) return message.channel.send("You need to add title, description and content");


const { key } = await fetch("https://sourceb.in/api/bins", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ "title": args[0], "description": args[1], "files": [{ "content": args.splice(2).join(' ') }] })
}).then(res => res.json());


if (!key) return message.channel.send("❌ Something went wrong");

const embed = new MessageEmbed()
.setTitle("Paste links")
.setDescription("🔸 Normal: https://sourceb.in/" + key + "\n🔹 Raw: https://cdn.sourceb.in/bins/" + key + "/0")
message.channel.send({ embeds: [embed] });
}
constructor(client) {
super(client, {
name: "paste",
description: "Paste something in sourceb.in",
cooldown: 5,
command: {
enabled: true,
category: "UTILITY",
botPermissions: ["EMBED_LINKS"],
},
slashCommand: {
enabled: false,
},
});
}

/**
* @param {Message} message
* @param {string[]} args
*/
async messageRun(message, args) {
if (!args || args.length < 3) return message.channel.send("You need to add title, description and content");

const { key } = await fetch("https://sourceb.in/api/bins", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ title: args[0], description: args[1], files: [{ content: args.splice(2).join(" ") }] }),
}).then((res) => res.json());

if (!key) return message.channel.send("❌ Something went wrong");

const embed = new MessageEmbed()
.setTitle("Paste links")
.setDescription("🔸 Normal: https://sourceb.in/" + key + "\n🔹 Raw: https://cdn.sourceb.in/bins/" + key + "/0");
message.channel.send({ embeds: [embed] });
}
};

0 comments on commit 24a832e

Please sign in to comment.