feat(commands/voice): add ff
This commit is contained in:
parent
f06d8075ea
commit
439095116f
@ -6,6 +6,7 @@ import constants
|
|||||||
class Command(enum.Enum):
|
class Command(enum.Enum):
|
||||||
CLEAR = "clear"
|
CLEAR = "clear"
|
||||||
EXECUTE = "execute"
|
EXECUTE = "execute"
|
||||||
|
FAST_FORWARD = "ff"
|
||||||
HELP = "help"
|
HELP = "help"
|
||||||
JOIN = "join"
|
JOIN = "join"
|
||||||
LEAVE = "leave"
|
LEAVE = "leave"
|
||||||
|
@ -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):
|
async def skip(message):
|
||||||
if not command_allowed(message):
|
if not command_allowed(message):
|
||||||
return
|
return
|
||||||
|
3
core.py
3
core.py
@ -47,6 +47,7 @@ async def on_message(message, edited=False):
|
|||||||
match matched[0]:
|
match matched[0]:
|
||||||
case C.RELOAD if message.author.id in constants.OWNERS:
|
case C.RELOAD if message.author.id in constants.OWNERS:
|
||||||
reloaded_modules = set()
|
reloaded_modules = set()
|
||||||
|
rreload(reloaded_modules, __import__("core"))
|
||||||
for module in filter(
|
for module in filter(
|
||||||
lambda v: inspect.ismodule(v)
|
lambda v: inspect.ismodule(v)
|
||||||
and v.__name__ in constants.RELOADABLE_MODULES,
|
and v.__name__ in constants.RELOADABLE_MODULES,
|
||||||
@ -123,6 +124,8 @@ async def on_message(message, edited=False):
|
|||||||
await commands.bot.uptime(message)
|
await commands.bot.uptime(message)
|
||||||
case C.PLAYING:
|
case C.PLAYING:
|
||||||
await commands.voice.playing(message)
|
await commands.voice.playing(message)
|
||||||
|
case C.FAST_FORWARD:
|
||||||
|
await commands.voice.fast_forward(message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await utils.reply(
|
await utils.reply(
|
||||||
message,
|
message,
|
||||||
|
@ -24,7 +24,7 @@ class CustomAudioSource(disnake.AudioSource):
|
|||||||
|
|
||||||
def fast_forward(self, seconds: int):
|
def fast_forward(self, seconds: int):
|
||||||
for _ in range(int(seconds / 0.02)):
|
for _ in range(int(seconds / 0.02)):
|
||||||
self._source.read()
|
self.read()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def progress(self) -> float:
|
def progress(self) -> float:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user