mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-21 10:50:09 +00:00
fix(bot)!: Add guild.features to guild transformer (#3705)
* Add guild.features to guild transformer * Use a getter on the toggles for features
This commit is contained in:
@@ -4,7 +4,6 @@ import {
|
||||
type DiscordGuild,
|
||||
type DiscordPresenceUpdate,
|
||||
type ExplicitContentFilterLevels,
|
||||
type GuildFeatures,
|
||||
type GuildNsfwLevel,
|
||||
type MfaLevels,
|
||||
type PremiumTiers,
|
||||
@@ -12,13 +11,13 @@ import {
|
||||
type VerificationLevels,
|
||||
} from '@discordeno/types'
|
||||
import { Collection, iconHashToBigInt } from '@discordeno/utils'
|
||||
import type { Bot, Channel, Member, PresenceUpdate, Role, StageInstance, Sticker, VoiceState, WelcomeScreen } from '../index.js'
|
||||
import type { Bot, Channel, GuildFeatureKeys, Member, PresenceUpdate, Role, StageInstance, Sticker, VoiceState, WelcomeScreen } from '../index.js'
|
||||
import type { Emoji } from '../transformers/emoji.js'
|
||||
import { GuildToggles } from './toggles/guild.js'
|
||||
|
||||
const baseGuild = {
|
||||
get threads() {
|
||||
if (!this.channels) return
|
||||
if (!this.channels) return new Collection<bigint, Channel>()
|
||||
|
||||
const threads = this.channels
|
||||
.array()
|
||||
@@ -26,6 +25,9 @@ const baseGuild = {
|
||||
|
||||
return new Collection(threads.map((x) => [x.id, x]))
|
||||
},
|
||||
get features() {
|
||||
return this.toggles.features
|
||||
},
|
||||
} as Guild
|
||||
|
||||
export function transformGuild(bot: Bot, payload: { guild: DiscordGuild } & { shardId: number }): Guild {
|
||||
@@ -165,7 +167,7 @@ export interface Guild {
|
||||
/** Explicit content filter level */
|
||||
explicitContentFilter: ExplicitContentFilterLevels
|
||||
/** Enabled guild features */
|
||||
features: GuildFeatures[]
|
||||
features: GuildFeatureKeys[]
|
||||
/** Required MFA level for the guild */
|
||||
mfaLevel: MfaLevels
|
||||
/** System channel flags */
|
||||
|
||||
@@ -140,13 +140,13 @@ export class GuildToggles extends ToggleBitfieldBigint {
|
||||
}
|
||||
}
|
||||
|
||||
get features(): GuildToggleKeys[] {
|
||||
const features: GuildToggleKeys[] = []
|
||||
get features(): GuildFeatureKeys[] {
|
||||
const features: GuildFeatureKeys[] = []
|
||||
for (const key of Object.keys(GuildToggle)) {
|
||||
if (!featureNames.includes(key)) continue
|
||||
if (!super.contains(GuildToggle[key as GuildToggleKeys])) continue
|
||||
|
||||
features.push(key as GuildToggleKeys)
|
||||
features.push(key as GuildFeatureKeys)
|
||||
}
|
||||
|
||||
return features
|
||||
@@ -306,3 +306,5 @@ export class GuildToggles extends ToggleBitfieldBigint {
|
||||
}
|
||||
|
||||
export type GuildToggleKeys = keyof typeof GuildToggle
|
||||
|
||||
export type GuildFeatureKeys = keyof typeof featureNames
|
||||
|
||||
Reference in New Issue
Block a user