【问题标题】:Ban command won't work, no error message discord.js禁止命令不起作用,没有错误消息 discord.js
【发布时间】:2021-07-24 21:32:32
【问题描述】:

我的禁令命令不起作用,它在几天前起作用,但现在不起作用,我不知道为什么。我刚开始编码,所以我真的不知道该尝试什么,如果有人可以帮助我,将不胜感激!我的控制台没有出现错误,所以我真的不知道该怎么做。 这是我的代码:

if (cmd === `${prefix}ban`) {
        if(!message.member.hasPermission("BAN_MEMBERS")) return message.reply("You do not have permission to do that.");
        const user = message.mentions.users.first();
        if (!user) return message.reply("Please specify someone you want to ban. **.ban <user> [reason]**");
        if(user.id === message.author.id) return message.reply("You cannot ban yourself.");
        const reason = args.slice(1).join(" ");
        message.guild.members.cache.get(user.id).ban({reason: reason});
 
        const banmessage = new Discord.MessageEmbed()
        .setColor("#00aaaa")
        .setDescription(`${user} has been banned. Reason: **${reason != "" ? reason : "-"}**`);
        message.channel.send(banmessage);
    }

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    当您尝试禁止某人时,无需使用收藏集。 (不需要缓存

    这应该可以解决问题:

    message.guild.member(user.id).ban({reason: "bad"});
    

    参考:

    GuildMember#ban 方法更深入。

    【讨论】:

      猜你喜欢
      • 2023-03-03
      • 2021-03-01
      • 2021-07-27
      • 2021-05-13
      • 2023-03-14
      • 2021-06-01
      • 2020-11-18
      • 2021-01-26
      • 1970-01-01
      相关资源
      最近更新 更多