Skip to content

Commit

Permalink
feat(non-vegan): add outreach and non-vegan roles, adjust user role a…
Browse files Browse the repository at this point in the history
…ssignment workflow

Expanded the role assignment feature with the addition of "outreach" and "non-vegan" roles. Adjusted the role assignment process to accommodate these new roles. Updates include modifying role assignment functions, extending the welcome message feature to the non-vegan group and importing new environment variables for these roles.
  • Loading branch information
joeyaurel committed Jan 23, 2024
1 parent bf544d0 commit 5915105
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ NEW_USER_ROLE_ID=
SUPPORT_ROLE_ID=
VEGAN_ROLE_ID=
NON_VEGAN_ROLE_ID=
OUTREACH_ROLE_ID=

TEAM_BANS_CHANNEL_ID=

MAIN_CHAT_CHANNEL_ID=
NON_VEGAN_MAIN_CHAT_CHANNEL_ID=
57 changes: 54 additions & 3 deletions src/cogs/team_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from discord.utils import MISSING

from src.helpers.env import VEGAN_ROLE_ID, NON_VEGAN_ROLE_ID, TEAM_ROLE_ID, NEW_USER_ROLE_ID, \
ROLE_JUSTIFICATION_CHANNEL_ID, MAIN_CHAT_CHANNEL_ID, TEAM_BANS_CHANNEL_ID
ROLE_JUSTIFICATION_CHANNEL_ID, MAIN_CHAT_CHANNEL_ID, TEAM_BANS_CHANNEL_ID, NON_VEGAN_MAIN_CHAT_CHANNEL_ID, \
OUTREACH_ROLE_ID
from src.vale import Vale


Expand Down Expand Up @@ -92,6 +93,21 @@ async def vegan(self, interaction: discord.Interaction, member: discord.Member,

await self._assign_initial_role(interaction, member, vegan_role, non_vegan_role, reason)

@app_commands.command(
description='Einer Person die "Auf dem Weg"-Rolle vergeben',
)
@app_commands.describe(
member='Eine Person die die "Auf dem Weg"-Rolle bekommen soll',
reason='Der Grund warum die Person die "Auf dem Weg"-Rolle bekommen soll',
)
@app_commands.guild_only()
@app_commands.checks.has_role(TEAM_ROLE_ID)
async def non_vegan(self, interaction: discord.Interaction, member: discord.Member, reason: str):
non_vegan_role = discord.utils.get(interaction.guild.roles, id=NON_VEGAN_ROLE_ID)
vegan_role = discord.utils.get(interaction.guild.roles, id=VEGAN_ROLE_ID)

await self._assign_initial_role(interaction, member, non_vegan_role, vegan_role, reason)

async def _assign_initial_role(
self,
interaction: discord.Interaction,
Expand Down Expand Up @@ -160,7 +176,7 @@ async def _report_role_assignment(
)

embed = discord.Embed(
title='{} freigeschaltet'.format(member.display_name),
title='Rollenvergabe {}'.format(member.display_name),
description=description,
timestamp=interaction.created_at,
colour=assigned_role.colour
Expand All @@ -180,6 +196,15 @@ async def _welcome_user(
member: discord.Member,
assigned_role: discord.Role,
):
if assigned_role.id == VEGAN_ROLE_ID:
await self._welcome_vegan(assigned_role, executor, interaction, member)
return

if assigned_role.id == NON_VEGAN_ROLE_ID:
await self._welcome_non_vegan(assigned_role, executor, interaction, member)
return

async def _welcome_vegan(self, assigned_role, executor, interaction, member):
embed = discord.Embed(
title='Willkommen {}!'.format(member.display_name),
description='{} wurde soeben freigeschaltet und ist jetzt Teil der Vegan Safespace Community!'.format(
Expand All @@ -191,7 +216,7 @@ async def _welcome_user(
embed.set_thumbnail(url=member.display_avatar.url)

embed.set_footer(
text='Von {} freigeschaltet!'.format(executor.display_name),
text='Von {} freigeschaltet'.format(executor.display_name),
icon_url=executor.display_avatar.url,
)

Expand All @@ -203,6 +228,32 @@ async def _welcome_user(
embed=embed,
)

async def _welcome_non_vegan(self, assigned_role, executor, interaction, member):
embed = discord.Embed(
title='Hey {}! Willkommen!'.format(member.display_name),
description='{} wurde soeben freigeschaltet für den "Auf dem Weg"-Space freigeschaltet!'.format(
member.display_name,
),
colour=assigned_role.colour,
)

embed.set_thumbnail(url=member.display_avatar.url)

embed.set_footer(
text='Rolle von {} vergeben'.format(executor.display_name),
icon_url=executor.display_avatar.url,
)

# Welcome member to everyone in the non-vegan channel
non_vegan_main_chat_channel = interaction.guild.get_channel(NON_VEGAN_MAIN_CHAT_CHANNEL_ID)

outreach_role = discord.utils.get(member.guild.roles, id=OUTREACH_ROLE_ID)

await non_vegan_main_chat_channel.send(
content="Hey {}! Willkommen! ({})".format(member.mention, outreach_role.mention),
embed=embed,
)


async def setup(bot: Vale):
await bot.add_cog(
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
SUPPORT_ROLE_ID: int = int(os.getenv('SUPPORT_ROLE_ID'))
VEGAN_ROLE_ID: int = int(os.getenv('VEGAN_ROLE_ID'))
NON_VEGAN_ROLE_ID: int = int(os.getenv('NON_VEGAN_ROLE_ID'))
OUTREACH_ROLE_ID: int = int(os.getenv('OUTREACH_ROLE_ID'))

TEAM_BANS_CHANNEL_ID: int = int(os.getenv('TEAM_BANS_CHANNEL_ID'))

MAIN_CHAT_CHANNEL_ID: int = int(os.getenv('MAIN_CHAT_CHANNEL_ID'))
NON_VEGAN_MAIN_CHAT_CHANNEL_ID: int = int(os.getenv('NON_VEGAN_MAIN_CHAT_CHANNEL_ID'))

0 comments on commit 5915105

Please sign in to comment.