Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsbirb committed Feb 10, 2025
1 parent 30cc5e9 commit 3d51290
Showing 1 changed file with 62 additions and 41 deletions.
103 changes: 62 additions & 41 deletions Cogs/Modules/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,50 +391,54 @@ async def manage(self, ctx: commands.Context, staff: discord.Member):
MessageData = await mccollection.find_one(
{"guild_id": ctx.guild.id, "user_id": staff.id}
)

Config = await Configuration.find_one({"_id": ctx.guild.id})
if Config is None:

return await ctx.send(embed=BotNotConfigured(), view=Support())
if not Config.get("Message Quota"):
return await ctx.send(embed=ModuleNotEnabled(), view=Support())
Quota = Config.get("Message Quota", {}).get("quota", 0)
OnLOA = False
if Config.get("LOA", {}).get("role"):
OnLOA = any(
role.id == Config.get("LOA", {}).get("role") for role in staff.roles
)
YourEmoji = None
view = StaffManage(staff.id, ctx.author)
YourEmoji = (
"`LOA`"
if OnLOA
else (
(
"Met"
if environment == "custom"
else "<:status_green:1227365520857104405>"
YouPlace = None
if MessageData:
Quota = Config.get("Message Quota", {}).get("quota", 0)
OnLOA = False
if Config.get("LOA", {}).get("role"):
OnLOA = any(
role.id == Config.get("LOA", {}).get("role") for role in staff.roles
)
if MessageData.get("message_count") >= Quota
YourEmoji = (
"`LOA`"
if OnLOA
else (
"Not Met"
if environment == "custom"
else "<:status_red:1227365495376711700>"
(
"Met"
if environment == "custom"
else "<:status_green:1227365520857104405>"
)
if MessageData.get("message_count") >= Quota
else (
"Not Met"
if environment == "custom"
else "<:status_red:1227365495376711700>"
)
)
)
)
users = (
await mccollection.find({"guild_id": ctx.guild.id})
.sort("message_count", pymongo.DESCENDING)
.to_list(length=None)
)
YouPlace = self.GetPlace(users, staff)
users = (
await mccollection.find({"guild_id": ctx.guild.id})
.sort("message_count", pymongo.DESCENDING)
.to_list(length=None)
)
YouPlace = self.GetPlace(users, staff)

embed = discord.Embed(
title=f"",
color=discord.Color.dark_embed(),
)
embed.add_field(
name="<:tablerprogressbolt:1330500442551091210> Manage Messages",
value=f"> **Messages:** {MessageData.get('message_count')} messages\n> **Passed:** {YourEmoji if YourEmoji else 'N/A'}\n> **Place:** {ordinal(YouPlace) if YouPlace else 'N/A'}",
value=f"> **Messages:** {MessageData.get('message_count', 0) if MessageData else 0} messages\n> **Passed:** {YourEmoji if YourEmoji else 'N/A'}\n> **Place:** {ordinal(YouPlace) if MessageData else 'N/A' if YouPlace else 'N/A'}",
)
embed.set_author(name=f"@{staff.name}", icon_url=staff.display_avatar)
embed.set_thumbnail(url=staff.display_avatar)
Expand All @@ -459,7 +463,9 @@ async def messages(self, ctx: commands.Context, staff: discord.Member):
{"guild_id": ctx.guild.id, "user_id": staff.id}
)
if not MessageData:
return await ctx.send(f"{no} **{ctx.author.display_name}**, they haven't sent any messages.")
return await ctx.send(
f"{no} **{ctx.author.display_name}**, they haven't sent any messages."
)
Config = await config.find_one({"_id": ctx.guild.id})
if Config is None:
return await ctx.send(embed=BotNotConfigured(), view=Support())
Expand Down Expand Up @@ -725,34 +731,49 @@ async def leaderboard(self, ctx: commands.Context):
)
paginator = Paginator.Simple(
PreviousButton=discord.ui.Button(
emoji="<:chevronleft:1220806425140531321>" if environment != "custom" else None,
label="<<" if environment == "custom" else None
emoji=(
"<:chevronleft:1220806425140531321>"
if environment != "custom"
else None
),
label="<<" if environment == "custom" else None,
),
NextButton=discord.ui.Button(
emoji="<:chevronright:1220806430010118175>" if environment != "custom" else None,
label=">>" if environment == "custom" else None
emoji=(
"<:chevronright:1220806430010118175>"
if environment != "custom"
else None
),
label=">>" if environment == "custom" else None,
),
FirstEmbedButton=discord.ui.Button(
emoji="<:chevronsleft:1220806428726661130>" if environment != "custom" else None,
label="<<" if environment == "custom" else None
emoji=(
"<:chevronsleft:1220806428726661130>"
if environment != "custom"
else None
),
label="<<" if environment == "custom" else None,
),
LastEmbedButton=discord.ui.Button(
emoji="<:chevronsright:1220806426583371866>" if environment != "custom" else None,
label=">>" if environment == "custom" else None
emoji=(
"<:chevronsright:1220806426583371866>"
if environment != "custom"
else None
),
label=">>" if environment == "custom" else None,
),
InitialPage=0,
timeout=360,
extra=[
discord.ui.Button(
label="View Online",
style=discord.ButtonStyle.link,
url=f"https://astrobirb.dev/panel/{ctx.guild.id}",
),
discord.ui.Button(
label="View Online",
style=discord.ButtonStyle.link,
url=f"https://astrobirb.dev/panel/{ctx.guild.id}",
),
],
)
await paginator.start(ctx, pages=pages[:45], msg=msg)


@quota.command(name="reset", description="Reset the message quota leaderboard")
async def reset_staff_message_counts(self, ctx: commands.Context):
await ctx.defer()
Expand Down

0 comments on commit 3d51290

Please sign in to comment.