Changed send_highscore_message to take guild rather than channel.

This commit is contained in:
alwayscompiling
2022-12-08 13:02:39 -05:00
parent a9b889234a
commit f468a028d0
4 changed files with 12 additions and 29 deletions
+6 -14
View File
@@ -298,23 +298,22 @@ def get_time_str(time_in: float) -> str:
return time.strftime(f"%-M:%S.{milliseconds}", time.gmtime(time_in))
async def send_highscore_message(
session: Session, channel: nextcord.TextChannel, group: CategoryGroup
) -> nextcord.Message:
async def send_highscore_message(session: Session, guild: nextcord.Guild, group: CategoryGroup) -> nextcord.Message:
"""
Function takes care of checking if a message exists for a group.
Creates and sends/edits the message.
Args:
session (Session): The sqlalchemy session being used for this function call.
channel (nextcord.TextChannel): Discord channel object where message is sent
group (CategoryGroup): group to post to the message
guild (nextcord.Guild): the nextcord.Guild object requesting this message.
group (CategoryGroup): group to post to the message.
Returns:
nextcord.Message: Message object that was posted with group contents
nextcord.Message: Message object that was posted with group contents.
"""
highscore_string = format_highscore_message(session, group)
channel = guild.get_channel(group.ChannelId)
try:
message: nextcord.Message = await channel.fetch_message(group.MessageId)
@@ -367,14 +366,7 @@ async def submit_score(
stmt = select(CategoryGroup).where(CategoryGroup.GroupId == group_id)
group = session.scalar(stmt)
# edit message
channel = interaction.guild.get_channel(group.ChannelId)
error_response = "Registered Highscores channel does not exist or was never registered."
error_response += 'Register with "/register" command.'
assert channel is not None, await interaction.send(error_response, ephemeral=True)
await send_highscore_message(session, channel, group)
await send_highscore_message(session, interaction.guild, group)
def add_preset_configuration(guild_id: int, config_str: str) -> None: