topgg-votes
TypeScript icon, indicating that this package has built-in type declarations

2.2.1 • Public • Published

Topgg-votes

Easily trade all your votes with this super easy framework!

downloadsBadge versionBadge

💻 Installation

  1. Install module: npm i topgg-votes
  2. Put the following in your index.ts:
import { VoteClient, VoteClientEvents } from 'topgg-votes'

const votesClient = new VoteClient({
    token: "TOKEN",
    webhook: {
        port: 22565,
        path: "/dblwebhook",
        authorization: "WEBHOOK"
    }
})

// Event for vote notifications
votesClient.on(VoteClientEvents.BotVote, ({ userId }) => {
    console.log(`${userId} has voted!`)
})

📨 Check votes

votesClient.hasVoted(interaction.user.id).then(voted => {
    if (voted) {
        console.log("User has voted!");
    }

    if (!voted) {
        console.log("User has not voted!");
    }
})

📂 Other examples

Change client

const votesClient = new VoteClient()
    .setToken("TOKEN") // Your top.gg token
    .setWebhookPort(22565) // Your host port
    .setWebhookPath("/dblwebhook") // Webhook path
    .setWebhookAuthorization("DOTWOODJS") // Webhook password

New bot vote event

votesClient.on(VoteClientEvents.BotVote, ({ userId, botId, isWeekend, type }) => {
    let embed = new Discord.EmbedBuilder()
        .setTitle(`New bot vote!!`)
        .addFields([
            {
                name: 'User',
                value: `<@!${userId}>`,
                inline: true
            },
            {
                name: 'Bot',
                value: `<@!${botId}>`,
                inline: true
            },
            {
                name: 'Weekend',
                value: `${isWeekend}`,
                inline: true
            },
            {
                name: 'Type',
                value: `${type}`,
                inline: true
            }
        ])
    client.channels.cache.get(ID).send({ embeds: [embed] });
    // Enter the ID of the logs channel at ID
})

New server vote event

votesClient.on(VoteClientEvents.ServerVote, ({ userId, guildId, type }) => {
    let embed = new Discord.EmbedBuilder()
        .setTitle(`New server vote!!`)
        .addFields([
            {
                name: 'User',
                value: `<@!${userId}>`,
                inline: true
            },
            {
                name: 'Guild',
                value: `<@!${guildId}>`,
                inline: true
            },
            {
                name: 'Type',
                value: `${type}`,
                inline: true
            }
        ])
    client.channels.cache.get(ID).send({ embeds: [embed] });
    // Enter the ID of the logs channel at ID
})

Get votes

votesClient.getVotes()

Get bot

votesClient.getBot(BOTID) // Replace BOTID with Discord bot id

Get user

votesClient.getUser(USERID) // Replace USERID with Discord user id

📑 License

This project has an Apache 2.0 license

Package Sidebar

Install

npm i topgg-votes

Weekly Downloads

43

Version

2.2.1

License

Apache License

Unpacked Size

23.9 kB

Total Files

19

Last publish

Collaborators

  • dotwoodmedia