【发布时间】:2022-01-18 23:11:36
【问题描述】:
我在授予message.author 和员工权限以在创建频道后立即查看频道时遇到一些问题,问题是,当频道的父级(类别)更改时,它会同步父级(类别)的权限),不允许用户和工作人员看到频道,我不知道如何解决这个问题,我希望我解释清楚,如果您有任何问题,请询问。
这是我的代码:
module.exports = {
name: 'new',
category: 'Ticket',
description: 'Creates a new ticket.',
aliases: ['newticket'],
usage: 'New',
userperms: [],
botperms: [],
run: async (client, message, args) => {
if(message.author.bot) return;
if(!message.channel.id == process.env.COMMAND_T) return;
if(!client.userTickets) {
client.userTickets = new Map();
const channels = message.guild.channels.cache.filter(channel => {
if(channel) return channel.name.startsWith('t-');
});
if(channels) {
for (i in Array.from(channels)) {
client.userTickets.set(i, +i + 1);
}
}
}
console.log(client.userTickets)
if(client.userTickets.has(message.author.id)) {
return message.channel.send('<@' + message.author.id + 'You already have a ticket, please close it then run this command again!').then(m => m.delete({timeout: 10000}));
}
message.guild.channels.create(`t-${client.userTickets.size + 1}`, {
permissionOverwrites: [
{
id: message.author.id,
allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
},
{
id: process.env.ROLE_STAFF,
allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
},
{
id: process.env.ROLE_MEMBER,
deny: ['VIEW_CHANNEL']
}
],
type: 'text',
}).then(async channel => {
channel.setParent(process.env.TICKET_C);
client.userTickets.set(message.author.id, client.userTickets.size + 1);
message.channel.send(`<@` + message.author.id + `>, Done, go to your ticket! ${channel}`).then(m => m.delete({timeout: 10000}));
client.users.cache.get(message.author.id).send(`Your ticket has been opened, go take a look: ${channel}`)
channel.send(`Hi <@` + message.author.id + `>, Hello and welcome to your DwaCraft ticket!`);
channel.send(`https://tenor.com/view/is-there-something-i-can-help-you-with-dan-levy-david-david-rose-schitts-creek-gif-20776045`);
const logchannel = message.guild.channels.cache.find(channel => channel.id === process.env.TICKET_L);
if(logchannel) {
logchannel.send(`There was a new ticket created by <@${message.author.id}>! Channel: <#${channel.id}>`);
}
});
}
}
注意:我已经研究过,但没有找到任何答案。
感谢您抽出宝贵时间阅读本文。
【问题讨论】:
标签: javascript discord.js