Skip to content

Commit

Permalink
Fixing klefki command
Browse files Browse the repository at this point in the history
  • Loading branch information
greystorm101 committed Dec 31, 2024
1 parent a682b46 commit affe762
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/cogs/klefki.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
APPLICANT_ABANDONED_ID=0
APPLICANT_ROLE_GIVEN_ID=0

tags = {}

deny_reasons = {"alt": "One or more of sprites do not follow the criteria for a conventional head/body fusion. Please reapply with three sprites that meet the fusion requirements in https://discord.com/channels/302153478556352513/873571372981452830/909608552639897660",
"similar sprites": "Your sprites are **too similar**, which makes it difficult for the managers to evaluate your spriting skills! Please reapply "\
"with a trio of sprites that are more varied, such as using three **different Pokémon** for the heads of the 3 sprites.",
Expand Down Expand Up @@ -67,9 +69,11 @@ async def appaccept(self, ctx: Context, name: User, more_work_needed: bool = Fal
applicant_role = utils.get(ctx.guild.roles,id=SPRITER_APPLICANT_ID)
spriter_role = utils.get(ctx.guild.roles,id=SPRITER_ID)

await check_and_load_cache(self.bot)

await selected_user.add_roles(spriter_role)
await selected_user.remove_roles(applicant_role)
await ctx.channel.edit(archived=False, applied_tags=[APPLICANT_ROLE_GIVEN_ID])
await ctx.channel.edit(archived=False, applied_tags=[tags["given"]])

is_spman = "Sprite Manager" in [role.name for role in ctx.author.roles]
approver_role = "Sprite Manager" if is_spman else "Klefki"
Expand Down Expand Up @@ -108,9 +112,9 @@ async def appdeny(self, ctx: Context, name: User, reason:str, comment: str = "")
selected_user = ctx.guild.get_member(name.id)

applicant_role = utils.get(ctx.guild.roles,id=SPRITER_APPLICANT_ID)

await check_and_load_cache(self.bot)
await selected_user.remove_roles(applicant_role)
await ctx.channel.edit(archived=False, applied_tags=[APPLICANT_ABANDONED_ID])
await ctx.channel.edit(archived=False, applied_tags=[tags["abandoned"]])

message = f"Hey {selected_user.mention}! Unfortunately, your application has been denied for the time being for the following reason: **{reason.upper()}**.\n\n"\

Expand Down Expand Up @@ -176,6 +180,12 @@ async def setup(bot:Bot):
await bot.add_cog(Klefki(bot))


async def check_and_load_cache(bot: Bot):
if tags == {}:
application_channel = bot.get_channel(SPRITE_APP_CHANNEL_ID)
tags["abandoned"] = application_channel.get_tag(APPLICANT_ABANDONED_ID) # "Needs Feedback" tag ID
tags["given"] = application_channel.get_tag(APPLICANT_ROLE_GIVEN_ID) # "Needs Feedback" tag ID

def load_env_vars(env: str):
""" Loads in env vars based on dev or prod. Makes me cry."""
is_dev = env == "dev"
Expand Down

0 comments on commit affe762

Please sign in to comment.