From 8b320d2f09129636b0b97abbd1d74e7020920644 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sat, 14 Apr 2018 17:03:39 +0100 Subject: [PATCH] More modals --- client/src/modules/discordapi.js | 5 +++++ client/src/modules/webpackmodules.js | 8 +++++++- client/src/structs/discord/guild.js | 30 ++++++++++++++++++++++++++++ client/src/structs/discord/user.js | 8 ++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/client/src/modules/discordapi.js b/client/src/modules/discordapi.js index 0ca332ce..9bcb337e 100644 --- a/client/src/modules/discordapi.js +++ b/client/src/modules/discordapi.js @@ -33,11 +33,16 @@ export const Modules = { get UserStore() { return this._getModule('UserStore'); }, get RelationshipStore() { return this._getModule('RelationshipStore'); }, get RelationshipManager() { return this._getModule('RelationshipManager'); }, + get ChangeNicknameModal() { return this._getModule('ChangeNicknameModal'); }, get UserSettingsStore() { return this._getModule('UserSettingsStore'); }, get UserSettingsWindow() { return this._getModule('UserSettingsWindow'); }, get UserStatusStore() { return this._getModule('UserStatusStore'); }, get ChannelSettingsWindow() { return this._getModule('ChannelSettingsWindow'); }, get GuildSettingsWindow() { return this._getModule('GuildSettingsWindow'); }, + get CreateChannelModal() { return this._getModule('CreateChannelModal'); }, + get PruneMembersModal() { return this._getModule('PruneMembersModal'); }, + get NotificationSettingsModal() { return this._getModule('NotificationSettingsModal'); }, + get PrivacySettingsModal() { return this._getModule('PrivacySettingsModal'); }, get DiscordPermissions() { return this.DiscordConstants.Permissions; } }; diff --git a/client/src/modules/webpackmodules.js b/client/src/modules/webpackmodules.js index 5862ba1d..41035ea0 100644 --- a/client/src/modules/webpackmodules.js +++ b/client/src/modules/webpackmodules.js @@ -188,8 +188,14 @@ const KnownModules = { /* Modals */ ModalStack: Filters.byProperties(['push', 'update', 'pop', 'popWithKey']), - UserProfileModals: Filters.byProperties(['fetchMutualFriends', 'setSection']), ConfirmModal: Filters.byPrototypeFields(['handleCancel', 'handleSubmit', 'handleMinorConfirm']), + UserProfileModals: Filters.byProperties(['fetchMutualFriends', 'setSection']), + ChangeNicknameModal: Filters.byProperties(['open', 'changeNickname']), + CreateChannelModal: Filters.byProperties(['open', 'createChannel']), + PruneMembersModal: Filters.byProperties(['open', 'prune']), + NotificationSettingsModal: Filters.byProperties(['open', 'updateNotificationSettings']), + PrivacySettingsModal: Filters.byCode(/PRIVACY_SETTINGS_MODAL_OPEN/, m => m.open), + CreateInviteModal: Filters.byProperties(['open', 'createInvite']), /* Popouts */ PopoutStack: Filters.byProperties(['open', 'close', 'closeAll']), diff --git a/client/src/structs/discord/guild.js b/client/src/structs/discord/guild.js index 1988a107..8c5b63b5 100644 --- a/client/src/structs/discord/guild.js +++ b/client/src/structs/discord/guild.js @@ -182,6 +182,36 @@ export class Guild { Modules.GuildSettingsWindow.setSection(section); } + /** + * Kicks members who don't have any roles and haven't been seen in the number of days passed. + * @param {Number} days + */ + pruneMembers(days) { + Modules.PruneMembersModal.prune(this.id, days); + } + + openPruneMumbersModal() { + Modules.PruneMembersModal.open(this.id); + } + + /** + * Opens the create channel modal for this guild. + * @param {Number} type The type of channel to create - either 0 (text), 2 (voice) or 4 (category) + * @param {ChannelCategory} category The category to create the channel in + * @param {GuildChannel} clone A channel to clone permissions of + */ + openCreateChannelModal(type = 0, category, clone) { + Modules.CreateChannelModal.open(type, this.id, category ? category.id : undefined, clone ? clone.id : undefined); + } + + openNotificationSettingsModal() { + Modules.NotificationSettingsModal.open(this.id); + } + + openPrivacySettingsModal() { + Modules.PrivacySettingsModal.open(this.id); + } + nsfwAgree() { Modules.GuildActions.nsfwAgree(this.id); } diff --git a/client/src/structs/discord/user.js b/client/src/structs/discord/user.js index 5ab98c5b..b25d4b62 100644 --- a/client/src/structs/discord/user.js +++ b/client/src/structs/discord/user.js @@ -141,6 +141,14 @@ export class GuildMember extends User { throw new InsufficientPermissions(name); } + /** + * Opens the modal to change this user's nickname. + */ + openChangeNicknameModal() { + if (DiscordApi.currentUser.id !== this.id) this.assertPermissions('MANAGE_NICKNAMES', Modules.DiscordPermissions.MANAGE_NICKNAMES); + Modules.ChangeNicknameModal.open(this.guild_id, this.id); + } + /** * Kicks this user from the guild. * @param {String} reason A reason to attach to the audit log entry