feat(integrations|application): implementation

This commit is contained in:
DjDeveloperr 2020-11-25 18:11:51 +05:30
parent 6e87aa2e83
commit c1bce28334
6 changed files with 518 additions and 395 deletions

124
mod.ts
View File

@ -1,57 +1,67 @@
export * from './src/gateway/index.ts' export * from './src/gateway/index.ts'
export * from './src/models/client.ts' export * from './src/models/client.ts'
export * from './src/models/rest.ts' export * from './src/models/rest.ts'
export * from './src/models/cacheAdapter.ts' export * from './src/models/cacheAdapter.ts'
export * from './src/models/shard.ts' export * from './src/models/shard.ts'
export * from './src/models/command.ts' export * from './src/models/command.ts'
export * from './src/models/commandClient.ts' export * from './src/models/extensions.ts'
export * from './src/managers/base.ts' export * from './src/models/commandClient.ts'
export * from './src/managers/baseChild.ts' export * from './src/managers/base.ts'
export * from './src/managers/channels.ts' export * from './src/managers/baseChild.ts'
export * from './src/managers/emojis.ts' export * from './src/managers/channels.ts'
export * from './src/managers/gatewayCache.ts' export * from './src/managers/emojis.ts'
export * from './src/managers/guildChannels.ts' export * from './src/managers/gatewayCache.ts'
export * from './src/managers/guilds.ts' export * from './src/managers/guildChannels.ts'
export * from './src/managers/members.ts' export * from './src/managers/guilds.ts'
export * from './src/managers/messages.ts' export * from './src/managers/guildChannels.ts'
export * from './src/managers/roles.ts' export * from './src/managers/guildEmojis.ts'
export * from './src/managers/users.ts' export * from './src/managers/members.ts'
export * from './src/structures/base.ts' export * from './src/managers/messages.ts'
export * from './src/structures/cdn.ts' export * from './src/managers/roles.ts'
export * from './src/structures/channel.ts' export * from './src/managers/users.ts'
export * from './src/structures/dmChannel.ts' export * from './src/structures/application.ts'
export * from './src/structures/embed.ts' export * from './src/structures/base.ts'
export * from './src/structures/emoji.ts' export * from './src/structures/cdn.ts'
export * from './src/structures/groupChannel.ts' export * from './src/structures/channel.ts'
export * from './src/structures/guild.ts' export * from './src/structures/dmChannel.ts'
export * from './src/structures/guildCategoryChannel.ts' export * from './src/structures/embed.ts'
export * from './src/structures/guildNewsChannel.ts' export * from './src/structures/emoji.ts'
export * from './src/structures/guildVoiceChannel.ts' export * from './src/structures/groupChannel.ts'
export * from './src/structures/invite.ts' export * from './src/structures/guild.ts'
export * from './src/structures/member.ts' export * from './src/structures/guildCategoryChannel.ts'
export * from './src/structures/message.ts' export * from './src/structures/guildNewsChannel.ts'
export * from './src/structures/messageMentions.ts' export * from './src/structures/guildVoiceChannel.ts'
export * from './src/structures/presence.ts' export * from './src/structures/invite.ts'
export * from './src/structures/role.ts' export * from './src/structures/member.ts'
export * from './src/structures/snowflake.ts' export * from './src/structures/message.ts'
export * from './src/structures/textChannel.ts' export * from './src/structures/messageMentions.ts'
export * from './src/structures/user.ts' export * from './src/structures/presence.ts'
export * from './src/structures/webhook.ts' export * from './src/structures/role.ts'
export * from './src/types/cdn.ts' export * from './src/structures/snowflake.ts'
export * from './src/types/channel.ts' export * from './src/structures/textChannel.ts'
export * from './src/types/emoji.ts' export * from './src/structures/user.ts'
export * from './src/types/endpoint.ts' export * from './src/structures/webhook.ts'
export * from './src/types/gateway.ts' export * from './src/types/application.ts'
export * from './src/types/gatewayBot.ts' export * from './src/types/cdn.ts'
export * from './src/types/gatewayResponse.ts' export * from './src/types/channel.ts'
export * from './src/types/guild.ts' export * from './src/types/emoji.ts'
export * from './src/types/invite.ts' export * from './src/types/endpoint.ts'
export * from './src/types/permissionFlags.ts' export * from './src/types/gateway.ts'
export * from './src/types/presence.ts' export * from './src/types/gatewayBot.ts'
export * from './src/types/role.ts' export * from './src/types/gatewayResponse.ts'
export * from './src/types/template.ts' export * from './src/types/guild.ts'
export * from './src/types/user.ts' export * from './src/types/invite.ts'
export * from './src/types/voice.ts' export * from './src/types/permissionFlags.ts'
export * from './src/types/webhook.ts' export * from './src/types/presence.ts'
export * from './src/utils/collection.ts' export * from './src/types/role.ts'
export * from './src/utils/intents.ts' export * from './src/types/template.ts'
export * from './src/types/user.ts'
export * from './src/types/voice.ts'
export * from './src/types/webhook.ts'
export * from './src/utils/collection.ts'
export * from './src/utils/intents.ts'
export * from './src/utils/buildInfo.ts'
export * from './src/utils/permissions.ts'
export * from './src/utils/userFlags.ts'
export * from './src/utils/bitfield.ts'
export * from './src/utils/getChannelByType.ts'

