Browse Source

Add guild prune and prune count.

pull/153/head
Luke 6 years ago
parent
commit
94507bd9f5
  1. 13
      disco/api/client.py
  2. 10
      disco/types/guild.py

13
disco/api/client.py

@ -11,7 +11,7 @@ from disco.util.logging import LoggingClass
from disco.util.sanitize import S
from disco.types.user import User
from disco.types.message import Message
from disco.types.guild import Guild, GuildMember, GuildBan, Role, GuildEmoji, AuditLogEntry
from disco.types.guild import Guild, GuildMember, GuildBan, PruneCount, Role, GuildEmoji, AuditLogEntry
from disco.types.channel import Channel
from disco.types.invite import Invite
from disco.types.voice import VoiceRegion
@ -433,6 +433,17 @@ class APIClient(LoggingClass):
dict(guild=guild, user=user),
headers=_reason_header(reason))
def guilds_prune_count_get(self, guild, days=None):
r = self.http(Routes.GUILDS_PRUNE_COUNT, dict(guild=guild), params=optional(days=days))
return PruneCount.create(self.client, r.json())
def guilds_prune(self, guild, days=None, compute_prune_count=None):
r = self.http(Routes.GUILDS_PRUNE_BEGIN, dict(guild=guild), params=optional(
days=days,
compute_prune_count=compute_prune_count,
))
return PruneCount.create(self.client, r.json())
def guilds_roles_list(self, guild):
r = self.http(Routes.GUILDS_ROLES_LIST, dict(guild=guild))
return Role.create_map(self.client, r.json(), guild_id=guild)

10
disco/types/guild.py

@ -79,6 +79,10 @@ class GuildEmoji(Emoji):
return self.client.state.guilds.get(self.guild_id)
class PruneCount(SlottedModel):
pruned = Field(int, default=None)
class Role(SlottedModel):
"""
A role object.
@ -417,6 +421,12 @@ class Guild(SlottedModel, Permissible):
return self.members.get(user)
def get_prune_count(self, days=None):
return self.client.api.guilds_prune_count_get(self.id, days=days)
def prune(self, days=None, compute_prune_count=None):
return self.client.api.guilds_prune(self.id, days=days, compute_prune_count=compute_prune_count)
def create_role(self, **kwargs):
"""
Create a new role.

Loading…
Cancel
Save