const Discord = require('discord.js');
const { Client, MessageAttachment } = require('discord.js');
const client = new Discord.Client();
client.once('ready', () => {
console.log("Ready!")
})
client.on('message', message =>{
msg = message.content.toLowerCase();
const generalBotTesting = '598918505605234723';
function cheekibreeki(){
client.channels.cache.get(generalBotTesting).send("Cheeki Breeki")
}
setInterval(cheekibreeki,60000)
}
)
client.login(process.env.token);
即使设置“间隔”值用于每分钟仅发送一次邮件,我的机器人也向垃圾邮件发送了垃圾邮件
答案 0 :(得分:1)
您要为每条收到 的消息开始一个新的间隔,您要做的是在客户端连接到Discord API时开始一个间隔。
const Discord = require('discord.js');
const { Client, MessageAttachment } = require('discord.js');
const client = new Discord.Client();
client.once('ready', () => {
console.log("Ready!")
setInterval(cheekibreeki, 60 * 1000)
})
const generalBotTesting = '598918505605234723';
function cheekibreeki(){
client.channels.cache.get(generalBotTesting).send("Cheeki Breeki")
}
client.on('message', message =>{
msg = message.content.toLowerCase();
})
client.login(process.env.token);