如何在投票 top.gg discord.js 后将 dm 作为 bot 发送?

How to send dm as bot after voted top.gg discord.js?

const Discord = require(discord.js);
const client = new Discord.Client();
const Topgg = require ("@top-gg/sdk");

所以我不知道下一个代码 抱歉我来早了javascript

学习

In here im using discord.js V12

您还没有正确要求 Discord。它应该是 require("discord.js"); 否则你试图要求一个不存在的变量。

滚动浏览 Top.gg API Docs it looks like you can use the webhook class 以获取用户投票的时间。

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
});

希望这有助于注意这是未经测试的,因此可能需要一些调整,但一定要阅读文档。