Compare commits

...
Author SHA1 Message Date
imcompiling 7ba7d3563c Rework logic to use less loops.
build_develop / build (push) Successful in 1m28s
2023-12-22 21:33:34 -05:00
imcompiling 0a18d819af Add command to view presences. 2023-12-22 16:32:32 -05:00
imcompiling 2bd4fcb136 Format change for presence request.
build_latest / build (push) Successful in 1m37s
build_release / build (push) Successful in 45s
build_develop / build (push) Successful in 52s
2023-12-21 19:23:13 -05:00
imcompiling 2a91274d7f Need to use the and keyword. 2023-12-21 19:22:48 -05:00
3 changed files with 45 additions and 4 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ class RequestCog(commands.Cog, name="Request Commands"):
"""
config: DakinyConfig = self.bot.config
content = f'<@{interaction.user.id}> would like to add presence"{presence}."'
content = f'<@{interaction.user.id}> would like to add presence" {presence}."'
view = PresenceChange(presence)
await self.bot.get_channel(config.params.admin_channel_id).send(
content=content, view=view
+43 -2
View File
@@ -7,7 +7,12 @@ from nextcord.ext import commands
from sqlalchemy import select
from sqlalchemy.orm import Session
from database_setup.sql_data_classes import ElectionInformation, Votes, engine
from database_setup.sql_data_classes import (
ElectionInformation,
Presences,
Votes,
engine,
)
class ViewCog(commands.Cog, name="View Commands"):
@@ -20,12 +25,48 @@ class ViewCog(commands.Cog, name="View Commands"):
Default constructor for ViewCog class. Does nothing.
"""
@nextcord.slash_command()
@nextcord.slash_command(guild_ids=[1000247361639030804]) # TODO remove guild ids
async def view(self, interaction: nextcord.Interaction):
"""
Parent slash command for set. Never called.
"""
@view.subcommand(description="Show all possible presence choices.")
async def presences(
self,
interaction: nextcord.Interaction,
search: str = nextcord.SlashOption(
description="A word or string to search for in the presences.",
required=False,
),
):
"""
Gathers all presences from the database and responds with a message showing them.
Args:
interaction (nextcord.Integration): User's interaction with the command.
"""
# might take a while depending on number of presences
await interaction.response.defer(ephemeral=True)
with Session(engine) as session:
stmt = select(Presences.Presence)
presences = session.scalars(stmt)
if search:
message = "\n".join(
[
presence
for presence in presences
if search.lower() in presence.lower()
]
)
else:
message = "\n".join(list(presences))
await interaction.followup.send(content=message, ephemeral=True)
@view.subcommand(
description="Shows all voters and who they voted for in a given election."
)
+1 -1
View File
@@ -28,7 +28,7 @@ def get_datetime(day: str) -> datetime:
day = int(day.split("/")[1])
# ensure that year rolls over if current month is December and the next month is less than 12.
if datetime.today().month == 12 & month < 12:
if datetime.today().month == 12 and month < 12:
year += 1
return datetime(year, month, day)