Skip to content

Commit

Permalink
Use ephemeral messages
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteHoodHacker authored Aug 30, 2024
1 parent f2a67ee commit 4479a64
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/cogs/roles/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def __init__(self, _):
async def add(self, ctx: SlashContext, role: str) -> None:
"""Add a private role. Requires the UIUC role."""
if (ctx.guild == None):
await ctx.send(":x: You can only run this command in a server.")
await ctx.send(":x: You can only run this command in a server.", ephemeral=True)
return
user = ctx.guild.get_member(ctx.user.id)
if (user == None):
await ctx.send(":x: You aren't in the server! Are you a ghost?")
await ctx.send(":x: You aren't in the server! Are you a ghost?", ephemeral=True)
return
if (not any(user.has_role(role) for role in UIUC_ROLES)):
await ctx.send(":x: You need to be UIUC verified to use this command. Verify yourself at <https://sigpwny.com/auth>.")
await ctx.send(":x: You need to be UIUC verified to use this command. Verify yourself at <https://sigpwny.com/auth>.", ephemeral=True)
return
for valid_role in self.roles:
valid_role_name = valid_role.get("name")
Expand All @@ -31,22 +31,22 @@ async def add(self, ctx: SlashContext, role: str) -> None:
continue
if role == valid_role_name:
if user.has_role(valid_role_id):
await ctx.send(f":x: You already have the **{role}** role.")
await ctx.send(f":x: You already have the **{role}** role.", ephemeral=True)
return
await user.add_role(valid_role_id)
await ctx.send(f":white_check_mark: Added you to **{role}**.")
await ctx.send(f":white_check_mark: Added you to **{role}**.", ephemeral=True)
return
await ctx.send(":x: Invalid role.")

@subcommand(role={"description": "Role to remove","autocomplete": True})
async def remove(self, ctx: SlashContext, role: str) -> None:
"""Removes a private role."""
if (ctx.guild == None):
await ctx.send(":x: You can only run this command in a server.")
await ctx.send(":x: You can only run this command in a server.", ephemeral=True)
return
user = ctx.guild.get_member(ctx.user.id)
if (user == None):
await ctx.send(":x: You aren't in the server! Are you a ghost?")
await ctx.send(":x: You aren't in the server! Are you a ghost?", ephemeral=True)
return
for valid_role in self.roles:
valid_role_name = valid_role.get("name")
Expand All @@ -55,10 +55,10 @@ async def remove(self, ctx: SlashContext, role: str) -> None:
continue
if role == valid_role_name:
if not user.has_role(valid_role_id):
await ctx.send(f":x: You do not have the **{role}** role.")
await ctx.send(f":x: You do not have the **{role}** role.", ephemeral=True)
return
await user.remove_role(valid_role_id)
await ctx.send(f":white_check_mark: Removed you from **{role}**.")
await ctx.send(f":white_check_mark: Removed you from **{role}**.", ephemeral=True)
return
await ctx.send(":x: Invalid role.")

Expand Down

0 comments on commit 4479a64

Please sign in to comment.