Skip to content

Commit

Permalink
refactor: Moved rank upgrade winner announcement into consts.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxgh committed Mar 20, 2024
1 parent ed5f43d commit 0d7827c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
18 changes: 18 additions & 0 deletions src/utils/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,24 @@
inline = False
)

rank_upgrade_winner_announcement = '''# RANK UPGRADE
{date}
**The winner is....**
## {winner}
> Total Guild Experience:- `{winner_gexp}`
> Valid Invites:- `{winner_invites}`
> Total Entries:- `{winner_entries}`
This rank upgrade must be claimed within a week of this message. If not claimed, it will be voided.
### Here are some statistics for the past week
- Total unscaled guild experience earned - `{total_gexp}`
- Total players invited (valid) - `{total_invites}`
- Total entries - `{total_entries}`
*To know how the winner is picked, go here https://discord.com/channels/522586672148381726/1152480866585554994/1164962591198683146*'''

rainbow_separator = "http://rainbowdivider.com/images/dividers/movrblin02.gif"


Expand Down
28 changes: 12 additions & 16 deletions src/utils/referral_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from random import shuffle, choice

from src.utils.calculation_utils import get_player_gexp, get_gexp_sorted
from src.utils.consts import guild_handle, member_req, active_req, rank_upgrade_channel
from src.utils.consts import guild_handle, member_req, active_req, rank_upgrade_channel, \
rank_upgrade_winner_announcement
from src.utils.db_utils import select_one, insert_new_inviter, add_invitee
from src.utils.request_utils import get_mojang_profile, get_player_guild, get_guild_by_name, get_name_by_uuid

Expand Down Expand Up @@ -108,20 +109,15 @@ async def generate_rank_upgrade(weekly_invites : list):
f"-"
f" {datetime.utcnow().strftime('%d %B %Y')}**")

announcement = f'''# RANK UPGRADE
{date}
**The winner is....**
## {winner}
> Total Guild Experience:- `{format(winner_gexp, ',d')}`
> Valid Invites:- `{format(len(winner_invites), ',d') if winner_invites else 0}`
> Total Entries:- `{format(entries[winner_uuid], ',d') if winner_uuid in entries else 0}`
### Here are some statistics for the past week
- Total unscaled guild experience earned - `{format(total_gexp, ',d')}`
- Total players invited (valid) - `{format(total_invitations, ',d')}`
*To know how the winner is picked, go here https://discord.com/channels/522586672148381726/1152480866585554994/1164962591198683146*'''
announcement = rank_upgrade_winner_announcement.format(
date=date,
winner=winner,
winner_gexp=format(winner_gexp, ',d'),
winner_invites=format(len(winner_invites), ',d') if winner_invites else 0,
winner_entries=format(entries[winner_uuid], ',d') if winner_uuid in entries else 0,
total_gexp=format(total_gexp, ',d'),
total_invites=format(total_invitations, ',d'),
total_entries=format(sum(entries.values()), ',d')
)

await bot.get_channel(rank_upgrade_channel).send(announcement)

0 comments on commit 0d7827c

Please sign in to comment.