BadWolf1023 / MKW-Table-Bot

MKW Table Bot is a Discord Bot created by Bad Wolf to automatically create tables for online rooms in Mario Kart Wii. It also played a part in transforming the way Lounge updates rating to a more automated process. MKW Table Bot also provides many other smaller tools for people. A full documentation of everything MKW Table Bot does can be found in the ReadMe.
MIT License
13 stars 6 forks source link

gpcount command #210

Closed Wexos closed 1 year ago

Wexos commented 1 year ago

Description

Adds a gpcount command, which allows a user to change the number of gps after a war has been started. Have tested with offline testing rooms, but not on live rooms from Wiimmfi.

Checklist

BadWolf1023 commented 1 year ago

Sorry the review took so long to do. I only saw the PR just now.

Also, please test with the gpsize or size command. Please test how this affects race edits (eg race order, score edits, changing place, etc) for races that "fall off" the end of the table when gp size is changed to 2 gps with 12 races played, and those edits occurred on Race 9-12.

TIA and thanks for the contribution!

Wexos commented 1 year ago

That should fix the issues. Let me know if there are more.

I noticed the /gpsize slash command didn't work, so I fixed it as well.

If running /gpsize 1 followed by gpcount 1, it will display 4 columns (=1gp = 4 races). Imo this is how it should work, because the /gpsize command only change the display size in table, not the actual size of an gp. Though of course one could argue that it should only display only 1 column. Change display size after gp count and inverse worked fine for me.

I tried /rr, /changeraceorder, /editrace and qe for races past the gp count, and it worked as expected. So one can run commands on races not displayed in the table, and if gp count is changed to include those races, the edits are still there.

Another comment, I got this stack trace if trying to run after install:


  File "X:\Development\MKW-Table-Bot\tablebotvenv\lib\site-packages\discord\ui\view.py", line 416, in _scheduled_task
    return await self.on_error(e, item, interaction)
  File "X:\Development\MKW-Table-Bot\Components.py", line 167, in on_error
    await InteractionUtils.on_component_error(error, interaction, self.prefix, self.bot)
  File "X:\Development\MKW-Table-Bot\InteractionUtils.py", line 199, in on_component_error
    await handle_component_exception(error, message, prefix, channel_bot)
  File "X:\Development\MKW-Table-Bot\InteractionUtils.py", line 207, in handle_component_exception
    await common.client.handle_exception(error,message,server_prefix, channel_bot)
  File "X:\Development\MKW-Table-Bot\BadWolfBot.py", line 706, in handle_exception
    raise e
  File "X:\Development\MKW-Table-Bot\BadWolfBot.py", line 644, in handle_exception
    raise error
  File "X:\Development\MKW-Table-Bot\tablebotvenv\lib\site-packages\discord\ui\view.py", line 414, in _scheduled_task
    await item.callback(interaction)
  File "X:\Development\MKW-Table-Bot\Components.py", line 121, in callback
    await commands.TablingCommands.after_start_war_command(message, self.view.bot, [self.cat], self.view.prefix, self.view.is_lounge)
  File "X:\Development\MKW-Table-Bot\commands.py", line 2273, in after_start_war_command
    await TablingCommands.war_picture_command(message, this_bot, ['wp'], server_prefix, is_lounge_server)
  File "X:\Development\MKW-Table-Bot\commands.py", line 2621, in war_picture_command
    footer_combine_success = ImageCombine.add_miis_to_table(this_bot, table_sorted_data, table_image_path=table_image_path, out_image_path=table_image_path)
  File "X:\Development\MKW-Table-Bot\ImageCombine.py", line 140, in add_miis_to_table
    extension_reflect, mii_footer = get_footer_with_miis(channel_bot, table_data)
  File "X:\Development\MKW-Table-Bot\ImageCombine.py", line 160, in get_footer_with_miis
    team_footers.append((team_tag, generate_footer_section_for_team(available_miis, team_tag, add_left_border=should_add_left_border)))
  File "X:\Development\MKW-Table-Bot\ImageCombine.py", line 230, in generate_footer_section_for_team
    if mii_font.getsize(mii_name)[0] > (actual_mii_picture_width - MII_NAME_WIDTH_PADDING) and mii_font.getsize(mii_name)[1] <= max_mii_name_height:
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'```

The fix is found here: https://github.com/ultralytics/yolov5/issues/11838#issuecomment-1630008890
BadWolf1023 commented 1 year ago

I agree that's how it should work. I think doing the other way would actually introduce a lot of bugs.

Noted on the Pillow. I believe I ran into the issue myself and forgot to update the requirements.txt.

PR looks good. Thanks for testing. Will merge in now and go live in a few minutes.

BadWolf1023 commented 1 year ago

If you want to type up an announcement of how to use the command, I will post in Table Bot server.

Wexos commented 1 year ago

Thanks for merging. Maybe something like:

The bot now allows changing the number of gps after a table has been started with /sw. This is done with the command gpcount. As an example, if a table was started with 3 gps and one wants to change it to 4 gps, one would run '@MKW Table Bot gpcount 4' or '/gpcount 4'.

Feel free to edit.