【问题标题】:Auto reaction message discord.js自动反应消息 discord.js
【发布时间】:2021-03-31 17:39:03
【问题描述】:

如何在 ID 为 731634178029912096 的特定频道中创建每 2.5 小时运行一次的自动消息代码?

(我对discord.js一无所知)

以下是机器人中当前的代码:

module.exports = {
    name: "help",
    description: "view all commands and their description",
    run: async (message, args) => {

        const { commands } = require("../selfbot.js")
        const { prefix } = require("../config.json")

        let msg = ""

        for (command of commands.keys()) {
            msg = msg + prefix + "**" + command + "** " + commands.get(command).description + "\n"
        }

        await message.edit(msg).then(() => {
            setTimeout(() => {
                message.delete().catch()
            }, 10000)
        })

    }
}

【问题讨论】:

    标签: node.js discord discord.js


    【解决方案1】:

    您的问题是在命令文件中执行setTimeout();。只有在调用命令时才会读取。这是你应该做的:

    //index.js
    var helpMessage = "whatever is in the message";
    const helpChannel = client.channels.cache.get(731634178029912096);
    const sendMessage = setInterval(() => helpChannel.send(helpMessage), 9000000); //9000000 = milliseconds in 2.5 hours
    

    注意:使用频道 ID 仅适用于该服务器中的特定频道

    【讨论】:

      猜你喜欢
      • 2021-05-13
      • 2020-06-25
      • 2021-01-03
      • 2021-03-23
      • 2021-04-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-21
      • 2020-11-30
      相关资源
      最近更新 更多