Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1b327ca05 | ||
|
|
fa39949b1a | ||
|
|
f1290af45b | ||
|
|
10954ef117 | ||
|
|
af7518c1a2 | ||
|
|
5be029fb57 |
@@ -251,6 +251,10 @@ class SetCog(commands.Cog, name="Set command."):
|
|||||||
channel (nextcord.abc.GuildChannel, optional): Channel to register.
|
channel (nextcord.abc.GuildChannel, optional): Channel to register.
|
||||||
Is a SlashOption. Limited to text channels, Defaults to None.
|
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
|
channel_id = interaction.channel.id if not channel else channel.id
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
@@ -262,11 +266,14 @@ class SetCog(commands.Cog, name="Set command."):
|
|||||||
if (group := session.scalar(stmt)) is None:
|
if (group := session.scalar(stmt)) is None:
|
||||||
await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
|
await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
old_channel_id = group.channel_id
|
||||||
group.channel_id = channel_id
|
group.channel_id = channel_id
|
||||||
session.commit()
|
session.commit()
|
||||||
# TODO(imcompiling): delete the message and call send_highscore_message to send a new one. Bug needs fixed
|
|
||||||
# first.
|
old_channel = interaction.guild.get_channel(old_channel_id)
|
||||||
# 082
|
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)
|
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
|
||||||
|
|
||||||
@group.subcommand(
|
@group.subcommand(
|
||||||
|
|||||||
@@ -80,9 +80,7 @@ class SubmissionCog(commands.Cog):
|
|||||||
if (
|
if (
|
||||||
verified_score := await self.verify_score(interaction, score, is_time_record=category.is_time_record)
|
verified_score := await self.verify_score(interaction, score, is_time_record=category.is_time_record)
|
||||||
) is None:
|
) is None:
|
||||||
# This response message will be filled out better once command is split up to
|
# Verify score handles responding. Might change when submit is split up.
|
||||||
# know which type it expects...
|
|
||||||
await interaction.response.send_message("Format was incorrect.", ephemeral=True)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Create submission verification request or submit score if verification not needed.
|
# Create submission verification request or submit score if verification not needed.
|
||||||
@@ -210,9 +208,9 @@ class SubmissionCog(commands.Cog):
|
|||||||
elif re.search("^[0-9](\\.[0-9])?$", score):
|
elif re.search("^[0-9](\\.[0-9])?$", score):
|
||||||
# need to add 0 in seconds and leading colon and 0
|
# need to add 0 in seconds and leading colon and 0
|
||||||
score = "0:0" + score
|
score = "0:0" + score
|
||||||
elif re.search("^[0]?[0-9]:[0-9]{2}(\\.[0-9])?$", score):
|
elif re.search("^[0][0-9]:[0-9]{2}(\\.[0-9])?$", score):
|
||||||
# if there is a minute 10ths place 0, remove
|
# if there is a minute 10ths place 0, remove
|
||||||
score = score.lstrip("0")
|
score = score[1:]
|
||||||
|
|
||||||
return score
|
return score
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -358,10 +358,14 @@ async def send_highscore_message(session: Session, guild: nextcord.Guild, group:
|
|||||||
group.message_id = message.id
|
group.message_id = message.id
|
||||||
session.commit()
|
session.commit()
|
||||||
else:
|
else:
|
||||||
# TODO(imcompiling): check what happens when message is deleted.
|
try:
|
||||||
# https://gitea.cheezers.org/imcompiling/agon/issues/83
|
message: nextcord.Message = await channel.fetch_message(group.message_id)
|
||||||
message: nextcord.Message = await channel.fetch_message(group.message_id)
|
await message.edit(content=highscore_string)
|
||||||
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
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user