【问题标题】:Discord.js Commands CooldownDiscord.js 命令冷却时间
【发布时间】:2021-06-17 22:53:04
【问题描述】:

我有一些代码,但我不完全知道如何对其进行冷却。它需要针对整个服务器,而不是针对个人用户 ID。

const Discord = require('discord.js');

module.exports = {
    name: 'bump',
    description: "This will bump the server",
    execute(message, args){
        const user = message.author;
        var bumpEmbed = new Discord.MessageEmbed()
        .setTitle('Time to Bump!')
        .setColor(0xFF0000)
        .setDescription('Please use the command `!d bump` to bump the server!!!')
        message.channel.send(`Thanks ${user.username} for the bump!!`)
            setTimeout(() => {
              message.channel.send('**PLEASE DO NOT BUMP, UNLESS THE BUMP ROLES HAS BEEN MENTIONED!!**')
            }, 1000)
            setTimeout(() => {
            message.channel.send('<@&821978298938425426>')
            message.channel.send(bumpEmbed)
        }, 7200000)
      }
    }

任何有关学习这方面的 youtube 视频都会有所帮助!

【问题讨论】:

  • 我能找到的都是锁定到用户 ID 的视频,而且对我来说没有任何意义。
  • Discord.JS 有一个关于如何创建冷却时间的官方指南,View The Guide
  • 锁定到用户 ID
  • 然后使用服务器 ID。

标签: node.js discord.js


【解决方案1】:

只需使用discord.js guide example on cooldowns 并将使用message.author.id 的部分替换为message.guild.id,这应该可以工作

【讨论】:

    猜你喜欢
    • 2021-05-20
    • 2020-05-27
    • 2021-02-16
    • 2021-02-11
    • 1970-01-01
    • 2021-10-10
    • 2017-11-21
    • 1970-01-01
    • 2021-03-11
    相关资源
    最近更新 更多