This snippet will create a channel and give access to the specified roles and users. Read the comments to see how to list the roles and users.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let roles = ['ROLE_ID_1', 'ROLE_ID_2']; //Insert here the roles you want to access the new channel - replace the ROLE_ID_1 and ROLE_ID_2
let users = ['USER_ID_1','USER_ID_2']; //Insert here the User IDs that you want to access the new channel - replace the USER_ID_1 and USER_ID_2
let channelName = `${context.params.event.author.username}-channel`; //Name of the new channel (username-channel)
let permissions = [
{
id: `${context.params.event.guild_id}`,
type: 0,
deny: `${1 << 10}`
},
{
id: `${context.params.event.author.id}`,
type: 1,
allow: `${1 << 10}`
}
];
for(let i = 0; i < roles.length; i++){
permissions.push({ id: roles[i], type: 0, allow: `${1 << 10}`});
}
for(let i = 0; i < users.length; i++){
permissions.push({id: users[i], type: 1, allow: `${1 << 10}`});
}
await lib.discord.guilds['@0.2.4'].channels.create({
guild_id: `${context.params.event.guild_id}`,
name: channelName,
topic: ``,
type: 0,
permission_overwrites: permissions
});