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

所以我不知道下一个代码对不起我很早就学习javascript了

在这里我使用 discord.js V12

4

1 回答 1

0

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

滚动浏览Top.gg API 文档后,您似乎可以使用webhook类来获取用户投票的时间。

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

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

于 2021-12-05T06:39:33.963 回答