More modals

This commit is contained in:
Samuel Elliott 2018-04-14 17:03:39 +01:00
parent ac22b14358
commit 8b320d2f09
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
4 changed files with 50 additions and 1 deletions

View File

@ -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; }
};

View File

@ -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']),

View File

@ -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);
}

View File

@ -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