[英]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.