GithubHelp home page GithubHelp logo

dotwoodmedia / topgg-votes Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 2.0 106 KB

Easily trade all your votes with this super easy framework!

License: Apache License 2.0

TypeScript 88.44% JavaScript 11.56%
bot discord nodejs topgg topgg-webhooks

topgg-votes's Introduction

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

topgg-votes's People

Contributors

dependabot[bot] avatar dotwoodmedia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

friktiny lukih

topgg-votes's Issues

Error: Cannot find module '~/util/VoteClientEvents'

node:internal/modules/cjs/loader:1080
  throw err;
  ^

Error: Cannot find module '~/util/VoteClientEvents'
Require stack:
- /home/container/projects/node_modules/topgg-votes/dist/structures/VoteWebhookManager.js
- /home/container/projects/node_modules/topgg-votes/dist/structures/VoteClient.js
- /home/container/projects/node_modules/topgg-votes/dist/index.js
- /home/container/projects/src/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/home/container/projects/node_modules/topgg-votes/dist/structures/VoteWebhookManager.js:7:28)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/container/projects/node_modules/topgg-votes/dist/structures/VoteWebhookManager.js',
    '/home/container/projects/node_modules/topgg-votes/dist/structures/VoteClient.js',
    '/home/container/projects/node_modules/topgg-votes/dist/index.js',
    '/home/container/projects/src/index.js'
  ]
}

Node.js v18.17.0

https://discord.com/channels/1016942011024158782/1050808924804235306/1138589304743018638

Types

Would be great if package could support all types also

image
image

Question

What do I set on topgg for the webhook URL?

Can't use checkVote()

Hello!
When I use checkVote(user.id) it always returns "undefined". Also the isWeekend parameter returns "undefined". You know why?
Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.