简体   繁体   English

如何在 Discord.js v14(斜杠命令)中安排机器人消息?

[英]How to schedule a bot message in Discord.js v14 (Slash commands)?

I need to schedule some messages for users and I would like to do this with the bot.我需要为用户安排一些消息,我想用机器人来做这件事。 If possible choosing the date and time of the message.如果可能,选择消息的日期和时间。

I'm very new to this part so I'm asking for help.我对这部分很陌生,所以我正在寻求帮助。

In my code, I add a.js file for the command inside the commands folder.在我的代码中,我为命令文件夹中的命令添加了一个 .js 文件。

By default, commands start with:默认情况下,命令以:

const Discord = require("discord.js")

module.exports = {
  name: "schedule", // Coloque o nome do comando
  description: "Schedule messages.", // Coloque a descrição do comando
  type: Discord.ApplicationCommandType.ChatInput,
  options: [
    {
        name: "schedule",
        description: "Schedule messages.",
        type: Discord.ApplicationCommandOptionType.String,
        required: true,
    }
],

  run: async (client, interaction) => {

You can use setTimeout() for making shedules您可以使用 setTimeout() 来制作日程表

 setTimeout(() => { console.log("Shedule is running"); //Do whatever you wanted to do when the time comes //... }, 3000)//3000 = 3 seconds

暂无
暂无

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

相关问题 如何向我的机器人在 v14 discord.js 中的所有 discord 服务器发送消息? - How would I send a message to all discord servers my bot is in v14 discord.js? 如何引用以前的机器人消息? (Discord.js v14) - How to reference to a previous bot message? (Discord.js v14) 如果斜线命令有效,我怎样才能让我的 discord.js v14 机器人停止说“应用程序没有响应”? - How can i get my discord.js v14 bot to stop saying "The application did not respond" if the slash command works? 创建不带选项的斜杠命令 Discord.js V14 - Creating slash commands without options Discord.js V14 如何使斜杠命令在 dms discord.js v14 中不可用 - How do I make a slash command not usable in dms discord.js v14 我怎样才能使这个 discord.js v14 斜杠命令不为每个选项返回“未定义”? - How can i make this discord.js v14 slash command not return "undefined" for each option? 如何在 Discord.js v14 中创建只有用户和机器人可以看到的私人频道? - How to create a private channel only the user and the bot can see in Discord.js v14? Discord.js v14 如何处理按钮交互 - Discord.js v14 how to handle button interactions 如何从 Discord.js v14 中的消息中嵌入 - How to get a embed from a message in Discord.js v14 discord.js v14 试图做到这一点我的机器人状态将是机器人在其中的服务器数量 - discord.js v14 trying to do that my bot status will be the amount of servers that the bot is in them
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM