|
|
@ -12,6 +12,7 @@ from redbot.core import commands, Config, checks
|
|
|
|
from redbot.core.bot import Red
|
|
|
|
from redbot.core.bot import Red
|
|
|
|
from redbot.core.data_manager import cog_data_path
|
|
|
|
from redbot.core.data_manager import cog_data_path
|
|
|
|
from redbot.core.utils.chat_formatting import box
|
|
|
|
from redbot.core.utils.chat_formatting import box
|
|
|
|
|
|
|
|
|
|
|
|
# from redbot.cogs.audio.utils import userlimit
|
|
|
|
# from redbot.cogs.audio.utils import userlimit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -65,7 +66,9 @@ class AudioTrivia(Trivia):
|
|
|
|
"""Set whether or not short audio will be repeated"""
|
|
|
|
"""Set whether or not short audio will be repeated"""
|
|
|
|
settings = self.audioconf.guild(ctx.guild)
|
|
|
|
settings = self.audioconf.guild(ctx.guild)
|
|
|
|
await settings.repeat.set(true_or_false)
|
|
|
|
await settings.repeat.set(true_or_false)
|
|
|
|
await ctx.send("Done. Repeating short audio is now set to {}.".format(true_or_false))
|
|
|
|
await ctx.send(
|
|
|
|
|
|
|
|
"Done. Repeating short audio is now set to {}.".format(true_or_false)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@commands.group(invoke_without_command=True)
|
|
|
|
@commands.group(invoke_without_command=True)
|
|
|
|
@commands.guild_only()
|
|
|
|
@commands.guild_only()
|
|
|
@ -89,19 +92,25 @@ class AudioTrivia(Trivia):
|
|
|
|
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.send(
|
|
|
|
|
|
|
|
"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.send(
|
|
|
|
"It is recommended to disable audio status with `{}audioset status`".format(ctx.prefix)
|
|
|
|
"It is recommended to disable audio status with `{}audioset status`".format(
|
|
|
|
|
|
|
|
ctx.prefix
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if notify:
|
|
|
|
if notify:
|
|
|
|
await ctx.send(
|
|
|
|
await ctx.send(
|
|
|
|
"It is recommended to disable audio notify with `{}audioset notify`".format(ctx.prefix)
|
|
|
|
"It is recommended to disable audio notify with `{}audioset notify`".format(
|
|
|
|
|
|
|
|
ctx.prefix
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if not self.audio._player_check(ctx):
|
|
|
|
if not self.audio._player_check(ctx):
|
|
|
@ -109,7 +118,9 @@ 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.send(
|
|
|
|
|
|
|
|
"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())
|
|
|
@ -166,7 +177,10 @@ class AudioTrivia(Trivia):
|
|
|
|
# Delay in audiosettings overwrites delay in settings
|
|
|
|
# Delay in audiosettings overwrites delay in settings
|
|
|
|
combined_settings = {**settings, **audiosettings}
|
|
|
|
combined_settings = {**settings, **audiosettings}
|
|
|
|
session = AudioSession.start(
|
|
|
|
session = AudioSession.start(
|
|
|
|
ctx=ctx, question_list=trivia_dict, settings=combined_settings, player=lavaplayer
|
|
|
|
ctx=ctx,
|
|
|
|
|
|
|
|
question_list=trivia_dict,
|
|
|
|
|
|
|
|
settings=combined_settings,
|
|
|
|
|
|
|
|
player=lavaplayer,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.trivia_sessions.append(session)
|
|
|
|
self.trivia_sessions.append(session)
|
|
|
|
LOG.debug("New audio trivia session; #%s in %d", ctx.channel, ctx.guild.id)
|
|
|
|
LOG.debug("New audio trivia session; #%s in %d", ctx.channel, ctx.guild.id)
|
|
|
@ -200,7 +214,9 @@ class AudioTrivia(Trivia):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
path = next(p for p in self._audio_lists() if p.stem == category)
|
|
|
|
path = next(p for p in self._audio_lists() if p.stem == category)
|
|
|
|
except StopIteration:
|
|
|
|
except StopIteration:
|
|
|
|
raise FileNotFoundError("Could not find the `{}` category.".format(category))
|
|
|
|
raise FileNotFoundError(
|
|
|
|
|
|
|
|
"Could not find the `{}` category.".format(category)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
with path.open(encoding="utf-8") as file:
|
|
|
|
with path.open(encoding="utf-8") as file:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|