| Total Complexity | 8 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import discord |
||
| 2 | |||
| 3 | from app.classes.abc.message_manager import MessageManager |
||
| 4 | from app.utils import get_int |
||
| 5 | |||
| 6 | |||
| 7 | class Pot(MessageManager): |
||
| 8 | |||
| 9 | def __init__(self, message): |
||
| 10 | self.pot_message = message |
||
| 11 | self.pot = parse_from_message(message.embeds[0].description) |
||
| 12 | |||
| 13 | async def update(self): |
||
| 14 | drink_list_embed = discord.Embed( |
||
| 15 | title="Cagnotte", |
||
| 16 | description=( |
||
| 17 | get_embed_description() |
||
| 18 | + f'\n\n**Total:** `${self.pot:,}`' |
||
| 19 | ) |
||
| 20 | ) |
||
| 21 | |||
| 22 | await self.pot_message.edit( |
||
| 23 | content='', |
||
| 24 | embed=drink_list_embed |
||
| 25 | ) |
||
| 26 | |||
| 27 | async def add(self, amount): |
||
| 28 | self.pot += amount |
||
| 29 | await self.update() |
||
| 30 | |||
| 31 | async def correct(self, amount): |
||
| 32 | self.pot -= amount |
||
| 33 | await self.update() |
||
| 34 | |||
| 35 | async def remove(self, amount): |
||
| 36 | self.pot -= amount |
||
| 37 | await self.update() |
||
| 38 | |||
| 39 | |||
| 40 | def get_embed_description() -> str: |
||
| 41 | with open('assets/pot_description.txt', encoding='utf-8') as f: |
||
| 42 | return f.read() |
||
| 43 | |||
| 44 | |||
| 45 | def parse_from_message(content): |
||
| 46 | return get_int(content.splitlines()[-1].split('$')[1]) |
||
| 47 |