【问题标题】:my nuke command dosent work as intended discord.js我的 nuke 命令无法按预期工作 discord.js
【发布时间】:2021-05-22 06:14:12
【问题描述】:

我已经为我的 nuke commad 编写了一个代码

const { MessageEmbed } = require('discord.js')
module.exports = {
    name: "nuke",
    description: "Nukes a given channel",
    run: async(client, message, args) => {
        if(!message.member.hasPermission("ADMINISTRATOR")) {
            return message.reply("You do not have the perms to use this cmd!")
        }
        let reason = args.join(" ") || "No Reason"
        if(!message.channel.deletable) {
            return message.reply("This channel cannot be nuked!")
        }
        let newchannel = await message.channel.clone()
        await message.channel.delete()
        let embed = new MessageEmbed()
        .setTitle("Channel Nuked")
        .setDescription(reason)
        .setImage('https://media0.giphy.com/media/oe33xf3B50fsc/200.gif')
        await newchannel.send(embed)
    }
}

但我想要它,所以克隆频道并将其位置设置为与已被核弹但没有发生的频道相同

【问题讨论】:

  • 这个命令不会把频道放到正确的位置,请帮忙

标签: command discord.js nuke


【解决方案1】:

然后在clone() 之前抓取父级并定位并在delete() 之后重置它

const oldParent = message.channel.parent;
const oldPosition = message.channel.position;
const newchannel = await message.channel.clone() 
await message.channel.delete()
if (!!oldPosition) {
    newchannel.setPosition(oldPosition, true);
}
if (!!oldParent) {
    newchannel.setParent(oldParent); 
}

【讨论】:

    猜你喜欢
    • 2021-03-29
    • 2014-11-28
    • 1970-01-01
    • 1970-01-01
    • 2019-07-31
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 2012-04-11
    相关资源
    最近更新 更多