mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Commands, commands, commands!
This commit is contained in:
parent
2771db22ae
commit
a55e71d4f7
8 changed files with 49 additions and 40 deletions
|
@ -7,7 +7,7 @@ from .rage import RageCommand
|
|||
from .reminder import ReminderCommand
|
||||
from .ship import ShipCommand
|
||||
from .smecds import SmecdsCommand
|
||||
# from .videochannel import VideochannelCommand
|
||||
from .videochannel import VideochannelCommand
|
||||
# from .trivia import TriviaCommand
|
||||
# from .matchmaking import MatchmakingCommand
|
||||
# from .pause import PauseCommand
|
||||
|
@ -35,7 +35,7 @@ available_commands = [
|
|||
ReminderCommand,
|
||||
ShipCommand,
|
||||
SmecdsCommand,
|
||||
# VideochannelCommand,
|
||||
VideochannelCommand,
|
||||
# TriviaCommand,
|
||||
# MatchmakingCommand,
|
||||
# PauseCommand,
|
||||
|
|
|
@ -10,11 +10,12 @@ class VideochannelCommand(Command):
|
|||
|
||||
description: str = "Converti il canale vocale in un canale video."
|
||||
|
||||
syntax = "[channelname]"
|
||||
syntax = "[nomecanale]"
|
||||
|
||||
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
||||
if self.interface.name == "discord":
|
||||
bot: discord.Client = self.interface.bot
|
||||
if self.interface.name != "discord":
|
||||
raise UnsupportedError(f"{self} non è supportato su {self.interface.name}.")
|
||||
bot: discord.Client = self.serf.client
|
||||
message: discord.Message = data.message
|
||||
channel_name: str = args.optional(0)
|
||||
if channel_name:
|
||||
|
@ -29,15 +30,15 @@ class VideochannelCommand(Command):
|
|||
if channel.name == channel_name:
|
||||
matching_channels.append(channel)
|
||||
if len(matching_channels) == 0:
|
||||
raise CommandError("Non esiste alcun canale vocale con il nome specificato.")
|
||||
raise InvalidInputError("Non esiste alcun canale vocale con il nome specificato.")
|
||||
elif len(matching_channels) > 1:
|
||||
raise CommandError("Esiste più di un canale vocale con il nome specificato.")
|
||||
raise UserError("Esiste più di un canale vocale con il nome specificato.")
|
||||
channel = matching_channels[0]
|
||||
else:
|
||||
author: discord.Member = message.author
|
||||
voice: typing.Optional[discord.VoiceState] = author.voice
|
||||
if voice is None:
|
||||
raise CommandError("Non sei connesso a nessun canale vocale.")
|
||||
raise InvalidInputError("Non sei connesso a nessun canale vocale.")
|
||||
channel = voice.channel
|
||||
if author.is_on_mobile():
|
||||
await data.reply(f"📹 Per entrare in modalità video, clicca qui:\n"
|
||||
|
@ -46,5 +47,3 @@ class VideochannelCommand(Command):
|
|||
return
|
||||
await data.reply(f"📹 Per entrare in modalità video, clicca qui:\n"
|
||||
f"<https://discordapp.com/channels/{channel.guild.id}/{channel.id}>")
|
||||
else:
|
||||
raise UnsupportedError()
|
||||
|
|
|
@ -3,6 +3,7 @@ from .api_user_list import ApiUserListStar
|
|||
from .api_user_get import ApiUserGetStar
|
||||
from .api_diario_list import ApiDiarioListStar
|
||||
from .api_diario_get import ApiDiarioGetStar
|
||||
# from .api_discord_cv import ApiDiscordCvStar
|
||||
|
||||
# Enter the PageStars of your Pack here!
|
||||
available_page_stars = [
|
||||
|
@ -10,6 +11,7 @@ available_page_stars = [
|
|||
ApiUserGetStar,
|
||||
ApiDiarioListStar,
|
||||
ApiDiarioGetStar,
|
||||
# ApiDiscordCvStar,
|
||||
]
|
||||
|
||||
# Enter the ExceptionStars of your Pack here!
|
||||
|
|
|
@ -2,7 +2,6 @@ from starlette.requests import Request
|
|||
from starlette.responses import *
|
||||
from royalnet.constellation import *
|
||||
from royalnet.utils import *
|
||||
from royalnet.backpack.tables import *
|
||||
from ..tables import *
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ from starlette.requests import Request
|
|||
from starlette.responses import *
|
||||
from royalnet.constellation import *
|
||||
from royalnet.utils import *
|
||||
from royalnet.backpack.tables import *
|
||||
from ..tables import *
|
||||
|
||||
|
||||
|
|
12
royalpack/stars/api_discord_cv.py
Normal file
12
royalpack/stars/api_discord_cv.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from starlette.requests import Request
|
||||
from starlette.responses import *
|
||||
from royalnet.constellation import *
|
||||
from royalnet.utils import *
|
||||
|
||||
|
||||
class ApiDiscordCvStar(PageStar):
|
||||
path = "/api/discord/cv"
|
||||
|
||||
async def page(self, request: Request) -> JSONResponse:
|
||||
response = await self.constellation.call_herald_event("discord", "discord_cv")
|
||||
return JSONResponse(response)
|
|
@ -3,7 +3,6 @@ from starlette.responses import *
|
|||
from royalnet.constellation import *
|
||||
from royalnet.utils import *
|
||||
from royalnet.backpack.tables import *
|
||||
from ..tables import *
|
||||
|
||||
|
||||
class ApiUserGetStar(PageStar):
|
||||
|
|
|
@ -3,7 +3,6 @@ from starlette.responses import *
|
|||
from royalnet.constellation import *
|
||||
from royalnet.utils import *
|
||||
from royalnet.backpack.tables import *
|
||||
from ..tables import *
|
||||
|
||||
|
||||
class ApiUserListStar(PageStar):
|
||||
|
|
Loading…
Reference in a new issue