【发布时间】:2021-05-17 03:20:32
【问题描述】:
在给予用户 xp 时尝试对消息事件进行冷却。遇到cooldowns.push() is not a fucntion 的问题,我已经完成了谷歌搜索,我发现我需要一个数组,但据我了解,Discord.Collection 是一回事。
我需要这个来检查集合以查看用户 ID 是否在其中,但如果在 3 秒内未添加,则将其删除。
const config = require(`../settings/config.js`)
const prefix = config.prefix
const { createConnection } = require(`mysql`)
const mysql = require("../settings/mysql.js")
const Discord = require(`discord.js`)
let cooldowns = new Discord.Collection()
module.exports = async (client, message, member) => {
if (!cooldowns.has(message.author.id)) {
cooldowns.push(message.author.id)
}
setTimeout(() => cooldowns.delete(message.author.id), 3000)
提前致谢!!
【问题讨论】:
-
Push 是一种数组方法。
cooldowns是一个扩展 Map 的集合
标签: node.js arrays discord.js