Compare commits

...
12 Commits
Author SHA1 Message Date
imcompiling 46bce400af Merge pull request 'Update actions/checkout action to v4' (#92) from renovate/actions-checkout-4.x into main
build_latest / build (push) Successful in 47s
build_release / build (push) Successful in 19s
Reviewed-on: #92
Reviewed-by: imcompiling <[email protected]>
2025-03-23 23:38:13 -04:00
imcompiling b681d7a923 Merge pull request 'Update ghcr.io/astral-sh/uv Docker tag to v0.6.9' (#91) from renovate/ghcr.io-astral-sh-uv-0.x into main
build_latest / build (push) Has been cancelled
Reviewed-on: #91
Reviewed-by: imcompiling <[email protected]>
2025-03-23 23:37:49 -04:00
renovate-bot ec086448ea Update actions/checkout action to v4 2025-03-23 04:01:09 +00:00
renovate-bot 476b0e89ef Update ghcr.io/astral-sh/uv Docker tag to v0.6.9 2025-03-23 04:01:04 +00:00
imcompiling fa39949b1a Merge branch 'main' of https://gitea.cheezers.org/imcompiling/agon
build_latest / build (push) Successful in 37s
2025-03-21 10:45:04 -04:00
imcompiling f1290af45b Remove a double respond. 2025-03-21 10:44:57 -04:00
imcompiling 10954ef117 Merge branch '82-group-message-after-deletion'
build_latest / build (push) Successful in 36s
build_release / build (push) Successful in 18s
2025-03-20 11:04:26 -04:00
imcompiling 0540f7a9eb Add thread as an option everywhere a textchannel is used.
build_develop / build (push) Successful in 35s
2025-03-20 11:04:00 -04:00
imcompiling a4aab09360 Use or instead of two isinstance calls. 2025-03-20 10:56:59 -04:00
imcompiling af7518c1a2 Delete old group message when changing output channel.
build_develop / build (push) Successful in 29s
2025-03-20 10:55:48 -04:00
imcompiling 5be029fb57 Catch when the message has been deleted without entry deletion in my database. 2025-03-20 10:42:24 -04:00
imcompiling d82999b141 Check for channel being None. Allow groups to be posted in threads. 2025-03-20 09:50:31 -04:00
9 changed files with 32 additions and 21 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Docker
+1 -1
View File
@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Docker
+1 -1
View File
@@ -1,7 +1,7 @@
FROM python:3.12.3-slim
# install uv
COPY --from=ghcr.io/astral-sh/uv:0.6.6 /uv /uvx /bin/
COPY --from=ghcr.io/astral-sh/uv:0.6.9 /uv /uvx /bin/
RUN apt-get update && apt-get -y upgrade && apt-get -y install sqlite3
+1 -1
View File
@@ -99,7 +99,7 @@ class CreateCog(commands.Cog, name="Create Cog"):
min_value=1,
max_value=30,
),
channel: nextcord.TextChannel | None = nextcord.SlashOption(
channel: nextcord.TextChannel | nextcord.Thread | None = nextcord.SlashOption(
description="Channel to post Group in. If left empty, defaults to current channel.",
required=False,
default=None,
+2 -2
View File
@@ -37,7 +37,7 @@ class DeleteCog(commands.Cog, name="Delete Cog"):
async def channel_messages(
self,
interaction: nextcord.Interaction,
channel: nextcord.TextChannel | None = nextcord.SlashOption(
channel: nextcord.TextChannel | nextcord.Thread | None = nextcord.SlashOption(
description="Channel to clear of messages.",
required=False,
default=None,
@@ -54,7 +54,7 @@ class DeleteCog(commands.Cog, name="Delete Cog"):
Is a SlashOption. Limited to text channels. Defaults to None.
"""
if not channel:
if isinstance(interaction.channel, nextcord.TextChannel):
if isinstance(interaction.channel, nextcord.TextChannel | nextcord.Thread):
channel = interaction.channel
else:
# This should never happen.
+10 -3
View File
@@ -251,6 +251,10 @@ class SetCog(commands.Cog, name="Set command."):
channel (nextcord.abc.GuildChannel, optional): Channel to register.
Is a SlashOption. Limited to text channels, Defaults to None.
"""
if interaction.guild is None or interaction.channel is None:
agon_logger.warning("Set command was called with an interaction that had no guild or channel.")
return
channel_id = interaction.channel.id if not channel else channel.id
with Session(engine) as session:
@@ -262,11 +266,14 @@ class SetCog(commands.Cog, name="Set command."):
if (group := session.scalar(stmt)) is None:
await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
return
old_channel_id = group.channel_id
group.channel_id = channel_id
session.commit()
# TODO(imcompiling): delete the message and call send_highscore_message to send a new one. Bug needs fixed
# first.
# 082
old_channel = interaction.guild.get_channel(old_channel_id)
if old_channel and isinstance(old_channel, nextcord.TextChannel | nextcord.Thread) and group.message_id:
await old_channel.get_partial_message(group.message_id).delete()
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
@group.subcommand(
+2 -4
View File
@@ -80,9 +80,7 @@ class SubmissionCog(commands.Cog):
if (
verified_score := await self.verify_score(interaction, score, is_time_record=category.is_time_record)
) is None:
# This response message will be filled out better once command is split up to
# know which type it expects...
await interaction.response.send_message("Format was incorrect.", ephemeral=True)
# Verify score handles responding. Might change when submit is split up.
return
# Create submission verification request or submit score if verification not needed.
@@ -103,7 +101,7 @@ class SubmissionCog(commands.Cog):
await interaction.response.send_message(error_response, ephemeral=True)
return
if not isinstance(channel, nextcord.TextChannel):
if not isinstance(channel, nextcord.TextChannel | nextcord.Thread):
await interaction.response.send_message("An error happened with submission.")
agon_logger.error(
"Channel id %s in guild %s is does not correspond to a TextChannel.", channel.id, channel.guild.id
+1 -1
View File
@@ -43,7 +43,7 @@ class DeleteConfirmView(nextcord.ui.Modal):
session.delete(group)
# delete the message related to group
channel = interaction.guild.get_channel(group.channel_id)
if not isinstance(channel, nextcord.TextChannel):
if not isinstance(channel, nextcord.TextChannel | nextcord.Thread):
return
message: nextcord.Message = await channel.fetch_message(group.message_id)
await message.delete()
+13 -7
View File
@@ -342,11 +342,13 @@ async def send_highscore_message(session: Session, guild: nextcord.Guild, group:
group (CategoryGroup): group to post to the message.
"""
highscore_string = format_highscore_message(session, group)
channel = guild.get_channel(group.channel_id)
if (channel := guild.get_channel(group.channel_id)) is None:
agon_logger.error("Channel id %s in guild %s does not exist.", group.channel_id, guild.id)
return
if not isinstance(channel, nextcord.TextChannel):
if not isinstance(channel, nextcord.TextChannel | nextcord.Thread):
agon_logger.error(
"Channel id %s in guild %s is does not correspond to a TextChannel.", channel.id, channel.guild.id
"Channel id %s in guild %s is does not correspond to a TextChannel or Thread.", channel.id, channel.guild.id
)
return
@@ -356,10 +358,14 @@ async def send_highscore_message(session: Session, guild: nextcord.Guild, group:
group.message_id = message.id
session.commit()
else:
# TODO(imcompiling): check what happens when message is deleted.
# https://gitea.cheezers.org/imcompiling/agon/issues/83
message: nextcord.Message = await channel.fetch_message(group.message_id)
await message.edit(content=highscore_string)
try:
message: nextcord.Message = await channel.fetch_message(group.message_id)
await message.edit(content=highscore_string)
except nextcord.NotFound:
# Message was deleted on discord's side.
message: nextcord.Message = await channel.send(highscore_string)
group.message_id = message.id
session.commit()
return