diff --git a/Document/User.md b/Document/User.md index c7f67b6..137e079 100644 --- a/Document/User.md +++ b/Document/User.md @@ -93,6 +93,7 @@ User { Code: ```js +// You can use client.relationships to manage your friends and blocked users. GuildMember.user.setFriend(); User.unFriend(); Message.member.user.sendFriendRequest(); @@ -208,6 +209,7 @@ And you can change the status 5 times every 20 seconds! await client.user.setHypeSquad('HOUSE_BRAVERY'); await client.user.setHypeSquad('HOUSE_BRILLIANCE'); await client.user.setHypeSquad('HOUSE_BALANCE'); +await client.user.setHypeSquad('LEAVE'); // Set Note to User await user.setNote('Hello World'); // Set Username diff --git a/package.json b/package.json index 7d326da..ac0f646 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord.js-selfbot-v13", - "version": "1.3.2", + "version": "1.3.3", "description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]", "main": "./src/index.js", "types": "./typings/index.d.ts", diff --git a/src/client/Client.js b/src/client/Client.js index 8115c43..06d43be 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -29,8 +29,7 @@ const Options = require('../util/Options'); const Permissions = require('../util/Permissions'); const Sweepers = require('../util/Sweepers'); // Patch -const FriendsManager = require('../managers/FriendsManager'); -const BlockedManager = require('../managers/BlockedManager'); +const RelationshipsManager = require('../managers/RelationshipsManager'); const ClientUserSettingManager = require('../managers/ClientUserSettingManager'); /** @@ -129,8 +128,7 @@ class Client extends BaseClient { /** Patch * */ - this.friends = new FriendsManager(this); - this.blocked = new BlockedManager(this); + this.relationships = new RelationshipsManager(this); this.setting = new ClientUserSettingManager(this); /** * All of the guilds the client is currently handling, mapped by their ids - diff --git a/src/client/websocket/handlers/READY.js b/src/client/websocket/handlers/READY.js index 354c190..576f8cf 100644 --- a/src/client/websocket/handlers/READY.js +++ b/src/client/websocket/handlers/READY.js @@ -38,9 +38,9 @@ module.exports = (client, { d: data }, shard) => { // console.log(data); if (client.options.checkUpdate) { try { - checkUpdate() + checkUpdate(); } catch (e) { - console.log(e) + console.log(e); } }; client.session_id = data.session_id; @@ -52,11 +52,6 @@ module.exports = (client, { d: data }, shard) => { client.users.cache.set(client.user.id, client.user); } - console.log(` -${chalk.yellow( - `Can you take a look at this notice and give me your opinion?\nhttps://github.com/aiko-chan-ai/discord.js-selfbot-v13/issues/29`, -)}`); - client.user.setAFK(false); client.setting.fetch().then(async (res) => { @@ -88,13 +83,7 @@ ${chalk.yellow( client.guilds._add(guild); } - for (const r of data.relationships) { - if (r.type == 1) { - client.friends.cache.set(r.id, new User(client, r.user)); - } else if (r.type == 2) { - client.blocked.cache.set(r.id, new User(client, r.user)); - } - } + client.relationships._setup(data.relationships); shard.checkReady(); }; diff --git a/src/client/websocket/handlers/RELATIONSHIP_ADD.js b/src/client/websocket/handlers/RELATIONSHIP_ADD.js new file mode 100644 index 00000000..00ea645 --- /dev/null +++ b/src/client/websocket/handlers/RELATIONSHIP_ADD.js @@ -0,0 +1,15 @@ +'use strict'; + +const { Events } = require('../../../util/Constants'); + +module.exports = (client, { d: data }) => { + data.user ? client.users._add(data.user) : null; + client.relationships.cache.set(data.id, data.type); + /** + * Emitted whenever a relationship is updated. + * @event Client#relationshipUpdate + * @param {UserID} user The userID that was updated + * @param {Number} type The new relationship type + */ + client.emit(Events.RELATIONSHIP_ADD, data.id, data.type); +}; diff --git a/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js b/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js new file mode 100644 index 00000000..437c26a --- /dev/null +++ b/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js @@ -0,0 +1,13 @@ +'use strict'; + +const { Events } = require('../../../util/Constants'); + +module.exports = (client, { d: data }) => { + client.relationships.cache.delete(data.id); + /** + * Emitted whenever a relationship is updated. + * @event Client#relationshipUpdate + * @param {UserID} user The userID that was updated + */ + client.emit(Events.RELATIONSHIP_REMOVE, data.id); +}; diff --git a/src/client/websocket/handlers/index.js b/src/client/websocket/handlers/index.js index e37b01f..bdad4f8 100644 --- a/src/client/websocket/handlers/index.js +++ b/src/client/websocket/handlers/index.js @@ -3,6 +3,8 @@ const handlers = Object.fromEntries([ ['READY', require('./READY')], ['RESUMED', require('./RESUMED')], + ['RELATIONSHIP_ADD', require('./RELATIONSHIP_ADD')], + ['RELATIONSHIP_REMOVE', require('./RELATIONSHIP_REMOVE')], ['APPLICATION_COMMAND_CREATE', require('./APPLICATION_COMMAND_CREATE')], ['APPLICATION_COMMAND_DELETE', require('./APPLICATION_COMMAND_DELETE')], ['APPLICATION_COMMAND_UPDATE', require('./APPLICATION_COMMAND_UPDATE')], @@ -16,7 +18,7 @@ const handlers = Object.fromEntries([ ['GUILD_MEMBER_UPDATE', require('./GUILD_MEMBER_UPDATE')], ['GUILD_MEMBERS_CHUNK', require('./GUILD_MEMBERS_CHUNK')], ['GUILD_MEMBER_LIST_UPDATE', require('./GUILD_MEMBER_LIST_UPDATE.js')], - ['GUILD_INTEGRATIONS_UPDATE', require('./GUILD_INTEGRATIONS_UPDATE')], + ['GUILD_INTEGRATIONS_UPDATE', require('./GUILD_INTEGRATIONS_UPDATE')], ['GUILD_ROLE_CREATE', require('./GUILD_ROLE_CREATE')], ['GUILD_ROLE_DELETE', require('./GUILD_ROLE_DELETE')], ['GUILD_ROLE_UPDATE', require('./GUILD_ROLE_UPDATE')], diff --git a/src/index.js b/src/index.js index dfc09ed..754cf72 100644 --- a/src/index.js +++ b/src/index.js @@ -65,6 +65,7 @@ exports.UserManager = require('./managers/UserManager'); exports.VoiceStateManager = require('./managers/VoiceStateManager'); exports.WebSocketManager = require('./client/websocket/WebSocketManager'); exports.WebSocketShard = require('./client/websocket/WebSocketShard'); +exports.RelationshipsManager = require('./managers/RelationshipsManager'); // Structures exports.Activity = require('./structures/Presence').Activity; diff --git a/src/managers/GuildMemberManager.js b/src/managers/GuildMemberManager.js index aea350e..8bcd4ec 100644 --- a/src/managers/GuildMemberManager.js +++ b/src/managers/GuildMemberManager.js @@ -432,7 +432,6 @@ class GuildMemberManager extends CachedManager { }, }); } else { - console.log('send lazy quest') let channel; let channels = this.guild.channels.cache.filter(c => c.isText()); channels = channels.filter(c => c.permissionsFor(this.guild.me).has('VIEW_CHANNEL')); diff --git a/src/managers/RelationshipsManager.js b/src/managers/RelationshipsManager.js new file mode 100644 index 00000000..c071edf --- /dev/null +++ b/src/managers/RelationshipsManager.js @@ -0,0 +1,115 @@ +'use strict'; + +const { Collection } = require('@discordjs/collection'); +const { GuildMember } = require('../structures/GuildMember'); +const { Message } = require('../structures/Message'); +const ThreadMember = require('../structures/ThreadMember'); +const User = require('../structures/User'); +const { RelationshipTypes } = require('../util/Constants'); + +/** + * Manages API methods for users and stores their cache. + */ +class RelationshipsManager { + constructor(client, users) { + this.client = client; + this.cache = new Collection(); + this._setup(users); + } + + _setup(users) { + if (!Array.isArray(users)) return; + for (const relationShip of users) { + this.cache.set(relationShip.id, relationShip.type); + } + } + + /** + * Resolves a {@link UserResolvable} to a {@link User} id. + * @param {UserResolvable} user The UserResolvable to identify + * @returns {?Snowflake} + */ + resolveId(user) { + if (user instanceof ThreadMember) return user.id; + if (user instanceof GuildMember) return user.user.id; + if (user instanceof Message) return user.author.id; + if (user instanceof User) return user.id; + return user; + } + + /** + * Obtains a user from Discord, or the user cache if it's already available. + * @param {UserResolvable} user The user to fetch + * @param {BaseFetchOptions} [options] Additional options for this fetch + * @returns {Promise} + */ + async fetch(user, { cache = true, force = false } = {}) { + const id = this.resolveId(user); + if (!force) { + const existing = this.cache.get(id); + if (existing && !existing.partial) return existing; + } + + const data = await this.client.api.users['@me'].relationships.get(); + await this._setup(data); + return this.cache.get(id); + } + + // some option .-. + + async deleteFriend(user) { + const id = this.resolveId(user); + // check if already friends + if (this.cache.get(id) !== RelationshipTypes.FRIEND) return false; + await this.client.api.users['@me'].relationships[id].delete(); // 204 status and no data + return true; + } + + async deleteBlocked(user) { + const id = this.resolveId(user); + // check if already blocked + if (this.cache.get(id) !== RelationshipTypes.BLOCKED) return false; + await this.client.api.users['@me'].relationships[id].delete(); // 204 status and no data + return true; + } + + async sendFriendRequest(username, discriminator) { + await this.client.api.users('@me').relationships.post({ + data: { + username, + discriminator: parseInt(discriminator), + }, + }); + return true; + } + + async addFriend(user) { + const id = this.resolveId(user); + // check if already friends + if (this.cache.get(id) === RelationshipTypes.FRIEND) return false; + // check if outgoing request + if (this.cache.get(id) === RelationshipTypes.OUTGOING_REQUEST) return false; + await this.client.api + .users['@me'].relationships[id].put({ + data: { + type: RelationshipTypes.FRIEND, + }, + }); + return true; + } + + async addBlocked(user) { + const id = this.resolveId(user); + // check + if (this.cache.get(id) === RelationshipTypes.BLOCKED) return false; + await this.client.api + .users['@me'].relationships[id].put({ + data: { + type: RelationshipTypes.BLOCKED, + }, + }); + return true; + } +} + +module.exports = RelationshipsManager; diff --git a/src/structures/User.js b/src/structures/User.js index 5c634e0..74cb8f5 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -7,6 +7,7 @@ const SnowflakeUtil = require('../util/SnowflakeUtil'); const UserFlags = require('../util/UserFlags'); const { default: Collection } = require('@discordjs/collection'); const ApplicationCommandManager = require('../managers/ApplicationCommandManager'); +const { Relationship } = require('../util/Constants'); /** * Represents a user on Discord. @@ -129,18 +130,12 @@ class User extends Base { } /** - * Friend ? + * Check relationship status * @readonly */ - get friend() { - return this.client.friends.cache.has(this.id); - } - /** - * Blocked ? - * @readonly - */ - get blocked() { - return this.client.blocked.cache.has(this.id); + get relationships() { + const i = this.client.relationships.cache.get(this.id) ?? 0; + return Relationship[parseInt(i)]; } // Code written by https://github.com/aiko-chan-ai @@ -185,10 +180,7 @@ class User extends Base { * @returns {Promise} the user object */ async setFriend() { - return await this.client.api - .user('@me') - .relationships[this.id].put({ data: { type: 1 } }) - .then((_) => _); + return this.client.relationships.addFriend(this); } /** @@ -196,25 +188,14 @@ class User extends Base { * @returns {Promise} the user object */ async sendFriendRequest() { - return await this.client.api - .users('@me') - .relationships.post({ - data: { - username: this.username, - discriminator: parseInt(this.discriminator), - }, - }) - .then((_) => _); + return this.client.relationships.sendFriendRequest(this.username, this.discriminator); } /** * Blocks the user * @returns {Promise} the user object */ async setBlock() { - return this.client.api - .users('@me') - .relationships[this.id].put({ data: { type: 2 } }) - .then((_) => _); + return this.client.relationships.addBlocked(this); } /** @@ -222,19 +203,15 @@ class User extends Base { * @returns {Promise} the user object */ async unBlock() { - return this.client.api - .users('@me') - .relationships[this.id].delete.then((_) => _); + return this.client.relationships.deleteBlocked(this); } /** * Removes the user from your friends list * @returns {Promise} the user object */ - async unFriend() { - return this.client.api - .users('@me') - .relationships[this.id].delete.then((_) => _); + unFriend() { + return this.client.relationships.deleteFriend(this); } /** diff --git a/src/util/Constants.js b/src/util/Constants.js index 78a1a56..42448f6 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -284,91 +284,93 @@ exports.Opcodes = { }; exports.Events = { - RATE_LIMIT: 'rateLimit', - INVALID_REQUEST_WARNING: 'invalidRequestWarning', - API_RESPONSE: 'apiResponse', - API_REQUEST: 'apiRequest', - CLIENT_READY: 'ready', - /** - * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information. - */ - APPLICATION_COMMAND_CREATE: 'applicationCommandCreate', - /** - * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information. - */ - APPLICATION_COMMAND_DELETE: 'applicationCommandDelete', - /** - * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information. - */ - APPLICATION_COMMAND_UPDATE: 'applicationCommandUpdate', - GUILD_CREATE: 'guildCreate', - GUILD_DELETE: 'guildDelete', - GUILD_UPDATE: 'guildUpdate', - GUILD_UNAVAILABLE: 'guildUnavailable', - GUILD_MEMBER_ADD: 'guildMemberAdd', - GUILD_MEMBER_REMOVE: 'guildMemberRemove', - GUILD_MEMBER_UPDATE: 'guildMemberUpdate', - GUILD_MEMBER_AVAILABLE: 'guildMemberAvailable', - GUILD_MEMBERS_CHUNK: 'guildMembersChunk', - GUILD_MEMBER_LIST_UPDATE: 'guildMemberListUpdate', - GUILD_INTEGRATIONS_UPDATE: 'guildIntegrationsUpdate', - GUILD_ROLE_CREATE: 'roleCreate', - GUILD_ROLE_DELETE: 'roleDelete', - INVITE_CREATE: 'inviteCreate', - INVITE_DELETE: 'inviteDelete', - GUILD_ROLE_UPDATE: 'roleUpdate', - GUILD_EMOJI_CREATE: 'emojiCreate', - GUILD_EMOJI_DELETE: 'emojiDelete', - GUILD_EMOJI_UPDATE: 'emojiUpdate', - GUILD_BAN_ADD: 'guildBanAdd', - GUILD_BAN_REMOVE: 'guildBanRemove', - CHANNEL_CREATE: 'channelCreate', - CHANNEL_DELETE: 'channelDelete', - CHANNEL_UPDATE: 'channelUpdate', - CHANNEL_PINS_UPDATE: 'channelPinsUpdate', - MESSAGE_CREATE: 'messageCreate', - MESSAGE_DELETE: 'messageDelete', - MESSAGE_UPDATE: 'messageUpdate', - MESSAGE_BULK_DELETE: 'messageDeleteBulk', - MESSAGE_REACTION_ADD: 'messageReactionAdd', - MESSAGE_REACTION_REMOVE: 'messageReactionRemove', - MESSAGE_REACTION_REMOVE_ALL: 'messageReactionRemoveAll', - MESSAGE_REACTION_REMOVE_EMOJI: 'messageReactionRemoveEmoji', - THREAD_CREATE: 'threadCreate', - THREAD_DELETE: 'threadDelete', - THREAD_UPDATE: 'threadUpdate', - THREAD_LIST_SYNC: 'threadListSync', - THREAD_MEMBER_UPDATE: 'threadMemberUpdate', - THREAD_MEMBERS_UPDATE: 'threadMembersUpdate', - USER_UPDATE: 'userUpdate', - PRESENCE_UPDATE: 'presenceUpdate', - VOICE_SERVER_UPDATE: 'voiceServerUpdate', - VOICE_STATE_UPDATE: 'voiceStateUpdate', - TYPING_START: 'typingStart', - WEBHOOKS_UPDATE: 'webhookUpdate', - INTERACTION_CREATE: 'interactionCreate', - ERROR: 'error', - WARN: 'warn', - DEBUG: 'debug', - CACHE_SWEEP: 'cacheSweep', - SHARD_DISCONNECT: 'shardDisconnect', - SHARD_ERROR: 'shardError', - SHARD_RECONNECTING: 'shardReconnecting', - SHARD_READY: 'shardReady', - SHARD_RESUME: 'shardResume', - INVALIDATED: 'invalidated', - RAW: 'raw', - STAGE_INSTANCE_CREATE: 'stageInstanceCreate', - STAGE_INSTANCE_UPDATE: 'stageInstanceUpdate', - STAGE_INSTANCE_DELETE: 'stageInstanceDelete', - GUILD_STICKER_CREATE: 'stickerCreate', - GUILD_STICKER_DELETE: 'stickerDelete', - GUILD_STICKER_UPDATE: 'stickerUpdate', - GUILD_SCHEDULED_EVENT_CREATE: 'guildScheduledEventCreate', - GUILD_SCHEDULED_EVENT_UPDATE: 'guildScheduledEventUpdate', - GUILD_SCHEDULED_EVENT_DELETE: 'guildScheduledEventDelete', - GUILD_SCHEDULED_EVENT_USER_ADD: 'guildScheduledEventUserAdd', - GUILD_SCHEDULED_EVENT_USER_REMOVE: 'guildScheduledEventUserRemove', + RATE_LIMIT: 'rateLimit', + INVALID_REQUEST_WARNING: 'invalidRequestWarning', + API_RESPONSE: 'apiResponse', + API_REQUEST: 'apiRequest', + CLIENT_READY: 'ready', + /** + * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information. + */ + APPLICATION_COMMAND_CREATE: 'applicationCommandCreate', + /** + * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information. + */ + APPLICATION_COMMAND_DELETE: 'applicationCommandDelete', + /** + * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information. + */ + APPLICATION_COMMAND_UPDATE: 'applicationCommandUpdate', + GUILD_CREATE: 'guildCreate', + GUILD_DELETE: 'guildDelete', + GUILD_UPDATE: 'guildUpdate', + GUILD_UNAVAILABLE: 'guildUnavailable', + GUILD_MEMBER_ADD: 'guildMemberAdd', + GUILD_MEMBER_REMOVE: 'guildMemberRemove', + GUILD_MEMBER_UPDATE: 'guildMemberUpdate', + GUILD_MEMBER_AVAILABLE: 'guildMemberAvailable', + GUILD_MEMBERS_CHUNK: 'guildMembersChunk', + GUILD_MEMBER_LIST_UPDATE: 'guildMemberListUpdate', + GUILD_INTEGRATIONS_UPDATE: 'guildIntegrationsUpdate', + GUILD_ROLE_CREATE: 'roleCreate', + GUILD_ROLE_DELETE: 'roleDelete', + INVITE_CREATE: 'inviteCreate', + INVITE_DELETE: 'inviteDelete', + GUILD_ROLE_UPDATE: 'roleUpdate', + GUILD_EMOJI_CREATE: 'emojiCreate', + GUILD_EMOJI_DELETE: 'emojiDelete', + GUILD_EMOJI_UPDATE: 'emojiUpdate', + GUILD_BAN_ADD: 'guildBanAdd', + GUILD_BAN_REMOVE: 'guildBanRemove', + CHANNEL_CREATE: 'channelCreate', + CHANNEL_DELETE: 'channelDelete', + CHANNEL_UPDATE: 'channelUpdate', + CHANNEL_PINS_UPDATE: 'channelPinsUpdate', + MESSAGE_CREATE: 'messageCreate', + MESSAGE_DELETE: 'messageDelete', + MESSAGE_UPDATE: 'messageUpdate', + MESSAGE_BULK_DELETE: 'messageDeleteBulk', + MESSAGE_REACTION_ADD: 'messageReactionAdd', + MESSAGE_REACTION_REMOVE: 'messageReactionRemove', + MESSAGE_REACTION_REMOVE_ALL: 'messageReactionRemoveAll', + MESSAGE_REACTION_REMOVE_EMOJI: 'messageReactionRemoveEmoji', + THREAD_CREATE: 'threadCreate', + THREAD_DELETE: 'threadDelete', + THREAD_UPDATE: 'threadUpdate', + THREAD_LIST_SYNC: 'threadListSync', + THREAD_MEMBER_UPDATE: 'threadMemberUpdate', + THREAD_MEMBERS_UPDATE: 'threadMembersUpdate', + USER_UPDATE: 'userUpdate', + PRESENCE_UPDATE: 'presenceUpdate', + VOICE_SERVER_UPDATE: 'voiceServerUpdate', + VOICE_STATE_UPDATE: 'voiceStateUpdate', + TYPING_START: 'typingStart', + WEBHOOKS_UPDATE: 'webhookUpdate', + INTERACTION_CREATE: 'interactionCreate', + ERROR: 'error', + WARN: 'warn', + DEBUG: 'debug', + CACHE_SWEEP: 'cacheSweep', + SHARD_DISCONNECT: 'shardDisconnect', + SHARD_ERROR: 'shardError', + SHARD_RECONNECTING: 'shardReconnecting', + SHARD_READY: 'shardReady', + SHARD_RESUME: 'shardResume', + INVALIDATED: 'invalidated', + RAW: 'raw', + STAGE_INSTANCE_CREATE: 'stageInstanceCreate', + STAGE_INSTANCE_UPDATE: 'stageInstanceUpdate', + STAGE_INSTANCE_DELETE: 'stageInstanceDelete', + GUILD_STICKER_CREATE: 'stickerCreate', + GUILD_STICKER_DELETE: 'stickerDelete', + GUILD_STICKER_UPDATE: 'stickerUpdate', + GUILD_SCHEDULED_EVENT_CREATE: 'guildScheduledEventCreate', + GUILD_SCHEDULED_EVENT_UPDATE: 'guildScheduledEventUpdate', + GUILD_SCHEDULED_EVENT_DELETE: 'guildScheduledEventDelete', + GUILD_SCHEDULED_EVENT_USER_ADD: 'guildScheduledEventUserAdd', + GUILD_SCHEDULED_EVENT_USER_REMOVE: 'guildScheduledEventUserRemove', + RELATIONSHIP_ADD: 'relationshipAdd', + RELATIONSHIP_REMOVE: 'relationshipRemove', }; exports.ShardEvents = { @@ -1310,6 +1312,26 @@ exports.PrivacyLevels = createEnum([null, 'PUBLIC', 'GUILD_ONLY']); */ exports.GuildScheduledEventPrivacyLevels = createEnum([null, null, 'GUILD_ONLY']); +/** + * Relationship Enum + * * FRIEND + * * BLOCKED + * * INCOMING_REQUEST + * * OUTGOING_REQUEST + * @typedef {string} RelationshipType + * @see {@link https://luna.gitlab.io/discord-unofficial-docs/relationships.html} + */ + +exports.RelationshipTypes = createEnum([null, 'FRIEND', 'BLOCKED', 'INCOMING_REQUEST', 'OUTGOING_REQUEST']); + +exports.Relationship = { + 0: 'NONE', + 1: 'FRIEND', + 2: 'BLOCKED', + 3: 'INCOMING_REQUEST', + 4: 'OUTGOING_REQUEST', +}; + /** * The premium tier (Server Boost level) of a guild: * * NONE diff --git a/typings/enums.d.ts b/typings/enums.d.ts index ed971d8..0f19a56 100644 --- a/typings/enums.d.ts +++ b/typings/enums.d.ts @@ -22,8 +22,15 @@ export const enum stickerAnimationMode { NEVER = 2, } +export const enum relationshipsType { + FRIEND = 1, + BLOCKED = 2, + INCOMING_REQUEST = 3, + OUTGOING_REQUEST = 4, +} + export const enum localeSetting { - DANISH = 'da', + DANISH = 'da', GERMAN = 'de', ENGLISH_UK = 'en-GB', ENGLISH_US = 'en-US', diff --git a/typings/index.d.ts b/typings/index.d.ts index a95d6b0..e79d132 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -62,6 +62,10 @@ import { ApplicationCommandPermissionTypes, ApplicationCommandTypes, ChannelTypes, + relationshipsType, + localeSetting, + stickerAnimationMode, + DMScanLevel, DefaultMessageNotificationLevels, ExplicitContentFilterLevels, InteractionResponseTypes, @@ -548,8 +552,7 @@ export class Client extends BaseClient { public application: If; // Added public setting: ClientUserSettingManager; - public friends: FriendsManager; - public blocked: BlockedManager; + public relationships: RelationshipsManager; public updateCookie(): Promise; // End public channels: ChannelManager; @@ -651,7 +654,6 @@ export class ClientUser extends User { public setPassword(oldPassword: string, newPassword: string): Promise; public disableAccount(password: string): Promise; public deleteAccount(password: string): Promise; - public findFriend(username: string, discriminator: string | number): Promise; // Selfbot public readonly nitro: boolean; /** @@ -2468,8 +2470,7 @@ export class User extends PartialTextBasedChannel(Base) { public banner: string | null | undefined; public bot: boolean; public readonly createdAt: Date; - public readonly friend: Boolean; - public readonly blocked: Boolean; + public readonly relationships: relationshipsType; public readonly createdTimestamp: number; public discriminator: string; public readonly defaultAvatarURL: string; @@ -3369,24 +3370,17 @@ export class UserManager extends CachedManager public send(user: UserResolvable, options: string | MessagePayload | MessageOptions): Promise; } -export class FriendsManager extends CachedManager { - private constructor(client: Client, iterable?: Iterable); - private dmChannel(userId: Snowflake): DMChannel | null; - public createDM(user: UserResolvable, options?: BaseFetchOptions): Promise; - public deleteDM(user: UserResolvable): Promise; +export class RelationshipsManager { + private constructor(client: Client, users?: Array); + public cache: Collection; + public client: Client; + private _setup(users: Array): null; public fetch(user: UserResolvable, options?: BaseFetchOptions): Promise; - public fetchFlags(user: UserResolvable, options?: BaseFetchOptions): Promise; - public send(user: UserResolvable, options: string | MessagePayload | MessageOptions): Promise; -} - -export class BlockedManager extends CachedManager { - private constructor(client: Client, iterable?: Iterable); - private dmChannel(userId: Snowflake): DMChannel | null; - public createDM(user: UserResolvable, options?: BaseFetchOptions): Promise; - public deleteDM(user: UserResolvable): Promise; - public fetch(user: UserResolvable, options?: BaseFetchOptions): Promise; - public fetchFlags(user: UserResolvable, options?: BaseFetchOptions): Promise; - public send(user: UserResolvable, options: string | MessagePayload | MessageOptions): Promise; + public deleteFriend(user: UserResolvable): Promise; + public deleteBlocked(user: UserResolvable): Promise; + public sendFriendRequest(username: User.username, discriminator: User.discriminator): Promise; + public addFriend(user: UserResolvable): Promise; + public addBlocked(user: UserResolvable): Promise; } export class VoiceStateManager extends CachedManager {