Add barebones "break" additions

This commit is contained in:
2025-10-16 16:06:22 -06:00
parent 3032210a85
commit b39de87e4b
2 changed files with 49 additions and 0 deletions

View File

@@ -247,6 +247,35 @@ async def callout(interaction: discord.Interaction, day: int, month: int, year:
await interaction.response.send_message(f'{user_char_name} -- you added a callout for {callout_date} with reason: {reason}')
await interaction.followup.send(f'{DATABASE_CONN.format_list_of_callouts(DATABASE_CONN.query_callouts(7))}')
@client.tree.command()
async def add_break(interaction: discord.Interaction, start_day: int, start_month: int,
start_year: int, end_day: int, end_month: int, end_year: int) -> None:
delete_invalidate()
cleanup_invalidate()
uid = interaction.user.id
user_nick = interaction.user.display_name
user_char_name = DATABASE_CONN.return_char_name(uid)
start_date: datetime.date = datetime.date(year=start_year, month=start_month, day=start_day)
end_date: datetime.date = datetime.date(year=end_year, month=end_month, day=end_day)
# TODO send to DATABASE_CONN to add callout
try:
DATABASE_CONN.add_break(user_id=uid, break_start=start_date, break_end=end_date)
except UNIQUEVIOLATION:
await interaction.response.send_message(f'{user_char_name} -- you have already added a callout for {callout_date} with reason: {reason}')
except INVALIDDATETIMEFORMAT:
await interaction.response.send_message(f'{user_char_name} -- please format the date as the following format: MM/DD/YYYY')
except FOREIGNKEYVIOLATION:
await interaction.response.send_message(f'{user_nick} -- please register with the bot using the following command!\n`/registercharacter`\n Please use your in-game name!')
except helper.db_helper.DateTimeError:
await interaction.response.send_message(f'{user_nick}, you\'re trying to submit a callout for a time in the past! Please verify that this is what you want to do!')
except psycopg2.Error as e:
await interaction.response.send_message(f'{user_nick} -- an error has occured!\nNotifying <@{CONTRASTELLAR}> of this error. Error is as follows --\n{e}')
else:
await interaction.response.send_message(f'{user_char_name} -- you added a callout for {callout_date} with reason: {reason}')
@client.tree.command()
async def remove_callout(interaction: discord.Interaction, day: int, month: int, year: int) -> None: