User settings (#1337)

* user settings bruh

* remove development dump

* emit stuff

* i am so done

* Update ClientUserSettings.js

* modularize

* Update ClientUserSettings.js

* Update Constants.js

* Update ClientUserSettings.js

* Update RESTMethods.js

* Update ClientUserSettings.js

* <.<
This commit is contained in:
Gus Caplan
2017-04-05 15:03:33 -05:00
committed by Crawl
parent 5d85de0883
commit 801633b970
11 changed files with 291 additions and 12 deletions

View File

@@ -310,6 +310,7 @@ exports.Events = {
MESSAGE_REACTION_REMOVE_ALL: 'messageReactionRemoveAll',
USER_UPDATE: 'userUpdate',
USER_NOTE_UPDATE: 'userNoteUpdate',
USER_SETTINGS_UPDATE: 'clientUserSettingsUpdate',
PRESENCE_UPDATE: 'presenceUpdate',
VOICE_STATE_UPDATE: 'voiceStateUpdate',
TYPING_START: 'typingStart',
@@ -350,6 +351,7 @@ exports.Events = {
* - MESSAGE_REACTION_REMOVE_ALL
* - USER_UPDATE
* - USER_NOTE_UPDATE
* - USER_SETTINGS_UPDATE
* - PRESENCE_UPDATE
* - VOICE_STATE_UPDATE
* - TYPING_START
@@ -388,6 +390,7 @@ exports.WSEvents = {
MESSAGE_REACTION_REMOVE_ALL: 'MESSAGE_REACTION_REMOVE_ALL',
USER_UPDATE: 'USER_UPDATE',
USER_NOTE_UPDATE: 'USER_NOTE_UPDATE',
USER_SETTINGS_UPDATE: 'USER_SETTINGS_UPDATE',
PRESENCE_UPDATE: 'PRESENCE_UPDATE',
VOICE_STATE_UPDATE: 'VOICE_STATE_UPDATE',
TYPING_START: 'TYPING_START',
@@ -416,6 +419,145 @@ exports.DefaultAvatars = {
RED: '1cbd08c76f8af6dddce02c5138971129',
};
exports.ExplicitContentFilterTypes = [
'DISABLED',
'NON_FRIENDS',
'FRIENDS_AND_NON_FRIENDS',
];
exports.UserSettingsMap = {
/**
* Automatically convert emoticons in your messages to emoji.
* For example, when you type `:-)` Discord will convert it to 😃
* @name ClientUserSettings#convertEmoticons
* @type {boolean}
*/
convert_emoticons: 'convertEmoticons',
/**
* If new guilds should automatically disable DMs between you and its members
* @name ClientUserSettings#defaultGuildsRestricted
* @type {boolean}
*/
default_guilds_restricted: 'defaultGuildsRestricted',
/**
* Automatically detect accounts from services like Steam and Blizzard when you open the Discord client
* @name ClientUserSettings#detectPlatformAccounts
* @type {boolean}
*/
detect_platform_accounts: 'detectPlatformAccounts',
/**
* Developer Mode exposes context menu items helpful for people writing bots using the Discord API
* @name ClientUserSettings#developerMode
* @type {boolean}
*/
developer_mode: 'developerMode',
/**
* Allow playback and usage of the `/tts` command
* @name ClientUserSettings#enableTTSCommand
* @type {boolean}
*/
enable_tts_command: 'enableTTSCommand',
/**
* The theme of the client. Either `light` or `dark`
* @name ClientUserSettings#theme
* @type {String}
*/
theme: 'theme',
/**
* Last status set in the client
* @name ClientUserSettings#status
* @type {PresenceStatus}
*/
status: 'status',
/**
* Display currently running game as status message
* @name ClientUserSettings#showCurrentGame
* @type {boolean}
*/
show_current_game: 'showCurrentGame',
/**
* Display images, videos, and lolcats when uploaded directly to Discord
* @name ClientUserSettings#inlineAttachmentMedia
* @type {boolean}
*/
inline_attachment_media: 'inlineAttachmentMedia',
/**
* Display images, videos, and lolcats when uploaded posted as links in chat
* @name ClientUserSettings#inlineEmbedMedia
* @type {boolean}
*/
inline_embed_media: 'inlineEmbedMedia',
/**
* Language the Discord client will use, as an RFC 3066 language identifier
* @name ClientUserSettings#locale
* @type {string}
*/
locale: 'locale',
/**
* Display messages in compact mode
* @name ClientUserSettings#messageDisplayCompact
* @type {boolean}
*/
message_display_compact: 'messageDisplayCompact',
/**
* Show emoji reactions on messages
* @name ClientUserSettings#renderReactions
* @type {boolean}
*/
render_reactions: 'renderReactions',
/**
* Array of snowflake IDs for guilds, in the order they appear in the Discord client
* @name ClientUserSettings#guildPositions
* @type {Snowflake[]}
*/
guild_positions: 'guildPositions',
/**
* Array of snowflake IDs for guilds which you will not recieve DMs from
* @name ClientUserSettings#restrictedGuilds
* @type {Snowflake[]}
*/
restricted_guilds: 'restrictedGuilds',
explicit_content_filter: function explicitContentFilter(type) { // eslint-disable-line func-name-matching
/**
* Safe direct messaging; force people's messages with images to be scanned before they are sent to you
* one of `DISABLED`, `NON_FRIENDS`, `FRIENDS_AND_NON_FRIENDS`
* @name ClientUserSettings#explicitContentFilter
* @type {string}
*/
return exports.ExplicitContentFilterTypes[type];
},
friend_source_flags: function friendSources(flags) { // eslint-disable-line func-name-matching
/**
* Who can add you as a friend
* @name ClientUserSettings#friendSources
* @type {Object}
* @property {boolean} all Mutual friends and mutual guilds
* @property {boolean} mutualGuilds Only mutual guilds
* @property {boolean} mutualFriends Only mutual friends
*/
return {
all: flags.all || false,
mutualGuilds: flags.all ? true : flags.mutual_guilds || false,
mutualFriends: flags.all ? true : flags.mutualFriends || false,
};
},
};
exports.Colors = {
DEFAULT: 0x000000,
AQUA: 0x1ABC9C,

View File

@@ -197,7 +197,7 @@ class Util {
* @param {*} element Element to move
* @param {number} newIndex Index or offset to move the element to
* @param {boolean} [offset=false] Move the element by an offset amount rather than to a set index
* @returns {Array<*>}
* @returns {number}
* @private
*/
static moveElementInArray(array, element, newIndex, offset = false) {
@@ -207,7 +207,7 @@ class Util {
const removedElement = array.splice(index, 1)[0];
array.splice(newIndex, 0, removedElement);
}
return array;
return array.indexOf(element);
}
}