diff --git a/packages/darkcord/src/cache/CacheManager.ts b/packages/darkcord/src/cache/CacheManager.ts index b03be4b..00f268d 100644 --- a/packages/darkcord/src/cache/CacheManager.ts +++ b/packages/darkcord/src/cache/CacheManager.ts @@ -7,8 +7,7 @@ import { GuildDataManager } from "@manager/GuildDataManager"; import { ClientRoles, RoleDataManager } from "@manager/RoleDataManager"; import { UserDataManager } from "@manager/UserDataManager"; import { ThreadChannel } from "@resources/Channel"; -import { CamelCase, ClientOptions } from "@typings/index"; -import { Partials } from "@utils/Constants"; +import { ClientOptions } from "@typings/index"; import { Cache } from "./Cache"; @@ -76,33 +75,6 @@ export class CacheManager { } } - isPartialCache(cache: `${CamelCase}s`) { - switch (cache) { - case "emojis": { - return this._partial(Partials.Emoji); - } - case "roles": { - return this._partial(Partials.Role); - } - case "reactions": { - return this._partial(Partials.Reaction); - } - case "stickers": { - return this._partial(Partials.Sticker); - } - case "users": { - return this._partial(Partials.User); - } - default: { - return false; - } - } - } - - _partial(p: Partials) { - return Boolean(this.client.options.partials?.includes(p)); - } - _cacheInstance(o: any): o is Cache { return o instanceof Cache; } diff --git a/packages/darkcord/src/client/Client.ts b/packages/darkcord/src/client/Client.ts index aa306d1..f01522e 100644 --- a/packages/darkcord/src/client/Client.ts +++ b/packages/darkcord/src/client/Client.ts @@ -63,13 +63,9 @@ export class BaseClient extends EventEmitter { super(); if (!options || typeof options !== "object") { - options = { - partials: [], - }; + options = {}; } - options.partials ??= []; - this.isReady = false; this.options = options; this.rest = new Rest(); diff --git a/packages/darkcord/src/gateway/events/messageReactionAdd.ts b/packages/darkcord/src/gateway/events/messageReactionAdd.ts index 37b5cfc..6df3a0e 100644 --- a/packages/darkcord/src/gateway/events/messageReactionAdd.ts +++ b/packages/darkcord/src/gateway/events/messageReactionAdd.ts @@ -1,6 +1,6 @@ import { TextBasedChannel } from "@resources/Channel"; import { APISuperReaction, Reaction } from "@resources/Emoji"; -import { Events, Partials } from "@utils/Constants"; +import { Events } from "@utils/Constants"; import { GatewayMessageReactionAddDispatchData } from "discord-api-types/v10"; import { Event } from "./Event"; @@ -24,9 +24,7 @@ export class MessageReactionAdd extends Event { raw.count++; - const reaction = this.client.cache._partial(Partials.Reaction) - ? raw - : new Reaction({ ...raw, client: this.client }); + const reaction = new Reaction({ ...raw, client: this.client }); const channel = this.client.channels.cache.get(data.channel_id); @@ -46,27 +44,8 @@ export class MessageReactionAdd extends Event { if (existingReactions) { reaction.count += existingReactions.count; - if ( - existingReactions instanceof Reaction && - reaction instanceof Reaction - ) { - reaction.countDetails.burst += existingReactions.countDetails.burst; - reaction.countDetails.normal += existingReactions.countDetails.normal; - } else if ( - existingReactions instanceof Reaction && - !(reaction instanceof Reaction) - ) { - reaction.count_details.burst += existingReactions.countDetails.burst; - reaction.count_details.normal += - existingReactions.countDetails.normal; - } else if ( - !(existingReactions instanceof Reaction) && - reaction instanceof Reaction - ) { - reaction.countDetails.burst += existingReactions.count_details.burst; - reaction.countDetails.normal += - existingReactions.count_details.normal; - } + reaction.countDetails.burst += existingReactions.countDetails.burst; + reaction.countDetails.normal += existingReactions.countDetails.normal; message.reactions._add( reaction, diff --git a/packages/darkcord/src/gateway/events/messageReactionRemove.ts b/packages/darkcord/src/gateway/events/messageReactionRemove.ts index 378679e..922bf77 100644 --- a/packages/darkcord/src/gateway/events/messageReactionRemove.ts +++ b/packages/darkcord/src/gateway/events/messageReactionRemove.ts @@ -1,6 +1,6 @@ import { TextBasedChannel } from "@resources/Channel"; import { Reaction } from "@resources/Emoji"; -import { Events, Partials } from "@utils/Constants"; +import { Events } from "@utils/Constants"; import { GatewayMessageReactionRemoveDispatchData } from "discord-api-types/v10"; import { Event } from "./Event"; @@ -18,9 +18,7 @@ export class MessageReactionRemove extends Event { }, }; - const reaction = this.client.cache._partial(Partials.Reaction) - ? raw - : new Reaction({ ...raw, client: this.client }); + const reaction = new Reaction({ ...raw, client: this.client }); const channel = this.client.channels.cache.get(data.channel_id); @@ -40,18 +38,10 @@ export class MessageReactionRemove extends Event { if (existingReactions) { reaction.count = existingReactions.count - 1; - let countDetails = - existingReactions instanceof Reaction - ? existingReactions.countDetails - : existingReactions.count_details; - + let countDetails = existingReactions.countDetails; countDetails[data.burst ? "burst" : "normal"]--; - if (reaction instanceof Reaction) { - reaction.countDetails = countDetails; - } else { - reaction.count_details = countDetails; - } + reaction.countDetails = countDetails; } if (reaction.count <= 0) { diff --git a/packages/darkcord/src/manager/ChannelDataManager.ts b/packages/darkcord/src/manager/ChannelDataManager.ts index 77776e5..8a1d283 100644 --- a/packages/darkcord/src/manager/ChannelDataManager.ts +++ b/packages/darkcord/src/manager/ChannelDataManager.ts @@ -66,12 +66,9 @@ export class ChannelDataManager extends DataManager { return channel; } - add( - channel: Channel | APIChannel, - replace = true, - ): Channel | APIChannel | null { + add(channel: Channel | APIChannel, replace = true): Channel { if (!channel || !channel.id) { - return null; + return null as unknown as Channel; } return super.add(this._resolve(channel), replace, channel.id); diff --git a/packages/darkcord/src/manager/DataManager.ts b/packages/darkcord/src/manager/DataManager.ts index de9e12f..85d3e86 100644 --- a/packages/darkcord/src/manager/DataManager.ts +++ b/packages/darkcord/src/manager/DataManager.ts @@ -21,7 +21,7 @@ export class DataCache> extends Cache { return super.get(key); } - _add(item: V, replace = true, id?: string) { + _add(item: V, replace = true, id?: string): V { if ("id" in item && !id) { id = item.id; } @@ -117,7 +117,7 @@ export class DataManager> { } } - add(item: V, replace = true, id?: string) { + add(item: V, replace = true, id?: string): V { return this.cache._add(item, replace, id); } } diff --git a/packages/darkcord/src/manager/EmojiDataManager.ts b/packages/darkcord/src/manager/EmojiDataManager.ts index d5d2a42..0699b42 100644 --- a/packages/darkcord/src/manager/EmojiDataManager.ts +++ b/packages/darkcord/src/manager/EmojiDataManager.ts @@ -2,12 +2,11 @@ import { CacheManager } from "@cache/CacheManager"; import { Emoji } from "@resources/Emoji"; import { Guild } from "@resources/Guild"; import { BaseCacheOptions } from "@typings/index"; -import { Partials } from "@utils/Constants"; import { APIEmoji, APIGuild } from "discord-api-types/v10"; import { DataManager } from "./DataManager"; import { Forge, Forged } from "@resources/forge/Forgified"; -export class EmojiDataManager extends DataManager { +export class EmojiDataManager extends DataManager { constructor( options: number | BaseCacheOptions, public manager: CacheManager, @@ -23,20 +22,16 @@ export class EmojiDataManager extends DataManager { } #resolve(emoji: APIEmoji | Emoji, addInCache = false) { - if ( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - emoji && - !this.manager._partial(Partials.Emoji) && - !(emoji instanceof Emoji) - ) { + if (emoji && !(emoji instanceof Emoji)) { emoji = new Emoji(emoji); - if (addInCache) this.add(emoji); } - return emoji; + if (addInCache) this.add(emoji); + + return emoji as Emoji; } - add(emoji: Emoji | APIEmoji, replace = true) { + add(emoji: Emoji | APIEmoji, replace = true): Emoji { return super.add(this.#resolve(emoji), replace, emoji.id || emoji.name!); } diff --git a/packages/darkcord/src/manager/RoleDataManager.ts b/packages/darkcord/src/manager/RoleDataManager.ts index 553575f..4940e64 100644 --- a/packages/darkcord/src/manager/RoleDataManager.ts +++ b/packages/darkcord/src/manager/RoleDataManager.ts @@ -1,22 +1,21 @@ import { CacheManager } from "@cache/CacheManager"; import { Guild } from "@resources/Guild"; import { Role } from "@resources/Role"; -import { BaseCacheOptions, DataWithClient } from "@typings/index"; -import { Partials } from "@utils/Constants"; +import { BaseCacheOptions } from "@typings/index"; import { APIGuild, APIRole } from "discord-api-types/v10"; import { DataCache, DataManager } from "./DataManager"; import { Forge } from "@resources/forge/Forgified"; export class ClientRoles { - cache: DataCache; - constructor(options?: number | BaseCacheOptions) { + cache: DataCache; + constructor(options?: number | BaseCacheOptions) { this.cache = new DataCache(options); } } -export class RoleDataManager extends DataManager { +export class RoleDataManager extends DataManager { constructor( - options: number | BaseCacheOptions, + options: number | BaseCacheOptions, public manager: CacheManager, public guild: Guild, ) { @@ -69,9 +68,9 @@ export class RoleDataManager extends DataManager { return this.cache.get(id); } - add(role: APIRole | Role, replace = true): APIRole | Role | null { + add(role: APIRole | Role, replace = true) { if (!role || !role.id) { - return null; + return null as unknown as Role; } return super.add(this._resolve(role), replace, role.id); @@ -84,14 +83,13 @@ export class RoleDataManager extends DataManager { typeof data === "string" ? { id: data } : data, ); - return this.add(forged, false); + return this.add(forged, false) as Role; } _resolve(role: APIRole | Role, addInCache = false) { if ( // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition role && - !this.manager._partial(Partials.Role) && !(role instanceof Role) ) { role = new Role({ ...role, client: this.manager.client }, this.guild); @@ -120,24 +118,22 @@ export class RoleDataManager extends DataManager { const resolvedRolesArr = Promise.all( rolesArr.map(async (role) => { - if (!this.manager._partial(Partials.Role)) { - if (!(guild instanceof Guild)) { - guild = this.manager.guilds.cache.get( - typeof guild === "string" ? guild : guild.id, - )!; - } - - return this.add( - new Role( - { - ...role, - client: this.manager.client, - }, - guild, - ), - ); + if (!(guild instanceof Guild)) { + guild = this.manager.guilds.cache.get( + typeof guild === "string" ? guild : guild.id, + )!; } + return this.add( + new Role( + { + ...role, + client: this.manager.client, + }, + guild, + ), + ); + return this.add(role); }), ); diff --git a/packages/darkcord/src/manager/StickerDataManager.ts b/packages/darkcord/src/manager/StickerDataManager.ts index ae73876..17c6f15 100644 --- a/packages/darkcord/src/manager/StickerDataManager.ts +++ b/packages/darkcord/src/manager/StickerDataManager.ts @@ -2,14 +2,13 @@ import { CacheManager } from "@cache/CacheManager"; import { Guild } from "@resources/Guild"; import { Sticker } from "@resources/Sticker"; import { BaseCacheOptions } from "@typings/index"; -import { Partials } from "@utils/Constants"; import { APIGuild, APISticker } from "discord-api-types/v10"; import { DataManager } from "./DataManager"; -export class StickerDataManager extends DataManager { +export class StickerDataManager extends DataManager { constructor( - options: number | BaseCacheOptions, + options: number | BaseCacheOptions, public manager: CacheManager, ) { super(options, (get, id) => { @@ -27,10 +26,7 @@ export class StickerDataManager extends DataManager { } #resolve(sticker: Sticker | APISticker, addInCache = false) { - if ( - !this.manager._partial(Partials.Sticker) && - !(sticker instanceof Sticker) - ) { + if (!(sticker instanceof Sticker)) { sticker = new Sticker({ ...sticker, client: this.manager.client, @@ -51,7 +47,7 @@ export class StickerDataManager extends DataManager { id: string, guild: APIGuild | Guild | string, addInCache = true, - ): Promise { + ): Promise { const sticker = await this.manager.client.rest.getGuildSticker( typeof guild === "string" ? guild : guild.id, id, @@ -61,13 +57,13 @@ export class StickerDataManager extends DataManager { return this.add(sticker); } - return sticker; + return this.#resolve(sticker, false); } } export class GuildStickerDataManager extends StickerDataManager { constructor( - options: number | BaseCacheOptions, + options: number | BaseCacheOptions, public manager: CacheManager, public guild: Guild, ) { diff --git a/packages/darkcord/src/manager/UserDataManager.ts b/packages/darkcord/src/manager/UserDataManager.ts index 6efa82c..397c474 100644 --- a/packages/darkcord/src/manager/UserDataManager.ts +++ b/packages/darkcord/src/manager/UserDataManager.ts @@ -1,14 +1,13 @@ import { CacheManager } from "@cache/CacheManager"; import { User } from "@resources/User"; -import { BaseCacheOptions, DataWithClient } from "@typings/index"; -import { Partials } from "@utils/Constants"; +import { BaseCacheOptions } from "@typings/index"; import { APIUser } from "discord-api-types/v10"; import { DataManager } from "./DataManager"; import { Forge } from "@resources/forge/Forgified"; -export class UserDataManager extends DataManager { +export class UserDataManager extends DataManager { constructor( - options: number | BaseCacheOptions, + options: number | BaseCacheOptions, public manager: CacheManager, ) { super(options); @@ -29,9 +28,9 @@ export class UserDataManager extends DataManager { return this.add(forged, false)! as User; } - add(user: User | APIUser, replace = true): User | APIUser | null { + add(user: User | APIUser, replace = true) { if (!user || !user.id) { - return null; + return null as unknown as User; } return super.add(this.#resolve(user), replace, user.id); @@ -41,7 +40,6 @@ export class UserDataManager extends DataManager { if ( // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition user && - !this.manager._partial(Partials.User) && !(user instanceof User) ) { user = new User({ ...user, client: this.manager.client }); diff --git a/packages/darkcord/src/resources/Guild.ts b/packages/darkcord/src/resources/Guild.ts index 2f3ec58..d099c65 100644 --- a/packages/darkcord/src/resources/Guild.ts +++ b/packages/darkcord/src/resources/Guild.ts @@ -388,6 +388,13 @@ export class Guild extends BaseGuild { this._update(data); } + /** + * Returns the client member object + */ + get clientMember() { + return this.members.cache.get(this._client.user!.id)!; + } + /** * Returns a ban object for the given user * @param userId @@ -488,8 +495,9 @@ export class Guild extends BaseGuild { reason, ); - this._client.roles.cache._add(role); - return this.roles.add(role); + const r = this.roles.add(role); + this._client.roles.cache._add(r); + return r; } /** @@ -520,8 +528,9 @@ export class Guild extends BaseGuild { const role = await this._client.rest.createGuildRole(this.id, opts, reason); - this._client.roles.cache._add(role); - return this.roles.add(role); + const r = this.roles.add(role); + this._client.roles.cache._add(r); + return r; } /** @@ -1086,8 +1095,8 @@ export class Guild extends BaseGuild { if ("roles" in data && Array.isArray(data.roles)) { for (const role of data.roles) { - this.roles.add(role); - this._client.cache.roles.cache._add(role); + const r = this.roles.add(role); + this._client.roles.cache._add(r); } } diff --git a/packages/darkcord/src/resources/Interaction.ts b/packages/darkcord/src/resources/Interaction.ts index 2553ba4..df31ebe 100644 --- a/packages/darkcord/src/resources/Interaction.ts +++ b/packages/darkcord/src/resources/Interaction.ts @@ -106,7 +106,11 @@ export class Interaction extends Base { this.member = null; if ("member" in data && data.member && this.guild) { - this.member = this.guild.members.add(new Member(data.member, this.guild)); + this.member = this.guild.members.add( + new Member(data.member, this.guild), + ) as HttpPartial extends true + ? APIInteractionGuildMember | null + : Member | null; this.user = this.member!.user!; } else if ("member" in data && data.member) { this.member = data.member as HttpPartial extends true diff --git a/packages/darkcord/src/resources/Member.ts b/packages/darkcord/src/resources/Member.ts index 6dda2bf..5dfbb1d 100644 --- a/packages/darkcord/src/resources/Member.ts +++ b/packages/darkcord/src/resources/Member.ts @@ -24,6 +24,15 @@ import { User } from "./User"; import { Role } from "./Role"; import { Cache } from "@cache/Cache"; +export class UncachedClientMemberError extends Error { + constructor() { + super( + "The client member is not cached. This is likely due to the member not being in the guild or the guild not being cached.", + ); + this.name = "UncachedClientMemberError"; + } +} + export class MemberRoles { private _roles: string[]; cache: Cache; @@ -40,7 +49,7 @@ export class MemberRoles { * Get the member role with the highest position * @returns */ - highest() { + get highest() { return this.cache.reduce( ([, prev], [, role]) => { return prev && this.guild.roles.comparePositions(role.id, prev.id) > 0 @@ -88,7 +97,7 @@ export class Member extends Base { /** * The user this guild member represents */ - user: User | null; + user: User; /** * Whether the user is deafened in voice channels */ @@ -127,18 +136,15 @@ export class Member extends Base { this.avatar = data.avatar; this.communicationDisabledUntil = data.communication_disabled_until; - this.user = null; + + Object.defineProperty(this, "user", { + value: null, + writable: true, + enumerable: false, + }); if (data.user) { - const rawUser = this._client.cache.users.add(data.user)!; - - this.user = - rawUser instanceof User - ? rawUser - : new User({ - ...rawUser, - client: guild._client, - }); + this.user = this._client.cache.users.add(data.user)!; } this.nickname = data.nick ?? null; @@ -160,6 +166,53 @@ export class Member extends Base { return this.guild.voiceStates.get(this.id); } + get manageable() { + if (this.id === this.guild.ownerId) { + return false; + } + + if (this.id === this._client.user!.id) { + return false; + } + + if (this._client.user!.id === this.guild.ownerId) { + return true; + } + + if (!this.guild.clientMember) { + throw new UncachedClientMemberError(); + } + + return ( + this.guild.clientMember.roles.comparePositions( + this.guild.clientMember.roles.highest.id, + this.roles.highest.id, + ) > 0 + ); + } + + get bannable() { + if (!this.guild.clientMember) { + throw new UncachedClientMemberError(); + } + + return ( + this.manageable && + this.guild.clientMember.permissions.has(Permissions.Flags.BanMembers) + ); + } + + get kickable() { + if (!this.guild.clientMember) { + throw new UncachedClientMemberError(); + } + + return ( + this.manageable && + this.guild.clientMember.permissions.has(Permissions.Flags.KickMembers) + ); + } + /** * The member's display name */ diff --git a/packages/darkcord/src/resources/Message.ts b/packages/darkcord/src/resources/Message.ts index 01d2720..def25e4 100644 --- a/packages/darkcord/src/resources/Message.ts +++ b/packages/darkcord/src/resources/Message.ts @@ -1,5 +1,4 @@ import { DataWithClient, MessagePostData } from "@typings/index"; -import { Partials } from "@utils/Constants"; import { Resolvable } from "@utils/Resolvable"; import { APIAttachment, @@ -110,7 +109,7 @@ export class Message extends Base { /** * Reactions in this message */ - reactions: DataCache; + reactions: DataCache; /** * Id of guild was message has sent */ @@ -200,21 +199,18 @@ export class Message extends Base { emoji = Emoji.getEncodedURI(emoji); } - let reaction = (await this._client.rest.createReaction( + let rawReaction = (await this._client.rest.createReaction( this.channelId, this.id, emoji, )) as unknown as APIReaction; - if (!this._client.cache._partial(Partials.Reaction)) { - // @ts-expect-error - raw reaction returns count_details - reaction = new Reaction({ - ...reaction, - client: this._client, - message_id: this.id, - channel_id: this.channel?.id!, - }); - } + const reaction = new Reaction({ + ...rawReaction, + client: this._client, + message_id: this.id, + channel_id: this.channel?.id!, + }); return this.reactions._add( reaction, @@ -282,9 +278,7 @@ export class Message extends Base { if (Array.isArray(data.reactions)) { for (const reaction of data.reactions as APIReaction[]) { - const resolved = this._client.cache._partial(Partials.Reaction) - ? reaction - : new Reaction({ ...reaction, client: this._client }); + const resolved = new Reaction({ ...reaction, client: this._client }); this.reactions._add( resolved, diff --git a/packages/darkcord/src/types/index.ts b/packages/darkcord/src/types/index.ts index b9f68f5..9298c5c 100644 --- a/packages/darkcord/src/types/index.ts +++ b/packages/darkcord/src/types/index.ts @@ -15,18 +15,13 @@ import { Message } from "@resources/Message"; import { Role } from "@resources/Role"; import { User } from "@resources/User"; import { VoiceState } from "@resources/VoiceState"; -import { Partials } from "@utils/Constants"; import { APIAuditLogChange, APIAuditLogEntry, APIChannel, - APIEmoji, APIGuild, APIGuildMember, - APIReaction, - APIRole, APIStageInstance, - APIUser, GatewayGuildMembersChunkDispatchData, GatewayIntentBits, GatewayReceivePayload, @@ -61,9 +56,7 @@ export interface DisplayUserBannerOptions extends ImageSize { export type GuildDataModel = T & { guild: Guild }; -export interface BaseClientOptions { - partials?: Partials[]; -} +export interface BaseClientOptions {} export interface InteractionClientOptions extends BaseClientOptions { webserver: WebServerOptions; @@ -200,34 +193,16 @@ export interface ClientEvents { messageUpdate: [old: Message, updated: Message]; messageDelete: [message: Message]; messageDeleteBulk: [messagesDeleted: Map]; - messageReactionAdd: [ - reaction: Reaction | APIReaction, - user: User | APIUser, - message: Message, - ]; - messageSuperReactionAdd: [ - reaction: Reaction | APIReaction, - user: User | APIUser, - message: Message, - ]; - messageReactionRemove: [ - reaction: Reaction | APIReaction, - user: User | APIUser, - message: Message, - ]; + messageReactionAdd: [reaction: Reaction, user: User, message: Message]; + messageSuperReactionAdd: [reaction: Reaction, user: User, message: Message]; + messageReactionRemove: [reaction: Reaction, user: User, message: Message]; messageSuperReactionRemove: [ - reaction: Reaction | APIReaction, - user: User | APIUser, - message: Message, - ]; - messageReactionRemoveAll: [ + reaction: Reaction, + user: User, message: Message, - removed: Cache, - ]; - messageReactionRemoveEmoji: [ - message: Message, - removed: Reaction | APIReaction, ]; + messageReactionRemoveAll: [message: Message, removed: Cache]; + messageReactionRemoveEmoji: [message: Message, removed: Reaction]; typingStart: [typing: Typing]; // Interaction @@ -240,19 +215,16 @@ export interface ClientEvents { guildUpdate: [old: Guild, updated: Guild]; guildDelete: [deleted: Guild]; guildAuditLogEntryCreate: [log: AuditLogEntry]; - guildBanAdd: [guild: Guild, userBanned: User | APIUser]; - guildBanRemove: [guild: Guild, userUnbanned: User | APIUser]; + guildBanAdd: [guild: Guild, userBanned: User]; + guildBanRemove: [guild: Guild, userUnbanned: User]; guildEmojisUpdate: [ - old: DataCache, - updated: DataCache, + old: DataCache, + updated: DataCache, guild: Guild, ]; - guildEmojiCreate: [emoji: Emoji | APIEmoji]; - guildEmojiDelete: [emoji: Emoji | APIEmoji]; - guildEmojiUpdate: [ - oldEmoji: Emoji | APIEmoji, - updatedEmoji: Emoji | APIEmoji, - ]; + guildEmojiCreate: [emoji: Emoji]; + guildEmojiDelete: [emoji: Emoji]; + guildEmojiUpdate: [oldEmoji: Emoji, updatedEmoji: Emoji]; guildStickersUpdate: [ old: DataCache, updated: DataCache, @@ -262,17 +234,17 @@ export interface ClientEvents { guildStickerDelete: [sticker: Sticker]; guildStickerUpdate: [oldSticker: Sticker, updatedSticker: Sticker]; guildMemberAdd: [newMember: Member, guild: Guild]; - guildMemberRemove: [user: User | APIUser, guild: Guild]; + guildMemberRemove: [user: User, guild: Guild]; guildMemberUpdate: [old: Member, updated: Member]; guildIntegrationsUpdate: [guild: Guild]; - guildRoleCreate: [role: Role | APIRole, guild: Guild]; - guildRoleUpdate: [old: Role | APIRole, updated: Role | APIRole, guild: Guild]; - guildRoleDelete: [deleted: Role | APIRole, guild: Guild]; + guildRoleCreate: [role: Role, guild: Guild]; + guildRoleUpdate: [old: Role, updated: Role, guild: Guild]; + guildRoleDelete: [deleted: Role, guild: Guild]; guildScheduledEventCreate: [event: ScheduledEvent]; guildScheduledEventUpdate: [old: ScheduledEvent, updated: ScheduledEvent]; guildScheduledEventDelete: [deleted: ScheduledEvent]; - guildScheduledEventUserAdd: [event: ScheduledEvent, user: User | APIUser]; - guildScheduledEventUserRemove: [event: ScheduledEvent, user: User | APIUser]; + guildScheduledEventUserAdd: [event: ScheduledEvent, user: User]; + guildScheduledEventUserRemove: [event: ScheduledEvent, user: User]; // Thread threadCreate: [thread: ThreadChannel]; @@ -303,7 +275,7 @@ export interface ClientEvents { channelPinsUpdate: [channel: TextBasedChannel]; // User - userUpdate: [old: User | APIUser, updated: User | APIUser]; + userUpdate: [old: User, updated: User]; // Voice voiceChannelSwitch: [ diff --git a/packages/darkcord/src/utils/Constants.ts b/packages/darkcord/src/utils/Constants.ts index d24119d..8dedbe6 100644 --- a/packages/darkcord/src/utils/Constants.ts +++ b/packages/darkcord/src/utils/Constants.ts @@ -1,13 +1,5 @@ import type { MessageTimestampStyle } from "@typings/index"; -export enum Partials { - Emoji, - User, - Reaction, - Role, - Sticker, -} - export { GatewayStatus, ShardEvents } from "@darkcord/ws"; export enum Events { diff --git a/packages/darkcord/src/utils/Resolvable.ts b/packages/darkcord/src/utils/Resolvable.ts index c36a8ac..958fc3c 100644 --- a/packages/darkcord/src/utils/Resolvable.ts +++ b/packages/darkcord/src/utils/Resolvable.ts @@ -78,8 +78,8 @@ export namespace Resolvable { if (Array.isArray(resolved.rawData.roles)) { for (const role of resolved.rawData.roles) { - resolved.roles.add(role); - client.roles.cache._add(role); + const r = resolved.roles.add(role); + client.roles.cache._add(r); } }