Skip to content

Commit

Permalink
Use the same method to get queue size as in move.py
Browse files Browse the repository at this point in the history
Fixed the issue "AttributeError: 'Bot' object has no attribute 'music'" and included the index fix (Darkempire78#14)
  • Loading branch information
Toby406 authored Jan 7, 2022
1 parent 5f0e6b5 commit 34f1440
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Cogs/removeRemoverange.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ async def remove(self, ctx, index):
if not await Check().userInVoiceChannel(ctx, self.bot): return
if not await Check().botInVoiceChannel(ctx, self.bot): return
if not await Check().userAndBotInSameVoiceChannel(ctx, self.bot): return


tracks = DBQueue(self.bot.dbConnection).display(ctx.guild.id)

if not index.isdigit():
return await ctx.channel.send(f"{self.bot.emojiList.false} {ctx.author.mention} The index have to be a number!")
if (int(index) -1) > len(self.bot.music[ctx.guild.id]["musics"]):
if (int(index) -1) > len(tracks):
return await ctx.channel.send(f"{self.bot.emojiList.false} {ctx.author.mention} The index is invalid!")

tracks = DBQueue(self.bot.dbConnection).display(ctx.guild.id)
Expand All @@ -39,7 +40,7 @@ async def remove(self, ctx, index):
# Remove
DBQueue(self.bot.dbConnection).remove(ctx.guild.id, index)

track = tracks[index]
track = tracks[index-2]
trackDuration = await Utils().durationFormat(track[6])
trackTitle = track[5].replace("*", "\\*")
trackUrl = track[4]
Expand Down Expand Up @@ -98,4 +99,4 @@ async def remove(self, ctx, index):


def setup(bot):
bot.add_cog(CogRemoveRemoverange(bot))
bot.add_cog(CogRemoveRemoverange(bot))

0 comments on commit 34f1440

Please sign in to comment.