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 .reminder import ReminderCommand
|
||||||
from .ship import ShipCommand
|
from .ship import ShipCommand
|
||||||
from .smecds import SmecdsCommand
|
from .smecds import SmecdsCommand
|
||||||
# from .videochannel import VideochannelCommand
|
from .videochannel import VideochannelCommand
|
||||||
# from .trivia import TriviaCommand
|
# from .trivia import TriviaCommand
|
||||||
# from .matchmaking import MatchmakingCommand
|
# from .matchmaking import MatchmakingCommand
|
||||||
# from .pause import PauseCommand
|
# from .pause import PauseCommand
|
||||||
|
@ -35,7 +35,7 @@ available_commands = [
|
||||||
ReminderCommand,
|
ReminderCommand,
|
||||||
ShipCommand,
|
ShipCommand,
|
||||||
SmecdsCommand,
|
SmecdsCommand,
|
||||||
# VideochannelCommand,
|
VideochannelCommand,
|
||||||
# TriviaCommand,
|
# TriviaCommand,
|
||||||
# MatchmakingCommand,
|
# MatchmakingCommand,
|
||||||
# PauseCommand,
|
# PauseCommand,
|
||||||
|
|
|
@ -10,41 +10,40 @@ class VideochannelCommand(Command):
|
||||||
|
|
||||||
description: str = "Converti il canale vocale in un canale video."
|
description: str = "Converti il canale vocale in un canale video."
|
||||||
|
|
||||||
syntax = "[channelname]"
|
syntax = "[nomecanale]"
|
||||||
|
|
||||||
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
||||||
if self.interface.name == "discord":
|
if self.interface.name != "discord":
|
||||||
bot: discord.Client = self.interface.bot
|
raise UnsupportedError(f"{self} non è supportato su {self.interface.name}.")
|
||||||
message: discord.Message = data.message
|
bot: discord.Client = self.serf.client
|
||||||
channel_name: str = args.optional(0)
|
message: discord.Message = data.message
|
||||||
if channel_name:
|
channel_name: str = args.optional(0)
|
||||||
guild: typing.Optional[discord.Guild] = message.guild
|
if channel_name:
|
||||||
if guild is not None:
|
guild: typing.Optional[discord.Guild] = message.guild
|
||||||
channels: typing.List[discord.abc.GuildChannel] = guild.channels
|
if guild is not None:
|
||||||
else:
|
channels: typing.List[discord.abc.GuildChannel] = guild.channels
|
||||||
channels = bot.get_all_channels()
|
|
||||||
matching_channels: typing.List[discord.VoiceChannel] = []
|
|
||||||
for channel in channels:
|
|
||||||
if isinstance(channel, discord.VoiceChannel):
|
|
||||||
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.")
|
|
||||||
elif len(matching_channels) > 1:
|
|
||||||
raise CommandError("Esiste più di un canale vocale con il nome specificato.")
|
|
||||||
channel = matching_channels[0]
|
|
||||||
else:
|
else:
|
||||||
author: discord.Member = message.author
|
channels = bot.get_all_channels()
|
||||||
voice: typing.Optional[discord.VoiceState] = author.voice
|
matching_channels: typing.List[discord.VoiceChannel] = []
|
||||||
if voice is None:
|
for channel in channels:
|
||||||
raise CommandError("Non sei connesso a nessun canale vocale.")
|
if isinstance(channel, discord.VoiceChannel):
|
||||||
channel = voice.channel
|
if channel.name == channel_name:
|
||||||
if author.is_on_mobile():
|
matching_channels.append(channel)
|
||||||
await data.reply(f"📹 Per entrare in modalità video, clicca qui:\n"
|
if len(matching_channels) == 0:
|
||||||
f"<https://discordapp.com/channels/{channel.guild.id}/{channel.id}>\n"
|
raise InvalidInputError("Non esiste alcun canale vocale con il nome specificato.")
|
||||||
f"[b]Attenzione: la modalità video non funziona su Android e iOS![/b]")
|
elif len(matching_channels) > 1:
|
||||||
return
|
raise UserError("Esiste più di un canale vocale con il nome specificato.")
|
||||||
await data.reply(f"📹 Per entrare in modalità video, clicca qui:\n"
|
channel = matching_channels[0]
|
||||||
f"<https://discordapp.com/channels/{channel.guild.id}/{channel.id}>")
|
|
||||||
else:
|
else:
|
||||||
raise UnsupportedError()
|
author: discord.Member = message.author
|
||||||
|
voice: typing.Optional[discord.VoiceState] = author.voice
|
||||||
|
if voice is None:
|
||||||
|
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"
|
||||||
|
f"<https://discordapp.com/channels/{channel.guild.id}/{channel.id}>\n"
|
||||||
|
f"[b]Attenzione: la modalità video non funziona su Android e iOS![/b]")
|
||||||
|
return
|
||||||
|
await data.reply(f"📹 Per entrare in modalità video, clicca qui:\n"
|
||||||
|
f"<https://discordapp.com/channels/{channel.guild.id}/{channel.id}>")
|
||||||
|
|
|
@ -3,6 +3,7 @@ from .api_user_list import ApiUserListStar
|
||||||
from .api_user_get import ApiUserGetStar
|
from .api_user_get import ApiUserGetStar
|
||||||
from .api_diario_list import ApiDiarioListStar
|
from .api_diario_list import ApiDiarioListStar
|
||||||
from .api_diario_get import ApiDiarioGetStar
|
from .api_diario_get import ApiDiarioGetStar
|
||||||
|
# from .api_discord_cv import ApiDiscordCvStar
|
||||||
|
|
||||||
# Enter the PageStars of your Pack here!
|
# Enter the PageStars of your Pack here!
|
||||||
available_page_stars = [
|
available_page_stars = [
|
||||||
|
@ -10,6 +11,7 @@ available_page_stars = [
|
||||||
ApiUserGetStar,
|
ApiUserGetStar,
|
||||||
ApiDiarioListStar,
|
ApiDiarioListStar,
|
||||||
ApiDiarioGetStar,
|
ApiDiarioGetStar,
|
||||||
|
# ApiDiscordCvStar,
|
||||||
]
|
]
|
||||||
|
|
||||||
# Enter the ExceptionStars of your Pack here!
|
# Enter the ExceptionStars of your Pack here!
|
||||||
|
|
|
@ -2,7 +2,6 @@ from starlette.requests import Request
|
||||||
from starlette.responses import *
|
from starlette.responses import *
|
||||||
from royalnet.constellation import *
|
from royalnet.constellation import *
|
||||||
from royalnet.utils import *
|
from royalnet.utils import *
|
||||||
from royalnet.backpack.tables import *
|
|
||||||
from ..tables import *
|
from ..tables import *
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ from starlette.requests import Request
|
||||||
from starlette.responses import *
|
from starlette.responses import *
|
||||||
from royalnet.constellation import *
|
from royalnet.constellation import *
|
||||||
from royalnet.utils import *
|
from royalnet.utils import *
|
||||||
from royalnet.backpack.tables import *
|
|
||||||
from ..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.constellation import *
|
||||||
from royalnet.utils import *
|
from royalnet.utils import *
|
||||||
from royalnet.backpack.tables import *
|
from royalnet.backpack.tables import *
|
||||||
from ..tables import *
|
|
||||||
|
|
||||||
|
|
||||||
class ApiUserGetStar(PageStar):
|
class ApiUserGetStar(PageStar):
|
||||||
|
|
|
@ -3,7 +3,6 @@ from starlette.responses import *
|
||||||
from royalnet.constellation import *
|
from royalnet.constellation import *
|
||||||
from royalnet.utils import *
|
from royalnet.utils import *
|
||||||
from royalnet.backpack.tables import *
|
from royalnet.backpack.tables import *
|
||||||
from ..tables import *
|
|
||||||
|
|
||||||
|
|
||||||
class ApiUserListStar(PageStar):
|
class ApiUserListStar(PageStar):
|
||||||
|
|
Loading…
Reference in a new issue