From 2da8317c1dff9b24ff83532bed4da5360ad731ce Mon Sep 17 00:00:00 2001 From: Skillz Date: Tue, 11 Feb 2020 23:50:05 -0500 Subject: [PATCH] more guild stuff --- constants/discord.ts | 5 +++-- structures/guild.ts | 52 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/constants/discord.ts b/constants/discord.ts index 0e8b84e8b..97bc5fb9d 100644 --- a/constants/discord.ts +++ b/constants/discord.ts @@ -10,12 +10,13 @@ export const endpoints = { GUILD_BANNER: (id: string, icon: string) => `${baseEndpoints.CDN_URL}/banners/${id}/${icon}`, GUILD_CHANNELS: (id: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/channels`, GUILD_EMBED: (id: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/embed`, - GUILD_EMOJI: (id: string, emojiID: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/emojis/${emojiID}`, + GUILD_EMOJI: (id: string, emoji_id: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/emojis/${emoji_id}`, GUILD_EMOJIS: (id: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/emojis`, GUILD_ICON: (id: string, icon: string) => `${baseEndpoints.CDN_URL}/icons/${id}/${icon}`, + GUILD_INTEGRATION: (id: string, integration_id: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/integrations/${integration_id}`, GUILD_INTEGRATIONS: (id: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/integrations`, GUILD_PRUNE: (id: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/prune`, - GUILD_ROLE: (id: string, roleID: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/roles/${roleID}`, + GUILD_ROLE: (id: string, role_id: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/roles/${role_id}`, GUILD_ROLES: (id: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/roles`, GUILD_SPLASH: (id: string, icon: string) => `${baseEndpoints.CDN_URL}/splashes/${id}/${icon}`, GUILD_VANITY_URL: (id: string) => `${baseEndpoints.BASE_URL}/guilds/${id}/vanity-url` diff --git a/structures/guild.ts b/structures/guild.ts index cd7a974e2..ff1b76b1c 100644 --- a/structures/guild.ts +++ b/structures/guild.ts @@ -166,10 +166,50 @@ interface Guild { get_vanity_url(): Promise /** Returns a list of integrations for the guild. Requires the MANAGE_GUILD permission. */ get_integrations(): Promise - + /** Modify the behavior and settings of an integration object for the guild. Requires the MANAGE_GUILD permission. */ + edit_integration(id: string, options: EditIntegrationOptions): Promise + /** Delete the attached integration object for the guild with this id. Requires MANAGE_GUILD permission. */ + delete_integration(id: string): Promise + edit(options: GuildEditOptions): Promise leave_voice_channel(): Promise } +export interface GuildEditOptions { + /** The guild name */ + name?: string + /** The guild voice region id */ + region?: string + /** The verification level. 0 is UNRESTRICTED. 1 is Verified email. 2 is 5 minutes user. 3 is 10 minutes member in guild. 4 is verified phone number */ + verification_level?: 0 | 1 | 2 | 3 + /** The default message notification level. 0 is ALL_MESSAGES and 1 is ONLY_MENTINS */ + default_message_notifications?: 0 | 1 + /** Explicit content filter level. 0 is DISABLED 1 is members without roles. 2 is all members */ + explicit_content_filter?: 0 | 1 | 2 + /** The id for the afk channel. */ + afk_channel_id?: string + /** The afk timeout in seconds. */ + afk_timeout?: number + /** base64 1024x1024 png/jpeg/gif image for the guild icon (can be animated gif when the server has ANIMATED_ICON feature) */ + icon?: string + /** user id to transfer guild ownership to (must be owner) */ + owner_id?: string + /** base64 16:9 png/jpeg image for the guild splash (when the server has INVITE_SPLASH feature) */ + splash?: string + /** base64 16:9 png/jpeg image for the guild banner (when the server has BANNER feature) */ + banner?: string + /** the id of the channel to which system messages are sent */ + system_channel_id?: string +} + +export interface EditIntegrationOptions { + /** The behavior when an integration subscription lapses. */ + expire_behavior: number + /** The period in seconds where the integration will ignore lapsed subscriptions */ + expire_grace_period: number + /** Whether emoticons should be synced for this integrations (twitch only currently) */ + enable_emoticons: boolean +} + export interface Guild_Integration { /** The integrations unique id */ id: string @@ -577,8 +617,18 @@ export const createGuild = (data: CreateGuildPayload, client: Client) => { // TODO: requires the MANAGE_GUILD permission return client.RequestManager.get(endpoints.GUILD_INTEGRATIONS(data.id)) }, + edit_integration: (id, options) => { + // TODO: requires the MANAGE_GUILD permission + return client.RequestManager.patch(endpoints.GUILD_INTEGRATION(data.id, id), options) + }, + delete_integration: id => { + // TODO: requires the MANAGE_GUILD permission + return client.RequestManager.delete(endpoints.GUILD_INTEGRATION(data.id, id)) + }, leave_voice_channel: () => {} } + guild.edit({ default_message_notifications: 5 }) + return guild }