Add a constant for guild ids. By setting guild ids in commands, commands are added immediately.
Added the /time gametime command.
This commit is contained in:
@@ -8,6 +8,7 @@ from cogs.commands.remove import RemoveCog
|
||||
from cogs.commands.request import RequestCog
|
||||
from cogs.commands.set import SetCog
|
||||
from cogs.commands.test import TestCog
|
||||
from cogs.commands.time import TimeCog
|
||||
from cogs.commands.view import ViewCog
|
||||
|
||||
|
||||
@@ -19,6 +20,7 @@ def setup(bot: commands.Bot) -> None:
|
||||
bot.add_cog(RefreshCog(bot))
|
||||
bot.add_cog(RemoveCog())
|
||||
bot.add_cog(RequestCog(bot))
|
||||
bot.add_cog(TestCog(bot))
|
||||
bot.add_cog(ViewCog())
|
||||
bot.add_cog(SetCog())
|
||||
bot.add_cog(TestCog(bot))
|
||||
bot.add_cog(TimeCog())
|
||||
bot.add_cog(ViewCog())
|
||||
|
||||
@@ -6,14 +6,13 @@ import nextcord
|
||||
from nextcord.ext import application_checks, commands
|
||||
|
||||
from classes.election_cycle import ElectionCycle
|
||||
from utils import get_current_election_cycle
|
||||
from utils import GUILDS, get_current_election_cycle
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from config import DakinyConfig
|
||||
|
||||
|
||||
ME = 206602713511886849
|
||||
GUILDS = [1000247361639030804]
|
||||
|
||||
|
||||
def is_me(): # noqa: ANN201
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
"""Contains commands for time commands."""
|
||||
|
||||
from datetime import UTC, datetime
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
|
||||
from utils import GUILDS
|
||||
|
||||
|
||||
class TimeCog(commands.Cog, name="Time Commands"):
|
||||
"""Class holds time commands."""
|
||||
|
||||
@nextcord.slash_command(guild_ids=GUILDS)
|
||||
async def time(self, interaction: nextcord.Interaction) -> None:
|
||||
"""Parent slash command. Never called."""
|
||||
|
||||
@time.subcommand(description="1")
|
||||
async def at(self, interaction: nextcord.Interaction) -> None:
|
||||
pass
|
||||
|
||||
@time.subcommand(description="1")
|
||||
async def at_gametime(self, interaction: nextcord.Interaction) -> None:
|
||||
pass
|
||||
|
||||
@time.subcommand(description="Get the current time in game.")
|
||||
async def gametime(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
ephemeral: bool = nextcord.SlashOption( # noqa: FBT001
|
||||
required=False, default=True, description="Whether the replying message will be public or not."
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Replies with the current time in game.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction with the command.
|
||||
ephemeral: (bool): Whether the response is ephemeral or not.
|
||||
"""
|
||||
gametime = datetime.now(tz=UTC)
|
||||
await interaction.response.send_message(content=f"{gametime.hour}:{gametime.minute}", ephemeral=ephemeral)
|
||||
Reference in New Issue
Block a user