✨ edit eval msg + add FINALISTE and hug visual improvements
This commit is contained in:
parent
cc8b7a9949
commit
6d1560ceaa
|
@ -21,7 +21,7 @@ from ptpython.repl import embed
|
|||
from src.constants import *
|
||||
from src.core import CustomBot
|
||||
from src.errors import TfjmError
|
||||
from src.utils import fg
|
||||
from src.utils import fg, french_join
|
||||
|
||||
COGS_SHORTCUTS = {
|
||||
"bt": "src.base_tirage",
|
||||
|
@ -136,10 +136,22 @@ class DevCog(Cog, name="Dev tools"):
|
|||
# noinspection PyUnreachableCode
|
||||
@command(name="setup")
|
||||
@has_role(Role.DEV)
|
||||
async def setup_roles(self, ctx):
|
||||
async def setup_roles(self, ctx: Context, *teams: discord.Role):
|
||||
"""
|
||||
(dev) Commande temporaire pour setup le serveur.
|
||||
"""
|
||||
return
|
||||
finalist = get(ctx.guild.roles, name=Role.FINALISTE)
|
||||
assert finalist
|
||||
|
||||
for t in teams:
|
||||
m: discord.Member
|
||||
for m in t.members:
|
||||
await m.add_roles(finalist)
|
||||
|
||||
await ctx.send(
|
||||
f"{french_join(t.mention for t in teams)} ont été ajouté en finale !"
|
||||
)
|
||||
|
||||
return
|
||||
guild: discord.Guild = ctx.guild
|
||||
|
@ -213,12 +225,10 @@ class DevCog(Cog, name="Dev tools"):
|
|||
await channel.delete_messages(to_delete)
|
||||
await ctx.message.delete()
|
||||
|
||||
@command(name="eval", aliases=["e"])
|
||||
@is_owner()
|
||||
async def eval_cmd(self, ctx: Context):
|
||||
""""""
|
||||
msg: Message = ctx.message
|
||||
guild: discord.Guild = ctx.guild
|
||||
def eval(self, msg: Message) -> discord.Embed:
|
||||
guild: discord.Guild = msg.guild
|
||||
roles = guild.roles
|
||||
members = guild.members
|
||||
|
||||
query = re.match(RE_QUERY, msg.content).group("query")
|
||||
|
||||
|
@ -258,7 +268,36 @@ class DevCog(Cog, name="Dev tools"):
|
|||
embed = discord.Embed(title="Result", color=discord.Colour.green())
|
||||
embed.add_field(name="Query", value=f"```py\n{query}```", inline=False)
|
||||
embed.add_field(name="Value", value=f"```py\n{out.read()}```", inline=False)
|
||||
await ctx.send(embed=embed)
|
||||
embed.set_footer(text="You may edit your message.")
|
||||
return embed
|
||||
|
||||
@command(name="eval", aliases=["e"])
|
||||
@is_owner()
|
||||
async def eval_cmd(self, ctx: Context):
|
||||
""""""
|
||||
embed = self.eval(ctx.message)
|
||||
resp = await ctx.send(embed=embed)
|
||||
|
||||
def check(before, after):
|
||||
return after.id == ctx.message.id
|
||||
|
||||
while True:
|
||||
try:
|
||||
before, after = await self.bot.wait_for(
|
||||
"message_edit", check=check, timeout=600
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
break
|
||||
|
||||
embed = self.eval(after)
|
||||
await resp.edit(embed=embed)
|
||||
|
||||
# Remove the "You may edit your message"
|
||||
embed.set_footer()
|
||||
try:
|
||||
await resp.edit(embed=embed)
|
||||
except discord.NotFound:
|
||||
pass
|
||||
|
||||
@Cog.listener()
|
||||
async def on_message(self, msg: Message):
|
||||
|
|
|
@ -8,6 +8,7 @@ import urllib
|
|||
from collections import defaultdict, Counter
|
||||
from dataclasses import dataclass, field
|
||||
from functools import partial
|
||||
from math import log
|
||||
from operator import attrgetter, itemgetter
|
||||
from time import time
|
||||
from typing import List, Set, Union
|
||||
|
@ -393,7 +394,7 @@ class MiscCog(Cog, name="Divers"):
|
|||
|
||||
async def send_hugs_stats_for(self, ctx: Context, who: Member):
|
||||
embed = discord.Embed(
|
||||
title=f"Calins de {who.display_name}", color=discord.Colour.magenta()
|
||||
title=f"Câlins de {who.display_name}", color=discord.Colour.magenta()
|
||||
)
|
||||
|
||||
given = self.hugs_given(ctx, who.id)
|
||||
|
@ -401,16 +402,19 @@ class MiscCog(Cog, name="Divers"):
|
|||
auto = self.auto_hugs(ctx, who.id)
|
||||
cut = [h for h in given if "coupé en deux" in h.text]
|
||||
infos = {
|
||||
"Câlins donnés": len(given),
|
||||
"Câlins reçus": len(received),
|
||||
"Personnes câlinées": len(set(h.hugged for h in given)),
|
||||
"Câliné par": len(set(h.hugger for h in received)),
|
||||
"Auto-câlins": len(auto),
|
||||
"Coupé en deux": len(cut),
|
||||
"Câlins donnés": (len(given), 1),
|
||||
"Câlins reçus": (len(received), 1),
|
||||
"Personnes câlinées": (len(set(h.hugged for h in given)), 20),
|
||||
"Câliné par": (len(set(h.hugger for h in received)), 30),
|
||||
"Auto-câlins": ((len(auto)), 3),
|
||||
"Morceaux": (len(cut), 30),
|
||||
}
|
||||
|
||||
for f, v in infos.items():
|
||||
embed.add_field(name=f, value=f"{v} {self.heart_for_stat(v)}")
|
||||
for f, (v, h_factor) in infos.items():
|
||||
heart = self.heart_for_stat(v * h_factor)
|
||||
if f == "Morceaux":
|
||||
v = 2 ** v
|
||||
embed.add_field(name=f, value=f"{v} {heart}")
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ TOURNOIS = [
|
|||
"Tours",
|
||||
"Bordeaux-Nancy",
|
||||
"Rennes",
|
||||
"Finale",
|
||||
]
|
||||
|
||||
|
||||
|
@ -73,6 +74,7 @@ class Role:
|
|||
JURY = tuple(f"Jury {t}" for t in TOURNOIS)
|
||||
BENEVOLE = "Bénévole"
|
||||
CAPTAIN = "Capitaine"
|
||||
FINALISTE = "Finaliste"
|
||||
PARTICIPANT = "Participant"
|
||||
TOURIST = "Touriste"
|
||||
PRETRESSE_CALINS = "Grande prêtresse des câlins"
|
||||
|
|
Loading…
Reference in New Issue