From c80c5a33db01ac918fed104300264071cbb401d1 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 28 Mar 2020 21:51:21 +0100 Subject: [PATCH] Some voice changes, add voicestatus command --- royalpack/commands/__init__.py | 2 ++ royalpack/commands/queue.py | 2 +- royalpack/commands/voicestatus.py | 44 +++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 royalpack/commands/voicestatus.py diff --git a/royalpack/commands/__init__.py b/royalpack/commands/__init__.py index 3d102aea..0586cea2 100644 --- a/royalpack/commands/__init__.py +++ b/royalpack/commands/__init__.py @@ -38,6 +38,7 @@ from .magickfiorygi import MagickfiorygiCommand from .brawlhalla import BrawlhallaCommand from .diarioshuffle import DiarioshuffleCommand from .funkwhaleplaylist import FunkwhaleplaylistCommand +from .voicestatus import VoicestatusCommand # Enter the commands of your Pack here! available_commands = [ @@ -80,6 +81,7 @@ available_commands = [ BrawlhallaCommand, DiarioshuffleCommand, FunkwhaleplaylistCommand, + VoicestatusCommand, ] # Don't change this, it should automatically generate __all__ diff --git a/royalpack/commands/queue.py b/royalpack/commands/queue.py index 751e2180..8357d45b 100644 --- a/royalpack/commands/queue.py +++ b/royalpack/commands/queue.py @@ -11,7 +11,7 @@ class QueueCommand(Command): aliases = ["q"] - description: str = "Visualizza la coda di riproduzione attuale.." + description: str = "Visualizza la coda di riproduzione attuale." async def run(self, args: CommandArgs, data: CommandData) -> None: if self.interface.name == "discord": diff --git a/royalpack/commands/voicestatus.py b/royalpack/commands/voicestatus.py new file mode 100644 index 00000000..511a44ae --- /dev/null +++ b/royalpack/commands/voicestatus.py @@ -0,0 +1,44 @@ +from typing import * +import royalnet.serf.discord as rsd +import royalnet.commands as rc + + +class VoicestatusCommand(rc.Command): + name: str = "voicestatus" + + description: str = "Visualizza lo stato interno dei voice player del bot." + + syntax: str = "" + + async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: + if self.interface.name != "discord": + raise rc.UnsupportedError("Questo comando funziona solo su Discord.") + serf: rsd.DiscordSerf = self.interface.serf + + message = [] + for index, voice_player in enumerate(serf.voice_players): + message.append(f"🎵 [b]Voice Player #{index}[/b]") + + voice_client = voice_player.voice_client + if voice_client.is_connected(): + message.append(f"🔵 Connected") + else: + message.append(f"🔴 Disconnected") + if voice_client.is_playing(): + message.append(f"🔵 Playing") + else: + message.append(f"⚪ Not playing") + if voice_client.is_paused(): + message.append(f"⚪ Paused") + else: + message.append(f"🔵 Not paused") + + playable = voice_player.playing + message.append(f"🔉 {playable.__class__.__name__}") + + message.append("") + + if len(serf.voice_players) == 0: + message.append("[i]Nessun voice player.[/i]") + + await data.reply("\n".join(message))