async def _create_text_channel(self): """ Creates the user-related text-channel """ channels = handler.load_json(JSON_CHANNEL_IDS_FILE) author = self.ctx.author self.users_using[str(author.id)] = 0 channel: TextChannel = await self.ctx.guild.create_text_channel(f'{self.manga["name"]}-{author.name}') ow = PermissionOverwrite() ow.send_messages = False ow.read_messages = True await channel.set_permissions(author, overwrite=ow) default_role = utils.get(self.ctx.guild.roles, name='@everyone') ow.read_messages = False await channel.set_permissions(default_role, overwrite=ow) channels[str(self.ctx.guild.id)][str(author.id)] = str(channel.id) handler.dump_json(JSON_CHANNEL_IDS_FILE, channels) return channel
async def CreateChat(self, guild, channelName, category, discordRole): chan = None cultistRole = get(guild.roles, name="Cultist") if str.lower(self.chat_type) == 'text': chan = await guild.create_text_channel(channelName, category=category) # Set Permissions for the channel # List of Permissions can be found here (they are the attributes): https://discordpy.readthedocs.io/en/stable/api.html?highlight=permissionoverwrite#discord.Permissions role_overwrite = PermissionOverwrite() role_overwrite.view_channel = True role_overwrite.read_messages = True role_overwrite.send_messages = True await chan.set_permissions(discordRole, overwrite=role_overwrite) cultist_overwrite = PermissionOverwrite() cultist_overwrite.view_channel = False await chan.set_permissions(cultistRole, overwrite=cultist_overwrite) if str.lower(self.chat_type) == 'voice': chan = await guild.create_voice_channel(channelName, category=category) await chan.set_permissions(discordRole, view_channel=True, speak=True, stream=True, connect=True) await chan.set_permissions(cultistRole, view_channel=True, connect=False, speak=True) # By default they cannot join, but can see who is in it self.chat_id = chan.id