繁体   English   中英

投票 top.gg discord.js 后如何将 dm 作为机器人发送?

[英]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 学习

在这里我使用 discord.js V12

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

滚动浏览Top.gg API 文档后,您似乎可以使用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
});

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM