Ejemplo n.º 1
0
 async def check_required_perms(
     self, guild: discord.guild, also_check_autorooms: bool = False
 ):
     result = (
         guild.me.guild_permissions.view_channel
         and guild.me.guild_permissions.manage_channels
         and guild.me.guild_permissions.manage_roles
         and guild.me.guild_permissions.connect
         and guild.me.guild_permissions.move_members
     )
     if also_check_autorooms:
         avcs = await self.get_all_autoroom_source_configs(guild)
         for avc_id in avcs.keys():
             source_channel = guild.get_channel(avc_id)
             if (
                 source_channel
                 and source_channel.overwrites
                 and guild.default_role in source_channel.overwrites
             ):
                 for testing_overwrite in source_channel.overwrites[
                     guild.default_role
                 ]:
                     if testing_overwrite[1] is not None and not getattr(
                         guild.me.guild_permissions, testing_overwrite[0]
                     ):
                         return False
     return result
Ejemplo n.º 2
0
 async def get_all_autoroom_source_configs(self, guild: discord.guild):
     """Return a dict of all autoroom source configs, cleaning up any invalid ones."""
     sorted_list_of_configs = []
     configs = await self.config.custom(
         "AUTOROOM_SOURCE",
         guild.id).all()  # Does NOT return default values
     for channel_id in configs.keys():
         channel = guild.get_channel(int(channel_id))
         config = await self.get_autoroom_source_config(channel)
         if config:
             sorted_list_of_configs.insert(channel.position,
                                           (channel_id, config))
         else:
             await self.config.custom("AUTOROOM_SOURCE", guild.id,
                                      channel_id).clear()
     result = {}
     for channel_id, config in sorted_list_of_configs:
         result[int(channel_id)] = config
     return result
Ejemplo n.º 3
0
 async def check_required_perms(self,
                                guild: discord.guild,
                                also_check_autorooms: bool = False):
     result = (guild.me.guild_permissions.view_channel
               and guild.me.guild_permissions.manage_channels
               and guild.me.guild_permissions.manage_roles
               and guild.me.guild_permissions.connect
               and guild.me.guild_permissions.move_members)
     if also_check_autorooms:
         async with self.config.guild(guild).auto_voice_channels() as avcs:
             for avc_id, avc_settings in avcs.items():
                 source_channel = guild.get_channel(int(avc_id))
                 if (source_channel and source_channel.overwrites and
                         guild.default_role in source_channel.overwrites):
                     for testing_overwrite in source_channel.overwrites[
                             guild.default_role]:
                         if testing_overwrite[1] is not None and not getattr(
                                 guild.me.guild_permissions,
                                 testing_overwrite[0]):
                             return False
     return result