如何设置频道中的parParent和权限?不和谐机器人编码

时间:2020-11-08 14:29:22

标签: javascript discord discord.js bots

使用我的命令“ ^ new”创建频道时,如何设置父级以及设置权限 因此,截至目前,我有以下代码:


exports.run = async(client, msg, args) => {
    
    if (msg.author.bot) return;

    const reason = msg.content.split(" ").slice(1).join(" ");
    const SupportRole = msg.guild.roles.cache.find(r => r.name === "Staff");

    if(!SupportRole) {
        msg.channel.send("Please create a role called 'Staff' before using this command!");
    }

    if(!reason) {
        return msg.channel.send("Please specify a reason!")
    }

const ticketChannel = await msg.guild.channels.create(`ticket-${msg.author.username}`).then(c => {
const sr = msg.guild.roles.cache.find(r => r.name === "Staff")
const everyone = msg.guild.roles.cache.find(r => r.name === "@everyone")
c.updateOverwrite(sr, {
    SEND_MESSAGES: true,
    VIEW_CHANNEL: true,
});
c.updateOverwrite(everyone, {
    SEND_MESSAGES: false,
    VIEW_CHANNEL: false,
});
c.updateOverwrite(msg.author, {
    SEND_MESSAGES: true,
    VIEW_CHANNEL: true,
});
let CreatedTicketEmbed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle("New Ticket")
.setDescription(`<@${msg.author.id}> Your support ticket is <#${c.id}>`)
.setTimestamp()
msg.channel.send(CreatedTicketEmbed)

let GreetEmbed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle("New Ticket!")
.addField(`${msg.author.username}'s Support Ticket`,"The staff team will be right with you!")
.addField("Reason:", reason)
.addField("Type ^close to close the ticket.", "Staff Team")
.setTimestamp()
c.send(GreetEmbed)
msg.delete()
}).then((channel) => {
    const categoryId = '774032663560192000';
    ticketChannel.setParent(categoryId);
})
.catch(console.error);

var channel = msg.guild.channels.cache.find(ch => ch.name === "ticket-logs")

if(!channel) return msg.channel.send("There is no channel called 'ticket-logs'");


let LogEmbed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle("New Support Ticket")
.addField(`${msg.author.username}'s Support Ticket`,"React with ✅ when dealing with / have dealt with ticket.")
.addField("Reason:", reason)
.setTimestamp()
channel.send(LogEmbed).then(messageReaction => {
    messageReaction.react('✅')
})
}

因此,当我同时拥有setParent和updateOverwrite代码时,它要么不会将它们移到类别下,要么不会设置权限,并且它们也不会发送我创建的嵌入内容。我该如何解决?

0 个答案:

没有答案