← back to browse
goat command

pastebin

Upload command code

2
views
0
likes
2
installs

Aliases: bin

raw source
const axios = require("axios");
const fs = require("fs");
const path = require("path");

module.exports = {
  config: {
    name: "pastebin",
    aliases: ["bin"],
    version: "3.0.0",
    author: "๐Œ๐š๐‘๐ฎ๐…",
    countDown: 5,
    role: 0,
    shortDescription: "Upload command code",
    category: "tool",
    guide: "{pn} <commandName>"
  },

  onStart: async function ({ api, event, args }) {
    const name = args[0];

    if (!name) {
      return api.sendMessage(
        "โžœ Please provide a command name.",
        event.threadID,
        event.messageID
      );
    }

    const file = path.join(__dirname, `${name}.js`);

    if (!fs.existsSync(file)) {
      return api.sendMessage(
        `โžœ Command "${name}.js" not found.`,
        event.threadID,
        event.messageID
      );
    }

    try {
      const code = fs.readFileSync(file, "utf8");

      const { data } = await axios.post(
        "https://pastebin-xyz.vercel.app/api/paste",
        {
          content: code,
          title: `${name}.js`
        }
      );

      if (!data?.success || !data?.raw) {
        return api.sendMessage(
          "โžœ Failed to upload code.",
          event.threadID,
          event.messageID
        );
      }

      return api.sendMessage(
        `โ•ญโ”€โ– ๐๐š๐ฌ๐ญ๐ž๐›๐ข๐ง
โ”‚
โ”œโ”€โžค ๐Ÿ“ ๐…๐ข๐ฅ๐ž : ${name}.js
โ”œโ”€โžค ๐Ÿ”— ๐‹๐ข๐ง๐ค : ${data.raw}
โ”‚
โ•ฐโ”€โ– ๐Œ๐š๐ซ๐ฎ๐Ÿ'๐ฌ ๐๐จ๐ญ`,
        event.threadID,
        event.messageID
      );

    } catch (error) {
      return api.sendMessage(
        "โžœ Failed to connect to Pastebin API.",
        event.threadID,
        event.messageID
      );
    }
  }
};

View raw file