因此,我试图做到这一点,以便当有人使用我的命令打开一个临时通道时,它会创建一个通道,然后它将更改其权限。这是我当前的代码:
bot.on('message', msg =>{
if(msg.content === (`${prefix}tempchannel`)) {
var server = msg.guild;
var name = msg.author.username;
const Welcome = new Discord.MessageEmbed()
.setTitle(`Welcome, Here is your temp channel.`)
.setDescription(`<@${msg.author.id}> Ask an admin at any time to close the temp channel. \n You cannot close one yourself due to safety reasons.`)
server.channels.create(`${name} temp channel.`, { reason: `Temp channel for ${name}` })
.then((channel) => channel.send(Welcome))
msg.channel.send('Created a temp channel for you! Check your unreads.')
}})``` Could someone help please?
答案 0 :(得分:0)
您可以像这样使用permissionOverwrites
选项
server.channels.create(`${name} temp channel.`, {
reason: `Temp channel for ${name}`,
permissionOverwrites: [
{
id: msg.author.id,
deny: ['VIEW_CHANNEL'],
},
],
})
https://discord.js.org/#/docs/main/stable/class/GuildChannelManager?scrollTo=create
所有权限:https://discord.js.org/#/docs/main/stable/class/Permissions?scrollTo=s-FLAGS