diff --git a/configTemplate.js b/configTemplate.js index 34b3f43..ed6b127 100644 --- a/configTemplate.js +++ b/configTemplate.js @@ -9,10 +9,14 @@ const config = { // API keys that are required for some features/commands keys: { dbl: '', // top.gg key - yt: '', // youtube API key sentry: '' // sentry.io dsn }, + // Configurable API endpoints + endpoints: { + invidious: "https://invidious.snopyta.org/api/" + }, + // Users added to this embed get access to developer-level commands devs: [''], diff --git a/index.js b/index.js index 53871db..ec797e4 100644 --- a/index.js +++ b/index.js @@ -28,12 +28,18 @@ client.db = require('./utils/mongoose') client.logger = require('./utils/logger') require('./utils/_functions')(client) -// Check if Woomy is running inside a Docker container -if (isDocker() === true) { - client.devmode = true +if (typeof client.config.devmode !== 'undefined') { //Check if devmode is explicitly overridden + client.devmode = client.config.devmode; +} else { //Check if Woomy is running inside a Docker + if (isDocker() === false) { + client.devmode = true + } else { + client.devmode = false + } +} + +if (client.devmode) { client.logger.warn('Running in development mode.') -} else { - client.devmode = false } // Create caches for permissions, commands, cooldowns and aliases @@ -101,7 +107,7 @@ const init = async () => { if (client.devmode !== true) { client.login(client.config.token).catch(failedToLogin) } else { - client.login(client.config.token_dev).catch(failedToLogin) + client.login(client.config.devtoken).catch(failedToLogin) } } diff --git a/utils/music.js b/utils/music.js index 078661e..b1b6b8d 100644 --- a/utils/music.js +++ b/utils/music.js @@ -33,14 +33,14 @@ exports.getLinkFromID = function (id) { return 'https://www.youtube.com/watch?v=' + id } -exports.getVideoByQuery = async query => { +exports.getVideoByQuery = async function (client, query) { let res try { const id = await ytdl.getURLVideoID(query) - res = await fetch('https://invidious.snopyta.org/api/v1/videos/' + id) + res = await fetch(`${client.config.endpoints.invidious}v1/videos/${id}`) } catch (err) { - res = await fetch('https://invidious.snopyta.org/api/v1/search?q=' + encodeURIComponent(query)) + res = await fetch(`${client.config.endpoints.invidious}v1/search?q=${encodeURIComponent(query)}`) } const parsed = await res.json() @@ -71,7 +71,7 @@ exports.play = async function (client, message, query, ignoreQueue) { let videos if (!ignoreQueue) { - videos = await exports.getVideoByQuery(query) + videos = await exports.getVideoByQuery(client, query) if (!videos[1]) { if (!videos[0]) { video = videos