From 949206738b89e837ff364dfb96bf1308756fa9d8 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Fri, 27 Apr 2018 23:51:37 +0100 Subject: [PATCH] Add user notes --- client/src/modules/discordapi.js | 1 + client/src/modules/webpackmodules.js | 2 ++ client/src/structs/discord/user.js | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/client/src/modules/discordapi.js b/client/src/modules/discordapi.js index 9911559f..aff099b0 100644 --- a/client/src/modules/discordapi.js +++ b/client/src/modules/discordapi.js @@ -54,6 +54,7 @@ export const Modules = { get PrivacySettingsModal() { return this._getModule('PrivacySettingsModal'); }, get UserProfileModal() { return this._getModule('UserProfileModal'); }, get APIModule() { return this._getModule('APIModule'); }, + get UserNoteStore() { return this._getModule('UserNoteStore'); }, get DiscordPermissions() { return this.DiscordConstants.Permissions; } }; diff --git a/client/src/modules/webpackmodules.js b/client/src/modules/webpackmodules.js index fe0d424c..a9493f83 100644 --- a/client/src/modules/webpackmodules.js +++ b/client/src/modules/webpackmodules.js @@ -53,6 +53,8 @@ const KnownModules = { UserTypingStore: Filters.byProperties(['isTyping']), UserActivityStore: Filters.byProperties(['getActivity']), UserNameResolver: Filters.byProperties(['getName']), + UserNoteStore: Filters.byProperties(['getNote']), + UserNoteActions: Filters.byProperties(['updateNote']), /* Emoji Store and Utils */ EmojiInfo: Filters.byProperties(['isEmojiDisabled']), diff --git a/client/src/structs/discord/user.js b/client/src/structs/discord/user.js index 7e35a477..295c88a2 100644 --- a/client/src/structs/discord/user.js +++ b/client/src/structs/discord/user.js @@ -69,6 +69,23 @@ export class User { return Modules.UserStatusStore.getActivity(this.id); } + get note() { + const note = Modules.UserNoteStore.getNote(this.id); + if (note) return note; + } + + /** + * Updates the note for this user. + * @param {String} note The new note + * @return {Promise} + */ + updateNote(note) { + return Modules.APIModule.put({ + url: `${Modules.DiscordConstants.Endpoints.NOTES}/${this.id}`, + body: { note } + }); + } + get privateChannel() { return DiscordApi.channels.find(c => c.type === 'DM' && c.recipientId === this.id); }