我想让我的机器人能够创建私人门票。它可以很好地创建通道,但是当我尝试在该通道上设置权限时,它说@everyone
是唯一角色(因此具有默认权限)。此外,控制台不会报告任何错误消息。
为澄清起见,我无法让漫游器将权限应用于频道。
const client = new discord.Client();
const config = require("./config.json");
var userTickets = new Map();
client.login(config.token);
client.on("ready", () => {
console.log(client.user.username + "has logged in.")
});
client.on("message", message => {
if(message.author.bot) return;
if(message.content.toLowerCase() === "?crearticket" && message.channel.id === "729851516667691058") {
if(userTickets.has(message.author.id) || message.guild.channels.cache.some(channel =>
channel.name.toLowerCase() === message.author.username + "-ticket")) {
message.author.send("¡Ya tienes un ticket!");
}
else {
let guild = message.guild;
message.guild.channels.create(`${message.author.username}-ticket`, {
type: "text",
permissionsOverwrites: [
{
id: message.author.id,
allow: ["VIEW_CHANNEL"]
},
{
id: message.guild.id,
deny: ["VIEW_CHANNEL"] //This is the part I mentioned.
},
{
id: "729481759955222538",
allow: ["VIEW_CHANNEL"]
},
],
}).then(ch => {
console.log("Creado el canal" + ch.name)
userTickets.set(message.author.id, ch.id);
console.log(userTickets);
}).catch(err => console.log(err));
}
}
else if(message.content.toLowerCase() == "?closeticket"){
if(userTickets.has(message.author.id)) {
if(message.channel.id === userTickets.get(message.author.id)) {
message.channel.delete("Cerrando Ticket")
.then(channel => {
console.log("Eliminado el canal " + channel.name);
userTickets.delete(message.author.id);
})
.catch(err => console.log(err));
}
}
}
});
答案 0 :(得分:0)
将>>> a = {1:14, 2:15, 3:16, 4:17}
>>> b = {2:19, 3:9, 4:11, 5:13}
>>> c = {**a, **b, **{key:min(a[key], b[key]) for key in set(a).intersection(set(b))} }
>>> c
{1: 14, 2: 15, 3: 9, 4: 11, 5: 13}
更改为permissionsOverwrites
(您有一个额外的 s )。
编码愉快!