Merge pull request #16 from purpleempress/next
remove unused yt api field, add config option for invidious host, devmode update
This commit is contained in:
commit
cd989caa93
3 changed files with 21 additions and 11 deletions
|
@ -9,10 +9,14 @@ const config = {
|
||||||
// API keys that are required for some features/commands
|
// API keys that are required for some features/commands
|
||||||
keys: {
|
keys: {
|
||||||
dbl: '', // top.gg key
|
dbl: '', // top.gg key
|
||||||
yt: '', // youtube API key
|
|
||||||
sentry: '' // sentry.io dsn
|
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
|
// Users added to this embed get access to developer-level commands
|
||||||
devs: [''],
|
devs: [''],
|
||||||
|
|
||||||
|
|
14
index.js
14
index.js
|
@ -28,13 +28,19 @@ client.db = require('./utils/mongoose')
|
||||||
client.logger = require('./utils/logger')
|
client.logger = require('./utils/logger')
|
||||||
require('./utils/_functions')(client)
|
require('./utils/_functions')(client)
|
||||||
|
|
||||||
// Check if Woomy is running inside a Docker container
|
if (typeof client.config.devmode !== 'undefined') { //Check if devmode is explicitly overridden
|
||||||
if (isDocker() === true) {
|
client.devmode = client.config.devmode;
|
||||||
|
} else { //Check if Woomy is running inside a Docker
|
||||||
|
if (isDocker() === false) {
|
||||||
client.devmode = true
|
client.devmode = true
|
||||||
client.logger.warn('Running in development mode.')
|
|
||||||
} else {
|
} else {
|
||||||
client.devmode = false
|
client.devmode = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (client.devmode) {
|
||||||
|
client.logger.warn('Running in development mode.')
|
||||||
|
}
|
||||||
|
|
||||||
// Create caches for permissions, commands, cooldowns and aliases
|
// Create caches for permissions, commands, cooldowns and aliases
|
||||||
client.levelCache = {}
|
client.levelCache = {}
|
||||||
|
@ -101,7 +107,7 @@ const init = async () => {
|
||||||
if (client.devmode !== true) {
|
if (client.devmode !== true) {
|
||||||
client.login(client.config.token).catch(failedToLogin)
|
client.login(client.config.token).catch(failedToLogin)
|
||||||
} else {
|
} else {
|
||||||
client.login(client.config.token_dev).catch(failedToLogin)
|
client.login(client.config.devtoken).catch(failedToLogin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,14 @@ exports.getLinkFromID = function (id) {
|
||||||
return 'https://www.youtube.com/watch?v=' + id
|
return 'https://www.youtube.com/watch?v=' + id
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getVideoByQuery = async query => {
|
exports.getVideoByQuery = async function (client, query) {
|
||||||
let res
|
let res
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const id = await ytdl.getURLVideoID(query)
|
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) {
|
} 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()
|
const parsed = await res.json()
|
||||||
|
@ -71,7 +71,7 @@ exports.play = async function (client, message, query, ignoreQueue) {
|
||||||
let videos
|
let videos
|
||||||
|
|
||||||
if (!ignoreQueue) {
|
if (!ignoreQueue) {
|
||||||
videos = await exports.getVideoByQuery(query)
|
videos = await exports.getVideoByQuery(client, query)
|
||||||
if (!videos[1]) {
|
if (!videos[1]) {
|
||||||
if (!videos[0]) {
|
if (!videos[0]) {
|
||||||
video = videos
|
video = videos
|
||||||
|
|
Loading…
Reference in a new issue