【问题标题】:How can i make my bot send back message when the Axiore Community say some random message? (v12)当 Axiore 社区说一些随机消息时,我如何让我的机器人发回消息? (v12)
【发布时间】:2021-11-28 21:57:49
【问题描述】:

我正在制作一个机器人,如果机器人 webhook Axiore 社区发送一些随机消息 This is Axiore Community webhook message 并且我希望我的机器人发回消息,我希望它发送消息,我该怎么做? (有时 Axiore 社区 webhook 每 4 小时发送不同的消息)

const Discord = require('discord.js');
const client = new Discord.Client();
const express = require("express");
const app = express()
app.get("/", (req, res) => {
  res.send("hello world!")
})

app.listen(3000, () => {
  console.log("Protect is already!")
})

client.on('ready', () => {
  console.log("is time to ping fruit stock!")
});

client.on("message", message => {
if (message.content === `Current stock`) {
message.channel.send("**New current stock!**")
}
})

client.login(process.env.token)

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    要检查消息作者是否是 webhook,您可以使用:

    client.on("message" message => {
    if(message.author.id == "id") { // change "id" to your webhook id
    //your code
    } 
    })
    

    【讨论】:

      猜你喜欢
      • 2019-11-23
      • 2022-01-03
      • 2021-07-19
      • 2021-11-18
      • 2021-08-19
      • 2019-09-19
      • 2022-01-23
      • 2020-12-24
      • 2021-03-22
      相关资源
      最近更新 更多