Corrected error causing the help command to not work
This commit is contained in:
parent
81b7cdeaf9
commit
2baf153ae3
2 changed files with 19 additions and 12 deletions
|
@ -173,7 +173,7 @@ class Core:
|
||||||
cmd = None
|
cmd = None
|
||||||
page = 1
|
page = 1
|
||||||
|
|
||||||
perms = self.bot.permissions_in(ctx.message.channel)
|
perms = ctx.message.server.me.permissions_in(ctx.message.channel)
|
||||||
if not (perms.embed_links and perms.add_reactions):
|
if not (perms.embed_links and perms.add_reactions):
|
||||||
fmt = "I need the permissions `embed_links` and `add_reactions` to send my help message! " \
|
fmt = "I need the permissions `embed_links` and `add_reactions` to send my help message! " \
|
||||||
" Otherwise you can use this link to view available commands {}".format(
|
" Otherwise you can use this link to view available commands {}".format(
|
||||||
|
|
|
@ -9,6 +9,7 @@ import time
|
||||||
import asyncio
|
import asyncio
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import socket
|
||||||
|
|
||||||
if not discord.opus.is_loaded():
|
if not discord.opus.is_loaded():
|
||||||
discord.opus.load_opus('/usr/lib64/libopus.so.0')
|
discord.opus.load_opus('/usr/lib64/libopus.so.0')
|
||||||
|
@ -132,7 +133,9 @@ class Music:
|
||||||
server = channel.server
|
server = channel.server
|
||||||
state = self.get_voice_state(server)
|
state = self.get_voice_state(server)
|
||||||
voice = self.bot.voice_client_in(server)
|
voice = self.bot.voice_client_in(server)
|
||||||
|
# Attempt 3 times
|
||||||
|
for i in range(3):
|
||||||
|
try:
|
||||||
if voice is None:
|
if voice is None:
|
||||||
state.voice = await self.bot.join_voice_channel(channel)
|
state.voice = await self.bot.join_voice_channel(channel)
|
||||||
return True
|
return True
|
||||||
|
@ -143,6 +146,9 @@ class Music:
|
||||||
await voice.disconnect()
|
await voice.disconnect()
|
||||||
state.voice = await self.bot.join_voice_channel(channel)
|
state.voice = await self.bot.join_voice_channel(channel)
|
||||||
return True
|
return True
|
||||||
|
except (discord.ClientException, socket.gaierror):
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
async def remove_voice_client(self, server):
|
async def remove_voice_client(self, server):
|
||||||
"""Removes any voice clients from a server
|
"""Removes any voice clients from a server
|
||||||
|
@ -289,8 +295,8 @@ class Music:
|
||||||
_entry, position = await state.songs.add_entry(song, ctx.message.author)
|
_entry, position = await state.songs.add_entry(song, ctx.message.author)
|
||||||
except WrongEntryTypeError:
|
except WrongEntryTypeError:
|
||||||
# This means that a song was attempted to be searched, instead of a link provided
|
# This means that a song was attempted to be searched, instead of a link provided
|
||||||
info = await self.downloader.extract_info(self.bot.loop, song, download=False, process=True)
|
|
||||||
try:
|
try:
|
||||||
|
info = await self.downloader.extract_info(self.bot.loop, song, download=False, process=True)
|
||||||
song = info.get('entries', [])[0]['webpage_url']
|
song = info.get('entries', [])[0]['webpage_url']
|
||||||
except IndexError:
|
except IndexError:
|
||||||
await self.bot.send_message(ctx.message.channel, "No results found for {}!".format(song))
|
await self.bot.send_message(ctx.message.channel, "No results found for {}!".format(song))
|
||||||
|
@ -310,6 +316,7 @@ class Music:
|
||||||
fmt = "Sorry but I couldn't download that! Either you provided a playlist, a streamed link, or " \
|
fmt = "Sorry but I couldn't download that! Either you provided a playlist, a streamed link, or " \
|
||||||
"a page that is not supported to download."
|
"a page that is not supported to download."
|
||||||
await self.bot.send_message(ctx.message.channel, fmt)
|
await self.bot.send_message(ctx.message.channel, fmt)
|
||||||
|
return
|
||||||
except ExtractionError as e:
|
except ExtractionError as e:
|
||||||
# This gets the youtube_dl error, instead of our error raised
|
# This gets the youtube_dl error, instead of our error raised
|
||||||
error = str(e).split("\n\n")[1]
|
error = str(e).split("\n\n")[1]
|
||||||
|
|
Loading…
Reference in a new issue