diff --git a/mod.ts b/mod.ts index 34d688d..c62042f 100644 --- a/mod.ts +++ b/mod.ts @@ -30,7 +30,6 @@ export { ChannelsManager } from './src/managers/channels.ts' export { EmojisManager } from './src/managers/emojis.ts' export { GatewayCache } from './src/managers/gatewayCache.ts' export { GuildChannelsManager } from './src/managers/guildChannels.ts' -export type { GuildChannel } from './src/managers/guildChannels.ts' export { GuildManager } from './src/managers/guilds.ts' export * from './src/structures/slash.ts' export * from './src/types/slash.ts' @@ -104,7 +103,8 @@ export type { GuildBanPayload, GuildFeatures, GuildIntegrationPayload, - GuildPayload + GuildPayload, + GuildChannels } from './src/types/guild.ts' export type { InvitePayload, PartialInvitePayload } from './src/types/invite.ts' export { PermissionFlags } from './src/types/permissionFlags.ts' diff --git a/src/gateway/handlers/guildMemberRemove.ts b/src/gateway/handlers/guildMemberRemove.ts index f4b89cb..c4c574f 100644 --- a/src/gateway/handlers/guildMemberRemove.ts +++ b/src/gateway/handlers/guildMemberRemove.ts @@ -12,7 +12,7 @@ export const guildMemberRemove: GatewayEventHandler = async ( if (guild === undefined) return 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) else { diff --git a/src/gateway/handlers/messageDeleteBulk.ts b/src/gateway/handlers/messageDeleteBulk.ts index d914911..245b6e5 100644 --- a/src/gateway/handlers/messageDeleteBulk.ts +++ b/src/gateway/handlers/messageDeleteBulk.ts @@ -25,7 +25,7 @@ export const messageDeleteBulk: GatewayEventHandler = async ( if (message === undefined) uncached.add(id) else { messages.set(id, message) - await channel.messages.delete(id) + await channel.messages._delete(id) } } diff --git a/src/gateway/handlers/messageReactionRemove.ts b/src/gateway/handlers/messageReactionRemove.ts index 77ca7df..658a1ce 100644 --- a/src/gateway/handlers/messageReactionRemove.ts +++ b/src/gateway/handlers/messageReactionRemove.ts @@ -31,7 +31,7 @@ export const messageReactionRemove: GatewayEventHandler = async ( const reaction = await message.reactions.get(emojiID) if (reaction === undefined) return - reaction.users.delete(d.user_id) + reaction.users._delete(d.user_id) gateway.client.emit('messageReactionRemove', reaction, user) } diff --git a/src/gateway/handlers/voiceStateUpdate.ts b/src/gateway/handlers/voiceStateUpdate.ts index 8a537b5..d3e52be 100644 --- a/src/gateway/handlers/voiceStateUpdate.ts +++ b/src/gateway/handlers/voiceStateUpdate.ts @@ -24,7 +24,7 @@ export const voiceStateUpdate: GatewayEventHandler = async ( return gateway.client.emit('voiceStateRemoveUncached', { guild, member }) } // No longer in the channel, so delete - await guild.voiceStates.delete(d.user_id) + await guild.voiceStates._delete(d.user_id) gateway.client.emit( 'voiceStateRemove', (voiceState as unknown) as VoiceState diff --git a/src/managers/base.ts b/src/managers/base.ts index 9d5bd7e..e522d31 100644 --- a/src/managers/base.ts +++ b/src/managers/base.ts @@ -41,11 +41,6 @@ export class BaseManager { return this.client.cache.delete(this.cacheName, key) } - /** Alias to _delete (cache) for compatibility purposes */ - async delete(key: string): Promise { - return await this._delete(key) - } - /** Gets an Array of values from Cache */ async array(): Promise { let arr = await (this.client.cache.array(this.cacheName) as T[]) diff --git a/src/managers/guildChannels.ts b/src/managers/guildChannels.ts index 258e6d9..eac3f5c 100644 --- a/src/managers/guildChannels.ts +++ b/src/managers/guildChannels.ts @@ -2,26 +2,16 @@ import { Client } from '../models/client.ts' import { Channel } from '../structures/channel.ts' import { Guild } from '../structures/guild.ts' import { CategoryChannel } from '../structures/guildCategoryChannel.ts' -import { GuildTextChannel } from '../structures/textChannel.ts' -import { VoiceChannel } from '../structures/guildVoiceChannel.ts' import { ChannelTypes, - GuildCategoryChannelPayload, GuildChannelPayload, - GuildTextChannelPayload, - GuildVoiceChannelPayload, Overwrite } from '../types/channel.ts' +import { GuildChannels, GuildChannelPayloads } from '../types/guild.ts' import { CHANNEL, GUILD_CHANNELS } from '../types/endpoint.ts' import { BaseChildManager } from './baseChild.ts' import { ChannelsManager } from './channels.ts' -export type GuildChannelPayloads = - | GuildTextChannelPayload - | GuildVoiceChannelPayload - | GuildCategoryChannelPayload -export type GuildChannel = GuildTextChannel | VoiceChannel | CategoryChannel - export interface CreateChannelOptions { name: string type?: ChannelTypes @@ -37,7 +27,7 @@ export interface CreateChannelOptions { export class GuildChannelsManager extends BaseChildManager< GuildChannelPayloads, - GuildChannel + GuildChannels > { guild: Guild @@ -46,7 +36,7 @@ export class GuildChannelsManager extends BaseChildManager< this.guild = guild } - async get(id: string): Promise { + async get(id: string): Promise { const res = await this.parent.get(id) if (res !== undefined && res.guild.id === this.guild.id) return res else return undefined @@ -57,7 +47,7 @@ export class GuildChannelsManager extends BaseChildManager< return this.client.rest.delete(CHANNEL(id)) } - async array(): Promise { + async array(): Promise { const arr = (await this.parent.array()) as Channel[] return arr.filter( (c: any) => c.guild !== undefined && c.guild.id === this.guild.id @@ -67,13 +57,13 @@ export class GuildChannelsManager extends BaseChildManager< async flush(): Promise { const arr = await this.array() for (const elem of arr) { - this.parent.delete(elem.id) + this.parent._delete(elem.id) } return true } /** Create a new Guild Channel */ - async create(options: CreateChannelOptions): Promise { + async create(options: CreateChannelOptions): Promise { if (options.name === undefined) throw new Error('name is required for GuildChannelsManager#create') const res = ((await this.client.rest.post(GUILD_CHANNELS(this.guild.id)), @@ -97,7 +87,7 @@ export class GuildChannelsManager extends BaseChildManager< await this.set(res.id, res) const channel = await this.get(res.id) - return (channel as unknown) as GuildChannel + return (channel as unknown) as GuildChannels } /** Modify the positions of a set of channel positions for the guild. */ diff --git a/src/managers/guildEmojis.ts b/src/managers/guildEmojis.ts index bab24c9..cac97eb 100644 --- a/src/managers/guildEmojis.ts +++ b/src/managers/guildEmojis.ts @@ -88,7 +88,7 @@ export class GuildEmojisManager extends BaseChildManager { const arr = await this.array() for (const elem of arr) { const emojiID = elem.id !== null ? elem.id : elem.name - this.parent.delete(emojiID as string) + this.parent._delete(emojiID as string) } return true } diff --git a/src/managers/guilds.ts b/src/managers/guilds.ts index c2c7970..dbff09e 100644 --- a/src/managers/guilds.ts +++ b/src/managers/guilds.ts @@ -2,10 +2,24 @@ import { fetchAuto } from '../../deps.ts' import { Client } from '../models/client.ts' import { Guild } from '../structures/guild.ts' import { Template } from '../structures/template.ts' -import { GUILD } from '../types/endpoint.ts' -import { GuildPayload, MemberPayload } from '../types/guild.ts' +import { Role } from '../structures/role.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 { MembersManager } from './members.ts' +import { fetchAuto } from '../../deps.ts' +import { Emoji } from '../structures/emoji.ts' export class GuildManager extends BaseManager { constructor(client: Client) { @@ -46,5 +60,183 @@ export class GuildManager extends BaseManager { typeof template === 'object' ? template.code : template ].post({ name, icon }) return new Guild(this.client, guild) + + /** + * Creates a guild. Returns Guild. Fires guildCreate event. + * @param options Options for creating a guild + */ + async create(options: GuildCreateOptions): Promise { + // 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 { + 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 + async edit( + guild: Guild | string, + options: GuildModifyOptions, + asRaw: true + ): Promise + async edit( + guild: Guild | string, + options: GuildModifyOptions, + asRaw: boolean = false + ): Promise { + 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 { + if (guild instanceof Guild) { + guild = guild.id + } + + const oldGuild = await this.get(guild) + + await this.client.rest.delete(GUILD(guild)) + return oldGuild } } diff --git a/src/managers/memberRoles.ts b/src/managers/memberRoles.ts index a405340..7c43920 100644 --- a/src/managers/memberRoles.ts +++ b/src/managers/memberRoles.ts @@ -42,7 +42,7 @@ export class MemberRolesManager extends BaseChildManager { async flush(): Promise { const arr = await this.array() for (const elem of arr) { - this.parent.delete(elem.id) + this.parent._delete(elem.id) } return true } diff --git a/src/managers/roles.ts b/src/managers/roles.ts index aaa5995..c1b371e 100644 --- a/src/managers/roles.ts +++ b/src/managers/roles.ts @@ -3,7 +3,7 @@ import { Client } from '../models/client.ts' import { Guild } from '../structures/guild.ts' import { Role } from '../structures/role.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' export interface CreateGuildRoleOptions { @@ -35,6 +35,12 @@ export class RolesManager extends BaseManager { }) } + async get(key: string): Promise { + const raw = await this._get(key) + if (raw === undefined) return + return new Role(this.client, raw, this.guild) + } + async fromPayload(roles: RolePayload[]): Promise { for (const role of roles) { await this.set(role.id, role) @@ -74,11 +80,26 @@ export class RolesManager extends BaseManager { } /** Delete a Guild Role */ - async delete(role: Role | string): Promise { + async delete(role: Role | string): Promise { + const oldRole = await this.get(typeof role === 'object' ? role.id : role) + await this.client.rest.delete( GUILD_ROLE(this.guild.id, typeof role === 'object' ? role.id : role) ) - return true + + return oldRole + } + + async edit(role: Role | string, options: RoleModifyPayload): Promise { + 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) } /** Modify the positions of a set of role positions for the guild. */ diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 263ae57..333d5fc 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -6,14 +6,22 @@ import { GuildPayload, GuildWidgetPayload, IntegrationAccountPayload, - IntegrationExpireBehavior + IntegrationExpireBehavior, + Verification, + GuildChannels, + GuildPreview, + MessageNotification, + ContentFilter, + GuildModifyOptions, + GuildGetPruneCountPayload, + GuildPruneCountPayload, + GuildBeginPrunePayload } from '../types/guild.ts' import { Base } from './base.ts' import { CreateGuildRoleOptions, RolesManager } from '../managers/roles.ts' import { InviteManager } from '../managers/invites.ts' import { CreateChannelOptions, - GuildChannel, GuildChannelsManager } from '../managers/guildChannels.ts' import { MembersManager } from '../managers/members.ts' @@ -22,7 +30,12 @@ import { GuildEmojisManager } from '../managers/guildEmojis.ts' import { Member } from './member.ts' import { User } from './user.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 { RequestMembersOptions } from '../gateway/index.ts' import { GuildPresencesManager } from '../managers/presences.ts' @@ -134,9 +147,9 @@ export class Guild extends Base { afkTimeout?: number widgetEnabled?: boolean widgetChannelID?: string - verificationLevel?: string - defaultMessageNotifications?: string - explicitContentFilter?: string + verificationLevel?: Verification + defaultMessageNotifications?: MessageNotification + explicitContentFilter?: ContentFilter roles: RolesManager emojis: GuildEmojisManager invites: InviteManager @@ -267,7 +280,7 @@ export class Guild extends Base { } /** Create a new Guild Channel */ - async createChannel(options: CreateChannelOptions): Promise { + async createChannel(options: CreateChannelOptions): Promise { return this.channels.create(options) } @@ -447,6 +460,82 @@ export class Guild extends Base { async deleteTemplate(code: string): Promise { await this.client.rest.api.guilds[this.id].templates[code].delete() return this + + /** Gets a preview of the guild. Returns GuildPreview. */ + async preview(): Promise { + return this.client.guilds.preview(this.id) + } + + /** + * Edits the guild. + * @param options Guild edit options + */ + async edit(options: GuildModifyOptions): Promise { + 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 { + const result = await this.client.guilds.delete(this.id) + + return result === undefined ? this : result + } + + async getPruneCount(options?: { + days?: number + includeRoles?: Array + }): Promise { + 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 + }): Promise + async prune(options?: { + days?: number + computePruneCount: false + includeRoles?: Array + }): Promise + async prune(options?: { + days?: number + computePruneCount?: boolean | undefined + includeRoles?: Array + }): Promise { + 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 } } diff --git a/src/structures/message.ts b/src/structures/message.ts index 920994a..5cdbf75 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -151,10 +151,19 @@ export class Message extends Base { 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 { 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( emoji: string | Emoji, user?: User | Member | string diff --git a/src/structures/role.ts b/src/structures/role.ts index ed2e821..91050aa 100644 --- a/src/structures/role.ts +++ b/src/structures/role.ts @@ -1,10 +1,12 @@ import { Client } from '../models/client.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 { Guild } from './guild.ts' export class Role extends Base { id: string + guild: Guild name: string color: number hoist: boolean @@ -14,9 +16,10 @@ export class Role extends Base { mentionable: boolean tags?: RoleTags - constructor(client: Client, data: RolePayload) { + constructor(client: Client, data: RolePayload, guild: Guild) { super(client, data) this.id = data.id + this.guild = guild this.name = data.name this.color = data.color this.hoist = data.hoist @@ -46,6 +49,14 @@ export class Role extends Base { this.managed = data.managed ?? this.managed this.mentionable = data.mentionable ?? this.mentionable } + + async delete(): Promise { + return this.guild.roles.delete(this) + } + + async edit(options: RoleModifyPayload): Promise { + return this.guild.roles.edit(this, options) + } } export interface RoleTags { diff --git a/src/test/cmd.ts b/src/test/cmd.ts index 75050eb..db58ca4 100644 --- a/src/test/cmd.ts +++ b/src/test/cmd.ts @@ -4,7 +4,7 @@ import { Intents, CommandContext, Extension, - GuildChannel + GuildChannels } from '../../mod.ts' import { Invite } from '../structures/invite.ts' import { TOKEN } from './config.ts' @@ -80,7 +80,7 @@ client.on('inviteDeleteUncached', (invite: Invite) => { client.on('commandError', console.error) class ChannelLog extends Extension { - onChannelCreate(ext: Extension, channel: GuildChannel): void { + onChannelCreate(ext: Extension, channel: GuildChannels): void { console.log(`Channel Created: ${channel.name}`) } @@ -111,8 +111,8 @@ client.on('messageDeleteBulk', (channel, messages, uncached) => { client.on('channelUpdate', (before, after) => { console.log( - `Channel Update: ${(before as GuildChannel).name}, ${ - (after as GuildChannel).name + `Channel Update: ${(before as GuildChannels).name}, ${ + (after as GuildChannels).name }` ) }) diff --git a/src/test/index.ts b/src/test/index.ts index 9a72fd0..7d7dd83 100644 --- a/src/test/index.ts +++ b/src/test/index.ts @@ -4,7 +4,7 @@ import { Message, Member, Role, - GuildChannel, + GuildChannels, Embed, Guild, EveryChannelTypes, @@ -88,7 +88,7 @@ client.on('messageCreate', async (msg: Message) => { } else if (msg.content === '!channels') { const col = await msg.guild?.channels.array() const data = col - ?.map((c: GuildChannel, i: number) => { + ?.map((c: GuildChannels, i: number) => { return `${i + 1}. ${c.name}` }) .join('\n') as string diff --git a/src/types/guild.ts b/src/types/guild.ts index 78d6940..f10fce7 100644 --- a/src/types/guild.ts +++ b/src/types/guild.ts @@ -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 { ChannelPayload } from './channel.ts' +import { + ChannelPayload, + ChannelTypes, + GuildCategoryChannelPayload, + GuildTextChannelPayload, + GuildVoiceChannelPayload +} from './channel.ts' import { EmojiPayload } from './emoji.ts' import { PresenceUpdatePayload } from './gateway.ts' import { RolePayload } from './role.ts' @@ -21,9 +32,9 @@ export interface GuildPayload { afk_timeout: number widget_enabled?: boolean widget_channel_id?: string - verification_level: string - default_message_notifications: string - explicit_content_filter: string + verification_level: Verification + default_message_notifications: MessageNotification + explicit_content_filter: ContentFilter roles: RolePayload[] emojis: EmojiPayload[] features: GuildFeatures[] @@ -73,7 +84,7 @@ export enum MessageNotification { export enum ContentFilter { DISABLED = 0, MEMBERS_WITHOUT_ROLES = 1, - ALL_MEMBERS = 3 + ALL_MEMBERS = 2 } export enum MFA { @@ -158,4 +169,137 @@ export interface GuildWidgetPayload { channels: Array<{ id: string; name: string; position: number }> members: MemberPayload[] presence_count: number + +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 + channels?: Array + 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[] } diff --git a/src/types/role.ts b/src/types/role.ts index 5ddfee8..72cea94 100644 --- a/src/types/role.ts +++ b/src/types/role.ts @@ -18,3 +18,11 @@ export interface RoleTagsPayload { /** The id of the integration this role belongs to */ integration_id?: string } + +export interface RoleModifyPayload { + name?: string | null + permissions?: string | null + color?: number | null + hoist?: boolean | null + mentionable?: boolean | null +}