Change all properties to camel case
This commit is contained in:
parent
5a6fb990c7
commit
b0ae424adb
|
@ -169,22 +169,22 @@ export class UserSettings {
|
|||
* 0 == off, 1 == everyone except friends, 2 == everyone
|
||||
* Configurable in the privacy and safety panel.
|
||||
*/
|
||||
static get explicit_content_filter() { return Modules.UserSettingsStore.explicitContentFilter }
|
||||
static get explicitContentFilter() { return Modules.UserSettingsStore.explicitContentFilter }
|
||||
|
||||
/**
|
||||
* Whether to disallow direct messages from server members by default.
|
||||
*/
|
||||
static get default_guilds_restricted() { return Modules.UserSettingsStore.defaultGuildsRestricted }
|
||||
static get defaultGuildsRestricted() { return Modules.UserSettingsStore.defaultGuildsRestricted }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
static get restricted_guild_ids() { return Modules.UserSettingsStore.restrictedGuilds }
|
||||
static get restrictedGuildIds() { return Modules.UserSettingsStore.restrictedGuilds }
|
||||
|
||||
static get restricted_guilds() {
|
||||
return List.from(this.restricted_guild_ids, id => Guild.fromId(id) || id);
|
||||
static get restrictedGuilds() {
|
||||
return List.from(this.restrictedGuildIds, id => Guild.fromId(id) || id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -192,77 +192,77 @@ export class UserSettings {
|
|||
* 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.
|
||||
*/
|
||||
static get friend_source_flags() { return Object.keys(Modules.UserSettingsStore.friendSourceFlags) }
|
||||
static get friend_source_everyone() { return this.friend_source_flags.include('all') }
|
||||
static get friend_source_mutual_friends() { return this.friend_source_flags.include('all') || this.friend_source_flags.include('mutual_friends') }
|
||||
static get friend_source_mutual_guilds() { return this.friend_source_flags.include('all') || this.friend_source_flags.include('mutual_guilds') }
|
||||
static get friend_source_anyone() { return this.friend_source_flags.length > 0 }
|
||||
static get friendSourceFlags() { return Object.keys(Modules.UserSettingsStore.friendSourceFlags) }
|
||||
static get friendSourceEveryone() { return this.friend_source_flags.include('all') }
|
||||
static get friendSourceMutual_friends() { return this.friend_source_flags.include('all') || this.friend_source_flags.include('mutual_friends') }
|
||||
static get friendSourceMutual_guilds() { return this.friend_source_flags.include('all') || this.friend_source_flags.include('mutual_guilds') }
|
||||
static get friendSourceAnyone() { return this.friend_source_flags.length > 0 }
|
||||
|
||||
/**
|
||||
* Whether to automatically add accounts from other platforms running on the user's computer.
|
||||
* Configurable in the connections panel.
|
||||
*/
|
||||
static get detect_platform_accounts() { return Modules.UserSettingsStore.detectPlatformAccounts }
|
||||
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.
|
||||
*/
|
||||
static get afk_timeout() { return Modules.UserSettingsStore.afkTimeout }
|
||||
static get afkTimeout() { return Modules.UserSettingsStore.afkTimeout }
|
||||
|
||||
/**
|
||||
* Whether to display the currently running game as a status message.
|
||||
* Configurable in the games panel.
|
||||
*/
|
||||
static get show_current_game() { return Modules.UserSettingsStore.showCurrentGame }
|
||||
static get showCurrentGame() { return Modules.UserSettingsStore.showCurrentGame }
|
||||
|
||||
/**
|
||||
* Whether to show images uploaded directly to Discord.
|
||||
* Configurable in the text and images panel.
|
||||
*/
|
||||
static get inline_attachment_media() { return Modules.UserSettingsStore.inlineAttachmentMedia }
|
||||
static get inlineAttachmentMedia() { return Modules.UserSettingsStore.inlineAttachmentMedia }
|
||||
|
||||
/**
|
||||
* Whether to show images linked in Discord.
|
||||
* Configurable in the text and images panel.
|
||||
*/
|
||||
static get inline_embed_media() { return Modules.UserSettingsStore.inlineEmbedMedia }
|
||||
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.
|
||||
*/
|
||||
static get autoplay_gifs() { return Modules.UserSettingsStore.gifAutoPlay }
|
||||
static get autoplayGifs() { return Modules.UserSettingsStore.gifAutoPlay }
|
||||
|
||||
/**
|
||||
* Whether to show content from HTTP[s] links as embeds.
|
||||
* Configurable in the text and images panel.
|
||||
*/
|
||||
static get show_embeds() { return Modules.UserSettingsStore.renderEmbeds }
|
||||
static get showEmbeds() { return Modules.UserSettingsStore.renderEmbeds }
|
||||
|
||||
/**
|
||||
* Whether to show a message's reactions.
|
||||
* Configurable in the text and images panel.
|
||||
*/
|
||||
static get show_reactions() { return Modules.UserSettingsStore.renderReactions }
|
||||
static get showReactions() { return Modules.UserSettingsStore.renderReactions }
|
||||
|
||||
/**
|
||||
* Whether to play animated emoji.
|
||||
* Configurable in the text and images panel.
|
||||
*/
|
||||
static get animate_emoji() { return Modules.UserSettingsStore.animateEmoji }
|
||||
static get animateEmoji() { return Modules.UserSettingsStore.animateEmoji }
|
||||
|
||||
/**
|
||||
* Whether to convert ASCII emoticons to emoji.
|
||||
* Configurable in the text and images panel.
|
||||
*/
|
||||
static get convert_emoticons() { return Modules.UserSettingsStore.convertEmoticons }
|
||||
static get convertEmoticons() { return Modules.UserSettingsStore.convertEmoticons }
|
||||
|
||||
/**
|
||||
* Whether to allow playing text-to-speech messages.
|
||||
* Configurable in the text and images panel.
|
||||
*/
|
||||
static get enable_tts() { return Modules.UserSettingsStore.enableTTSCommand }
|
||||
static get allowTts() { return Modules.UserSettingsStore.enableTTSCommand }
|
||||
|
||||
/**
|
||||
* The user's selected theme. Either "dark" or "light".
|
||||
|
@ -275,14 +275,14 @@ export class UserSettings {
|
|||
* `true` if compact mode is enabled, `false` if cozy mode is enabled.
|
||||
* Configurable in the appearance panel.
|
||||
*/
|
||||
static get display_compact() { return Modules.UserSettingsStore.messageDisplayCompact }
|
||||
static get displayCompact() { return Modules.UserSettingsStore.messageDisplayCompact }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
static get developer_mode() { return Modules.UserSettingsStore.developerMode }
|
||||
static get developerMode() { return Modules.UserSettingsStore.developerMode }
|
||||
|
||||
/**
|
||||
* The user's selected language code.
|
||||
|
@ -294,5 +294,5 @@ export class UserSettings {
|
|||
* The user's timezone offset in hours.
|
||||
* This is not configurable.
|
||||
*/
|
||||
static get timezone_offset() { return Modules.UserSettingsStore.timezoneOffset }
|
||||
static get timezoneOffset() { return Modules.UserSettingsStore.timezoneOffset }
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ export class Channel {
|
|||
static get GroupChannel() { return GroupChannel }
|
||||
|
||||
get id() { return this.discordObject.id }
|
||||
get application_id() { return this.discordObject.application_id }
|
||||
get applicationId() { return this.discordObject.application_id }
|
||||
get type() { return this.discordObject.type }
|
||||
get name() { return this.discordObject.name }
|
||||
|
||||
|
@ -62,9 +62,11 @@ export class Channel {
|
|||
*/
|
||||
async sendMessage(content, parse = false) {
|
||||
if (this.assertPermissions) this.assertPermissions('SEND_MESSAGES', Modules.DiscordPermissions.VIEW_CHANNEL | Modules.DiscordPermissions.SEND_MESSAGES);
|
||||
let response = {};
|
||||
if (parse) response = await Modules.MessageActions._sendMessage(this.id, Modules.MessageParser.parse(this.discordObject, content));
|
||||
else response = await Modules.MessageActions._sendMessage(this.id, {content});
|
||||
|
||||
if (parse) content = Modules.MessageParser.parse(this.discordObject, content);
|
||||
else content = {content};
|
||||
|
||||
const response = await Modules.MessageActions._sendMessage(this.id, content);
|
||||
return Message.from(Modules.MessageStore.getMessage(this.id, response.body.id));
|
||||
}
|
||||
|
||||
|
@ -116,13 +118,13 @@ export class Channel {
|
|||
*/
|
||||
select() {
|
||||
if (this.assertPermissions) this.assertPermissions('VIEW_CHANNEL', Modules.DiscordPermissions.VIEW_CHANNEL);
|
||||
Modules.NavigationUtils.transitionToGuild(this.guild_id ? this.guild_id : Modules.DiscordConstants.ME, this.id);
|
||||
Modules.NavigationUtils.transitionToGuild(this.guildId ? this.guildId : Modules.DiscordConstants.ME, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this channel is currently selected.
|
||||
*/
|
||||
get selected() {
|
||||
get isSelected() {
|
||||
return DiscordApi.currentChannel === this;
|
||||
}
|
||||
|
||||
|
@ -140,7 +142,7 @@ export class Channel {
|
|||
export class PermissionOverwrite {
|
||||
constructor(data, channel_id) {
|
||||
this.discordObject = data;
|
||||
this.channel_id = channel_id;
|
||||
this.channelId = channel_id;
|
||||
}
|
||||
|
||||
static from(data, channel_id) {
|
||||
|
@ -159,7 +161,7 @@ export class PermissionOverwrite {
|
|||
get deny() { return this.discordObject.deny }
|
||||
|
||||
get channel() {
|
||||
return Channel.fromId(this.channel_id);
|
||||
return Channel.fromId(this.channelId);
|
||||
}
|
||||
|
||||
get guild() {
|
||||
|
@ -168,26 +170,26 @@ export class PermissionOverwrite {
|
|||
}
|
||||
|
||||
export class RolePermissionOverwrite extends PermissionOverwrite {
|
||||
get role_id() { return this.discordObject.id }
|
||||
get roleId() { return this.discordObject.id }
|
||||
|
||||
get role() {
|
||||
if (this.guild) return this.guild.roles.find(r => r.id === this.role_id);
|
||||
if (this.guild) return this.guild.roles.find(r => r.id === this.roleId);
|
||||
}
|
||||
}
|
||||
|
||||
export class MemberPermissionOverwrite extends PermissionOverwrite {
|
||||
get member_id() { return this.discordObject.id }
|
||||
get memberId() { return this.discordObject.id }
|
||||
|
||||
get member() {
|
||||
return GuildMember.fromId(this.member_id);
|
||||
return GuildMember.fromId(this.memberId);
|
||||
}
|
||||
}
|
||||
|
||||
export class GuildChannel extends Channel {
|
||||
static get PermissionOverwrite() { return PermissionOverwrite }
|
||||
|
||||
get guild_id() { return this.discordObject.guild_id }
|
||||
get parent_id() { return this.discordObject.parent_id } // Channel category
|
||||
get guildId() { return this.discordObject.guild_id }
|
||||
get parentId() { return this.discordObject.parent_id } // Channel category
|
||||
get position() { return this.discordObject.position }
|
||||
get nicks() { return this.discordObject.nicks }
|
||||
|
||||
|
@ -196,12 +198,11 @@ export class GuildChannel extends Channel {
|
|||
}
|
||||
|
||||
assertPermissions(name, perms) {
|
||||
if (!this.checkPermissions(perms))
|
||||
throw new InsufficientPermissions(name);
|
||||
if (!this.checkPermissions(perms)) throw new InsufficientPermissions(name);
|
||||
}
|
||||
|
||||
get category() {
|
||||
return Channel.fromId(this.parent_id);
|
||||
return Channel.fromId(this.parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,20 +212,19 @@ export class GuildChannel extends Channel {
|
|||
return Modules.GuildPermissions.getChannelPermissions(this.id);
|
||||
}
|
||||
|
||||
get permission_overwrites() {
|
||||
get permissionOverwrites() {
|
||||
return List.from(Object.entries(this.discordObject.permissionOverwrites), ([i, p]) => PermissionOverwrite.from(p, this.id));
|
||||
}
|
||||
|
||||
get guild() {
|
||||
const guild = Modules.GuildStore.getGuild(this.guild_id);
|
||||
if (guild) return Guild.from(guild);
|
||||
return Guild.fromId(this.guildId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this channel is the guild's default channel.
|
||||
*/
|
||||
get default_channel() {
|
||||
return Modules.GuildChannelsStore.getDefaultChannel(this.guild_id).id === this.id;
|
||||
get defaultChannel() {
|
||||
return Modules.GuildChannelsStore.getDefaultChannel(this.guildId).id === this.id;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ export class GuildTextChannel extends GuildChannel {
|
|||
// Type 2 - GUILD_VOICE
|
||||
export class GuildVoiceChannel extends GuildChannel {
|
||||
get type() { return 'GUILD_VOICE' }
|
||||
get user_limit() { return this.discordObject.userLimit }
|
||||
get userLimit() { return this.discordObject.userLimit }
|
||||
get bitrate() { return this.discordObject.bitrate }
|
||||
|
||||
sendMessage() { throw new Error('Cannot send messages in a voice channel.'); }
|
||||
|
@ -252,7 +252,7 @@ export class GuildVoiceChannel extends GuildChannel {
|
|||
// Type 4 - GUILD_CATEGORY
|
||||
export class ChannelCategory extends GuildChannel {
|
||||
get type() { return 'GUILD_CATEGORY' }
|
||||
get parent_id() { return undefined }
|
||||
get parentId() { return undefined }
|
||||
get category() { return undefined }
|
||||
|
||||
sendMessage() { throw new Error('Cannot send messages in a channel category.'); }
|
||||
|
@ -266,31 +266,31 @@ export class ChannelCategory extends GuildChannel {
|
|||
* A list of channels in this category.
|
||||
*/
|
||||
get channels() {
|
||||
return List.from(this.guild.channels, c => c.parent_id === this.id);
|
||||
return List.from(this.guild.channels, c => c.parentId === this.id);
|
||||
}
|
||||
}
|
||||
|
||||
export class PrivateChannel extends Channel {
|
||||
get user_limit() { return this.discordObject.userLimit }
|
||||
get userLimit() { return this.discordObject.userLimit }
|
||||
get bitrate() { return this.discordObject.bitrate }
|
||||
}
|
||||
|
||||
// Type 1 - DM
|
||||
export class DirectMessageChannel extends PrivateChannel {
|
||||
get type() { return 'DM' }
|
||||
get recipient_id() { return this.discordObject.recipients[0] }
|
||||
get recipientId() { return this.discordObject.recipients[0] }
|
||||
|
||||
/**
|
||||
* The other user of this direct message channel.
|
||||
*/
|
||||
get recipient() {
|
||||
return User.fromId(this.recipient_id);
|
||||
return User.fromId(this.recipientId);
|
||||
}
|
||||
}
|
||||
|
||||
// Type 3 - GROUP_DM
|
||||
export class GroupChannel extends PrivateChannel {
|
||||
get owner_id() { return this.discordObject.ownerId }
|
||||
get ownerId() { return this.discordObject.ownerId }
|
||||
get type() { return 'GROUP_DM' }
|
||||
get icon() { return this.discordObject.icon }
|
||||
|
||||
|
@ -305,6 +305,6 @@ export class GroupChannel extends PrivateChannel {
|
|||
* The owner of this group direct message channel. This is usually the person who created it.
|
||||
*/
|
||||
get owner() {
|
||||
return User.fromId(this.owner_id);
|
||||
return User.fromId(this.ownerId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,22 +21,22 @@ export class Role {
|
|||
roles.set(data, this);
|
||||
|
||||
this.discordObject = data;
|
||||
this.guild_id = guild_id;
|
||||
this.guildId = guild_id;
|
||||
}
|
||||
|
||||
get id() { return this.discordObject.id }
|
||||
get name() { return this.discordObject.name }
|
||||
get position() { return this.discordObject.position }
|
||||
get original_position() { return this.discordObject.originalPosition }
|
||||
get originalPosition() { return this.discordObject.originalPosition }
|
||||
get permissions() { return this.discordObject.permissions }
|
||||
get managed() { return this.discordObject.managed }
|
||||
get mentionable() { return this.discordObject.mentionable }
|
||||
get hoist() { return this.discordObject.hoist }
|
||||
get colour() { return this.discordObject.color }
|
||||
get colour_string() { return this.discordObject.colorString }
|
||||
get colourString() { return this.discordObject.colorString }
|
||||
|
||||
get guild() {
|
||||
return Guild.fromId(this.guild_id);
|
||||
return Guild.fromId(this.guildId);
|
||||
}
|
||||
|
||||
get members() {
|
||||
|
@ -47,26 +47,25 @@ export class Role {
|
|||
const emojis = new WeakMap();
|
||||
|
||||
export class Emoji {
|
||||
constructor(data, guild_id) {
|
||||
constructor(data) {
|
||||
if (emojis.has(data)) return emojis.get(data);
|
||||
emojis.set(data, this);
|
||||
|
||||
this.discordObject = data;
|
||||
// this.guild_id = guild_id;
|
||||
}
|
||||
|
||||
get id() { return this.discordObject.id }
|
||||
get guild_id() { return this.discordObject.guild_id }
|
||||
get guildId() { return this.discordObject.guild_id }
|
||||
get name() { return this.discordObject.name }
|
||||
get managed() { return this.discordObject.managed }
|
||||
get animated() { return this.discordObject.animated }
|
||||
get all_names_string() { return this.discordObject.allNamesString }
|
||||
get require_colons() { return this.discordObject.require_colons }
|
||||
get allNamesString() { return this.discordObject.allNamesString }
|
||||
get requireColons() { return this.discordObject.require_colons }
|
||||
get url() { return this.discordObject.url }
|
||||
get roles() { return this.discordObject.roles }
|
||||
|
||||
get guild() {
|
||||
return Guild.fromId(this.guild_id);
|
||||
return Guild.fromId(this.guildId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,27 +93,27 @@ export class Guild {
|
|||
static get Emoji() { return Emoji }
|
||||
|
||||
get id() { return this.discordObject.id }
|
||||
get owner_id() { return this.discordObject.ownerId }
|
||||
get application_id() { return this.discordObject.application_id }
|
||||
get system_channel_id() { return this.discordObject.systemChannelId }
|
||||
get ownerId() { return this.discordObject.ownerId }
|
||||
get applicationId() { return this.discordObject.application_id }
|
||||
get systemChannelId() { return this.discordObject.systemChannelId }
|
||||
get name() { return this.discordObject.name }
|
||||
get acronym() { return this.discordObject.acronym }
|
||||
get icon() { return this.discordObject.icon }
|
||||
get joined_at() { return this.discordObject.joinedAt }
|
||||
get verification_level() { return this.discordObject.verificationLevel }
|
||||
get mfa_level() { return this.discordObject.mfaLevel }
|
||||
get joinedAt() { return this.discordObject.joinedAt }
|
||||
get verificationLevel() { return this.discordObject.verificationLevel }
|
||||
get mfaLevel() { return this.discordObject.mfaLevel }
|
||||
get large() { return this.discordObject.large }
|
||||
get lazy() { return this.discordObject.lazy }
|
||||
get voice_region() { return this.discordObject.region }
|
||||
get afk_channel_id() { return this.discordObject.afkChannelId }
|
||||
get afk_timeout() { return this.discordObject.afkTimeout }
|
||||
get explicit_content_filter() { return this.discordObject.explicitContentFilter }
|
||||
get default_message_notifications() { return this.discordObject.defaultMessageNotifications }
|
||||
get voiceRegion() { return this.discordObject.region }
|
||||
get afkChannelId() { return this.discordObject.afkChannelId }
|
||||
get afkTimeout() { return this.discordObject.afkTimeout }
|
||||
get explicitContentFilter() { return this.discordObject.explicitContentFilter }
|
||||
get defaultMessageNotifications() { return this.discordObject.defaultMessageNotifications }
|
||||
get splash() { return this.discordObject.splash }
|
||||
get features() { return this.discordObject.features }
|
||||
|
||||
get owner() {
|
||||
return this.members.find(m => m.user_id === this.owner_id);
|
||||
return this.members.find(m => m.userId === this.ownerId);
|
||||
}
|
||||
|
||||
get roles() {
|
||||
|
@ -142,17 +141,24 @@ export class Guild {
|
|||
/**
|
||||
* Channels that don't have a parent. (Channel categories and any text/voice channel not in one.)
|
||||
*/
|
||||
get main_channels() {
|
||||
return this.channels.filter(c => !c.parent_id);
|
||||
get mainChannels() {
|
||||
return this.channels.filter(c => !c.parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* The guild's default channel. (Usually the first in the list.)
|
||||
*/
|
||||
get default_channel() {
|
||||
get defaultChannel() {
|
||||
return Channel.from(Modules.GuildChannelsStore.getDefaultChannel(this.id));
|
||||
}
|
||||
|
||||
/**
|
||||
* The guild's AFK channel.
|
||||
*/
|
||||
get afkChannel() {
|
||||
if (this.afkChannelId) return Channel.fromId(this.afkChannelId);
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of GuildMember objects.
|
||||
*/
|
||||
|
@ -171,7 +177,7 @@ export class Guild {
|
|||
/**
|
||||
* The total number of members in the guild.
|
||||
*/
|
||||
get member_count() {
|
||||
get memberCount() {
|
||||
return Modules.MemberCountStore.getMemberCount(this.id);
|
||||
}
|
||||
|
||||
|
@ -201,8 +207,8 @@ export class Guild {
|
|||
/**
|
||||
* Whether the user has not restricted direct messages from members of this guild.
|
||||
*/
|
||||
get allow_dms() {
|
||||
return !DiscordApi.UserSettings.restricted_guild_ids.includes(this.id);
|
||||
get allowPrivateMessages() {
|
||||
return !DiscordApi.UserSettings.restrictedGuildIds.includes(this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -222,7 +228,7 @@ export class Guild {
|
|||
/**
|
||||
* Whether this channel is currently selected.
|
||||
*/
|
||||
get selected() {
|
||||
get isSelected() {
|
||||
return DiscordApi.currentGuild === this;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ export class Reaction {
|
|||
reactions.set(data, this);
|
||||
|
||||
this.discordObject = data;
|
||||
this.message_id = message_id;
|
||||
this.channel_id = channel_id;
|
||||
this.messageId = message_id;
|
||||
this.channelId = channel_id;
|
||||
}
|
||||
|
||||
get emoji() {
|
||||
|
@ -39,7 +39,7 @@ export class Reaction {
|
|||
}
|
||||
|
||||
get message() {
|
||||
if (this.channel) return this.channel.messages.find(m => m.id === this.message_id);
|
||||
if (this.channel) return this.channel.messages.find(m => m.id === this.messageId);
|
||||
}
|
||||
|
||||
get guild() {
|
||||
|
@ -55,8 +55,8 @@ export class Embed {
|
|||
embeds.set(data, this);
|
||||
|
||||
this.discordObject = data;
|
||||
this.message_id = message_id;
|
||||
this.channel_id = channel_id;
|
||||
this.messageId = message_id;
|
||||
this.channelId = channel_id;
|
||||
}
|
||||
|
||||
get title() { return this.discordObject.title }
|
||||
|
@ -74,11 +74,11 @@ export class Embed {
|
|||
get fields() { return this.discordObject.fields }
|
||||
|
||||
get channel() {
|
||||
return Channel.fromId(this.channel_id);
|
||||
return Channel.fromId(this.channelId);
|
||||
}
|
||||
|
||||
get message() {
|
||||
if (this.channel) return this.channel.messages.find(m => m.id === this.message_id);
|
||||
if (this.channel) return this.channel.messages.find(m => m.id === this.messageId);
|
||||
}
|
||||
|
||||
get guild() {
|
||||
|
@ -123,21 +123,20 @@ export class Message {
|
|||
static get Embed() { return Embed }
|
||||
|
||||
get id() { return this.discordObject.id }
|
||||
get channel_id() { return this.discordObject.channel_id }
|
||||
get channelId() { return this.discordObject.channel_id }
|
||||
get nonce() { return this.discordObject.nonce }
|
||||
get type() { return this.discordObject.type }
|
||||
get timestamp() { return this.discordObject.timestamp }
|
||||
get state() { return this.discordObject.state }
|
||||
get nick() { return this.discordObject.nick }
|
||||
get colour_string() { return this.discordObject.colorString }
|
||||
get colourString() { return this.discordObject.colorString }
|
||||
|
||||
get author() {
|
||||
if (this.webhook_id) return this.discordObject.author;
|
||||
if (this.discordObject.author) return User.from(this.discordObject.author);
|
||||
if (this.discordObject.author && !this.webhookId) return User.from(this.discordObject.author);
|
||||
}
|
||||
|
||||
get channel() {
|
||||
return Channel.fromId(this.channel_id);
|
||||
return Channel.fromId(this.channelId);
|
||||
}
|
||||
|
||||
get guild() {
|
||||
|
@ -149,30 +148,29 @@ export class Message {
|
|||
* TODO: how do we know if the message was deleted successfully?
|
||||
*/
|
||||
delete() {
|
||||
Modules.MessageActions.deleteMessage(this.channel_id, this.id);
|
||||
Modules.MessageActions.deleteMessage(this.channelId, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Jumps to the message.
|
||||
*/
|
||||
jumpTo(flash = true) {
|
||||
Modules.MessageActions.jumpToMessage(this.channel_id, this.id, flash);
|
||||
Modules.MessageActions.jumpToMessage(this.channelId, this.id, flash);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class DefaultMessage extends Message {
|
||||
get webhook_id() { return this.discordObject.webhookId }
|
||||
get webhookId() { return this.discordObject.webhookId }
|
||||
get type() { return 'DEFAULT' }
|
||||
get content() { return this.discordObject.content }
|
||||
get content_parsed() { return this.discordObject.contentParsed }
|
||||
get invite_codes() { return this.discordObject.invites }
|
||||
// get embeds() { return this.discordObject.embeds }
|
||||
get contentParsed() { return this.discordObject.contentParsed }
|
||||
get inviteCodes() { return this.discordObject.invites }
|
||||
get attachments() { return this.discordObject.attachments }
|
||||
get mention_ids() { return this.discordObject.mentions }
|
||||
get mention_role_ids() { return this.discordObject.mentionRoles }
|
||||
get mention_everyone() { return this.discordObject.mentionEveryone }
|
||||
get edited_timestamp() { return this.discordObject.editedTimestamp }
|
||||
get mentionIds() { return this.discordObject.mentions }
|
||||
get mentionRoleIds() { return this.discordObject.mentionRoles }
|
||||
get mentionEveryone() { return this.discordObject.mentionEveryone }
|
||||
get editedTimestamp() { return this.discordObject.editedTimestamp }
|
||||
get tts() { return this.discordObject.tts }
|
||||
get mentioned() { return this.discordObject.mentioned }
|
||||
get bot() { return this.discordObject.bot }
|
||||
|
@ -181,24 +179,28 @@ export class DefaultMessage extends Message {
|
|||
get activity() { return this.discordObject.activity }
|
||||
get application() { return this.discordObject.application }
|
||||
|
||||
get webhook() {
|
||||
if (this.webhookId) return this.discordObject.author;
|
||||
}
|
||||
|
||||
get mentions() {
|
||||
return List.from(this.mention_ids, id => User.fromId(id));
|
||||
return List.from(this.mentionIds, id => User.fromId(id));
|
||||
}
|
||||
|
||||
get mention_roles() {
|
||||
return List.from(this.mention_role_ids, id => this.guild.roles.find(r => r.id === id));
|
||||
return List.from(this.mentionRoleIds, id => this.guild.roles.find(r => r.id === id));
|
||||
}
|
||||
|
||||
get embeds() {
|
||||
return List.from(this.discordObject.embeds, r => new Embed(r, this.id, this.channel_id));
|
||||
return List.from(this.discordObject.embeds, r => new Embed(r, this.id, this.channelId));
|
||||
}
|
||||
|
||||
get reactions() {
|
||||
return List.from(this.discordObject.reactions, r => new Reaction(r, this.id, this.channel_id));
|
||||
return List.from(this.discordObject.reactions, r => new Reaction(r, this.id, this.channelId));
|
||||
}
|
||||
|
||||
get edited() {
|
||||
return !!this.edited_timestamp;
|
||||
return !!this.editedTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,19 +210,19 @@ export class DefaultMessage extends Message {
|
|||
* @param {Boolean} parse Whether to parse the message or update it as it is
|
||||
*/
|
||||
edit(content, parse = false) {
|
||||
if (this.author !== DiscordApi.currentUser)
|
||||
throw new Error('Cannot edit messages sent by other users.');
|
||||
if (parse) Modules.MessageActions.editMessage(this.channel_id, this.id, Modules.MessageParser.parse(this.discordObject, content));
|
||||
else Modules.MessageActions.editMessage(this.channel_id, this.id, {content});
|
||||
if (this.author !== DiscordApi.currentUser) throw new Error('Cannot edit messages sent by other users.');
|
||||
if (parse) content = Modules.MessageParser.parse(this.discordObject, content);
|
||||
else content = {content};
|
||||
Modules.MessageActions.editMessage(this.channelId, this.id, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the edit mode of the UI.
|
||||
* @param {String} content A string to show in the message text area - if empty the message's current content will be used
|
||||
*/
|
||||
startEdit(content) {
|
||||
if (this.author !== DiscordApi.currentUser)
|
||||
throw new Error('Cannot edit messages sent by other users.');
|
||||
Modules.MessageActions.startEditMessage(this.channel_id, this.id, content || this.content);
|
||||
if (this.author !== DiscordApi.currentUser) throw new Error('Cannot edit messages sent by other users.');
|
||||
Modules.MessageActions.startEditMessage(this.channelId, this.id, content || this.content);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,35 +235,35 @@ export class DefaultMessage extends Message {
|
|||
|
||||
export class RecipientAddMessage extends Message {
|
||||
get type() { return 'RECIPIENT_ADD' }
|
||||
get added_user_id() { return this.discordObject.mentions[0] }
|
||||
get addedUserId() { return this.discordObject.mentions[0] }
|
||||
|
||||
get added_user() {
|
||||
return User.fromId(this.added_user_id);
|
||||
get addedUser() {
|
||||
return User.fromId(this.addedUserId);
|
||||
}
|
||||
}
|
||||
|
||||
export class RecipientRemoveMessage extends Message {
|
||||
get type() { return 'RECIPIENT_REMOVE' }
|
||||
get removed_user_id() { return this.discordObject.mentions[0] }
|
||||
get removedUserId() { return this.discordObject.mentions[0] }
|
||||
|
||||
get removed_user() {
|
||||
return User.fromId(this.removed_user_id);
|
||||
get removedUser() {
|
||||
return User.fromId(this.removedUserId);
|
||||
}
|
||||
|
||||
get user_left() {
|
||||
return this.author === this.removed_user;
|
||||
get userLeft() {
|
||||
return this.author === this.removedUser;
|
||||
}
|
||||
}
|
||||
|
||||
export class CallMessage extends Message {
|
||||
get type() { return 'CALL' }
|
||||
get mention_ids() { return this.discordObject.mentions }
|
||||
get mentionIds() { return this.discordObject.mentions }
|
||||
get call() { return this.discordObject.call }
|
||||
|
||||
get ended_timestamp() { return this.call.endedTimestamp }
|
||||
get endedTimestamp() { return this.call.endedTimestamp }
|
||||
|
||||
get mentions() {
|
||||
return List.from(this.mention_ids, id => User.fromId(id));
|
||||
return List.from(this.mentionIds, id => User.fromId(id));
|
||||
}
|
||||
|
||||
get participants() {
|
||||
|
@ -271,7 +273,7 @@ export class CallMessage extends Message {
|
|||
|
||||
export class GroupChannelNameChangeMessage extends Message {
|
||||
get type() { return 'CHANNEL_NAME_CHANGE' }
|
||||
get new_name() { return this.discordObject.content }
|
||||
get newName() { return this.discordObject.content }
|
||||
}
|
||||
|
||||
export class GroupChannelIconChangeMessage extends Message {
|
||||
|
|
|
@ -35,25 +35,25 @@ export class User {
|
|||
|
||||
get id() { return this.discordObject.id }
|
||||
get username() { return this.discordObject.username }
|
||||
get username_lower_case() { return this.discordObject.usernameLowerCase }
|
||||
get usernameLowerCase() { return this.discordObject.usernameLowerCase }
|
||||
get discriminator() { return this.discordObject.discriminator }
|
||||
get avatar() { return this.discordObject.avatar }
|
||||
get email() { return undefined }
|
||||
get phone() { return undefined }
|
||||
get flags() { return this.discordObject.flags }
|
||||
get bot() { return this.discordObject.bot }
|
||||
get isBot() { return this.discordObject.bot }
|
||||
get premium() { return this.discordObject.premium }
|
||||
get verified() { return this.discordObject.verified }
|
||||
get mfa_enabled() { return this.discordObject.mfaEnabled }
|
||||
get mfaEnabled() { return this.discordObject.mfaEnabled }
|
||||
get mobile() { return this.discordObject.mobile }
|
||||
|
||||
get tag() { return this.discordObject.tag }
|
||||
get avatar_url() { return this.discordObject.avatarURL }
|
||||
get created_at() { return this.discordObject.createdAt }
|
||||
get avatarUrl() { return this.discordObject.avatarURL }
|
||||
get createdAt() { return this.discordObject.createdAt }
|
||||
|
||||
get is_clamied() { return this.discordObject.isClaimed() }
|
||||
get is_local_bot() { return this.discordObject.isLocalBot() }
|
||||
get is_phone_verified() { return this.discordObject.isPhoneVerified() }
|
||||
get isClamied() { return this.discordObject.isClaimed() }
|
||||
get isLocalBot() { return this.discordObject.isLocalBot() }
|
||||
get isPhoneVerified() { return this.discordObject.isPhoneVerified() }
|
||||
|
||||
get guilds() {
|
||||
return DiscordApi.guilds.filter(g => g.members.find(m => m.user === this));
|
||||
|
@ -69,14 +69,14 @@ export class User {
|
|||
return Modules.UserStatusStore.getActivity(this.id);
|
||||
}
|
||||
|
||||
get direct_messages() {
|
||||
return DiscordApi.channels.find(c => c.type === 'DM' && c.recipient_id === this.id);
|
||||
get privateChannel() {
|
||||
return DiscordApi.channels.find(c => c.type === 'DM' && c.recipientId === this.id);
|
||||
}
|
||||
|
||||
async ensurePrivateChannel() {
|
||||
if (DiscordApi.currentUser === this)
|
||||
throw new Error('Cannot create a direct message channel to the current user.');
|
||||
return Channel.from(await Modules.PrivateChannelActions.ensurePrivateChannel(DiscordApi.currentUser.id, this.id));
|
||||
return Channel.fromId(await Modules.PrivateChannelActions.ensurePrivateChannel(DiscordApi.currentUser.id, this.id));
|
||||
}
|
||||
|
||||
async sendMessage(content, parse = true) {
|
||||
|
@ -84,11 +84,11 @@ export class User {
|
|||
return channel.sendMessage(content, parse);
|
||||
}
|
||||
|
||||
get is_friend() {
|
||||
get isFriend() {
|
||||
return Modules.RelationshipStore.isFriend(this.id);
|
||||
}
|
||||
|
||||
get is_blocked() {
|
||||
get isBlocked() {
|
||||
return Modules.RelationshipStore.isBlocked(this.id);
|
||||
}
|
||||
|
||||
|
@ -127,17 +127,17 @@ export class GuildMember {
|
|||
guild_members.set(data, this);
|
||||
|
||||
this.discordObject = data;
|
||||
this.guild_id = guild_id;
|
||||
this.guildId = guild_id;
|
||||
}
|
||||
|
||||
get user_id() { return this.discordObject.userId }
|
||||
get userId() { return this.discordObject.userId }
|
||||
get nickname() { return this.discordObject.nick }
|
||||
get colour_string() { return this.discordObject.colorString }
|
||||
get hoist_role_id() { return this.discordObject.hoistRoleId }
|
||||
get role_ids() { return this.discordObject.roles }
|
||||
get colourString() { return this.discordObject.colorString }
|
||||
get hoistRoleId() { return this.discordObject.hoistRoleId }
|
||||
get roleIds() { return this.discordObject.roles }
|
||||
|
||||
get user() {
|
||||
return User.fromId(this.user_id);
|
||||
return User.fromId(this.userId);
|
||||
}
|
||||
|
||||
get name() {
|
||||
|
@ -145,16 +145,16 @@ export class GuildMember {
|
|||
}
|
||||
|
||||
get guild() {
|
||||
return Guild.fromId(this.guild_id);
|
||||
return Guild.fromId(this.guildId);
|
||||
}
|
||||
|
||||
get roles() {
|
||||
return List.from(this.role_ids, id => this.guild.roles.find(r => r.id === id))
|
||||
return List.from(this.roleIds, id => this.guild.roles.find(r => r.id === id))
|
||||
.sort((r1, r2) => r1.position === r2.position ? 0 : r1.position > r2.position ? 1 : -1);
|
||||
}
|
||||
|
||||
get hoist_role() {
|
||||
return this.guild.roles.find(r => r.id === this.hoist_role_id);
|
||||
get hoistRole() {
|
||||
return this.guild.roles.find(r => r.id === this.hoistRoleId);
|
||||
}
|
||||
|
||||
checkPermissions(perms) {
|
||||
|
@ -162,8 +162,7 @@ export class GuildMember {
|
|||
}
|
||||
|
||||
assertPermissions(name, perms) {
|
||||
if (!this.checkPermissions(perms))
|
||||
throw new InsufficientPermissions(name);
|
||||
if (!this.checkPermissions(perms)) throw new InsufficientPermissions(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,7 +173,7 @@ export class GuildMember {
|
|||
this.assertPermissions('CHANGE_NICKNAME', Modules.DiscordPermissions.CHANGE_NICKNAME);
|
||||
else this.assertPermissions('MANAGE_NICKNAMES', Modules.DiscordPermissions.MANAGE_NICKNAMES);
|
||||
|
||||
Modules.ChangeNicknameModal.open(this.guild_id, this.user_id);
|
||||
Modules.ChangeNicknameModal.open(this.guildId, this.userId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,7 +187,7 @@ export class GuildMember {
|
|||
else this.assertPermissions('MANAGE_NICKNAMES', Modules.DiscordPermissions.MANAGE_NICKNAMES);
|
||||
|
||||
return Modules.APIModule.patch({
|
||||
url: `${Modules.DiscordConstants.Endpoints.GUILD_MEMBERS(this.guild_id)}/${DiscordApi.currentUser === this.user ? '@me/nick' : this.user_id}`,
|
||||
url: `${Modules.DiscordConstants.Endpoints.GUILD_MEMBERS(this.guild_id)}/${DiscordApi.currentUser === this.user ? '@me/nick' : this.userId}`,
|
||||
body: { nick }
|
||||
});
|
||||
}
|
||||
|
@ -200,7 +199,7 @@ export class GuildMember {
|
|||
*/
|
||||
kick(reason = '') {
|
||||
this.assertPermissions('KICK_MEMBERS', Modules.DiscordPermissions.KICK_MEMBERS);
|
||||
return Modules.GuildActions.kickUser(this.guild_id, this.user_id, reason);
|
||||
return Modules.GuildActions.kickUser(this.guildId, this.userId, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,7 +210,7 @@ export class GuildMember {
|
|||
*/
|
||||
ban(daysToDelete = 1, reason = '') {
|
||||
this.assertPermissions('BAN_MEMBERS', Modules.DiscordPermissions.BAN_MEMBERS);
|
||||
return Modules.GuildActions.banUser(this.guild_id, this.user_id, daysToDelete, reason);
|
||||
return Modules.GuildActions.banUser(this.guildId, this.userId, daysToDelete, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -220,7 +219,7 @@ export class GuildMember {
|
|||
*/
|
||||
unban() {
|
||||
this.assertPermissions('BAN_MEMBERS', Modules.DiscordPermissions.BAN_MEMBERS);
|
||||
return Modules.GuildActions.unbanUser(this.guild_id, this.user_id);
|
||||
return Modules.GuildActions.unbanUser(this.guildId, this.userId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -229,7 +228,7 @@ export class GuildMember {
|
|||
*/
|
||||
move(channel) {
|
||||
this.assertPermissions('MOVE_MEMBERS', Modules.DiscordPermissions.MOVE_MEMBERS);
|
||||
Modules.GuildActions.setChannel(this.guild_id, this.user_id, channel.id);
|
||||
Modules.GuildActions.setChannel(this.guildId, this.userId, channel.id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -237,7 +236,7 @@ export class GuildMember {
|
|||
*/
|
||||
mute(active = true) {
|
||||
this.assertPermissions('MUTE_MEMBERS', Modules.DiscordPermissions.MUTE_MEMBERS);
|
||||
Modules.GuildActions.setServerMute(this.guild_id, this.user_id, active);
|
||||
Modules.GuildActions.setServerMute(this.guildId, this.userId, active);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,7 +251,7 @@ export class GuildMember {
|
|||
*/
|
||||
deafen(active = true) {
|
||||
this.assertPermissions('DEAFEN_MEMBERS', Modules.DiscordPermissions.DEAFEN_MEMBERS);
|
||||
Modules.GuildActions.setServerDeaf(this.guild_id, this.user_id, active);
|
||||
Modules.GuildActions.setServerDeaf(this.guildId, this.userId, active);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue