繁体   English   中英

Discord JS V11禁令命令

[英]Discord JS V11 BAN COMMAND

您好,我有一个禁止命令。 我也有一个错误。 这是我要解决的代码。 但我没有。

const Discord = require('discord.js')

module.exports = {
    komut: "ban",  
    açıklama: "", 
    kategori: "moderasyon", 
    alternatifler: ["!ban", "!yasakla"], 
    kullanım: "!ban", 
    yetki: "BAN_MEMBERS"
}

module.exports.baslat = (message) => {

// if(!message.member.hasPermission(["BAN_MEMBERS"])) return message.channel.send("Ban atabilmek için yetkili olman gerek!")

let banMember = message.mention.members.first() || message.guild.member.get(args[0])
if(banMember) return message.channel.send("Lütfen banlamak istediğiniz kişiyi etiketleyin!")

let reason = args.slice(1).join(" ")
if (!reason) reason = "Lütfen bir sebep belirtiniz!"

// if(!message.guild.me.hasPermission(["BAN_MEMBERS" , "ADMINISTRATOR"])) return message.channel.send("Bu komutu kullanmak için yetkim yok")

message.delete()

banMember.send(`Merhaba, iyi günler dilerim. ${message.guild.name} adlı sunucudan ${reason} sebebiyle banlandın.`).then(() =>
message.guild.ban(banMember, {days : 1 , reason : reason})).catch(err => console.log(err))

message.channel.send(`**${banMember.user.tag}** banlandı.`)

let embed = new Discord.RichEmbed()
.setColor("RED")
.setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
.addField("Moderasyon :", "ban")
.addField("Kişi : ", banMember.user.username)
.addField("Banlayan Admin :", message.author.username)
.addField("Sebep : ", reason)
.addField("Date :", message.createdAt.toLocaleString())

    let sChannel = message.guild.channels.find(c => c.name === "ban-log")
    sChannel.send({embed:embed})
};

这是一个终端错误:

(node:16116) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'members' of undefined
    at Object.module.exports.baslat (C:\Users\RYZEN\Desktop\U4 BOT\komutlar\moderasyon\ban.js:16:33)
    at AdvancedClient.<anonymous> (C:\Users\RYZEN\Desktop\U4 BOT\node_modules\discordjs-advanced\src\client.js:549:5)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:16116) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:16116) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

请帮我

好吧,没看到

module.exports = { komut: "ban",
açıklama: "", 类别: "moderasyon", alternatifler: [",ban", ":yasakla"], kullanım: "!ban", yetki: "BAN_MEMBERS" }

注意:我更改成员和用户。 机器人不再工作。

(对不起,我的英语不好:) )

您正在使用message.mention.members.first()但应该mentions -

message.mentions.members.first()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM