added a generic command for getting the single person with the most of a certain emoji
This commit is contained in:
11
msg.py
11
msg.py
@@ -139,6 +139,15 @@ class MsgData:
|
||||
)
|
||||
return res
|
||||
|
||||
async def biggest_single(self, client: discord.Client, emoji: str, days: int) -> str:
|
||||
data = self.emoji_totals(emoji_name=emoji, days=days)
|
||||
username = data.index[0]
|
||||
reacted_msgs = self.emoji_messages(emoji_name=emoji, days=days)
|
||||
d = reacted_msgs.set_index('display_name')['user id'].drop_duplicates().to_dict()
|
||||
user: discord.User = await client.fetch_user(user_id=d[username])
|
||||
LOGGER.info(f'User: {user.mention}')
|
||||
return f'{user.mention} with {data.iloc[0]["total"]:.0f} over the past {int(days)} days'
|
||||
|
||||
async def message_df(client: discord.Client, **kwargs):
|
||||
return pd.DataFrame(
|
||||
[message_dict(m) async for m in message_gen(client, **kwargs)]
|
||||
@@ -213,7 +222,7 @@ def emoji_messages(msg_df, react_df, emoji_name: str, days: int = 10) -> pd.Data
|
||||
|
||||
|
||||
def emoji_totals(edf: pd.DataFrame) -> pd.DataFrame:
|
||||
totals = edf.groupby('display_name').sum()['count'].sort_values(ascending=False)
|
||||
totals = edf.groupby('display_name').sum()['count'].sort_values(ascending=False).apply(int)
|
||||
max_channels = (
|
||||
edf
|
||||
.groupby(['display_name', 'channel'])
|
||||
|
||||
Reference in New Issue
Block a user