Add guild preview feature
This commit is contained in:
		
							parent
							
								
									d8e65a4328
								
							
						
					
					
						commit
						35da2dbe98
					
				
					 2 changed files with 53 additions and 2 deletions
				
			
		|  | @ -1,7 +1,7 @@ | ||||||
| import { Client } from '../models/client.ts' | import { Client } from '../models/client.ts' | ||||||
| import { Guild } from '../structures/guild.ts' | import { Guild } from '../structures/guild.ts' | ||||||
| import { Role } from '../structures/role.ts' | import { Role } from '../structures/role.ts' | ||||||
| import { GUILD, GUILDS } from '../types/endpoint.ts' | import { GUILD, GUILDS, GUILD_PREVIEW } from '../types/endpoint.ts' | ||||||
| import { | import { | ||||||
|   GuildChannels, |   GuildChannels, | ||||||
|   GuildPayload, |   GuildPayload, | ||||||
|  | @ -10,11 +10,14 @@ import { | ||||||
|   GuildCreatePayload, |   GuildCreatePayload, | ||||||
|   Verification, |   Verification, | ||||||
|   GuildCreateChannelOptions, |   GuildCreateChannelOptions, | ||||||
|   GuildCreateChannelPayload |   GuildCreateChannelPayload, | ||||||
|  |   GuildPreview, | ||||||
|  |   GuildPreviewPayload | ||||||
| } from '../types/guild.ts' | } from '../types/guild.ts' | ||||||
| import { BaseManager } from './base.ts' | import { BaseManager } from './base.ts' | ||||||
| import { MembersManager } from './members.ts' | import { MembersManager } from './members.ts' | ||||||
| import { fetchAuto } from '../../deps.ts' | import { fetchAuto } from '../../deps.ts' | ||||||
|  | import { Emoji } from '../structures/emoji.ts' | ||||||
| 
 | 
 | ||||||
| export interface GuildCreateOptions { | export interface GuildCreateOptions { | ||||||
|   name: string |   name: string | ||||||
|  | @ -109,4 +112,25 @@ export class GuildManager extends BaseManager<GuildPayload, Guild> { | ||||||
| 
 | 
 | ||||||
|     return guild |     return guild | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  |   async preview(guildID: string): Promise<GuildPreview> { | ||||||
|  |     const resp: GuildPreviewPayload = await this.client.rest.get( | ||||||
|  |       GUILD_PREVIEW(guildID) | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     const result: GuildPreview = { | ||||||
|  |       id: resp.id, | ||||||
|  |       name: resp.name, | ||||||
|  |       icon: resp.icon, | ||||||
|  |       splash: resp.splash, | ||||||
|  |       discoverySplash: resp.discovery_splash, | ||||||
|  |       emojis: resp.emojis.map((emoji) => new Emoji(this.client, emoji)), | ||||||
|  |       features: resp.features, | ||||||
|  |       approximateMemberCount: resp.approximate_member_count, | ||||||
|  |       approximatePresenceCount: resp.approximate_presence_count, | ||||||
|  |       description: resp.description | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return result | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,3 +1,4 @@ | ||||||
|  | import { Emoji } from '../structures/emoji.ts' | ||||||
| import { CategoryChannel } from '../structures/guildCategoryChannel.ts' | import { CategoryChannel } from '../structures/guildCategoryChannel.ts' | ||||||
| import { VoiceChannel } from '../structures/guildVoiceChannel.ts' | import { VoiceChannel } from '../structures/guildVoiceChannel.ts' | ||||||
| import { GuildTextChannel } from '../structures/textChannel.ts' | import { GuildTextChannel } from '../structures/textChannel.ts' | ||||||
|  | @ -204,3 +205,29 @@ export interface GuildCreateChannelOptions { | ||||||
|   type: ChannelTypes |   type: ChannelTypes | ||||||
|   parentID?: string |   parentID?: string | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | export interface GuildPreviewPayload { | ||||||
|  |   id: string | ||||||
|  |   name: string | ||||||
|  |   icon: string | null | ||||||
|  |   splash: string | null | ||||||
|  |   discovery_splash: string | null | ||||||
|  |   emojis: EmojiPayload[] | ||||||
|  |   features: GuildFeatures[] | ||||||
|  |   approximate_member_count: number | ||||||
|  |   approximate_presence_count: number | ||||||
|  |   description: string | null | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface GuildPreview { | ||||||
|  |   id: string | ||||||
|  |   name: string | ||||||
|  |   icon: string | null | ||||||
|  |   splash: string | null | ||||||
|  |   discoverySplash: string | null | ||||||
|  |   emojis: Emoji[] | ||||||
|  |   features: GuildFeatures[] | ||||||
|  |   approximateMemberCount: number | ||||||
|  |   approximatePresenceCount: number | ||||||
|  |   description: string | null | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue