Browse Source

Add support for reading guild descriptions

Added `Guild.description` and `PartialInviteGuild.description`.
pull/1994/head
Nadir Chowdhury 6 years ago
committed by Danny
parent
commit
8f7ce7c64e
  1. 6
      discord/guild.py
  2. 7
      discord/invite.py

6
discord/guild.py

@ -97,6 +97,8 @@ class Guild(Hashable):
Check the :func:`on_guild_unavailable` and :func:`on_guild_available` events. Check the :func:`on_guild_unavailable` and :func:`on_guild_available` events.
banner: Optional[:class:`str`] banner: Optional[:class:`str`]
The guild's banner. The guild's banner.
description: Optional[:class:`str`]
The guild's description.
mfa_level: :class:`int` mfa_level: :class:`int`
Indicates the guild's two factor authorisation level. If this value is 0 then Indicates the guild's two factor authorisation level. If this value is 0 then
the guild does not require 2FA for their administrative members. If the value is the guild does not require 2FA for their administrative members. If the value is
@ -125,7 +127,8 @@ class Guild(Hashable):
'_default_role', '_roles', '_member_count', '_large', '_default_role', '_roles', '_member_count', '_large',
'owner_id', 'mfa_level', 'emojis', 'features', 'owner_id', 'mfa_level', 'emojis', 'features',
'verification_level', 'explicit_content_filter', 'splash', 'verification_level', 'explicit_content_filter', 'splash',
'_voice_states', '_system_channel_id', 'default_notifications') '_voice_states', '_system_channel_id', 'default_notifications',
'description')
def __init__(self, *, data, state): def __init__(self, *, data, state):
self._channels = {} self._channels = {}
@ -227,6 +230,7 @@ class Guild(Hashable):
self.features = guild.get('features', []) self.features = guild.get('features', [])
self.splash = guild.get('splash') self.splash = guild.get('splash')
self._system_channel_id = utils._get_as_snowflake(guild, 'system_channel_id') self._system_channel_id = utils._get_as_snowflake(guild, 'system_channel_id')
self.description = guild.get('description')
for mdata in guild.get('members', []): for mdata in guild.get('members', []):
member = Member(data=mdata, guild=self, state=state) member = Member(data=mdata, guild=self, state=state)

7
discord/invite.py

@ -81,7 +81,7 @@ class PartialInviteChannel(namedtuple('PartialInviteChannel', 'id name type')):
"""Returns the channel's creation time in UTC.""" """Returns the channel's creation time in UTC."""
return snowflake_time(self.id) return snowflake_time(self.id)
class PartialInviteGuild(namedtuple('PartialInviteGuild', 'features icon banner id name splash verification_level')): class PartialInviteGuild(namedtuple('PartialInviteGuild', 'features icon banner id name splash verification_level description')):
"""Represents a "partial" invite guild. """Represents a "partial" invite guild.
This model will be given when the user is not part of the This model will be given when the user is not part of the
@ -121,6 +121,8 @@ class PartialInviteGuild(namedtuple('PartialInviteGuild', 'features icon banner
The partial guild's banner. The partial guild's banner.
splash: Optional[:class:`str`] splash: Optional[:class:`str`]
The partial guild's invite splash. The partial guild's invite splash.
description: Optional[:class:`str`]
The partial guild's description.
""" """
__slots__ = () __slots__ = ()
@ -278,7 +280,8 @@ class Invite(Hashable):
icon=guild_data.get('icon'), icon=guild_data.get('icon'),
banner=guild_data.get('banner'), banner=guild_data.get('banner'),
splash=guild_data.get('splash'), splash=guild_data.get('splash'),
verification_level=try_enum(VerificationLevel, guild_data.get('verification_level'))) verification_level=try_enum(VerificationLevel, guild_data.get('verification_level')),
description=guild_data.get('description'))
data['guild'] = guild data['guild'] = guild
data['channel'] = channel data['channel'] = channel
return cls(state=state, data=data) return cls(state=state, data=data)

Loading…
Cancel
Save