Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commands for managing boosting roles #19

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
22 changes: 15 additions & 7 deletions cogs/hideout/boost_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
from . import HideoutManager

BOOSTER_ROLE_ID: int = 878410045505798154
itswilliboy marked this conversation as resolved.
Show resolved Hide resolved
T = Optional[Union[str, bytes]]


class BoostRoles(HideoutCog):
@staticmethod
async def get_emoji(input: str) -> T:
async def get_emoji(input: str) -> Optional[Union[str, bytes]]:
if is_emoji(input):
return input

Expand All @@ -28,8 +27,16 @@ async def get_emoji(input: str) -> T:

return await partial.read()

boost = app_commands.Group(name="boost", description="Commands for managing your boost.")
role = app_commands.Group(name="role", description="Commands for manging your boost role.", parent=boost)
@app_commands.guild_only()
class BoostGroup(app_commands.Group):
pass

@app_commands.guild_only()
class RoleGroup(app_commands.Group):
pass

boost = BoostGroup(name="boost", description="Commands for managing your boost.")
role = RoleGroup(name="role", description="Commands for manging your boost role.", parent=boost)
itswilliboy marked this conversation as resolved.
Show resolved Hide resolved

@role.command()
@app_commands.describe(
Expand Down Expand Up @@ -67,7 +74,7 @@ async def create(
"Could not parse the colour, make sure it's a valid hex colour code.", ephemeral=True
)

if all((icon, emoji)):
if icon and emoji:
return await interaction.response.send_message("You can not supply both `icon` and `emoji`.", ephemeral=True)

elif emoji is not None:
Expand Down Expand Up @@ -122,11 +129,12 @@ async def edit(
):
"""Edits your boost role."""
assert isinstance(interaction.user, discord.Member) and interaction.guild

if BOOSTER_ROLE_ID not in [role.id for role in interaction.user.roles]:
return await interaction.response.send_message("You're currently not boosting this server.", ephemeral=True)
return await interaction.response.send_message("You're currently not boosting the server.", ephemeral=True)

colour_: discord.Colour = discord.Colour.default()
icon_: T = ""
icon_ = ""

db = await interaction.client.pool.fetchrow("SELECT * FROM booster_roles WHERE user_id = $1", interaction.user.id)
if db is None:
Expand Down