diff --git a/client/src/modules/discordapi.js b/client/src/modules/discordapi.js index b9c4113e..e3b398e5 100644 --- a/client/src/modules/discordapi.js +++ b/client/src/modules/discordapi.js @@ -69,6 +69,7 @@ export default class DiscordApi { /** * A list of loaded guilds. + * @type {List} */ static get guilds() { const guilds = Modules.GuildStore.getGuilds(); @@ -77,6 +78,7 @@ export default class DiscordApi { /** * A list of loaded channels. + * @type {List} */ static get channels() { const channels = Modules.ChannelStore.getChannels(); @@ -85,6 +87,7 @@ export default class DiscordApi { /** * A list of loaded users. + * @type {List} */ static get users() { const users = Modules.UserStore.getUsers(); @@ -93,6 +96,7 @@ export default class DiscordApi { /** * An object mapping guild IDs to their member counts. + * @type {Object} */ static get memberCounts() { return Modules.MemberCountStore.getMemberCounts(); @@ -100,6 +104,7 @@ export default class DiscordApi { /** * A list of guilds in the order they appear in the server list. + * @type {List} */ static get sortedGuilds() { const guilds = Modules.SortedGuildStore.getSortedGuilds(); @@ -108,6 +113,7 @@ export default class DiscordApi { /** * An array of guild IDs in the order they appear in the server list. + * @type {Number[]} */ static get guildPositions() { return Modules.SortedGuildStore.guildPositions; @@ -115,6 +121,7 @@ export default class DiscordApi { /** * The currently selected guild. + * @type {Guild} */ static get currentGuild() { const guild = Modules.GuildStore.getGuild(Modules.SelectedGuildStore.getGuildId()); @@ -123,6 +130,7 @@ export default class DiscordApi { /** * The currently selected channel. + * @type {Channel} */ static get currentChannel() { const channel = Modules.ChannelStore.getChannel(Modules.SelectedChannelStore.getChannelId()); @@ -131,6 +139,7 @@ export default class DiscordApi { /** * The current user. + * @type {User} */ static get currentUser() { const user = Modules.UserStore.getCurrentUser(); @@ -139,12 +148,15 @@ export default class DiscordApi { /** * A list of the current user's friends. + * @type {List} */ static get friends() { const friends = Modules.RelationshipStore.getFriendIDs(); return List.from(friends, id => User.fromId(id)); } - + /** + * User settings + */ static get UserSettings() { return UserSettings; } @@ -162,6 +174,7 @@ export class UserSettings { /** * The user's current status. Either "online", "idle", "dnd" or "invisible". + * @type {String} */ static get status() { return Modules.UserSettingsStore.status } @@ -169,11 +182,13 @@ export class UserSettings { * The user's selected explicit content filter level. * 0 == off, 1 == everyone except friends, 2 == everyone * Configurable in the privacy and safety panel. + * @type {Number} */ static get explicitContentFilter() { return Modules.UserSettingsStore.explicitContentFilter } /** * Whether to disallow direct messages from server members by default. + * @type {Boolean} */ static get defaultGuildsRestricted() { return Modules.UserSettingsStore.defaultGuildsRestricted } @@ -181,6 +196,7 @@ export class UserSettings { * An array of guilds to disallow direct messages from their members. * This is bypassed if the member is has another mutual guild with this disabled, or the member is friends with the current user. * Configurable in each server's privacy settings. + * @type {Guild[]} */ static get restrictedGuildIds() { return Modules.UserSettingsStore.restrictedGuilds } @@ -192,6 +208,7 @@ export class UserSettings { * An array of flags specifying who should be allowed to add the current user as a friend. * If everyone is checked, this will only have one item, "all". Otherwise it has either "mutual_friends", "mutual_guilds", both or neither. * Configurable in the privacy and safety panel. + * @type {Array} */ static get friendSourceFlags() { return Object.keys(Modules.UserSettingsStore.friendSourceFlags) } static get friendSourceEveryone() { return this.friendSourceFlags.include('all') } @@ -202,72 +219,84 @@ export class UserSettings { /** * Whether to automatically add accounts from other platforms running on the user's computer. * Configurable in the connections panel. + * @type {Boolean} */ static get detectPlatformAccounts() { return Modules.UserSettingsStore.detectPlatformAccounts } /** * The number of seconds Discord will wait for activity before sending mobile push notifications. * Configurable in the notifications panel. + * @type {Number} */ static get afkTimeout() { return Modules.UserSettingsStore.afkTimeout } /** * Whether to display the currently running game as a status message. * Configurable in the games panel. + * @type {Boolean} */ static get showCurrentGame() { return Modules.UserSettingsStore.showCurrentGame } /** * Whether to show images uploaded directly to Discord. * Configurable in the text and images panel. + * @type {Boolean} */ static get inlineAttachmentMedia() { return Modules.UserSettingsStore.inlineAttachmentMedia } /** * Whether to show images linked in Discord. * Configurable in the text and images panel. + * @type {Boolean} */ static get inlineEmbedMedia() { return Modules.UserSettingsStore.inlineEmbedMedia } /** * Whether to automatically play GIFs when the Discord window is active without having to hover the mouse over the image. * Configurable in the text and images panel. + * @type {Boolean} */ static get autoplayGifs() { return Modules.UserSettingsStore.gifAutoPlay } /** * Whether to show content from HTTP[s] links as embeds. * Configurable in the text and images panel. + * @type {Boolean} */ static get showEmbeds() { return Modules.UserSettingsStore.renderEmbeds } /** * Whether to show a message's reactions. * Configurable in the text and images panel. + * @type {Boolean} */ static get showReactions() { return Modules.UserSettingsStore.renderReactions } /** * Whether to play animated emoji. * Configurable in the text and images panel. + * @type {Boolean} */ static get animateEmoji() { return Modules.UserSettingsStore.animateEmoji } /** * Whether to convert ASCII emoticons to emoji. * Configurable in the text and images panel. + * @type {Boolean} */ static get convertEmoticons() { return Modules.UserSettingsStore.convertEmoticons } /** * Whether to allow playing text-to-speech messages. * Configurable in the text and images panel. + * @type {Boolean} */ static get allowTts() { return Modules.UserSettingsStore.enableTTSCommand } /** * The user's selected theme. Either "dark" or "light". * Configurable in the appearance panel. + * @type {String} */ static get theme() { return Modules.UserSettingsStore.theme } @@ -275,6 +304,7 @@ export class UserSettings { * Whether the user has enabled compact mode. * `true` if compact mode is enabled, `false` if cozy mode is enabled. * Configurable in the appearance panel. + * @type {Boolean} */ static get displayCompact() { return Modules.UserSettingsStore.messageDisplayCompact } @@ -282,18 +312,21 @@ export class UserSettings { * Whether the user has enabled developer mode. * Currently only adds a "Copy ID" option to the context menu on users, guilds and channels. * Configurable in the appearance panel. + * @type {Boolean} */ static get developerMode() { return Modules.UserSettingsStore.developerMode } /** * The user's selected language code. * Configurable in the language panel. + * @type {String} */ static get locale() { return Modules.UserSettingsStore.locale } /** * The user's timezone offset in hours. * This is not configurable. + * @type {Number} */ static get timezoneOffset() { return Modules.UserSettingsStore.timezoneOffset } } diff --git a/client/src/structs/discord/channel.js b/client/src/structs/discord/channel.js index f56ea9af..35a0688f 100644 --- a/client/src/structs/discord/channel.js +++ b/client/src/structs/discord/channel.js @@ -1,4 +1,4 @@ -/** +/* * BetterDiscord Channel Struct * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks * All rights reserved. @@ -16,6 +16,9 @@ import { User, GuildMember } from './user'; const channels = new WeakMap(); +/** + * Class representing a Discord Channel + */ export class Channel { constructor(data) { @@ -86,6 +89,7 @@ export class Channel { /** * A list of messages in this channel. + * @type {List} */ get messages() { const messages = Modules.MessageStore.getMessages(this.id).toArray(); @@ -126,6 +130,7 @@ export class Channel { /** * Whether this channel is currently selected. + * @type {Boolean} */ get isSelected() { return DiscordApi.currentChannel === this; diff --git a/client/src/structs/discord/guild.js b/client/src/structs/discord/guild.js index e96e06b2..3e419046 100644 --- a/client/src/structs/discord/guild.js +++ b/client/src/structs/discord/guild.js @@ -1,4 +1,4 @@ -/** +/* * BetterDiscord Guild Struct * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks * All rights reserved. @@ -16,6 +16,9 @@ import { GuildMember } from './user'; const roles = new WeakMap(); +/** + * Class representing a Discord Role + */ export class Role { constructor(data, guild_id) { if (roles.has(data)) return roles.get(data); @@ -47,6 +50,9 @@ export class Role { const emojis = new WeakMap(); +/** + * Class representing a Discord Emoji + */ export class Emoji { constructor(data) { if (emojis.has(data)) return emojis.get(data); @@ -72,6 +78,9 @@ export class Emoji { const guilds = new WeakMap(); +/** + * Class representing a Discord Guild + */ export class Guild { constructor(data) { diff --git a/client/src/structs/discord/message.js b/client/src/structs/discord/message.js index 0c6ae81d..feb240be 100644 --- a/client/src/structs/discord/message.js +++ b/client/src/structs/discord/message.js @@ -15,6 +15,9 @@ import { User } from './user'; const reactions = new WeakMap(); +/** + * Class representing a Discord Reaction + */ export class Reaction { constructor(data, message_id, channel_id) { if (reactions.has(data)) return reactions.get(data); @@ -49,6 +52,9 @@ export class Reaction { const embeds = new WeakMap(); +/** + * Class representing a Discord Embed + */ export class Embed { constructor(data, message_id, channel_id) { if (embeds.has(data)) return embeds.get(data); @@ -88,6 +94,9 @@ export class Embed { const messages = new WeakMap(); +/** + * Class representing a Discord Message + */ export class Message { constructor(data) { @@ -170,6 +179,9 @@ export class Message { } +/** + * Class representing a default Discord Message + */ export class DefaultMessage extends Message { get webhookId() { return this.discordObject.webhookId } get type() { return 'DEFAULT' } diff --git a/client/src/structs/discord/user.js b/client/src/structs/discord/user.js index d942ffb2..086d3504 100644 --- a/client/src/structs/discord/user.js +++ b/client/src/structs/discord/user.js @@ -1,4 +1,4 @@ -/** +/* * BetterDiscord User Struct * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks * All rights reserved. @@ -16,6 +16,9 @@ import { Channel } from './channel'; const users = new WeakMap(); +/** + * Class representing a Discord user + */ export class User { constructor(data) { @@ -141,6 +144,9 @@ export class User { const guild_members = new WeakMap(); +/** + * Class representing a Discord Guild Member + */ export class GuildMember { constructor(data, guild_id) { if (guild_members.has(data)) return guild_members.get(data); diff --git a/client/src/structs/list.js b/client/src/structs/list.js index da47fdf4..680ab277 100644 --- a/client/src/structs/list.js +++ b/client/src/structs/list.js @@ -1,4 +1,4 @@ -/** +/* * BetterDiscord List * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks * All rights reserved. @@ -8,6 +8,11 @@ * LICENSE file in the root directory of this source tree. */ +/** + * Class representing a list. + * @extends Array + */ + export default class List extends Array { get(...filters) {