Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkempire78 committed Feb 15, 2021
1 parent 22f1d3c commit 53d8b53
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
5 changes: 4 additions & 1 deletion Cogs/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ async def on_command_error(self, ctx, error):

embed = discord.Embed(title=f"__**COMMAND ERROR**__", description=f"[**GitHub**](https://github.com/Darkempire78/Music-Discord-Bot)\n\n**You may report this issue on the [GitHub repository](https://github.com/Darkempire78/Music-Discord-Bot)**\n```{error}```", color=discord.Colour.red())
embed.set_footer(text="Bot Created by Darkempire#8245")
await ctx.channel.send(embed=embed)
try:
await ctx.channel.send(embed=embed)
except:
pass

# Send the error on the support server
channel = self.bot.get_channel(800839028659453952)
Expand Down
11 changes: 6 additions & 5 deletions Cogs/lavalinkEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ async def on_player_stop(self, node: wavelink.Node, payload):
track = DBQueue(self.bot.dbConnection).getNextSong(payload.player.guild_id)
if track is None:
currentTrack = DBQueue(self.bot.dbConnection).getCurrentSong(payload.player.guild_id)
channelID = currentTrack[3]
channel = self.bot.get_channel(int(channelID))
if channel:
await channel.send(f"{self.bot.emojiList.false} Disconnected because the queue is empty!")
await payload.player.disconnect()
if currentTrack:
channelID = currentTrack[3]
channel = self.bot.get_channel(int(channelID))
if channel:
await channel.send(f"{self.bot.emojiList.false} Disconnected because the queue is empty!")
await payload.player.disconnect()
return

channelID = track[3]
Expand Down
21 changes: 12 additions & 9 deletions DataBase/Queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,18 @@ def getIndexFromFakeIndex(self, server, index):

def getCurrentSong(self, server):
"""Return the playing song of a server's queue"""
mydb = self.dbConnection.getConnection()
mycursor = mydb.cursor()
query = f"SELECT * FROM queue WHERE `server`= %s AND isPlaying= true;"
val = (str(server), )
mycursor.execute(query, val)
result = mycursor.fetchall()
mycursor.close()
mydb.close()
return result[0]
try:
mydb = self.dbConnection.getConnection()
mycursor = mydb.cursor()
query = f"SELECT * FROM queue WHERE `server`= %s AND isPlaying= true;"
val = (str(server), )
mycursor.execute(query, val)
result = mycursor.fetchall()
mycursor.close()
mydb.close()
return result[0]
except:
return None

def getNextSong(self, server):
"""Return the next song of a server's queue"""
Expand Down

0 comments on commit 53d8b53

Please sign in to comment.