diff --git a/commands/utils.py b/commands/utils.py index 01308d7..e2e0875 100644 --- a/commands/utils.py +++ b/commands/utils.py @@ -6,6 +6,7 @@ import constants class Command(enum.Enum): CLEAR = "clear" EXECUTE = "execute" + FAST_FORWARD = "ff" HELP = "help" JOIN = "join" LEAVE = "leave" diff --git a/commands/voice.py b/commands/voice.py index 1e79eb1..5682a2d 100644 --- a/commands/voice.py +++ b/commands/voice.py @@ -295,6 +295,31 @@ async def playing(message): ) +async def fast_forward(message): + if not command_allowed(message): + return + + tokens = commands.tokenize(message.content) + parser = arguments.ArgumentParser(tokens[0], "fast forward audio playback") + parser.add_argument( + "seconds", + type=lambda v: arguments.range_type(v, min=0, max=300), + help="the amount of seconds to fast forward", + ) + if not (args := await parser.parse_args(message, tokens)): + return + + if not message.guild.voice_client.source: + await utils.reply(message, "nothing is playing!") + return + + message.guild.voice_client.pause() + message.guild.voice_client.source.original.fast_forward(args.seconds) + message.guild.voice_client.resume() + + await utils.add_check_reaction(message) + + async def skip(message): if not command_allowed(message): return diff --git a/core.py b/core.py index 914d332..83442c6 100644 --- a/core.py +++ b/core.py @@ -47,6 +47,7 @@ async def on_message(message, edited=False): match matched[0]: case C.RELOAD if message.author.id in constants.OWNERS: reloaded_modules = set() + rreload(reloaded_modules, __import__("core")) for module in filter( lambda v: inspect.ismodule(v) and v.__name__ in constants.RELOADABLE_MODULES, @@ -123,6 +124,8 @@ async def on_message(message, edited=False): await commands.bot.uptime(message) case C.PLAYING: await commands.voice.playing(message) + case C.FAST_FORWARD: + await commands.voice.fast_forward(message) except Exception as e: await utils.reply( message, diff --git a/youtubedl.py b/youtubedl.py index b00a97b..83588b9 100644 --- a/youtubedl.py +++ b/youtubedl.py @@ -24,7 +24,7 @@ class CustomAudioSource(disnake.AudioSource): def fast_forward(self, seconds: int): for _ in range(int(seconds / 0.02)): - self._source.read() + self.read() @property def progress(self) -> float: