【问题标题】:Unban command | discord.js解禁命令 |不和谐.js
【发布时间】:2021-07-17 23:39:07
【问题描述】:

我最近为我的机器人做了一个不和谐的解禁命令:

这是我目前的代码:

const Discord = require('discord.js');
const { Client, Message, MessageEmbed } = require('discord.js');

module.exports = {
  name: 'unban',
  description: 'unban',
  aliases: ['unban'],
  execute: async (client, message, args) => {

        if(!message.member.hasPermission("BAN_MEMBERS")) {
          return message.channel.send(`**${message.author.username}, you do not have perms to unban someone.**`)
        }
        
        if(!message.guild.me.hasPermission("BAN_MEMBERS")) {
          return message.channel.send(`**${messageg.author.username}, I do not have perms to unban someone.**`)
        }

  
        let userID = args[0]
          message.guild.fetchBans().then(bans=> {
          if(bans.size == 0) return 
          let bUser = bans.find(b => b.user.id == userID)
          if(!bUser) return
          message.guild.members.unban(bUser.user)
    })
        
      ;}}`

我希望机器人在解除成员禁令时发送消息。我已经尝试了很多方法,但都没有奏效,所以我在这里问!

如果用户发送了错误的 ID,我还希望机器人发送消息。

注意:bot 命令有效!)

【问题讨论】:

  • 只需在message.guild.members.unban(bUser.user) 之后添加message.channel.send(`I have successfully unbanned ${bUser.user.tag}.`) 即可。
  • 有效!谢谢你^^
  • 是的没问题:)

标签: javascript discord.js bots


【解决方案1】:
message.guilds.members.unban(bUser.user).then(() => {
message.channel.send('Success!')
})

这会在您取消禁止后发送消息。

【讨论】:

    猜你喜欢
    • 2021-06-30
    • 2018-06-08
    • 2020-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-26
    • 1970-01-01
    • 2020-11-23
    相关资源
    最近更新 更多