Reformatting and f string syntax
This commit is contained in:
parent
e13518dc42
commit
0ec877d5f9
@ -5,20 +5,19 @@ from typing import List
|
|||||||
import lavalink
|
import lavalink
|
||||||
import yaml
|
import yaml
|
||||||
from redbot.cogs.audio import Audio
|
from redbot.cogs.audio import Audio
|
||||||
from redbot.cogs.audio.core.utilities import validation
|
|
||||||
from redbot.cogs.trivia import LOG
|
from redbot.cogs.trivia import LOG
|
||||||
from redbot.cogs.trivia.trivia import InvalidListError, Trivia
|
from redbot.cogs.trivia.trivia import InvalidListError, Trivia
|
||||||
from redbot.core import commands, Config, checks
|
from redbot.core import Config, checks, commands
|
||||||
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 .audiosession import AudioSession
|
from .audiosession import AudioSession
|
||||||
|
|
||||||
|
|
||||||
|
# from redbot.cogs.audio.utils import userlimit
|
||||||
|
|
||||||
|
|
||||||
class AudioTrivia(Trivia):
|
class AudioTrivia(Trivia):
|
||||||
"""
|
"""
|
||||||
Upgrade to the Trivia cog that enables audio trivia
|
Upgrade to the Trivia cog that enables audio trivia
|
||||||
@ -66,9 +65,7 @@ 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(
|
await ctx.send("Done. Repeating short audio is now set to {}.".format(true_or_false))
|
||||||
"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()
|
||||||
@ -92,25 +89,19 @@ 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(
|
await ctx.send("There is already an ongoing trivia session in this channel.")
|
||||||
"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(
|
f"It is recommended to disable audio status with `{ctx.prefix}audioset status`"
|
||||||
ctx.prefix
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if notify:
|
if notify:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"It is recommended to disable audio notify with `{}audioset notify`".format(
|
f"It is recommended to disable audio notify with `{ctx.prefix}audioset notify`"
|
||||||
ctx.prefix
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if not self.audio._player_check(ctx):
|
if not self.audio._player_check(ctx):
|
||||||
@ -118,9 +109,7 @@ 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(
|
return await ctx.send("I don't have permission to connect to your channel.")
|
||||||
"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())
|
||||||
@ -177,10 +166,7 @@ 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,
|
ctx=ctx, question_list=trivia_dict, settings=combined_settings, player=lavaplayer,
|
||||||
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)
|
||||||
@ -214,9 +200,7 @@ 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(
|
raise FileNotFoundError("Could not find the `{}` category.".format(category))
|
||||||
"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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user