Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ba7d3563c | ||
|
|
0a18d819af | ||
|
|
2bd4fcb136 | ||
|
|
2a91274d7f | ||
|
|
4fb4927fb8 |
@@ -49,7 +49,7 @@ class RequestCog(commands.Cog, name="Request Commands"):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
config: DakinyConfig = self.bot.config
|
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)
|
view = PresenceChange(presence)
|
||||||
await self.bot.get_channel(config.params.admin_channel_id).send(
|
await self.bot.get_channel(config.params.admin_channel_id).send(
|
||||||
content=content, view=view
|
content=content, view=view
|
||||||
|
|||||||
+43
-2
@@ -7,7 +7,12 @@ from nextcord.ext import commands
|
|||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.orm import Session
|
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"):
|
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.
|
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):
|
async def view(self, interaction: nextcord.Interaction):
|
||||||
"""
|
"""
|
||||||
Parent slash command for set. Never called.
|
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(
|
@view.subcommand(
|
||||||
description="Shows all voters and who they voted for in a given election."
|
description="Shows all voters and who they voted for in a given election."
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ def get_datetime(day: str) -> datetime:
|
|||||||
day = int(day.split("/")[1])
|
day = int(day.split("/")[1])
|
||||||
|
|
||||||
# ensure that year rolls over if current month is December and the next month is less than 12.
|
# 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
|
year += 1
|
||||||
|
|
||||||
return datetime(year, month, day)
|
return datetime(year, month, day)
|
||||||
|
|||||||
Reference in New Issue
Block a user