View File

@ -12,6 +12,7 @@ import {
} from '../structures/presence.ts' } from '../structures/presence.ts'
import { EmojisManager } from '../managers/emojis.ts' import { EmojisManager } from '../managers/emojis.ts'
import { ActivityGame, ClientActivity } from "../types/presence.ts" import { ActivityGame, ClientActivity } from "../types/presence.ts"
// import { Application } from "../../mod.ts"
/** Some Client Options to modify behaviour */ /** Some Client Options to modify behaviour */
export interface ClientOptions { export interface ClientOptions {
@ -103,6 +104,9 @@ export class Client extends EventEmitter {
this.emit('debug', `[${tag}] ${msg}`) this.emit('debug', `[${tag}] ${msg}`)
} }
// TODO(DjDeveloperr): Implement this
// fetchApplication(): Promise<Application>
/** /**
* This function is used for connect to discord. * This function is used for connect to discord.
* @param token Your token. This is required. * @param token Your token. This is required.

View File

@ -0,0 +1,24 @@
import { Client } from "../models/client.ts";
import { ApplicationPayload } from "../types/application.ts";
import { Base } from "./base.ts";
import { User } from "./user.ts";
export class Application extends Base {
id: string
name: string
icon: string
description: string
summary: string
bot?: User
constructor(client: Client, data: ApplicationPayload) {
super(client, data)
this.id = data.id
this.name = data.name
this.icon = data.icon
this.description = data.description
this.summary = data.summary
this.bot = data.bot !== undefined ? new User(client, data.bot) : undefined
}
}

View File

@ -1,224 +1,270 @@
import { Client } from '../models/client.ts' import { Client } from '../models/client.ts'
import { GuildFeatures, GuildPayload } from '../types/guild.ts' import { GuildFeatures, GuildIntegrationPayload, GuildPayload, IntegrationAccountPayload, IntegrationExpireBehavior } from '../types/guild.ts'
import { PresenceUpdatePayload } from '../types/gateway.ts' import { PresenceUpdatePayload } from '../types/gateway.ts'
import { Base } from './base.ts' import { Base } from './base.ts'
import { VoiceState } from './voiceState.ts' import { VoiceState } from './voiceState.ts'
import { RolesManager } from '../managers/roles.ts' import { RolesManager } from '../managers/roles.ts'
import { GuildChannelsManager } from '../managers/guildChannels.ts' import { GuildChannelsManager } from '../managers/guildChannels.ts'
import { MembersManager } from '../managers/members.ts' import { MembersManager } from '../managers/members.ts'
import { Role } from './role.ts' import { Role } from './role.ts'
import { GuildEmojisManager } from '../managers/guildEmojis.ts' import { GuildEmojisManager } from '../managers/guildEmojis.ts'
import { Member } from "./member.ts" import { Member } from "./member.ts"
import { User } from "./user.ts"
export class Guild extends Base { import { Application } from "./application.ts"
id: string import { GUILD_INTEGRATIONS } from "../types/endpoint.ts"
name?: string
icon?: string export class Guild extends Base {
iconHash?: string id: string
splash?: string name?: string
discoverySplash?: string icon?: string
owner?: boolean iconHash?: string
ownerID?: string splash?: string
permissions?: string discoverySplash?: string
region?: string owner?: boolean
afkChannelID?: string ownerID?: string
afkTimeout?: number permissions?: string
widgetEnabled?: boolean region?: string
widgetChannelID?: string afkChannelID?: string
verificationLevel?: string afkTimeout?: number
defaultMessageNotifications?: string widgetEnabled?: boolean
explicitContentFilter?: string widgetChannelID?: string
roles: RolesManager verificationLevel?: string
emojis: GuildEmojisManager defaultMessageNotifications?: string
features?: GuildFeatures[] explicitContentFilter?: string
mfaLevel?: string roles: RolesManager
applicationID?: string emojis: GuildEmojisManager
systemChannelID?: string features?: GuildFeatures[]
systemChannelFlags?: string mfaLevel?: string
rulesChannelID?: string applicationID?: string
joinedAt?: string systemChannelID?: string
large?: boolean systemChannelFlags?: string
unavailable: boolean rulesChannelID?: string
memberCount?: number joinedAt?: string
voiceStates?: VoiceState[] large?: boolean
members: MembersManager unavailable: boolean
channels: GuildChannelsManager memberCount?: number
presences?: PresenceUpdatePayload[] voiceStates?: VoiceState[]
maxPresences?: number members: MembersManager
maxMembers?: number channels: GuildChannelsManager
vanityURLCode?: string presences?: PresenceUpdatePayload[]
description?: string maxPresences?: number
banner?: string maxMembers?: number
premiumTier?: number vanityURLCode?: string
premiumSubscriptionCount?: number description?: string
preferredLocale?: string banner?: string
publicUpdatesChannelID?: string premiumTier?: number
maxVideoChannelUsers?: number premiumSubscriptionCount?: number
approximateNumberCount?: number preferredLocale?: string
approximatePresenceCount?: number publicUpdatesChannelID?: string
maxVideoChannelUsers?: number
constructor (client: Client, data: GuildPayload) { approximateNumberCount?: number
super(client, data) approximatePresenceCount?: number
this.id = data.id
this.unavailable = data.unavailable constructor (client: Client, data: GuildPayload) {
this.members = new MembersManager(this.client, this) super(client, data)
this.channels = new GuildChannelsManager( this.id = data.id
this.client, this.unavailable = data.unavailable
this.client.channels, this.members = new MembersManager(this.client, this)
this this.channels = new GuildChannelsManager(
) this.client,
this.roles = new RolesManager(this.client, this) this.client.channels,
this.emojis = new GuildEmojisManager(this.client, this.client.emojis, this) this
)
if (!this.unavailable) { this.roles = new RolesManager(this.client, this)
this.name = data.name this.emojis = new GuildEmojisManager(this.client, this.client.emojis, this)
this.icon = data.icon
this.iconHash = data.icon_hash if (!this.unavailable) {
this.splash = data.splash this.name = data.name
this.discoverySplash = data.discovery_splash this.icon = data.icon
this.owner = data.owner this.iconHash = data.icon_hash
this.ownerID = data.owner_id this.splash = data.splash
this.permissions = data.permissions this.discoverySplash = data.discovery_splash
this.region = data.region this.owner = data.owner
this.afkTimeout = data.afk_timeout this.ownerID = data.owner_id
this.afkChannelID = data.afk_channel_id this.permissions = data.permissions
this.widgetEnabled = data.widget_enabled this.region = data.region
this.widgetChannelID = data.widget_channel_id this.afkTimeout = data.afk_timeout
this.verificationLevel = data.verification_level this.afkChannelID = data.afk_channel_id
this.defaultMessageNotifications = data.default_message_notifications this.widgetEnabled = data.widget_enabled
this.explicitContentFilter = data.explicit_content_filter this.widgetChannelID = data.widget_channel_id
// this.roles = data.roles.map( this.verificationLevel = data.verification_level
// v => cache.get('role', v.id) ?? new Role(client, v) this.defaultMessageNotifications = data.default_message_notifications
// ) this.explicitContentFilter = data.explicit_content_filter
// data.roles.forEach(role => { // this.roles = data.roles.map(
// this.roles.set(role.id, new Role(client, role)) // v => cache.get('role', v.id) ?? new Role(client, v)
// }) // )
// this.emojis = data.emojis.map( // data.roles.forEach(role => {
// v => cache.get('emoji', v.id) ?? new Emoji(client, v) // this.roles.set(role.id, new Role(client, role))
// ) // })
this.features = data.features // this.emojis = data.emojis.map(
this.mfaLevel = data.mfa_level // v => cache.get('emoji', v.id) ?? new Emoji(client, v)
this.systemChannelID = data.system_channel_id // )
this.systemChannelFlags = data.system_channel_flags this.features = data.features
this.rulesChannelID = data.rules_channel_id this.mfaLevel = data.mfa_level
this.joinedAt = data.joined_at this.systemChannelID = data.system_channel_id
this.large = data.large this.systemChannelFlags = data.system_channel_flags
this.memberCount = data.member_count this.rulesChannelID = data.rules_channel_id
// TODO: Cache in Gateway Event code this.joinedAt = data.joined_at
// this.voiceStates = data.voice_states?.map( this.large = data.large
// v => this.memberCount = data.member_count
// cache.get('voiceState', `${v.guild_id}:${v.user_id}`) ?? // TODO: Cache in Gateway Event code
// new VoiceState(client, v) // this.voiceStates = data.voice_states?.map(
// ) // v =>
// this.members = data.members?.map( // cache.get('voiceState', `${v.guild_id}:${v.user_id}`) ??
// v => // new VoiceState(client, v)
// cache.get('member', `${this.id}:${v.user.id}`) ?? // )
// new Member(client, v) // this.members = data.members?.map(
// ) // v =>
// this.channels = data.channels?.map( // cache.get('member', `${this.id}:${v.user.id}`) ??
// v => cache.get('channel', v.id) ?? getChannelByType(this.client, v) // new Member(client, v)
// ) // )
this.presences = data.presences // this.channels = data.channels?.map(
this.maxPresences = data.max_presences // v => cache.get('channel', v.id) ?? getChannelByType(this.client, v)
this.maxMembers = data.max_members // )
this.vanityURLCode = data.vanity_url_code this.presences = data.presences
this.description = data.description this.maxPresences = data.max_presences
this.banner = data.banner this.maxMembers = data.max_members
this.premiumTier = data.premium_tier this.vanityURLCode = data.vanity_url_code
this.premiumSubscriptionCount = data.premium_subscription_count this.description = data.description
this.preferredLocale = data.preferred_locale this.banner = data.banner
this.publicUpdatesChannelID = data.public_updates_channel_id this.premiumTier = data.premium_tier
this.maxVideoChannelUsers = data.max_video_channel_users this.premiumSubscriptionCount = data.premium_subscription_count
this.approximateNumberCount = data.approximate_number_count this.preferredLocale = data.preferred_locale
this.approximatePresenceCount = data.approximate_presence_count this.publicUpdatesChannelID = data.public_updates_channel_id
} this.maxVideoChannelUsers = data.max_video_channel_users
} this.approximateNumberCount = data.approximate_number_count
this.approximatePresenceCount = data.approximate_presence_count
protected readFromData (data: GuildPayload): void { }
super.readFromData(data) }
this.id = data.id ?? this.id
this.unavailable = data.unavailable ?? this.unavailable protected readFromData (data: GuildPayload): void {
super.readFromData(data)
if (!this.unavailable) { this.id = data.id ?? this.id
this.name = data.name ?? this.name this.unavailable = data.unavailable ?? this.unavailable
this.icon = data.icon ?? this.icon
this.iconHash = data.icon_hash ?? this.iconHash if (!this.unavailable) {
this.splash = data.splash ?? this.splash this.name = data.name ?? this.name
this.discoverySplash = data.discovery_splash ?? this.discoverySplash this.icon = data.icon ?? this.icon
this.owner = data.owner ?? this.owner this.iconHash = data.icon_hash ?? this.iconHash
this.ownerID = data.owner_id ?? this.ownerID this.splash = data.splash ?? this.splash
this.permissions = data.permissions ?? this.permissions this.discoverySplash = data.discovery_splash ?? this.discoverySplash
this.region = data.region ?? this.region this.owner = data.owner ?? this.owner
this.afkTimeout = data.afk_timeout ?? this.afkTimeout this.ownerID = data.owner_id ?? this.ownerID
this.afkChannelID = data.afk_channel_id ?? this.afkChannelID this.permissions = data.permissions ?? this.permissions
this.widgetEnabled = data.widget_enabled ?? this.widgetEnabled this.region = data.region ?? this.region
this.widgetChannelID = data.widget_channel_id ?? this.widgetChannelID this.afkTimeout = data.afk_timeout ?? this.afkTimeout
this.verificationLevel = data.verification_level ?? this.verificationLevel this.afkChannelID = data.afk_channel_id ?? this.afkChannelID
this.defaultMessageNotifications = this.widgetEnabled = data.widget_enabled ?? this.widgetEnabled
data.default_message_notifications ?? this.defaultMessageNotifications this.widgetChannelID = data.widget_channel_id ?? this.widgetChannelID
this.explicitContentFilter = this.verificationLevel = data.verification_level ?? this.verificationLevel
data.explicit_content_filter ?? this.explicitContentFilter this.defaultMessageNotifications =
// this.roles = data.default_message_notifications ?? this.defaultMessageNotifications
// data.roles.map( this.explicitContentFilter =
// v => cache.get('role', v.id) ?? new Role(this.client, v) data.explicit_content_filter ?? this.explicitContentFilter
// ) ?? this.roles // this.roles =
// this.emojis = // data.roles.map(
// data.emojis.map( // v => cache.get('role', v.id) ?? new Role(this.client, v)
// v => cache.get('emoji', v.id) ?? new Emoji(this.client, v) // ) ?? this.roles
// ) ?? this.emojis // this.emojis =
this.features = data.features ?? this.features // data.emojis.map(
this.mfaLevel = data.mfa_level ?? this.mfaLevel // v => cache.get('emoji', v.id) ?? new Emoji(this.client, v)
this.systemChannelID = data.system_channel_id ?? this.systemChannelID // ) ?? this.emojis
this.systemChannelFlags = this.features = data.features ?? this.features
data.system_channel_flags ?? this.systemChannelFlags this.mfaLevel = data.mfa_level ?? this.mfaLevel
this.rulesChannelID = data.rules_channel_id ?? this.rulesChannelID this.systemChannelID = data.system_channel_id ?? this.systemChannelID
this.joinedAt = data.joined_at ?? this.joinedAt this.systemChannelFlags =
this.large = data.large ?? this.large data.system_channel_flags ?? this.systemChannelFlags
this.memberCount = data.member_count ?? this.memberCount this.rulesChannelID = data.rules_channel_id ?? this.rulesChannelID
// this.voiceStates = this.joinedAt = data.joined_at ?? this.joinedAt
// data.voice_states?.map( this.large = data.large ?? this.large
// v => this.memberCount = data.member_count ?? this.memberCount
// cache.get('voiceState', `${v.guild_id}:${v.user_id}`) ?? // this.voiceStates =
// new VoiceState(this.client, v) // data.voice_states?.map(
// ) ?? this.voiceStates // v =>
// this.members = // cache.get('voiceState', `${v.guild_id}:${v.user_id}`) ??
// data.members?.map( // new VoiceState(this.client, v)
// v => // ) ?? this.voiceStates
// cache.get('member', `${this.id}:${v.user.id}`) ?? // this.members =
// new Member(this.client, v) // data.members?.map(
// ) ?? this.members // v =>
// this.channels = // cache.get('member', `${this.id}:${v.user.id}`) ??
// data.channels?.map( // new Member(this.client, v)
// v => cache.get('channel', v.id) ?? getChannelByType(this.client, v, this) // ) ?? this.members
// ) ?? this.members // this.channels =
this.presences = data.presences ?? this.presences // data.channels?.map(
this.maxPresences = data.max_presences ?? this.maxPresences // v => cache.get('channel', v.id) ?? getChannelByType(this.client, v, this)
this.maxMembers = data.max_members ?? this.maxMembers // ) ?? this.members
this.vanityURLCode = data.vanity_url_code ?? this.vanityURLCode this.presences = data.presences ?? this.presences
this.description = data.description ?? this.description this.maxPresences = data.max_presences ?? this.maxPresences
this.banner = data.banner ?? this.banner this.maxMembers = data.max_members ?? this.maxMembers
this.premiumTier = data.premium_tier ?? this.premiumTier this.vanityURLCode = data.vanity_url_code ?? this.vanityURLCode
this.premiumSubscriptionCount = this.description = data.description ?? this.description
data.premium_subscription_count ?? this.premiumSubscriptionCount this.banner = data.banner ?? this.banner
this.preferredLocale = data.preferred_locale ?? this.preferredLocale this.premiumTier = data.premium_tier ?? this.premiumTier
this.publicUpdatesChannelID = this.premiumSubscriptionCount =
data.public_updates_channel_id ?? this.publicUpdatesChannelID data.premium_subscription_count ?? this.premiumSubscriptionCount
this.maxVideoChannelUsers = this.preferredLocale = data.preferred_locale ?? this.preferredLocale
data.max_video_channel_users ?? this.maxVideoChannelUsers this.publicUpdatesChannelID =
this.approximateNumberCount = data.public_updates_channel_id ?? this.publicUpdatesChannelID
data.approximate_number_count ?? this.approximateNumberCount this.maxVideoChannelUsers =
this.approximatePresenceCount = data.max_video_channel_users ?? this.maxVideoChannelUsers
data.approximate_presence_count ?? this.approximatePresenceCount this.approximateNumberCount =
} data.approximate_number_count ?? this.approximateNumberCount
} this.approximatePresenceCount =
data.approximate_presence_count ?? this.approximatePresenceCount
async getEveryoneRole (): Promise<Role> { }
return (await this.roles.array().then(arr => arr?.sort((b, a) => a.position - b.position)[0]) as any) as Role }
}
async getEveryoneRole (): Promise<Role> {
async me(): Promise<Member> { return (await this.roles.get(this.id) as unknown) as Role
const get = await this.members.get(this.client.user?.id as string) }
if (get === undefined) throw new Error('Guild#me is not cached')
return get async me(): Promise<Member> {
} const get = await this.members.get(this.client.user?.id as string)
} if (get === undefined) throw new Error('Guild#me is not cached')
return get
}
async fetchIntegrations(): Promise<GuildIntegration[]> {
const raw = await this.client.rest.get(GUILD_INTEGRATIONS(this.id)) as GuildIntegrationPayload[]
return raw.map(e => new GuildIntegration(this.client, e))
}
}
export class GuildIntegration extends Base {
id: string
name: string
type: string
enabled: boolean
syncing?: boolean
roleID?: string
enableEmoticons?: boolean
expireBehaviour?: IntegrationExpireBehavior
expireGracePeriod?: number
user?: User
account: IntegrationAccountPayload
syncedAt?: string // Actually a ISO Timestamp, but we parse in constructor'
subscriberCount?: number
revoked?: boolean
application?: Application
constructor(client: Client, data: GuildIntegrationPayload) {
super(client, data)
this.id = data.id
this.name= data.name
this.type = data.type
this.enabled = data.enabled
this.syncing = data.syncing
this.roleID = data.role_id
this.enableEmoticons = data.enable_emoticons
this.expireBehaviour = data.expire_behaviour
this.expireGracePeriod = data.expire_grace_period
this.user = data.user !== undefined ? new User(client, data.user) : undefined
this.account = data.account
this.syncedAt = data.synced_at
this.subscriberCount = data.subscriber_count
this.revoked = data.revoked
this.application = data.application !== undefined ? new Application(client, data.application) : undefined
}
}

10
src/types/application.ts Normal file
View File

@ -0,0 +1,10 @@
import { UserPayload } from "./user.ts";
export interface ApplicationPayload {
id: string
name: string
icon: string
description: string
summary: string
bot?: UserPayload
}

View File

@ -1,114 +1,143 @@
import { ChannelPayload } from './channel.ts' import { ApplicationPayload } from "./application.ts"
import { EmojiPayload } from './emoji.ts' import { ChannelPayload } from './channel.ts'
import { PresenceUpdatePayload } from './gateway.ts' import { EmojiPayload } from './emoji.ts'
import { RolePayload } from './role.ts' import { PresenceUpdatePayload } from './gateway.ts'
import { UserPayload } from './user.ts' import { RolePayload } from './role.ts'
import { VoiceStatePayload } from './voice.ts' import { UserPayload } from './user.ts'
import { VoiceStatePayload } from './voice.ts'
export interface GuildPayload {
id: string export interface GuildPayload {
name: string id: string
icon?: string name: string
icon_hash?: string icon?: string
splash?: string icon_hash?: string
discovery_splash?: string splash?: string
owner?: boolean discovery_splash?: string
owner_id: string owner?: boolean
permissions?: string owner_id: string
region: string permissions?: string
afk_channel_id?: string region: string
afk_timeout: number afk_channel_id?: string
widget_enabled?: boolean afk_timeout: number
widget_channel_id?: string widget_enabled?: boolean
verification_level: string widget_channel_id?: string
default_message_notifications: string verification_level: string
explicit_content_filter: string default_message_notifications: string
roles: RolePayload[] explicit_content_filter: string
emojis: EmojiPayload[] roles: RolePayload[]
features: GuildFeatures[] emojis: EmojiPayload[]
mfa_level: string features: GuildFeatures[]
application_id?: string mfa_level: string
system_channel_id?: string application_id?: string
system_channel_flags: string system_channel_id?: string
rules_channel_id?: string system_channel_flags: string
joined_at?: string rules_channel_id?: string
large?: boolean joined_at?: string
unavailable: boolean large?: boolean
member_count?: number unavailable: boolean
voice_states?: VoiceStatePayload[] member_count?: number
members?: MemberPayload[] voice_states?: VoiceStatePayload[]
channels?: ChannelPayload[] members?: MemberPayload[]
presences?: PresenceUpdatePayload[] channels?: ChannelPayload[]
max_presences?: number presences?: PresenceUpdatePayload[]
max_members?: number max_presences?: number
vanity_url_code?: string max_members?: number
description?: string vanity_url_code?: string
banner?: string description?: string
premium_tier: number banner?: string
premium_subscription_count?: number premium_tier: number
preferred_locale: string premium_subscription_count?: number
public_updates_channel_id?: string preferred_locale: string
max_video_channel_users?: number public_updates_channel_id?: string
approximate_number_count?: number max_video_channel_users?: number
approximate_presence_count?: number approximate_number_count?: number
} approximate_presence_count?: number
}
export interface MemberPayload {
user: UserPayload export interface MemberPayload {
nick?: string user: UserPayload
roles: string[] nick?: string
joined_at: string roles: string[]
premium_since?: string joined_at: string
deaf: boolean premium_since?: string
mute: boolean deaf: boolean
} mute: boolean
}
export enum MessageNotification {
ALL_MESSAGES = 0, export enum MessageNotification {
ONLY_MENTIONS = 1 ALL_MESSAGES = 0,
} ONLY_MENTIONS = 1
}
export enum ContentFilter {
DISABLED = 0, export enum ContentFilter {
MEMBERS_WITHOUT_ROLES = 1, DISABLED = 0,
ALL_MEMBERS = 3 MEMBERS_WITHOUT_ROLES = 1,
} ALL_MEMBERS = 3
}
export enum MFA {
NONE = 0, export enum MFA {
ELEVATED = 1 NONE = 0,
} ELEVATED = 1
}
export enum Verification {
NONE = 0, export enum Verification {
LOW = 1, NONE = 0,
MEDIUM = 2, LOW = 1,
HIGH = 3, MEDIUM = 2,
VERY_HIGH = 4 HIGH = 3,
} VERY_HIGH = 4
}
export enum PremiumTier {
NONE = 0, export enum PremiumTier {
TIER_1 = 1, NONE = 0,
TIER_2 = 2, TIER_1 = 1,
TIER_3 = 3 TIER_2 = 2,
} TIER_3 = 3
}
export enum SystemChannelFlags {
SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0, export enum SystemChannelFlags {
SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1 SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0,
} SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1
}
export type GuildFeatures =
| 'INVITE_SPLASH' export type GuildFeatures =
| 'VIP_REGIONS' | 'INVITE_SPLASH'
| 'VANITY_URL' | 'VIP_REGIONS'
| 'VERIFIED' | 'VANITY_URL'
| 'PARTNERED' | 'VERIFIED'
| 'PUBLIC' | 'PARTNERED'
| 'COMMERCE' | 'PUBLIC'
| 'NEWS' | 'COMMERCE'
| 'DISCOVERABLE' | 'NEWS'
| 'FEATURABLE' | 'DISCOVERABLE'
| 'ANIMATED_ICON' | 'FEATURABLE'
| 'BANNER' | 'ANIMATED_ICON'
| 'BANNER'
export enum IntegrationExpireBehavior {
REMOVE_ROLE = 0,
KICK = 1
}
export interface IntegrationAccountPayload {
id: string
name: string
}
export interface GuildIntegrationPayload {
id: string
name: string
type: string
enabled: boolean
syncing?: boolean
role_id?: string
enable_emoticons?: boolean
expire_behaviour?: IntegrationExpireBehavior
expire_grace_period?: number
user?: UserPayload
account: IntegrationAccountPayload
synced_at?: string // Actually a ISO Timestamp, but we parse in constructor'
subscriber_count?: number
revoked?: boolean
application?: ApplicationPayload
}