Esempio n. 1
0
 async def on_guild_update(self, before, after):
     for user in self.bot.dash_guild_users:
         member = after.get_member(user)
         if member is not None:
             old = DashUtils.get_guild_perms(member)
             new = DashUtils.get_guild_perms(member)
             if old != new:
                 await self._notify_user(member, old, new, after)
             elif before.name != after.name or before.icon != after.icon:
                 await self._notify_user(member, 0, 15, after)
Esempio n. 2
0
 async def on_guild_role_update(self, before, after):
     for user in self.bot.dash_guild_users:
         member = after.guild.get_member(user)
         if member is not None and after in member.roles:
             new = DashUtils.get_guild_perms(member)
             await self._notify_user(member, 0 if new is not 0 else 15, new,
                                     after.guild)
Esempio n. 3
0
 async def on_guild_remove(self, guild):
     for user in self.bot.dash_guild_users:
         member = guild.get_member(user)
         if member is not None:
             permission = DashUtils.get_guild_perms(member)
             if permission > 0:
                 await self.send_to_dash("guild_remove",
                                         user_id=user,
                                         guild=str(guild.id))
Esempio n. 4
0
 async def user_guilds(self, message):
     user_id = int(message["user_id"])
     self.bot.dash_guild_users.add(user_id)
     self.redis_link.publish_json(
         "bot-dash-messages",
         dict(type="guild_add",
              message=dict(user_id=user_id,
                           guilds=DashUtils.get_user_guilds(
                               self.bot, user_id))))
Esempio n. 5
0
 async def on_guild_join(self, guild):
     for user in self.bot.dash_guild_users:
         member = guild.get_member(user)
         if member is not None:
             permission = DashUtils.get_guild_perms(member)
             if permission > 0:
                 await self.send_to_dash("guild_add",
                                         user_id=user,
                                         guilds={
                                             str(guild.id): {
                                                 "id": str(guild.id),
                                                 "name": guild.name,
                                                 "permissions": permission,
                                                 "icon": guild.icon
                                             }
                                         })
Esempio n. 6
0
 async def on_member_update(self, before, after):
     if after.id in self.bot.dash_guild_users:
         old = DashUtils.get_guild_perms(before)
         new = DashUtils.get_guild_perms(after)
         await self._notify_user(after, old, new, before.guild)
Esempio n. 7
0
 async def send_guild_info(self, member):
     await self.send_to_dash("guild_update",
                             user_id=member.id,
                             guild_id=member.guild.id,
                             info=DashUtils.assemble_guild_info(
                                 self.bot, member))
Esempio n. 8
0
 async def guild_user_perms(self, message):
     guild = self.bot.get_guild(int(message["guild_id"]))
     if guild is None:
         return 0
     return DashUtils.get_guild_perms(
         guild.get_member(int(message["user_id"])))