【问题标题】:Discord JS V11 BAN COMMANDDiscord JS V11 禁止命令
【发布时间】:2020-12-14 02:46:35
【问题描述】:

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

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:“禁令”,
açıklama: "", 类别:“moderasyon”, alternatifler: ["!ban", "!yasakla"], kullanım: "!ban", Yetki:“BAN_MEMBERS” }

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

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

【问题讨论】:

    标签: javascript discord


    【解决方案1】:

    您使用的是message.mention.members.first(),但它应该是mentions -

    message.mentions.members.first()
    

    【讨论】:

    • (node:12324) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'first' of undefined 不工作
    • 这是因为您的公会缓存是空的,请按照此答案进行修复 -stackoverflow.com/a/65277312/14200419
    猜你喜欢
    • 1970-01-01
    • 2021-04-02
    • 2021-12-13
    • 2021-05-31
    • 2021-03-20
    • 2019-05-02
    • 1970-01-01
    • 2021-09-15
    • 2021-03-11
    相关资源
    最近更新 更多