簡體   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