Merge pull request #87 from Helloyunho/guild-update
Add Missing Guild Implementations
This commit is contained in:
		
						commit
						8927939dea
					
				
					 19 changed files with 529 additions and 66 deletions
				
			
		
							
								
								
									
										4
									
								
								mod.ts
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								mod.ts
									
										
									
									
									
								
							|  | @ -30,7 +30,6 @@ export { ChannelsManager } from './src/managers/channels.ts' | ||||||
| export { EmojisManager } from './src/managers/emojis.ts' | export { EmojisManager } from './src/managers/emojis.ts' | ||||||
| export { GatewayCache } from './src/managers/gatewayCache.ts' | export { GatewayCache } from './src/managers/gatewayCache.ts' | ||||||
| export { GuildChannelsManager } from './src/managers/guildChannels.ts' | export { GuildChannelsManager } from './src/managers/guildChannels.ts' | ||||||
| export type { GuildChannel } from './src/managers/guildChannels.ts' |  | ||||||
| export { GuildManager } from './src/managers/guilds.ts' | export { GuildManager } from './src/managers/guilds.ts' | ||||||
| export * from './src/structures/slash.ts' | export * from './src/structures/slash.ts' | ||||||
| export * from './src/types/slash.ts' | export * from './src/types/slash.ts' | ||||||
|  | @ -104,7 +103,8 @@ export type { | ||||||
|   GuildBanPayload, |   GuildBanPayload, | ||||||
|   GuildFeatures, |   GuildFeatures, | ||||||
|   GuildIntegrationPayload, |   GuildIntegrationPayload, | ||||||
|   GuildPayload |   GuildPayload, | ||||||
|  |   GuildChannels | ||||||
| } from './src/types/guild.ts' | } from './src/types/guild.ts' | ||||||
| export type { InvitePayload, PartialInvitePayload } from './src/types/invite.ts' | export type { InvitePayload, PartialInvitePayload } from './src/types/invite.ts' | ||||||
| export { PermissionFlags } from './src/types/permissionFlags.ts' | export { PermissionFlags } from './src/types/permissionFlags.ts' | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ export const guildMemberRemove: GatewayEventHandler = async ( | ||||||
|   if (guild === undefined) return |   if (guild === undefined) return | ||||||
| 
 | 
 | ||||||
|   const member = await guild.members.get(d.user.id) |   const member = await guild.members.get(d.user.id) | ||||||
|   await guild.members.delete(d.user.id) |   await guild.members._delete(d.user.id) | ||||||
| 
 | 
 | ||||||
|   if (member !== undefined) gateway.client.emit('guildMemberRemove', member) |   if (member !== undefined) gateway.client.emit('guildMemberRemove', member) | ||||||
|   else { |   else { | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ export const messageDeleteBulk: GatewayEventHandler = async ( | ||||||
|     if (message === undefined) uncached.add(id) |     if (message === undefined) uncached.add(id) | ||||||
|     else { |     else { | ||||||
|       messages.set(id, message) |       messages.set(id, message) | ||||||
|       await channel.messages.delete(id) |       await channel.messages._delete(id) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ export const messageReactionRemove: GatewayEventHandler = async ( | ||||||
|   const reaction = await message.reactions.get(emojiID) |   const reaction = await message.reactions.get(emojiID) | ||||||
|   if (reaction === undefined) return |   if (reaction === undefined) return | ||||||
| 
 | 
 | ||||||
|   reaction.users.delete(d.user_id) |   reaction.users._delete(d.user_id) | ||||||
| 
 | 
 | ||||||
|   gateway.client.emit('messageReactionRemove', reaction, user) |   gateway.client.emit('messageReactionRemove', reaction, user) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ export const voiceStateUpdate: GatewayEventHandler = async ( | ||||||
|       return gateway.client.emit('voiceStateRemoveUncached', { guild, member }) |       return gateway.client.emit('voiceStateRemoveUncached', { guild, member }) | ||||||
|     } |     } | ||||||
|     // No longer in the channel, so delete
 |     // No longer in the channel, so delete
 | ||||||
|     await guild.voiceStates.delete(d.user_id) |     await guild.voiceStates._delete(d.user_id) | ||||||
|     gateway.client.emit( |     gateway.client.emit( | ||||||
|       'voiceStateRemove', |       'voiceStateRemove', | ||||||
|       (voiceState as unknown) as VoiceState |       (voiceState as unknown) as VoiceState | ||||||
|  |  | ||||||
|  | @ -41,11 +41,6 @@ export class BaseManager<T, T2> { | ||||||
|     return this.client.cache.delete(this.cacheName, key) |     return this.client.cache.delete(this.cacheName, key) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** Alias to _delete (cache) for compatibility purposes */ |  | ||||||
|   async delete(key: string): Promise<boolean> { |  | ||||||
|     return await this._delete(key) |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   /** Gets an Array of values from Cache */ |   /** Gets an Array of values from Cache */ | ||||||
|   async array(): Promise<T2[]> { |   async array(): Promise<T2[]> { | ||||||
|     let arr = await (this.client.cache.array(this.cacheName) as T[]) |     let arr = await (this.client.cache.array(this.cacheName) as T[]) | ||||||
|  |  | ||||||
|  | @ -2,26 +2,16 @@ import { Client } from '../models/client.ts' | ||||||
| import { Channel } from '../structures/channel.ts' | import { Channel } from '../structures/channel.ts' | ||||||
| import { Guild } from '../structures/guild.ts' | import { Guild } from '../structures/guild.ts' | ||||||
| import { CategoryChannel } from '../structures/guildCategoryChannel.ts' | import { CategoryChannel } from '../structures/guildCategoryChannel.ts' | ||||||
| import { GuildTextChannel } from '../structures/textChannel.ts' |  | ||||||
| import { VoiceChannel } from '../structures/guildVoiceChannel.ts' |  | ||||||
| import { | import { | ||||||
|   ChannelTypes, |   ChannelTypes, | ||||||
|   GuildCategoryChannelPayload, |  | ||||||
|   GuildChannelPayload, |   GuildChannelPayload, | ||||||
|   GuildTextChannelPayload, |  | ||||||
|   GuildVoiceChannelPayload, |  | ||||||
|   Overwrite |   Overwrite | ||||||
| } from '../types/channel.ts' | } from '../types/channel.ts' | ||||||
|  | import { GuildChannels, GuildChannelPayloads } from '../types/guild.ts' | ||||||
| import { CHANNEL, GUILD_CHANNELS } from '../types/endpoint.ts' | import { CHANNEL, GUILD_CHANNELS } from '../types/endpoint.ts' | ||||||
| import { BaseChildManager } from './baseChild.ts' | import { BaseChildManager } from './baseChild.ts' | ||||||
| import { ChannelsManager } from './channels.ts' | import { ChannelsManager } from './channels.ts' | ||||||
| 
 | 
 | ||||||
| export type GuildChannelPayloads = |  | ||||||
|   | GuildTextChannelPayload |  | ||||||
|   | GuildVoiceChannelPayload |  | ||||||
|   | GuildCategoryChannelPayload |  | ||||||
| export type GuildChannel = GuildTextChannel | VoiceChannel | CategoryChannel |  | ||||||
| 
 |  | ||||||
| export interface CreateChannelOptions { | export interface CreateChannelOptions { | ||||||
|   name: string |   name: string | ||||||
|   type?: ChannelTypes |   type?: ChannelTypes | ||||||
|  | @ -37,7 +27,7 @@ export interface CreateChannelOptions { | ||||||
| 
 | 
 | ||||||
| export class GuildChannelsManager extends BaseChildManager< | export class GuildChannelsManager extends BaseChildManager< | ||||||
|   GuildChannelPayloads, |   GuildChannelPayloads, | ||||||
|   GuildChannel |   GuildChannels | ||||||
| > { | > { | ||||||
|   guild: Guild |   guild: Guild | ||||||
| 
 | 
 | ||||||
|  | @ -46,7 +36,7 @@ export class GuildChannelsManager extends BaseChildManager< | ||||||
|     this.guild = guild |     this.guild = guild | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async get(id: string): Promise<GuildChannel | undefined> { |   async get(id: string): Promise<GuildChannels | undefined> { | ||||||
|     const res = await this.parent.get(id) |     const res = await this.parent.get(id) | ||||||
|     if (res !== undefined && res.guild.id === this.guild.id) return res |     if (res !== undefined && res.guild.id === this.guild.id) return res | ||||||
|     else return undefined |     else return undefined | ||||||
|  | @ -57,7 +47,7 @@ export class GuildChannelsManager extends BaseChildManager< | ||||||
|     return this.client.rest.delete(CHANNEL(id)) |     return this.client.rest.delete(CHANNEL(id)) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async array(): Promise<GuildChannel[]> { |   async array(): Promise<GuildChannels[]> { | ||||||
|     const arr = (await this.parent.array()) as Channel[] |     const arr = (await this.parent.array()) as Channel[] | ||||||
|     return arr.filter( |     return arr.filter( | ||||||
|       (c: any) => c.guild !== undefined && c.guild.id === this.guild.id |       (c: any) => c.guild !== undefined && c.guild.id === this.guild.id | ||||||
|  | @ -67,13 +57,13 @@ export class GuildChannelsManager extends BaseChildManager< | ||||||
|   async flush(): Promise<boolean> { |   async flush(): Promise<boolean> { | ||||||
|     const arr = await this.array() |     const arr = await this.array() | ||||||
|     for (const elem of arr) { |     for (const elem of arr) { | ||||||
|       this.parent.delete(elem.id) |       this.parent._delete(elem.id) | ||||||
|     } |     } | ||||||
|     return true |     return true | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** Create a new Guild Channel */ |   /** Create a new Guild Channel */ | ||||||
|   async create(options: CreateChannelOptions): Promise<GuildChannel> { |   async create(options: CreateChannelOptions): Promise<GuildChannels> { | ||||||
|     if (options.name === undefined) |     if (options.name === undefined) | ||||||
|       throw new Error('name is required for GuildChannelsManager#create') |       throw new Error('name is required for GuildChannelsManager#create') | ||||||
|     const res = ((await this.client.rest.post(GUILD_CHANNELS(this.guild.id)), |     const res = ((await this.client.rest.post(GUILD_CHANNELS(this.guild.id)), | ||||||
|  | @ -97,6 +87,6 @@ export class GuildChannelsManager extends BaseChildManager< | ||||||
| 
 | 
 | ||||||
|     await this.set(res.id, res) |     await this.set(res.id, res) | ||||||
|     const channel = await this.get(res.id) |     const channel = await this.get(res.id) | ||||||
|     return (channel as unknown) as GuildChannel |     return (channel as unknown) as GuildChannels | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -88,7 +88,7 @@ export class GuildEmojisManager extends BaseChildManager<EmojiPayload, Emoji> { | ||||||
|     const arr = await this.array() |     const arr = await this.array() | ||||||
|     for (const elem of arr) { |     for (const elem of arr) { | ||||||
|       const emojiID = elem.id !== null ? elem.id : elem.name |       const emojiID = elem.id !== null ? elem.id : elem.name | ||||||
|       this.parent.delete(emojiID as string) |       this.parent._delete(emojiID as string) | ||||||
|     } |     } | ||||||
|     return true |     return true | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | @ -1,9 +1,23 @@ | ||||||
| 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 { GUILD } from '../types/endpoint.ts' | import { Role } from '../structures/role.ts' | ||||||
| import { GuildPayload, MemberPayload } from '../types/guild.ts' | import { GUILD, GUILDS, GUILD_PREVIEW } from '../types/endpoint.ts' | ||||||
|  | import { | ||||||
|  |   GuildPayload, | ||||||
|  |   MemberPayload, | ||||||
|  |   GuildCreateRolePayload, | ||||||
|  |   GuildCreatePayload, | ||||||
|  |   GuildCreateChannelPayload, | ||||||
|  |   GuildPreview, | ||||||
|  |   GuildPreviewPayload, | ||||||
|  |   GuildModifyOptions, | ||||||
|  |   GuildModifyPayload, | ||||||
|  |   GuildCreateOptions | ||||||
|  | } 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 { Emoji } from '../structures/emoji.ts' | ||||||
| 
 | 
 | ||||||
| export class GuildManager extends BaseManager<GuildPayload, Guild> { | export class GuildManager extends BaseManager<GuildPayload, Guild> { | ||||||
|   constructor(client: Client) { |   constructor(client: Client) { | ||||||
|  | @ -32,4 +46,183 @@ export class GuildManager extends BaseManager<GuildPayload, Guild> { | ||||||
|         .catch((e) => reject(e)) |         .catch((e) => reject(e)) | ||||||
|     }) |     }) | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  |   /** | ||||||
|  |    * Creates a guild. Returns Guild. Fires guildCreate event. | ||||||
|  |    * @param options Options for creating a guild | ||||||
|  |    */ | ||||||
|  |   async create(options: GuildCreateOptions): Promise<Guild> { | ||||||
|  |     // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
 | ||||||
|  |     if (options.icon !== undefined && !options.icon.startsWith('data:')) { | ||||||
|  |       options.icon = await fetchAuto(options.icon) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const body: GuildCreatePayload = { | ||||||
|  |       name: options.name, | ||||||
|  |       region: options.region, | ||||||
|  |       icon: options.icon, | ||||||
|  |       verification_level: options.verificationLevel, | ||||||
|  |       roles: | ||||||
|  |         options.roles !== undefined | ||||||
|  |           ? options.roles.map((obj) => { | ||||||
|  |               let result: GuildCreateRolePayload | ||||||
|  |               if (obj instanceof Role) { | ||||||
|  |                 result = { | ||||||
|  |                   id: obj.id, | ||||||
|  |                   name: obj.name, | ||||||
|  |                   color: obj.color, | ||||||
|  |                   hoist: obj.hoist, | ||||||
|  |                   position: obj.position, | ||||||
|  |                   permissions: obj.permissions.bitfield.toString(), | ||||||
|  |                   managed: obj.managed, | ||||||
|  |                   mentionable: obj.mentionable | ||||||
|  |                 } | ||||||
|  |               } else { | ||||||
|  |                 result = obj | ||||||
|  |               } | ||||||
|  | 
 | ||||||
|  |               return result | ||||||
|  |             }) | ||||||
|  |           : undefined, | ||||||
|  |       channels: | ||||||
|  |         options.channels !== undefined | ||||||
|  |           ? options.channels.map( | ||||||
|  |               (obj): GuildCreateChannelPayload => ({ | ||||||
|  |                 id: obj.id, | ||||||
|  |                 name: obj.name, | ||||||
|  |                 type: obj.type, | ||||||
|  |                 parent_id: obj.parentID | ||||||
|  |               }) | ||||||
|  |             ) | ||||||
|  |           : undefined, | ||||||
|  |       afk_channel_id: options.afkChannelID, | ||||||
|  |       afk_timeout: options.afkTimeout, | ||||||
|  |       system_channel_id: options.systemChannelID | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const result: GuildPayload = await this.client.rest.post(GUILDS(), body) | ||||||
|  |     const guild = new Guild(this.client, result) | ||||||
|  | 
 | ||||||
|  |     return guild | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   /** | ||||||
|  |    * Gets a preview of a guild. Returns GuildPreview. | ||||||
|  |    * @param guildID Guild id | ||||||
|  |    */ | ||||||
|  |   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 | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   /** | ||||||
|  |    * Edits a guild. Returns edited guild. | ||||||
|  |    * @param guild Guild or guild id | ||||||
|  |    * @param options Guild edit options | ||||||
|  |    * @param asRaw true for get raw data, false for get guild(defaults to false) | ||||||
|  |    */ | ||||||
|  |   async edit( | ||||||
|  |     guild: Guild | string, | ||||||
|  |     options: GuildModifyOptions, | ||||||
|  |     asRaw: false | ||||||
|  |   ): Promise<Guild> | ||||||
|  |   async edit( | ||||||
|  |     guild: Guild | string, | ||||||
|  |     options: GuildModifyOptions, | ||||||
|  |     asRaw: true | ||||||
|  |   ): Promise<GuildPayload> | ||||||
|  |   async edit( | ||||||
|  |     guild: Guild | string, | ||||||
|  |     options: GuildModifyOptions, | ||||||
|  |     asRaw: boolean = false | ||||||
|  |   ): Promise<Guild | GuildPayload> { | ||||||
|  |     if ( | ||||||
|  |       options.icon !== undefined && | ||||||
|  |       options.icon !== null && | ||||||
|  |       // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
 | ||||||
|  |       !options.icon.startsWith('data:') | ||||||
|  |     ) { | ||||||
|  |       options.icon = await fetchAuto(options.icon) | ||||||
|  |     } | ||||||
|  |     if ( | ||||||
|  |       options.splash !== undefined && | ||||||
|  |       options.splash !== null && | ||||||
|  |       // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
 | ||||||
|  |       !options.splash.startsWith('data:') | ||||||
|  |     ) { | ||||||
|  |       options.splash = await fetchAuto(options.splash) | ||||||
|  |     } | ||||||
|  |     if ( | ||||||
|  |       options.banner !== undefined && | ||||||
|  |       options.banner !== null && | ||||||
|  |       // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
 | ||||||
|  |       !options.banner.startsWith('data:') | ||||||
|  |     ) { | ||||||
|  |       options.banner = await fetchAuto(options.banner) | ||||||
|  |     } | ||||||
|  |     if (guild instanceof Guild) { | ||||||
|  |       guild = guild.id | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const body: GuildModifyPayload = { | ||||||
|  |       name: options.name, | ||||||
|  |       region: options.region, | ||||||
|  |       verification_level: options.verificationLevel, | ||||||
|  |       default_message_notifications: options.defaultMessageNotifications, | ||||||
|  |       explicit_content_filter: options.explicitContentFilter, | ||||||
|  |       afk_channel_id: options.afkChannelID, | ||||||
|  |       afk_timeout: options.afkTimeout, | ||||||
|  |       owner_id: options.ownerID, | ||||||
|  |       icon: options.icon, | ||||||
|  |       splash: options.splash, | ||||||
|  |       banner: options.banner, | ||||||
|  |       system_channel_id: options.systemChannelID, | ||||||
|  |       rules_channel_id: options.rulesChannelID, | ||||||
|  |       public_updates_channel_id: options.publicUpdatesChannelID, | ||||||
|  |       preferred_locale: options.preferredLocale | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const result: GuildPayload = await this.client.rest.patch( | ||||||
|  |       GUILD(guild), | ||||||
|  |       body | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     if (asRaw) { | ||||||
|  |       const guild = new Guild(this.client, result) | ||||||
|  |       return guild | ||||||
|  |     } else { | ||||||
|  |       return result | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   /** | ||||||
|  |    * Deletes a guild. Returns deleted guild. | ||||||
|  |    * @param guild Guild or guild id | ||||||
|  |    */ | ||||||
|  |   async delete(guild: Guild | string): Promise<Guild | undefined> { | ||||||
|  |     if (guild instanceof Guild) { | ||||||
|  |       guild = guild.id | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const oldGuild = await this.get(guild) | ||||||
|  | 
 | ||||||
|  |     await this.client.rest.delete(GUILD(guild)) | ||||||
|  |     return oldGuild | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -42,7 +42,7 @@ export class MemberRolesManager extends BaseChildManager<RolePayload, Role> { | ||||||
|   async flush(): Promise<boolean> { |   async flush(): Promise<boolean> { | ||||||
|     const arr = await this.array() |     const arr = await this.array() | ||||||
|     for (const elem of arr) { |     for (const elem of arr) { | ||||||
|       this.parent.delete(elem.id) |       this.parent._delete(elem.id) | ||||||
|     } |     } | ||||||
|     return true |     return true | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ 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_ROLE, GUILD_ROLES } from '../types/endpoint.ts' | import { GUILD_ROLE, GUILD_ROLES } from '../types/endpoint.ts' | ||||||
| import { RolePayload } from '../types/role.ts' | import { RoleModifyPayload, RolePayload } from '../types/role.ts' | ||||||
| import { BaseManager } from './base.ts' | import { BaseManager } from './base.ts' | ||||||
| 
 | 
 | ||||||
| export interface CreateGuildRoleOptions { | export interface CreateGuildRoleOptions { | ||||||
|  | @ -35,6 +35,12 @@ export class RolesManager extends BaseManager<RolePayload, Role> { | ||||||
|     }) |     }) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   async get(key: string): Promise<Role | undefined> { | ||||||
|  |     const raw = await this._get(key) | ||||||
|  |     if (raw === undefined) return | ||||||
|  |     return new Role(this.client, raw, this.guild) | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   async fromPayload(roles: RolePayload[]): Promise<boolean> { |   async fromPayload(roles: RolePayload[]): Promise<boolean> { | ||||||
|     for (const role of roles) { |     for (const role of roles) { | ||||||
|       await this.set(role.id, role) |       await this.set(role.id, role) | ||||||
|  | @ -74,10 +80,25 @@ export class RolesManager extends BaseManager<RolePayload, Role> { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** Delete a Guild Role */ |   /** Delete a Guild Role */ | ||||||
|   async delete(role: Role | string): Promise<boolean> { |   async delete(role: Role | string): Promise<Role | undefined> { | ||||||
|  |     const oldRole = await this.get(typeof role === 'object' ? role.id : role) | ||||||
|  | 
 | ||||||
|     await this.client.rest.delete( |     await this.client.rest.delete( | ||||||
|       GUILD_ROLE(this.guild.id, typeof role === 'object' ? role.id : role) |       GUILD_ROLE(this.guild.id, typeof role === 'object' ? role.id : role) | ||||||
|     ) |     ) | ||||||
|     return true | 
 | ||||||
|  |     return oldRole | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   async edit(role: Role | string, options: RoleModifyPayload): Promise<Role> { | ||||||
|  |     if (role instanceof Role) { | ||||||
|  |       role = role.id | ||||||
|  |     } | ||||||
|  |     const resp: RolePayload = await this.client.rest.patch( | ||||||
|  |       GUILD_ROLE(this.guild.id, role), | ||||||
|  |       options | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     return new Role(this.client, resp, this.guild) | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -135,6 +135,7 @@ export class Collector extends EventEmitter { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** Returns a Promise resolved when Collector ends or a timeout occurs */ |   /** Returns a Promise resolved when Collector ends or a timeout occurs */ | ||||||
|  |   // eslint-disable-next-line
 | ||||||
|   async wait(timeout: number = this.timeout ?? 0): Promise<Collector> { |   async wait(timeout: number = this.timeout ?? 0): Promise<Collector> { | ||||||
|     return await new Promise((resolve, reject) => { |     return await new Promise((resolve, reject) => { | ||||||
|       // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
 |       // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
 | ||||||
|  |  | ||||||
|  | @ -5,14 +5,22 @@ import { | ||||||
|   GuildIntegrationPayload, |   GuildIntegrationPayload, | ||||||
|   GuildPayload, |   GuildPayload, | ||||||
|   IntegrationAccountPayload, |   IntegrationAccountPayload, | ||||||
|   IntegrationExpireBehavior |   IntegrationExpireBehavior, | ||||||
|  |   Verification, | ||||||
|  |   GuildChannels, | ||||||
|  |   GuildPreview, | ||||||
|  |   MessageNotification, | ||||||
|  |   ContentFilter, | ||||||
|  |   GuildModifyOptions, | ||||||
|  |   GuildGetPruneCountPayload, | ||||||
|  |   GuildPruneCountPayload, | ||||||
|  |   GuildBeginPrunePayload | ||||||
| } from '../types/guild.ts' | } from '../types/guild.ts' | ||||||
| import { Base } from './base.ts' | import { Base } from './base.ts' | ||||||
| import { CreateGuildRoleOptions, RolesManager } from '../managers/roles.ts' | import { CreateGuildRoleOptions, RolesManager } from '../managers/roles.ts' | ||||||
| import { InviteManager } from '../managers/invites.ts' | import { InviteManager } from '../managers/invites.ts' | ||||||
| import { | import { | ||||||
|   CreateChannelOptions, |   CreateChannelOptions, | ||||||
|   GuildChannel, |  | ||||||
|   GuildChannelsManager |   GuildChannelsManager | ||||||
| } from '../managers/guildChannels.ts' | } from '../managers/guildChannels.ts' | ||||||
| import { MembersManager } from '../managers/members.ts' | import { MembersManager } from '../managers/members.ts' | ||||||
|  | @ -21,7 +29,12 @@ import { GuildEmojisManager } from '../managers/guildEmojis.ts' | ||||||
| import { Member } from './member.ts' | import { Member } from './member.ts' | ||||||
| import { User } from './user.ts' | import { User } from './user.ts' | ||||||
| import { Application } from './application.ts' | import { Application } from './application.ts' | ||||||
| import { GUILD_BAN, GUILD_BANS, GUILD_INTEGRATIONS } from '../types/endpoint.ts' | import { | ||||||
|  |   GUILD_BAN, | ||||||
|  |   GUILD_BANS, | ||||||
|  |   GUILD_INTEGRATIONS, | ||||||
|  |   GUILD_PRUNE | ||||||
|  | } from '../types/endpoint.ts' | ||||||
| import { GuildVoiceStatesManager } from '../managers/guildVoiceStates.ts' | import { GuildVoiceStatesManager } from '../managers/guildVoiceStates.ts' | ||||||
| import { RequestMembersOptions } from '../gateway/index.ts' | import { RequestMembersOptions } from '../gateway/index.ts' | ||||||
| import { GuildPresencesManager } from '../managers/presences.ts' | import { GuildPresencesManager } from '../managers/presences.ts' | ||||||
|  | @ -131,9 +144,9 @@ export class Guild extends Base { | ||||||
|   afkTimeout?: number |   afkTimeout?: number | ||||||
|   widgetEnabled?: boolean |   widgetEnabled?: boolean | ||||||
|   widgetChannelID?: string |   widgetChannelID?: string | ||||||
|   verificationLevel?: string |   verificationLevel?: Verification | ||||||
|   defaultMessageNotifications?: string |   defaultMessageNotifications?: MessageNotification | ||||||
|   explicitContentFilter?: string |   explicitContentFilter?: ContentFilter | ||||||
|   roles: RolesManager |   roles: RolesManager | ||||||
|   emojis: GuildEmojisManager |   emojis: GuildEmojisManager | ||||||
|   invites: InviteManager |   invites: InviteManager | ||||||
|  | @ -264,7 +277,7 @@ export class Guild extends Base { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** Create a new Guild Channel */ |   /** Create a new Guild Channel */ | ||||||
|   async createChannel(options: CreateChannelOptions): Promise<GuildChannel> { |   async createChannel(options: CreateChannelOptions): Promise<GuildChannels> { | ||||||
|     return this.channels.create(options) |     return this.channels.create(options) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | @ -292,14 +305,14 @@ export class Guild extends Base { | ||||||
|         const listener = (guild: Guild): void => { |         const listener = (guild: Guild): void => { | ||||||
|           if (guild.id === this.id) { |           if (guild.id === this.id) { | ||||||
|             chunked = true |             chunked = true | ||||||
|             this.client.removeListener('guildMembersChunked', listener) |             this.client.off('guildMembersChunked', listener) | ||||||
|             resolve(this) |             resolve(this) | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|         this.client.on('guildMembersChunked', listener) |         this.client.on('guildMembersChunked', listener) | ||||||
|         setTimeout(() => { |         setTimeout(() => { | ||||||
|           if (!chunked) { |           if (!chunked) { | ||||||
|             this.client.removeListener('guildMembersChunked', listener) |             this.client.off('guildMembersChunked', listener) | ||||||
|           } |           } | ||||||
|         }, timeout) |         }, timeout) | ||||||
|       } |       } | ||||||
|  | @ -312,19 +325,96 @@ export class Guild extends Base { | ||||||
|    */ |    */ | ||||||
|   async awaitAvailability(timeout: number = 1000): Promise<Guild> { |   async awaitAvailability(timeout: number = 1000): Promise<Guild> { | ||||||
|     return await new Promise((resolve, reject) => { |     return await new Promise((resolve, reject) => { | ||||||
|       if(!this.unavailable) resolve(this); |       if (!this.unavailable) resolve(this) | ||||||
|       const listener = (guild: Guild): void => { |       const listener = (guild: Guild): void => { | ||||||
|         if (guild.id === this.id) { |         if (guild.id === this.id) { | ||||||
|           this.client.removeListener('guildLoaded', listener); |           this.client.removeListener('guildLoaded', listener) | ||||||
|           resolve(this); |           resolve(this) | ||||||
|         } |         } | ||||||
|       }; |       } | ||||||
|       this.client.on('guildLoaded', listener); |       this.client.on('guildLoaded', listener) | ||||||
|       setTimeout(() => { |       setTimeout(() => { | ||||||
|         this.client.removeListener('guildLoaded', listener); |         this.client.removeListener('guildLoaded', listener) | ||||||
|         reject(Error("Timeout. Guild didn't arrive in time.")); |         reject(Error("Timeout. Guild didn't arrive in time.")) | ||||||
|       }, timeout); |       }, timeout) | ||||||
|     }); |     }) | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   /** Gets a preview of the guild. Returns GuildPreview. */ | ||||||
|  |   async preview(): Promise<GuildPreview> { | ||||||
|  |     return this.client.guilds.preview(this.id) | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   /** | ||||||
|  |    * Edits the guild. | ||||||
|  |    * @param options Guild edit options | ||||||
|  |    */ | ||||||
|  |   async edit(options: GuildModifyOptions): Promise<Guild> { | ||||||
|  |     const result = await this.client.guilds.edit(this.id, options, true) | ||||||
|  |     this.readFromData(result) | ||||||
|  | 
 | ||||||
|  |     return new Guild(this.client, result) | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   /** Deletes the guild. */ | ||||||
|  |   async delete(): Promise<Guild> { | ||||||
|  |     const result = await this.client.guilds.delete(this.id) | ||||||
|  | 
 | ||||||
|  |     return result === undefined ? this : result | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   async getPruneCount(options?: { | ||||||
|  |     days?: number | ||||||
|  |     includeRoles?: Array<Role | string> | ||||||
|  |   }): Promise<number> { | ||||||
|  |     const query: GuildGetPruneCountPayload = { | ||||||
|  |       days: options?.days, | ||||||
|  |       include_roles: options?.includeRoles | ||||||
|  |         ?.map((role) => (role instanceof Role ? role.id : role)) | ||||||
|  |         .join(',') | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const result: GuildPruneCountPayload = await this.client.rest.get( | ||||||
|  |       // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
 | ||||||
|  |       GUILD_PRUNE(this.id) + | ||||||
|  |         '?' + | ||||||
|  |         Object.entries(query) | ||||||
|  |           .map(([key, value]) => `${key}=${value}`) | ||||||
|  |           .join('&') | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     return result.pruned as number | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   async prune(options?: { | ||||||
|  |     days?: number | ||||||
|  |     computePruneCount: true | undefined | ||||||
|  |     includeRoles?: Array<Role | string> | ||||||
|  |   }): Promise<number> | ||||||
|  |   async prune(options?: { | ||||||
|  |     days?: number | ||||||
|  |     computePruneCount: false | ||||||
|  |     includeRoles?: Array<Role | string> | ||||||
|  |   }): Promise<null> | ||||||
|  |   async prune(options?: { | ||||||
|  |     days?: number | ||||||
|  |     computePruneCount?: boolean | undefined | ||||||
|  |     includeRoles?: Array<Role | string> | ||||||
|  |   }): Promise<number | null> { | ||||||
|  |     const body: GuildBeginPrunePayload = { | ||||||
|  |       days: options?.days, | ||||||
|  |       compute_prune_count: options?.computePruneCount, | ||||||
|  |       include_roles: options?.includeRoles?.map((role) => | ||||||
|  |         role instanceof Role ? role.id : role | ||||||
|  |       ) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const result: GuildPruneCountPayload = await this.client.rest.post( | ||||||
|  |       GUILD_PRUNE(this.id), | ||||||
|  |       body | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     return result.pruned | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -151,10 +151,19 @@ export class Message extends Base { | ||||||
|     return this.client.rest.delete(CHANNEL_MESSAGE(this.channelID, this.id)) |     return this.client.rest.delete(CHANNEL_MESSAGE(this.channelID, this.id)) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   /** | ||||||
|  |    * Adds a reaction to the message. | ||||||
|  |    * @param emoji Emoji in string or object | ||||||
|  |    */ | ||||||
|   async addReaction(emoji: string | Emoji): Promise<void> { |   async addReaction(emoji: string | Emoji): Promise<void> { | ||||||
|     return this.channel.addReaction(this, emoji) |     return this.channel.addReaction(this, emoji) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   /** | ||||||
|  |    * Removes a reaction to the message. | ||||||
|  |    * @param emoji Emoji in string or object | ||||||
|  |    * @param user User or Member or user id | ||||||
|  |    */ | ||||||
|   async removeReaction( |   async removeReaction( | ||||||
|     emoji: string | Emoji, |     emoji: string | Emoji, | ||||||
|     user?: User | Member | string |     user?: User | Member | string | ||||||
|  |  | ||||||
|  | @ -1,10 +1,12 @@ | ||||||
| import { Client } from '../models/client.ts' | import { Client } from '../models/client.ts' | ||||||
| import { Base } from './base.ts' | import { Base } from './base.ts' | ||||||
| import { RolePayload } from '../types/role.ts' | import { RoleModifyPayload, RolePayload } from '../types/role.ts' | ||||||
| import { Permissions } from '../utils/permissions.ts' | import { Permissions } from '../utils/permissions.ts' | ||||||
|  | import { Guild } from './guild.ts' | ||||||
| 
 | 
 | ||||||
| export class Role extends Base { | export class Role extends Base { | ||||||
|   id: string |   id: string | ||||||
|  |   guild: Guild | ||||||
|   name: string |   name: string | ||||||
|   color: number |   color: number | ||||||
|   hoist: boolean |   hoist: boolean | ||||||
|  | @ -14,9 +16,10 @@ export class Role extends Base { | ||||||
|   mentionable: boolean |   mentionable: boolean | ||||||
|   tags?: RoleTags |   tags?: RoleTags | ||||||
| 
 | 
 | ||||||
|   constructor(client: Client, data: RolePayload) { |   constructor(client: Client, data: RolePayload, guild: Guild) { | ||||||
|     super(client, data) |     super(client, data) | ||||||
|     this.id = data.id |     this.id = data.id | ||||||
|  |     this.guild = guild | ||||||
|     this.name = data.name |     this.name = data.name | ||||||
|     this.color = data.color |     this.color = data.color | ||||||
|     this.hoist = data.hoist |     this.hoist = data.hoist | ||||||
|  | @ -46,6 +49,14 @@ export class Role extends Base { | ||||||
|     this.managed = data.managed ?? this.managed |     this.managed = data.managed ?? this.managed | ||||||
|     this.mentionable = data.mentionable ?? this.mentionable |     this.mentionable = data.mentionable ?? this.mentionable | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  |   async delete(): Promise<Role | undefined> { | ||||||
|  |     return this.guild.roles.delete(this) | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   async edit(options: RoleModifyPayload): Promise<Role> { | ||||||
|  |     return this.guild.roles.edit(this, options) | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface RoleTags { | export interface RoleTags { | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ import { | ||||||
|   Intents, |   Intents, | ||||||
|   CommandContext, |   CommandContext, | ||||||
|   Extension, |   Extension, | ||||||
|   GuildChannel |   GuildChannels | ||||||
| } from '../../mod.ts' | } from '../../mod.ts' | ||||||
| import { Invite } from '../structures/invite.ts' | import { Invite } from '../structures/invite.ts' | ||||||
| import { TOKEN } from './config.ts' | import { TOKEN } from './config.ts' | ||||||
|  | @ -80,7 +80,7 @@ client.on('inviteDeleteUncached', (invite: Invite) => { | ||||||
| client.on('commandError', console.error) | client.on('commandError', console.error) | ||||||
| 
 | 
 | ||||||
| class ChannelLog extends Extension { | class ChannelLog extends Extension { | ||||||
|   onChannelCreate(ext: Extension, channel: GuildChannel): void { |   onChannelCreate(ext: Extension, channel: GuildChannels): void { | ||||||
|     console.log(`Channel Created: ${channel.name}`) |     console.log(`Channel Created: ${channel.name}`) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | @ -111,8 +111,8 @@ client.on('messageDeleteBulk', (channel, messages, uncached) => { | ||||||
| 
 | 
 | ||||||
| client.on('channelUpdate', (before, after) => { | client.on('channelUpdate', (before, after) => { | ||||||
|   console.log( |   console.log( | ||||||
|     `Channel Update: ${(before as GuildChannel).name}, ${ |     `Channel Update: ${(before as GuildChannels).name}, ${ | ||||||
|       (after as GuildChannel).name |       (after as GuildChannels).name | ||||||
|     }` |     }` | ||||||
|   ) |   ) | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ import { | ||||||
|   Message, |   Message, | ||||||
|   Member, |   Member, | ||||||
|   Role, |   Role, | ||||||
|   GuildChannel, |   GuildChannels, | ||||||
|   Embed, |   Embed, | ||||||
|   Guild, |   Guild, | ||||||
|   EveryChannelTypes, |   EveryChannelTypes, | ||||||
|  | @ -88,7 +88,7 @@ client.on('messageCreate', async (msg: Message) => { | ||||||
|   } else if (msg.content === '!channels') { |   } else if (msg.content === '!channels') { | ||||||
|     const col = await msg.guild?.channels.array() |     const col = await msg.guild?.channels.array() | ||||||
|     const data = col |     const data = col | ||||||
|       ?.map((c: GuildChannel, i: number) => { |       ?.map((c: GuildChannels, i: number) => { | ||||||
|         return `${i + 1}. ${c.name}` |         return `${i + 1}. ${c.name}` | ||||||
|       }) |       }) | ||||||
|       .join('\n') as string |       .join('\n') as string | ||||||
|  |  | ||||||
|  | @ -1,5 +1,16 @@ | ||||||
|  | import { Emoji } from '../structures/emoji.ts' | ||||||
|  | import { CategoryChannel } from '../structures/guildCategoryChannel.ts' | ||||||
|  | import { VoiceChannel } from '../structures/guildVoiceChannel.ts' | ||||||
|  | import { Role } from '../structures/role.ts' | ||||||
|  | import { GuildTextChannel } from '../structures/textChannel.ts' | ||||||
| import { ApplicationPayload } from './application.ts' | import { ApplicationPayload } from './application.ts' | ||||||
| import { ChannelPayload } from './channel.ts' | import { | ||||||
|  |   ChannelPayload, | ||||||
|  |   ChannelTypes, | ||||||
|  |   GuildCategoryChannelPayload, | ||||||
|  |   GuildTextChannelPayload, | ||||||
|  |   GuildVoiceChannelPayload | ||||||
|  | } from './channel.ts' | ||||||
| import { EmojiPayload } from './emoji.ts' | import { EmojiPayload } from './emoji.ts' | ||||||
| import { PresenceUpdatePayload } from './gateway.ts' | import { PresenceUpdatePayload } from './gateway.ts' | ||||||
| import { RolePayload } from './role.ts' | import { RolePayload } from './role.ts' | ||||||
|  | @ -21,9 +32,9 @@ export interface GuildPayload { | ||||||
|   afk_timeout: number |   afk_timeout: number | ||||||
|   widget_enabled?: boolean |   widget_enabled?: boolean | ||||||
|   widget_channel_id?: string |   widget_channel_id?: string | ||||||
|   verification_level: string |   verification_level: Verification | ||||||
|   default_message_notifications: string |   default_message_notifications: MessageNotification | ||||||
|   explicit_content_filter: string |   explicit_content_filter: ContentFilter | ||||||
|   roles: RolePayload[] |   roles: RolePayload[] | ||||||
|   emojis: EmojiPayload[] |   emojis: EmojiPayload[] | ||||||
|   features: GuildFeatures[] |   features: GuildFeatures[] | ||||||
|  | @ -73,7 +84,7 @@ export enum MessageNotification { | ||||||
| export enum ContentFilter { | export enum ContentFilter { | ||||||
|   DISABLED = 0, |   DISABLED = 0, | ||||||
|   MEMBERS_WITHOUT_ROLES = 1, |   MEMBERS_WITHOUT_ROLES = 1, | ||||||
|   ALL_MEMBERS = 3 |   ALL_MEMBERS = 2 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export enum MFA { | export enum MFA { | ||||||
|  | @ -150,3 +161,137 @@ export interface GuildBanPayload { | ||||||
|   reason: string | null |   reason: string | null | ||||||
|   user: UserPayload |   user: UserPayload | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | export type GuildChannelPayloads = | ||||||
|  |   | GuildTextChannelPayload | ||||||
|  |   | GuildVoiceChannelPayload | ||||||
|  |   | GuildCategoryChannelPayload | ||||||
|  | export type GuildChannels = GuildTextChannel | VoiceChannel | CategoryChannel | ||||||
|  | 
 | ||||||
|  | export interface GuildCreatePayload { | ||||||
|  |   name: string | ||||||
|  |   region?: string | ||||||
|  |   icon?: string | ||||||
|  |   verification_level?: number | ||||||
|  |   default_message_notifications?: number | ||||||
|  |   explicit_content_filter?: number | ||||||
|  |   roles?: GuildCreateRolePayload[] | ||||||
|  |   channels?: GuildCreateChannelPayload[] | ||||||
|  |   afk_channel_id?: string | ||||||
|  |   afk_timeout?: number | ||||||
|  |   system_channel_id?: string | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface GuildCreateRolePayload { | ||||||
|  |   id?: string | ||||||
|  |   name: string | ||||||
|  |   color?: number | ||||||
|  |   hoist?: boolean | ||||||
|  |   position?: number | ||||||
|  |   permissions?: string | ||||||
|  |   managed?: boolean | ||||||
|  |   mentionable?: boolean | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface GuildCreateChannelPayload { | ||||||
|  |   id?: string | ||||||
|  |   name: string | ||||||
|  |   type: ChannelTypes | ||||||
|  |   parent_id?: string | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface GuildCreateChannelOptions { | ||||||
|  |   id?: string | ||||||
|  |   name: string | ||||||
|  |   type: ChannelTypes | ||||||
|  |   parentID?: string | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface GuildCreateOptions { | ||||||
|  |   name: string | ||||||
|  |   region?: string | ||||||
|  |   icon?: string | ||||||
|  |   verificationLevel?: Verification | ||||||
|  |   roles?: Array<Role | GuildCreateRolePayload> | ||||||
|  |   channels?: Array<GuildChannels | GuildCreateChannelOptions> | ||||||
|  |   afkChannelID?: string | ||||||
|  |   afkTimeout?: number | ||||||
|  |   systemChannelID?: 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 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface GuildModifyPayload { | ||||||
|  |   name?: string | ||||||
|  |   region?: string | null | ||||||
|  |   verification_level?: Verification | null | ||||||
|  |   default_message_notifications?: MessageNotification | null | ||||||
|  |   explicit_content_filter?: ContentFilter | null | ||||||
|  |   afk_channel_id?: string | null | ||||||
|  |   afk_timeout?: number | ||||||
|  |   icon?: string | null | ||||||
|  |   owner_id?: string | ||||||
|  |   splash?: string | null | ||||||
|  |   banner?: string | null | ||||||
|  |   system_channel_id?: string | null | ||||||
|  |   rules_channel_id?: string | null | ||||||
|  |   public_updates_channel_id?: string | null | ||||||
|  |   preferred_locale?: string | null | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface GuildModifyOptions { | ||||||
|  |   name?: string | ||||||
|  |   region?: string | null | ||||||
|  |   verificationLevel?: Verification | null | ||||||
|  |   defaultMessageNotifications?: MessageNotification | null | ||||||
|  |   explicitContentFilter?: ContentFilter | null | ||||||
|  |   afkChannelID?: string | null | ||||||
|  |   afkTimeout?: number | ||||||
|  |   icon?: string | null | ||||||
|  |   ownerID?: string | ||||||
|  |   splash?: string | null | ||||||
|  |   banner?: string | null | ||||||
|  |   systemChannelID?: string | null | ||||||
|  |   rulesChannelID?: string | null | ||||||
|  |   publicUpdatesChannelID?: string | null | ||||||
|  |   preferredLocale?: string | null | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface GuildPruneCountPayload { | ||||||
|  |   pruned: number | null | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface GuildGetPruneCountPayload { | ||||||
|  |   days?: number | ||||||
|  |   include_roles?: string | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface GuildBeginPrunePayload { | ||||||
|  |   days?: number | ||||||
|  |   compute_prune_count?: boolean | ||||||
|  |   include_roles?: string[] | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -18,3 +18,11 @@ export interface RoleTagsPayload { | ||||||
|   /** The id of the integration this role belongs to */ |   /** The id of the integration this role belongs to */ | ||||||
|   integration_id?: string |   integration_id?: string | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | export interface RoleModifyPayload { | ||||||
|  |   name?: string | null | ||||||
|  |   permissions?: string | null | ||||||
|  |   color?: number | null | ||||||
|  |   hoist?: boolean | null | ||||||
|  |   mentionable?: boolean | null | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue