diff --git a/src/apis/Chorus.js b/src/apis/Chorus.js index 99f77d2f7..9b9704f3b 100644 --- a/src/apis/Chorus.js +++ b/src/apis/Chorus.js @@ -6,8 +6,9 @@ const API_URL = 'https://chorus.fightthe.pw/api' module.exports = class ChorusAPI extends APIWrapper { constructor () { - super() - this.name = 'chorus' + super({ + name: 'chorus' + }) } search (query) { diff --git a/src/apis/Crowdin.js b/src/apis/Crowdin.js index dd7b9eb4d..7971f4d0a 100644 --- a/src/apis/Crowdin.js +++ b/src/apis/Crowdin.js @@ -3,9 +3,10 @@ const Crowdin = require('crowdin-without-vulnerability') module.exports = class CrowdinAPI extends APIWrapper { constructor () { - super() - this.name = 'crowdin' - this.envVars = ['CROWDIN_API_KEY', 'CROWDIN_PROJECT_ID'] + super({ + name: 'crowdin', + envVars: ['CROWDIN_API_KEY', 'CROWDIN_PROJECT_ID'] + }) } load () { diff --git a/src/apis/DBL.js b/src/apis/DBL.js index 3543f00c0..e37a42944 100644 --- a/src/apis/DBL.js +++ b/src/apis/DBL.js @@ -6,9 +6,10 @@ const API_URL = 'https://discordbots.org/api' module.exports = class DBL extends APIWrapper { constructor () { - super() - this.name = 'dbl' - this.envVars = ['DBL_TOKEN'] + super({ + name: 'dbl', + envVars: ['DBL_TOKEN'] + }) } searchBots (query, maxValues) { diff --git a/src/apis/DarkSky.js b/src/apis/DarkSky.js index afba41f03..f170d3800 100644 --- a/src/apis/DarkSky.js +++ b/src/apis/DarkSky.js @@ -6,9 +6,10 @@ const API_URL = 'https://api.darksky.net' module.exports = class DarkSkyAPI extends APIWrapper { constructor () { - super() - this.name = 'darksky' - this.envVars = ['DARKSKY_KEY'] + super({ + name: 'darksky', + envVars: 'DARKSKY_KEY' + }) } // Get diff --git a/src/apis/Deezer.js b/src/apis/Deezer.js index 24d43e31a..cc3a10924 100644 --- a/src/apis/Deezer.js +++ b/src/apis/Deezer.js @@ -6,8 +6,9 @@ const API_URL = 'https://api.deezer.com' module.exports = class DeezerAPI extends APIWrapper { constructor () { - super() - this.name = 'deezer' + super({ + name: 'deezer' + }) } // Get diff --git a/src/apis/Genius.js b/src/apis/Genius.js index e4228bd77..cac8a5405 100644 --- a/src/apis/Genius.js +++ b/src/apis/Genius.js @@ -7,9 +7,10 @@ const API_URL = 'https://api.genius.com' module.exports = class GeniusAPI extends APIWrapper { constructor () { - super() - this.name = 'genius' - this.envVars = ['GENIUS_API'] + super({ + name: 'genius', + envVars: ['GENIUS_API'] + }) } // Find a track diff --git a/src/apis/GitHub.js b/src/apis/GitHub.js index b552e8f96..458245294 100644 --- a/src/apis/GitHub.js +++ b/src/apis/GitHub.js @@ -6,9 +6,10 @@ const API_URL = 'https://api.github.com' module.exports = class GitHubAPI extends APIWrapper { constructor () { - super() - this.name = 'github' - this.envVars = ['GITHUB_CLIENT_ID', 'GITHUB_CLIENT_SECRET'] + super({ + name: 'github', + envVars: ['GITHUB_CLIENT_ID', 'GITHUB_CLIENT_SECRET'] + }) } getUser (username) { diff --git a/src/apis/GoogleMaps.js b/src/apis/GoogleMaps.js index 1a91980df..bfaac0bba 100644 --- a/src/apis/GoogleMaps.js +++ b/src/apis/GoogleMaps.js @@ -6,9 +6,10 @@ const API_URL = 'https://maps.googleapis.com/maps/api' module.exports = class GoogleMapsAPI extends APIWrapper { constructor () { - super() - this.name = 'gmaps' - this.envVars = ['GMAPS_KEY'] + super({ + name: 'gmaps', + envVars: ['GMAPS_KEY'] + }) } // Search diff --git a/src/apis/GoogleTranslate.js b/src/apis/GoogleTranslate.js index fbfbd9b0d..8d849a17a 100644 --- a/src/apis/GoogleTranslate.js +++ b/src/apis/GoogleTranslate.js @@ -3,8 +3,9 @@ const snekfetch = require('snekfetch') module.exports = class GoogleTranslate extends APIWrapper { constructor () { - super() - this.name = 'gtranslate' + super({ + name: 'gtranslate' + }) } /** diff --git a/src/apis/HIBP.js b/src/apis/HIBP.js index b7cd34eb7..27b8f071d 100644 --- a/src/apis/HIBP.js +++ b/src/apis/HIBP.js @@ -6,8 +6,9 @@ const USER_AGENT = 'Switchblade-Discord-Bot' module.exports = class HIBP extends APIWrapper { constructor () { - super() - this.name = 'hibp' + super({ + name: 'hibp' + }) } getBreaches (query) { diff --git a/src/apis/Icecast.js b/src/apis/Icecast.js index 8d2733baa..0ec0cd429 100644 --- a/src/apis/Icecast.js +++ b/src/apis/Icecast.js @@ -3,8 +3,9 @@ const IcecastParser = require('icecast-parser') module.exports = class Icecast extends APIWrapper { constructor () { - super() - this.name = 'icecast' + super({ + name: 'icecast' + }) } fetchMetadata (url) { diff --git a/src/apis/LastFm.js b/src/apis/LastFm.js index f31230407..95544ca22 100644 --- a/src/apis/LastFm.js +++ b/src/apis/LastFm.js @@ -7,9 +7,10 @@ const API_URL = 'http://ws.audioscrobbler.com/2.0/' module.exports = class LastFM extends APIWrapper { constructor () { - super() - this.name = 'lastfm' - this.envVars = ['LASTFM_KEY', 'LASTFM_SECRET'] + super({ + name: 'lastfm', + envVars: ['LASTFM_KEY', 'LASTFM_SECRET'] + }) } // GET METHODS diff --git a/src/apis/LeagueOfLegends.js b/src/apis/LeagueOfLegends.js index 1cff44846..c57b3ab94 100644 --- a/src/apis/LeagueOfLegends.js +++ b/src/apis/LeagueOfLegends.js @@ -5,8 +5,10 @@ const API_URL = 'https://ddragon.leagueoflegends.com' module.exports = class LeagueOfLegends extends APIWrapper { constructor () { - super() - this.name = 'lol' + super({ + name: 'lol' + }) + this.version = null } diff --git a/src/apis/Mixer.js b/src/apis/Mixer.js index 0d7acacc4..657e773dd 100644 --- a/src/apis/Mixer.js +++ b/src/apis/Mixer.js @@ -6,8 +6,9 @@ const API_URL = 'https://mixer.com/api/v1' module.exports = class MixerAPI extends APIWrapper { constructor () { - super() - this.name = 'mixer' + super({ + name: 'mixer' + }) } getUser (id) { diff --git a/src/apis/Soundcloud.js b/src/apis/Soundcloud.js index 3ace65a60..b45918c86 100644 --- a/src/apis/Soundcloud.js +++ b/src/apis/Soundcloud.js @@ -10,8 +10,9 @@ const APP_SCRIPT_CLIENT_ID_REGEX = /,client_id:"([a-zA-Z0-9-_]+)"/ module.exports = class SoundcloudAPI extends APIWrapper { constructor () { - super() - this.name = 'soundcloud' + super({ + name: 'soundcloud' + }) this.lastClientIdUpdate = 0 this.clientId = null diff --git a/src/apis/Spotify.js b/src/apis/Spotify.js index 20e6d829e..3ee7ce931 100644 --- a/src/apis/Spotify.js +++ b/src/apis/Spotify.js @@ -7,9 +7,11 @@ const API_URL = 'https://api.spotify.com/v1' module.exports = class SpotifyAPI extends APIWrapper { constructor () { - super() - this.name = 'spotify' - this.envVars = ['SPOTIFY_CLIENT_ID', 'SPOTIFY_CLIENT_SECRET'] + super({ + name: 'spotify', + envVars: ['SPOTIFY_CLIENT_ID', 'SPOTIFY_CLIENT_SECRET'] + }) + this.token = null } diff --git a/src/apis/Steam.js b/src/apis/Steam.js index e6c9822a8..db896d856 100644 --- a/src/apis/Steam.js +++ b/src/apis/Steam.js @@ -3,9 +3,10 @@ const Steam = require('steamapi') module.exports = class SteamAPI extends APIWrapper { constructor () { - super() - this.name = 'steam' - this.envVars = ['STEAM_API_KEY'] + super({ + name: 'steam', + envVars: ['STEAM_API_KEY'] + }) } load () { diff --git a/src/apis/SteamLadder.js b/src/apis/SteamLadder.js index 8322b67d4..a093a3eec 100644 --- a/src/apis/SteamLadder.js +++ b/src/apis/SteamLadder.js @@ -3,7 +3,10 @@ const SteamLadder = require('steamladder') module.exports = class SteamLadderAPI extends APIWrapper { constructor () { - super() + super({ + name: 'steamladder', + envVars: ['STEAM_LADDER_API_KEY'] + }) this.name = 'steamladder' this.envVars = ['STEAM_LADDER_API_KEY'] } diff --git a/src/apis/Tumblr.js b/src/apis/Tumblr.js index 076096f9f..baef701b3 100644 --- a/src/apis/Tumblr.js +++ b/src/apis/Tumblr.js @@ -6,9 +6,10 @@ const API_URL = 'https://api.tumblr.com/v2' module.exports = class TumblrAPI extends APIWrapper { constructor () { - super() - this.name = 'tumblr' - this.envVars = ['TUMBLR_API_KEY'] + super({ + name: 'tumblr', + envVars: ['TUMBLR_API_KEY'] + }) } /** diff --git a/src/apis/Twitch.js b/src/apis/Twitch.js index df68b2029..2d280a67d 100644 --- a/src/apis/Twitch.js +++ b/src/apis/Twitch.js @@ -6,9 +6,10 @@ const API_URL = 'https://api.twitch.tv/helix' module.exports = class TwitchAPI extends APIWrapper { constructor () { - super() - this.name = 'twitch' - this.envVars = ['TWITCH_CLIENT_ID'] + super({ + name: 'twitch', + envVars: ['TWITCH_CLIENT_ID'] + }) } getUser (id) { diff --git a/src/apis/Youtube.js b/src/apis/Youtube.js index bfc5ea2be..1ba681d25 100644 --- a/src/apis/Youtube.js +++ b/src/apis/Youtube.js @@ -3,9 +3,10 @@ const { google } = require('googleapis') module.exports = class YoutubeAPI extends APIWrapper { constructor () { - super() - this.name = 'youtube' - this.envVars = ['YOUTUBE_API_KEY'] + super({ + name: 'youtube', + envVars: ['YOUTUBE_API_KEY'] + }) } load () { diff --git a/src/structures/APIWrapper.js b/src/structures/APIWrapper.js index 419ed525d..a72765361 100644 --- a/src/structures/APIWrapper.js +++ b/src/structures/APIWrapper.js @@ -3,9 +3,14 @@ * @constructor */ module.exports = class APIWrapper { - constructor () { - this.name = '' - this.envVars = [] + /** + * @param {Object} [options] - Options + * @param {string} options.name - Name + * @param {string[]} [options.envVars] - Required Environment Variables + */ + constructor (options = {}) { + this.name = options.name + this.envVars = options.envVars || [] } /**