const Discord = require(discord.js);
const client = new Discord.Client();
const Topgg = require ("@top-gg/sdk");
So i dont know about next code Sorry im to early for studying in javascript
In here im using discord.js V12
You're not yet requiring Discord properly. It should be require("discord.js");
otherwise you're trying to require a non-existent variable.
Upon scrolling through the Top.gg API Docs it looks like you can use the webhook class to get when a user votes.
const Discord = require("discord.js");
const Client = new Discord.Client();
// top.gg example
const Topgg = require("@top-gg/sdk");
// Webhook options can be found here if you wish to include them, currently the only one is an error callback: https://topgg.js.org/interfaces/webhookoptions
// You'll have to set up a webhook on top.gg in your bot's settings
const TopWebhook = new Topgg.Webhook("authorization");
const express = require("express");
const app = express();
app.listen(process.env.PORT || 8080);
// This example assumes you're using express
app.post("/webhook", async TopWebhook.listener(vote) => {
let user = vote.user; // the User ID
// get the user from their user id, then send a DM
});
Hopefully this helps note that this is untested so may require some tweaking, but definitely read the documentation.