【发布时间】: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