0.1.0 • Published 9 months ago

@infinitybots/client v0.1.0

Weekly downloads
-
License
LGPL-3.0-only
Repository
github
Last release
9 months ago

client

Official NPM Client for our Autoposter Module!


Webhooks v1

Available Data

{
  "bot": "string",
  "botID": "string",
  "test": false,
  "time": 0,
  "user": "string",
  "userID": "string",
  "userObj": {
    "avatar": "string",
    "bot": false,
    "discriminator": "string",
    "id": "string",
    "in_guild": "string",
    "nickname": "string",
    "status": "string",
    "username": "string"
  },
  "votes": 0
}

Example Fastify Server

  • For a basic server we created for you to use go here
const { MessageEmbed } = require("discord.js");
const { Webhook } = require("@infinitybots/client");
const moment = require("moment");

const webhook = new Webhook(`YOUR_WEBHOOK_SECRET`);

module.exports = async (fastify, opts) => {
  fastify.post(
    "/votes",
    webhook.hookListener(async (vote, req, res) => {
      
      /** LOG MESSAGE TO DISCORD WITH VOTE DATA */
      let embed = new MessageEmbed()
        .setTitle(`Vote Logs`)
        .setColor("RANDOM")
        .setDescription(`Woah someone has voted for me on Infinity Bot List`)
        .addFields(
          {
            name: "Total Votes",
            value: `${vote.votes}`,
            inline: true,
          },
          {
            name: "User",
            value: `${vote.userObj.username}#${vote.userObj.discriminator}`,
            inline: true,
          },
          {
            name: "Time",
            value: `${moment(vote.timeStamp)}`,
            inline: true,
          }
        )
        .setTimestamp()
        .setFooter({
          text: "Infinity Vote Logger",
          iconURL: `${vote.userObj.avatar}`,
        });

    })
  );
};

Webhooks v2

Available Data

{
  "created_at": 0,
  "creator": {
    "avatar": "string",
    "bot": false,
    "discriminator": "string",
    "id": "string",
    "in_guild": "string",
    "nickname": "string",
    "status": "string",
    "username": "string"
  },
  "data": {
    "test": false,
    "votes": 0
  },
  "targets": {
    "bot": {
      "avatar": "string",
      "bot": false,
      "discriminator": "string",
      "id": "string",
      "in_guild": "string",
      "nickname": "string",
      "status": "string",
      "username": "string"
    }
  },
  "type": "BOT_VOTE"
}

Example Fastify Server

  • For a basic server we created for you to use go here
const { MessageEmbed } = require("discord.js");
const { Reedhook } = require("@infinitybots/client");
const moment = require("moment");

const webhook = new Reedhook("YOUR_WEBHOOK_SECRET");

module.exports = async (fastify, opts) => {
  fastify.post(
    "/votes",
    webhook.hookListener(async (voteData, req, res) => {

      let embed = new MessageEmbed()
        .setTitle(`Vote Logs`)
        .setColor("RANDOM")
        .setDescription(`Woah someone has voted for me on Infinity Bot List`)
        .addFields(
          {
            name: "Total Votes",
            value: `${voteData.data.votes}`,
            inline: true,
          },
          {
            name: "User",
            value: `${voteData.creator.username}#${voteData.creator.discriminator}`,
            inline: true,
          },
          {
            name: "Time",
            value: `${moment(voteData.created_at)}`,
            inline: true,
          }
        )
        .setTimestamp()
        .setFooter({
          text: "Infinity Vote Logger",
          iconURL: `${voteData.creator.avatar}`,
        });
    })
  );
};
0.1.0

9 months ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago