Beispiel #1
0
    def guilds_auditlogs_list(self,
                              guild,
                              before=None,
                              user_id=None,
                              action_type=None,
                              limit=50):
        r = self.http(
            Routes.GUILDS_AUDITLOGS_LIST,
            dict(guild=guild),
            params=optional(
                before=before,
                user_id=user_id,
                action_type=int(action_type) if action_type else None,
                limit=limit,
            ))

        data = r.json()

        users = User.create_hash(self.client, 'id', data['users'])
        webhooks = Webhook.create_hash(self.client, 'id', data['webhooks'])
        return AuditLogEntry.create_map(self.client,
                                        r.json()['audit_log_entries'],
                                        users,
                                        webhooks,
                                        guild_id=guild)
Beispiel #2
0
 def fetch_user(self, id, raise_on_error=True):
     try:
         r = self.bot.client.api.http(Routes.USERS_GET, dict(user=id))
         return DiscoUser.create(self.bot.client.api.client,r.json())
     except APIException:
         if raise_on_error:
             raise CommandFail('unknown user')
         return
Beispiel #3
0
    def test_user_avatar(self):
        u = User(id=12345,
                 username='******',
                 avatar='1234567890abcdefghijkl',
                 discriminator='1234',
                 bot=False)

        self.assertEqual(
            u.avatar_url,
            'https://cdn.discordapp.com/avatars/12345/1234567890abcdefghijkl.webp?size=1024'
        )
Beispiel #4
0
 def channels_messages_reactions_get(self,
                                     channel,
                                     message,
                                     emoji,
                                     after=None,
                                     limit=100):
     r = self.http(Routes.CHANNELS_MESSAGES_REACTIONS_GET,
                   dict(channel=channel, message=message, emoji=emoji),
                   params={
                       'after': after,
                       'limit': limit
                   })
     return User.create_map(self.client, r.json())
Beispiel #5
0
 def guilds_bans_list(self, guild):
     r = self.http(Routes.GUILDS_BANS_LIST, dict(guild=guild))
     return User.create_map(self.client, r.json())
Beispiel #6
0
 def channels_messages_reactions_get(self, channel, message, emoji):
     r = self.http(Routes.CHANNELS_MESSAGES_REACTIONS_GET, dict(channel=channel, message=message, emoji=emoji))
     return User.create_map(self.client, r.json())
Beispiel #7
0
 def users_me_patch(self, payload):
     r = self.http(Routes.USERS_ME_PATCH, json=payload)
     return User.create(self.client, r.json())
Beispiel #8
0
 def users_me_get(self):
     return User.create(self.client, self.http(Routes.USERS_ME_GET).json())
Beispiel #9
0
 def users_get(self, user):
     r = self.http(Routes.USERS_GET, dict(user=user))
     return User.create(self.client, r.json())
Beispiel #10
0
 def test_user_default_avatar(self):
     u = User(id=123456, discriminator='1234')
     self.assertEqual(u.default_avatar, DefaultAvatars.RED)
     self.assertEqual(u.avatar_url,
                      'https://cdn.discordapp.com/embed/avatars/4.png')