Add user notes

This commit is contained in:
Samuel Elliott 2018-04-27 23:51:37 +01:00
parent 4dc715a39a
commit 949206738b
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
3 changed files with 20 additions and 0 deletions

View File

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

View File

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

View File

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