diff --git a/.eslintrc.json b/.eslintrc.json index e477d36c69e0..dcd2cc335a0d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,6 +11,9 @@ "no-extra-parens": ["warn", "all", { "nestedBinaryExpressions": false }], + "arrow-parens": ["error", "as-needed", { + "requireForBlockBody": false + }], "valid-jsdoc": ["error", { "requireReturn": false, "requireReturnDescription": false, diff --git a/src/client/rest/RESTMethods.js b/src/client/rest/RESTMethods.js index 2d2829f2cf51..727245fc452f 100644 --- a/src/client/rest/RESTMethods.js +++ b/src/client/rest/RESTMethods.js @@ -99,7 +99,7 @@ class RESTMethods { const messages = []; (function sendChunk(list, index) { const options = index === list.length ? { tts, embed } : { tts }; - chan.send(list[index], options, index === list.length ? file : null).then((message) => { + chan.send(list[index], options, index === list.length ? file : null).then(message => { messages.push(message); if (index >= list.length - 1) return resolve(messages); return sendChunk(list, ++index); @@ -856,7 +856,7 @@ class RESTMethods { acceptInvite(code) { if (code.id) code = code.id; return new Promise((resolve, reject) => - this.rest.makeRequest('post', Constants.Endpoints.invite(code), true).then((res) => { + this.rest.makeRequest('post', Constants.Endpoints.invite(code), true).then(res => { const handler = guild => { if (guild.id === res.id) { resolve(guild); diff --git a/src/client/voice/VoiceBroadcast.js b/src/client/voice/VoiceBroadcast.js index 40e26a7fce30..024f3fa0443c 100644 --- a/src/client/voice/VoiceBroadcast.js +++ b/src/client/voice/VoiceBroadcast.js @@ -301,7 +301,7 @@ class VoiceBroadcast extends VolumeInterface { let packetMatrix = {}; - const getOpusPacket = (volume) => { + const getOpusPacket = volume => { if (packetMatrix[volume]) return packetMatrix[volume]; const opusEncoder = this._encoders.get(volume); diff --git a/src/structures/Message.js b/src/structures/Message.js index fc8bf31b53f1..13aff164a558 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -278,7 +278,7 @@ class Message { get cleanContent() { return this.content .replace(/@(everyone|here)/g, '@\u200b$1') - .replace(/<@!?[0-9]+>/g, (input) => { + .replace(/<@!?[0-9]+>/g, input => { const id = input.replace(/<|!|>|@/g, ''); if (this.channel.type === 'dm' || this.channel.type === 'group') { return this.client.users.has(id) ? `@${this.client.users.get(id).username}` : input; @@ -294,12 +294,12 @@ class Message { return input; } }) - .replace(/<#[0-9]+>/g, (input) => { + .replace(/<#[0-9]+>/g, input => { const channel = this.client.channels.get(input.replace(/<|#|>/g, '')); if (channel) return `#${channel.name}`; return input; }) - .replace(/<@&[0-9]+>/g, (input) => { + .replace(/<@&[0-9]+>/g, input => { if (this.channel.type === 'dm' || this.channel.type === 'group') return input; const role = this.guild.roles.get(input.replace(/<|@|>|&/g, '')); if (role) return `@${role.name}`; diff --git a/src/util/Constants.js b/src/util/Constants.js index 65d8a08fda81..c78b36d9ae6f 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -87,61 +87,61 @@ const Endpoints = exports.Endpoints = { logout: `${API}/auth/logout`, gateway: `${API}/gateway`, botGateway: `${API}/gateway/bot`, - invite: (id) => `${API}/invite/${id}`, - inviteLink: (id) => `https://discord.gg/${id}`, - assets: (asset) => `${HOST}/assets/${asset}`, + invite: id => `${API}/invite/${id}`, + inviteLink: id => `https://discord.gg/${id}`, + assets: asset => `${HOST}/assets/${asset}`, CDN: 'https://cdn.discordapp.com', // users - user: (userID) => `${API}/users/${userID}`, - userChannels: (userID) => `${Endpoints.user(userID)}/channels`, - userProfile: (userID) => `${Endpoints.user(userID)}/profile`, + user: userID => `${API}/users/${userID}`, + userChannels: userID => `${Endpoints.user(userID)}/channels`, + userProfile: userID => `${Endpoints.user(userID)}/profile`, avatar: (userID, avatar) => { if (userID === '1') return avatar; return `${Endpoints.CDN}/avatars/${userID}/${avatar}.${avatar.startsWith('a_') ? 'gif' : 'jpg'}?size=1024`; }, me: `${API}/users/@me`, - meGuild: (guildID) => `${Endpoints.me}/guilds/${guildID}`, + meGuild: guildID => `${Endpoints.me}/guilds/${guildID}`, meChannels: `${API}/users/@me/channels`, meMentions: (limit, roles, everyone, guildID) => `users/@me/mentions?limit=${limit}&roles=${roles}&everyone=${everyone}${guildID ? `&guild_id=${guildID}` : ''}`, - relationships: (userID) => `${Endpoints.user(userID)}/relationships`, - note: (userID) => `${Endpoints.me}/notes/${userID}`, + relationships: userID => `${Endpoints.user(userID)}/relationships`, + note: userID => `${Endpoints.me}/notes/${userID}`, voiceRegions: `${API}/voice/regions`, // guilds guilds: `${API}/guilds`, - guild: (guildID) => `${Endpoints.guilds}/${guildID}`, + guild: guildID => `${Endpoints.guilds}/${guildID}`, guildIcon: (guildID, hash) => `${Endpoints.CDN}/icons/${guildID}/${hash}.jpg`, guildSplash: (guildID, hash) => `${Endpoints.CDN}/splashes/${guildID}/${hash}.jpg`, - guildPrune: (guildID) => `${Endpoints.guild(guildID)}/prune`, - guildEmbed: (guildID) => `${Endpoints.guild(guildID)}/embed`, - guildInvites: (guildID) => `${Endpoints.guild(guildID)}/invites`, - guildRoles: (guildID) => `${Endpoints.guild(guildID)}/roles`, + guildPrune: guildID => `${Endpoints.guild(guildID)}/prune`, + guildEmbed: guildID => `${Endpoints.guild(guildID)}/embed`, + guildInvites: guildID => `${Endpoints.guild(guildID)}/invites`, + guildRoles: guildID => `${Endpoints.guild(guildID)}/roles`, guildRole: (guildID, roleID) => `${Endpoints.guildRoles(guildID)}/${roleID}`, - guildBans: (guildID) => `${Endpoints.guild(guildID)}/bans`, - guildIntegrations: (guildID) => `${Endpoints.guild(guildID)}/integrations`, - guildMembers: (guildID) => `${Endpoints.guild(guildID)}/members`, + guildBans: guildID => `${Endpoints.guild(guildID)}/bans`, + guildIntegrations: guildID => `${Endpoints.guild(guildID)}/integrations`, + guildMembers: guildID => `${Endpoints.guild(guildID)}/members`, guildMember: (guildID, memberID) => `${Endpoints.guildMembers(guildID)}/${memberID}`, guildMemberRole: (guildID, memberID, roleID) => `${Endpoints.guildMember(guildID, memberID)}/roles/${roleID}`, - guildMemberNickname: (guildID) => `${Endpoints.guildMember(guildID, '@me')}/nick`, - guildChannels: (guildID) => `${Endpoints.guild(guildID)}/channels`, - guildEmojis: (guildID) => `${Endpoints.guild(guildID)}/emojis`, + guildMemberNickname: guildID => `${Endpoints.guildMember(guildID, '@me')}/nick`, + guildChannels: guildID => `${Endpoints.guild(guildID)}/channels`, + guildEmojis: guildID => `${Endpoints.guild(guildID)}/emojis`, guildEmoji: (guildID, emojiID) => `${Endpoints.guildEmojis(guildID)}/${emojiID}`, - guildSearch: (guildID) => `${Endpoints.guild(guildID)}/messages/search`, - guildVoiceRegions: (guildID) => `${Endpoints.guild(guildID)}/regions`, + guildSearch: guildID => `${Endpoints.guild(guildID)}/messages/search`, + guildVoiceRegions: guildID => `${Endpoints.guild(guildID)}/regions`, // channels channels: `${API}/channels`, - channel: (channelID) => `${Endpoints.channels}/${channelID}`, - channelMessages: (channelID) => `${Endpoints.channel(channelID)}/messages`, - channelInvites: (channelID) => `${Endpoints.channel(channelID)}/invites`, - channelTyping: (channelID) => `${Endpoints.channel(channelID)}/typing`, - channelPermissions: (channelID) => `${Endpoints.channel(channelID)}/permissions`, + channel: channelID => `${Endpoints.channels}/${channelID}`, + channelMessages: channelID => `${Endpoints.channel(channelID)}/messages`, + channelInvites: channelID => `${Endpoints.channel(channelID)}/invites`, + channelTyping: channelID => `${Endpoints.channel(channelID)}/typing`, + channelPermissions: channelID => `${Endpoints.channel(channelID)}/permissions`, channelMessage: (channelID, messageID) => `${Endpoints.channelMessages(channelID)}/${messageID}`, - channelWebhooks: (channelID) => `${Endpoints.channel(channelID)}/webhooks`, - channelSearch: (channelID) => `${Endpoints.channelMessages(channelID)}/search`, + channelWebhooks: channelID => `${Endpoints.channel(channelID)}/webhooks`, + channelSearch: channelID => `${Endpoints.channelMessages(channelID)}/search`, dmChannelRecipient: (channelID, recipientID) => `${Endpoints.channel(channelID)}/recipients/${recipientID}`, @@ -160,11 +160,11 @@ const Endpoints = exports.Endpoints = { webhook: (webhookID, token) => `${API}/webhooks/${webhookID}${token ? `/${token}` : ''}`, // oauth - oauth2Application: (appID) => `${API}/oauth2/applications/${appID}`, - getApp: (id) => `${API}/oauth2/authorize?client_id=${id}`, + oauth2Application: appID => `${API}/oauth2/applications/${appID}`, + getApp: id => `${API}/oauth2/authorize?client_id=${id}`, // emoji - emoji: (emojiID) => `${Endpoints.CDN}/emojis/${emojiID}.png`, + emoji: emojiID => `${Endpoints.CDN}/emojis/${emojiID}.png`, }; /**