Conversation
…ember and did not have permission to do so
…g the precised role and start a game, subject to a cooldown
…lement the command.
…for command, edited the way translations work to allow nesting, and worked more on the structure of the database
…he api, did not succeed yet, but I need to sleep sometimes so let's continue that tomorrow
…tyle issues, still need some work to get clean code =D
… up mess and globally made something clean. => Ready for review
Astremy
left a comment
There was a problem hiding this comment.
Don't put the lang changes in the same PR, don't do synchronous requests in an asynchronous bot, just use a foreign key to another table in the guild table, don't put _ in front of half of the functions... some other things
| return | ||
|
|
||
| try: | ||
| (game, game_id) = _get_game(link) |
There was a problem hiding this comment.
why some _ in the start of the function? That's not a library, and that's not some not-to-call methods of an object
| from yaml import load, Loader | ||
| with open("vesta/data/lang.yml") as file: | ||
| lang = Lang(load(file.read(), Loader), session_maker) | ||
| lang_file = Lang(load(file.read(), Loader), session_maker) |
There was a problem hiding this comment.
why letting the lang file named as "lang" and renaming the lang as "lang file"?
| start_update_loop(message=announcement_message, guild=interaction.guild) | ||
|
|
||
|
|
||
| def _get_game(link: str): |
There was a problem hiding this comment.
don't put some _ in front of the function name, as said before
| return game, game_id | ||
|
|
||
|
|
||
| def _get_guild_game(interaction: discord.Interaction) -> ClashOfCodeGuildGame: |
There was a problem hiding this comment.
if you have only one clash of code game per guild, maybe just use a foreign key in the guild table to a clash of code game
|
|
||
| :return: Nothing | ||
| """ | ||
| from .. import session_maker, vesta_client |
There was a problem hiding this comment.
If imported at the top of the file, creates a circular import, so it's a workaround that works to avoid it, needs more debugging to find where the circular import takes place
| :param guild: The guild to update the data for | ||
| :return: Nothing | ||
| """ | ||
| from .. import session_maker |
|
|
||
| await asyncio.sleep(10) | ||
|
|
||
| asyncio.create_task(update_loop(fetched_game)) No newline at end of file |
There was a problem hiding this comment.
NO. Don't start a while True task for each one. If you want to do something like that properly, start one task, and use an updating queue. It will prevent any "oh it never actually finish for some weird reasons" problem
There was a problem hiding this comment.
That's an absolutely must not
There was a problem hiding this comment.
Should never happen because the API always ends the game at a moment
| __tablename__ = "clash_of_code_guild_game" | ||
|
|
||
| guild_id = db.Column(db.BigInteger, nullable=False, primary_key=True) | ||
| last_clash_id = db.Column(db.String(511), nullable=True) |
There was a problem hiding this comment.
Is there a need for a so long ID? verify the actual size before setting random values
|
|
||
| session = session_maker() | ||
|
|
||
| class ClashOfCodeGuildGame(Base): |
There was a problem hiding this comment.
Why is it not just "ClashOfCodeGame" if there is only one per guild?
There was a problem hiding this comment.
As said maybe use a foreign key from guild to link it up
There was a problem hiding this comment.
ClashOfCodeGame is already used to talk about the representation of an api object
Object: Adding a module to be able to share a clash of code game with part or all a discord server
Clash of code module
Main features:
/clash-of-code [link]to share a game of clash of code/config coc-role [role]to configure the role to be pinged when a game is shared/config coc-channel [channel]to configure the channel where the ping message will be sentTechnical features:
vesta/services/clash_of_code_helper#resume_update_loopsBreaking changes:
Guildtable has been updated to add some more configurationTechnical changes:
/configcommand to be able to add a configuration command more easily. Still needs some work, but in an other PR.requestsmodule to the list of dependencies to be able to poll the Codingame APIlangtolang_fileto avoid confusion between the lang.py file and the lang variable managing the translations