1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-12-17 23:24:20 +00:00
royalnet/royalpack/commands/pause.py

28 lines
956 B
Python
Raw Normal View History

2019-12-03 00:57:21 +00:00
from typing import *
2020-05-10 22:46:12 +00:00
import discord
import royalnet.commands as rc
2019-11-11 08:56:08 +00:00
2020-05-10 22:46:12 +00:00
class PauseCommand(rc.Command):
2019-11-11 08:56:08 +00:00
name: str = "pause"
2019-12-03 00:57:21 +00:00
aliases = ["resume"]
2019-11-11 08:56:08 +00:00
2019-12-03 00:57:21 +00:00
description: str = "Metti in pausa o riprendi la riproduzione di un file."
2019-11-11 08:56:08 +00:00
2020-05-10 22:46:12 +00:00
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
2019-12-03 00:57:21 +00:00
if self.interface.name == "discord":
message: discord.Message = data.message
guild: discord.Guild = message.guild
guild_id: Optional[int] = guild.id
2019-11-11 08:56:08 +00:00
else:
2019-12-03 00:57:21 +00:00
guild_id = None
response: Dict[str, Any] = await self.interface.call_herald_event("discord", "discord_pause",
guild_id=guild_id)
2019-11-11 08:56:08 +00:00
2019-12-03 00:57:21 +00:00
if response["action"] == "paused":
await data.reply("⏸ Riproduzione messa in pausa.")
2019-11-11 08:56:08 +00:00
2019-12-03 00:57:21 +00:00
elif response["action"] == "resumed":
await data.reply("▶️ Riproduzione ripresa!")