diff --git a/client/src/modules/discordapi.js b/client/src/modules/discordapi.js index 040caa27..0812b832 100644 --- a/client/src/modules/discordapi.js +++ b/client/src/modules/discordapi.js @@ -52,6 +52,7 @@ export const Modules = { get PruneMembersModal() { return this._getModule('PruneMembersModal'); }, get NotificationSettingsModal() { return this._getModule('NotificationSettingsModal'); }, get PrivacySettingsModal() { return this._getModule('PrivacySettingsModal'); }, + get UserProfileModal() { return this._getModule('UserProfileModal'); }, get DiscordPermissions() { return this.DiscordConstants.Permissions; } }; diff --git a/client/src/modules/webpackmodules.js b/client/src/modules/webpackmodules.js index 41035ea0..6fa3cc54 100644 --- a/client/src/modules/webpackmodules.js +++ b/client/src/modules/webpackmodules.js @@ -189,7 +189,7 @@ const KnownModules = { /* Modals */ ModalStack: Filters.byProperties(['push', 'update', 'pop', 'popWithKey']), ConfirmModal: Filters.byPrototypeFields(['handleCancel', 'handleSubmit', 'handleMinorConfirm']), - UserProfileModals: Filters.byProperties(['fetchMutualFriends', 'setSection']), + UserProfileModal: Filters.byProperties(['fetchMutualFriends', 'setSection']), ChangeNicknameModal: Filters.byProperties(['open', 'changeNickname']), CreateChannelModal: Filters.byProperties(['open', 'createChannel']), PruneMembersModal: Filters.byProperties(['open', 'prune']), diff --git a/client/src/structs/discord/user.js b/client/src/structs/discord/user.js index db109efd..f28194b0 100644 --- a/client/src/structs/discord/user.js +++ b/client/src/structs/discord/user.js @@ -108,6 +108,15 @@ export class User { Modules.RelationshipManager.removeRelationship(this.id, {location: 'Context Menu'}); } + /** + * Opens the profile modal for this user. + * @param {String} section The section to open (see DiscordConstants.UserProfileSections) + */ + openUserProfileModal(section = 'USER_INFO') { + Modules.UserProfileModal.open(this.id); + Modules.UserProfileModal.setSection(section); + } + } const guild_members = new WeakMap(); diff --git a/client/src/ui/profilebadges.js b/client/src/ui/profilebadges.js index da50b68d..f2451d3f 100644 --- a/client/src/ui/profilebadges.js +++ b/client/src/ui/profilebadges.js @@ -22,7 +22,7 @@ export default class extends Module { this.patchMessage(); this.patchChannelMember(); this.patchNameTag(); - this.patchUserProfileModals(); + this.patchUserProfileModal(); } get contributors() { @@ -167,13 +167,13 @@ export default class extends Module { } /** - * Patches UserProfileModals to inject profile badges into the modal once opened. + * Patches UserProfileModal to inject profile badges into the modal once opened. * TODO: just patch the modal component */ - async patchUserProfileModals() { - const UserProfileModals = WebpackModules.getModuleByName('UserProfileModals'); + async patchUserProfileModal() { + const UserProfileModal = WebpackModules.getModuleByName('UserProfileModal'); - MonkeyPatch('BdUI', UserProfileModals).after('open', async (context, [userid]) => { + MonkeyPatch('BdUI', UserProfileModal).after('open', async (context, [userid]) => { const c = contributors.find(c => c.id === userid); if (!c) return;