Embeds and track variable
This commit is contained in:
parent
e0042780a1
commit
bf81d7c157
@ -58,15 +58,18 @@ class AudioSession(TriviaSession):
|
|||||||
log.info(f"Track has error: {load_result.exception_message}")
|
log.info(f"Track has error: {load_result.exception_message}")
|
||||||
continue # Skip tracks with error
|
continue # Skip tracks with error
|
||||||
tracks = load_result.tracks
|
tracks = load_result.tracks
|
||||||
seconds = tracks[0].length / 1000
|
|
||||||
|
track = tracks[0]
|
||||||
|
seconds = track.length / 1000
|
||||||
|
|
||||||
if self.settings["repeat"] and seconds < delay:
|
if self.settings["repeat"] and seconds < delay:
|
||||||
|
# Append it until it's longer than the delay
|
||||||
tot_length = seconds + 0
|
tot_length = seconds + 0
|
||||||
while tot_length < delay:
|
while tot_length < delay:
|
||||||
self.player.add(self.ctx.author, tracks[0])
|
self.player.add(self.ctx.author, track)
|
||||||
tot_length += seconds
|
tot_length += seconds
|
||||||
else:
|
else:
|
||||||
self.player.add(self.ctx.author, tracks[0])
|
self.player.add(self.ctx.author, track)
|
||||||
|
|
||||||
if not self.player.current:
|
if not self.player.current:
|
||||||
log.debug("Pressing play")
|
log.debug("Pressing play")
|
||||||
|
@ -84,24 +84,24 @@ class AudioTrivia(Trivia):
|
|||||||
self.audio: Audio = self.bot.get_cog("Audio")
|
self.audio: Audio = self.bot.get_cog("Audio")
|
||||||
|
|
||||||
if self.audio is None:
|
if self.audio is None:
|
||||||
await ctx.send("Audio is not loaded. Load it and try again")
|
await ctx.maybe_send_embed("Audio is not loaded. Load it and try again")
|
||||||
return
|
return
|
||||||
|
|
||||||
categories = [c.lower() for c in categories]
|
categories = [c.lower() for c in categories]
|
||||||
session = self._get_trivia_session(ctx.channel)
|
session = self._get_trivia_session(ctx.channel)
|
||||||
if session is not None:
|
if session is not None:
|
||||||
await ctx.send("There is already an ongoing trivia session in this channel.")
|
await ctx.maybe_send_embed("There is already an ongoing trivia session in this channel.")
|
||||||
return
|
return
|
||||||
status = await self.audio.config.status()
|
status = await self.audio.config.status()
|
||||||
notify = await self.audio.config.guild(ctx.guild).notify()
|
notify = await self.audio.config.guild(ctx.guild).notify()
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
await ctx.send(
|
await ctx.maybe_send_embed(
|
||||||
f"It is recommended to disable audio status with `{ctx.prefix}audioset status`"
|
f"It is recommended to disable audio status with `{ctx.prefix}audioset status`"
|
||||||
)
|
)
|
||||||
|
|
||||||
if notify:
|
if notify:
|
||||||
await ctx.send(
|
await ctx.maybe_send_embed(
|
||||||
f"It is recommended to disable audio notify with `{ctx.prefix}audioset notify`"
|
f"It is recommended to disable audio notify with `{ctx.prefix}audioset notify`"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -110,12 +110,12 @@ class AudioTrivia(Trivia):
|
|||||||
if not ctx.author.voice.channel.permissions_for(
|
if not ctx.author.voice.channel.permissions_for(
|
||||||
ctx.me
|
ctx.me
|
||||||
).connect or self.audio.is_vc_full(ctx.author.voice.channel):
|
).connect or self.audio.is_vc_full(ctx.author.voice.channel):
|
||||||
return await ctx.send("I don't have permission to connect to your channel.")
|
return await ctx.maybe_send_embed("I don't have permission to connect to your channel.")
|
||||||
await lavalink.connect(ctx.author.voice.channel)
|
await lavalink.connect(ctx.author.voice.channel)
|
||||||
lavaplayer = lavalink.get_player(ctx.guild.id)
|
lavaplayer = lavalink.get_player(ctx.guild.id)
|
||||||
lavaplayer.store("connect", datetime.datetime.utcnow())
|
lavaplayer.store("connect", datetime.datetime.utcnow())
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return await ctx.send("Connect to a voice channel first.")
|
return await ctx.maybe_send_embed("Connect to a voice channel first.")
|
||||||
|
|
||||||
lavaplayer = lavalink.get_player(ctx.guild.id)
|
lavaplayer = lavalink.get_player(ctx.guild.id)
|
||||||
lavaplayer.store("channel", ctx.channel.id) # What's this for? I dunno
|
lavaplayer.store("channel", ctx.channel.id) # What's this for? I dunno
|
||||||
@ -123,7 +123,7 @@ class AudioTrivia(Trivia):
|
|||||||
await self.audio.set_player_settings(ctx)
|
await self.audio.set_player_settings(ctx)
|
||||||
|
|
||||||
if not ctx.author.voice or ctx.author.voice.channel != lavaplayer.channel:
|
if not ctx.author.voice or ctx.author.voice.channel != lavaplayer.channel:
|
||||||
return await ctx.send(
|
return await ctx.maybe_send_embed(
|
||||||
"You must be in the voice channel to use the audiotrivia command."
|
"You must be in the voice channel to use the audiotrivia command."
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -135,13 +135,13 @@ class AudioTrivia(Trivia):
|
|||||||
try:
|
try:
|
||||||
dict_ = self.get_audio_list(category)
|
dict_ = self.get_audio_list(category)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
await ctx.send(
|
await ctx.maybe_send_embed(
|
||||||
"Invalid category `{0}`. See `{1}audiotrivia list`"
|
"Invalid category `{0}`. See `{1}audiotrivia list`"
|
||||||
" for a list of trivia categories."
|
" for a list of trivia categories."
|
||||||
"".format(category, ctx.prefix)
|
"".format(category, ctx.prefix)
|
||||||
)
|
)
|
||||||
except InvalidListError:
|
except InvalidListError:
|
||||||
await ctx.send(
|
await ctx.maybe_send_embed(
|
||||||
"There was an error parsing the trivia list for"
|
"There was an error parsing the trivia list for"
|
||||||
" the `{}` category. It may be formatted"
|
" the `{}` category. It may be formatted"
|
||||||
" incorrectly.".format(category)
|
" incorrectly.".format(category)
|
||||||
@ -152,7 +152,7 @@ class AudioTrivia(Trivia):
|
|||||||
continue
|
continue
|
||||||
return
|
return
|
||||||
if not trivia_dict:
|
if not trivia_dict:
|
||||||
await ctx.send(
|
await ctx.maybe_send_embed(
|
||||||
"The trivia list was parsed successfully, however it appears to be empty!"
|
"The trivia list was parsed successfully, however it appears to be empty!"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user