From 40d22921fa2735ece85fe83c9271fa8af98a9f22 Mon Sep 17 00:00:00 2001 From: Snabbare Hastighet Date: Sun, 3 Nov 2019 20:19:11 +0000 Subject: [PATCH] Add Guild embed related endpoints. (#163) * Guild Embed endpoints * Fix failing test --- disco/api/client.py | 14 +++++++++++++- disco/types/guild.py | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/disco/api/client.py b/disco/api/client.py index df4f69b..5446af4 100644 --- a/disco/api/client.py +++ b/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, PruneCount, Role, GuildEmoji, AuditLogEntry +from disco.types.guild import Guild, GuildMember, GuildBan, GuildEmbed, PruneCount, Role, GuildEmoji, AuditLogEntry from disco.types.channel import Channel from disco.types.invite import Invite from disco.types.voice import VoiceRegion @@ -516,6 +516,18 @@ class APIClient(LoggingClass): r = self.http(Routes.GUILDS_VANITY_URL_GET, dict(guild=guild)) return Invite.create(self.client, r.json()) + def guilds_embed_get(self, guild): + r = self.http(Routes.GUILDS_EMBED_GET, dict(guild=guild)) + return GuildEmbed.create(self.client, r.json()) + + def guilds_embed_modify(self, guild, reason=None, **kwargs): + r = self.http( + Routes.GUILDS_EMBED_MODIFY, + dict(guild=guild), + json=kwargs, + headers=_reason_header(reason)) + return GuildEmbed.create(self.client, r.json()) + def guilds_webhooks_list(self, guild): r = self.http(Routes.GUILDS_WEBHOOKS_LIST, dict(guild=guild)) return Webhook.create_map(self.client, r.json()) diff --git a/disco/types/guild.py b/disco/types/guild.py index baaac48..7f599fa 100644 --- a/disco/types/guild.py +++ b/disco/types/guild.py @@ -137,6 +137,11 @@ class GuildBan(SlottedModel): reason = Field(text) +class GuildEmbed(SlottedModel): + enabled = Field(bool) + channel_id = Field(snowflake) + + class GuildMember(SlottedModel): """ A GuildMember object.