Compare commits

..
Author SHA1 Message Date
imcompiling 47a33128be Merge commit 'fdb04149aabea373e1f9b9570da0e5e66f6ac9da'
build_latest / build (push) Successful in 22s
build_release / build (push) Successful in 16s
build_develop / build (push) Successful in 1m57s
2024-05-31 15:21:06 -04:00
imcompiling fdb04149aa Define the /time at command.
build_develop / build (push) Successful in 1m32s
2024-05-31 15:20:59 -04:00
imcompiling 4805f6cd5d Add a constant for guild ids. By setting guild ids in commands, commands are added immediately.
Added the /time gametime command.
2024-05-31 14:28:22 -04:00
imcompiling ff85c8d485 Bugfix in record command. Missed moving a positional argument.
build_latest / build (push) Successful in 1m36s
build_release / build (push) Successful in 17s
build_develop / build (push) Successful in 24s
2024-05-26 20:06:43 -04:00
imcompiling ca0d27a929 Update dockerfile image. Need python3.12
build_latest / build (push) Successful in 1m47s
build_release / build (push) Successful in 23s
2024-05-24 14:19:17 -04:00
imcompiling 8ebb689ee7 Merge branch '63-bad-sorting'
build_latest / build (push) Failing after 31s
build_release / build (push) Failing after 29s
2024-05-24 14:11:44 -04:00
6 changed files with 117 additions and 6 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
FROM python:3.11.9-slim FROM python:3.12.3-slim
# install dependencies # install dependencies
RUN apt-get update && apt-get -y upgrade && apt-get -y install git sqlite3 RUN apt-get update && apt-get -y upgrade && apt-get -y install git sqlite3
+4 -2
View File
@@ -8,6 +8,7 @@ from cogs.commands.remove import RemoveCog
from cogs.commands.request import RequestCog from cogs.commands.request import RequestCog
from cogs.commands.set import SetCog from cogs.commands.set import SetCog
from cogs.commands.test import TestCog from cogs.commands.test import TestCog
from cogs.commands.time import TimeCog
from cogs.commands.view import ViewCog from cogs.commands.view import ViewCog
@@ -19,6 +20,7 @@ def setup(bot: commands.Bot) -> None:
bot.add_cog(RefreshCog(bot)) bot.add_cog(RefreshCog(bot))
bot.add_cog(RemoveCog()) bot.add_cog(RemoveCog())
bot.add_cog(RequestCog(bot)) bot.add_cog(RequestCog(bot))
bot.add_cog(TestCog(bot))
bot.add_cog(ViewCog())
bot.add_cog(SetCog()) bot.add_cog(SetCog())
bot.add_cog(TestCog(bot))
bot.add_cog(TimeCog())
bot.add_cog(ViewCog())
+1 -1
View File
@@ -109,8 +109,8 @@ class EventView(nextcord.ui.View):
record_event_points( record_event_points(
self.config, self.config,
discord_users_list, discord_users_list,
True, # noqa: FBT003
self.config.params.event_participate_points, self.config.params.event_participate_points,
is_member=True,
) )
non_discord_users = interaction.message.embeds[0].fields[1].value non_discord_users = interaction.message.embeds[0].fields[1].value
+1 -2
View File
@@ -6,14 +6,13 @@ import nextcord
from nextcord.ext import application_checks, commands from nextcord.ext import application_checks, commands
from classes.election_cycle import ElectionCycle from classes.election_cycle import ElectionCycle
from utils import get_current_election_cycle from utils import GUILDS, get_current_election_cycle
if TYPE_CHECKING: if TYPE_CHECKING:
from config import DakinyConfig from config import DakinyConfig
ME = 206602713511886849 ME = 206602713511886849
GUILDS = [1000247361639030804]
def is_me(): # noqa: ANN201 def is_me(): # noqa: ANN201
+109
View File
@@ -0,0 +1,109 @@
"""Contains commands for time commands."""
from datetime import MAXYEAR, MINYEAR, 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="Get a discord timestamp of the given game time. If date information is left blank, uses current day." # noqa: E501
)
async def at( # noqa: PLR0913
self,
interaction: nextcord.Interaction,
hour: int = nextcord.SlashOption(
description="The hour you want a timestamp of. Given in gametime/UTC.",
min_value=0,
max_value=23,
required=True,
),
minute: int = nextcord.SlashOption(
description="The minute you want a timestamp of. Given in gametime/UTC.",
min_value=0,
max_value=59,
required=True,
),
year: int = nextcord.SlashOption(
description="Year to make timestamp of.", required=False, min_value=MINYEAR, max_value=MAXYEAR
),
month: int = nextcord.SlashOption(
description="Month to make timestamp of.", required=False, min_value=1, max_value=12
),
day: int = nextcord.SlashOption(
description="Day to make timestamp of.", required=False, min_value=1, max_value=31
),
ephemeral: bool = nextcord.SlashOption( # noqa: FBT001
description="Whether the replying message will be public or not.", required=False, default=True
),
) -> None:
"""
Replies with a discord timestamp of given UTC time.
Args:
interaction (nextcord.Interaction): Interaction with the command.
hour (int): The hour in UTC to make the timestamp of..
minute (int): The minute in UTC to make the timestamp of..
year (int): The year to make the timestamp of.
month (int): The month to make the timestamp of.
day (int): The day to make the timestamp of.
ephemeral (bool): Whether the response is ephemeral or not.
"""
gametime_today: datetime = datetime.now(tz=UTC).replace(hour=hour, minute=minute)
if year is not None:
gametime_today = gametime_today.replace(year=year)
if month is not None and day is not None:
try:
gametime_today = gametime_today.replace(month=month, day=day)
except ValueError:
await interaction.response.send_message(f"Day {day} is out of range for month {month}.", ephemeral=True)
return
else:
if month is not None:
try:
gametime_today = gametime_today.replace(month=month)
except ValueError:
await interaction.response.send_message(
f"Today ({gametime_today.day}) is out of range for month {month}.", ephemeral=True
)
return
if day is not None:
try:
gametime_today = gametime_today.replace(day=day)
except ValueError:
await interaction.response.send_message(
f"Day {day} is out of range for this month {gametime_today.month}.", ephemeral=True
)
return
await interaction.response.send_message(content=f"<t:{int(gametime_today.timestamp())}:t>", ephemeral=ephemeral)
@time.subcommand(description="Get the current time in game.")
async def gametime(
self,
interaction: nextcord.Interaction,
ephemeral: bool = nextcord.SlashOption( # noqa: FBT001
description="Whether the replying message will be public or not.", required=False, default=True
),
) -> 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)
+1
View File
@@ -27,6 +27,7 @@ REPO_DIR = "./dakiny-messages"
MESSAGES_DIR = f"{REPO_DIR}/messages" MESSAGES_DIR = f"{REPO_DIR}/messages"
TEMPLATES_DIR = f"{REPO_DIR}/message_templates" TEMPLATES_DIR = f"{REPO_DIR}/message_templates"
MAX_DISCORD_MESSAGE_LENGTH = 2000 MAX_DISCORD_MESSAGE_LENGTH = 2000
GUILDS = [1000247361639030804, 239758371358638080]
VoteType = StrEnum("VoteType", ["COUNCIL", "DISCORDMANAGER", "CLANLEADER"]) VoteType = StrEnum("VoteType", ["COUNCIL", "DISCORDMANAGER", "CLANLEADER"])