forked from embee/woomy
		
	don't hardcode invidious url, add default to configtemplate
This commit is contained in:
		
							parent
							
								
									39aa33d669
								
							
						
					
					
						commit
						dd04b04500
					
				
					 2 changed files with 9 additions and 4 deletions
				
			
		| 
						 | 
					@ -12,6 +12,11 @@ const config = {
 | 
				
			||||||
    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: [''],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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…
	
	Add table
		Add a link
		
	
		Reference in a new issue