Skip to content

Commit

Permalink
Added get_membership command, not checking HA api yet
Browse files Browse the repository at this point in the history
  • Loading branch information
Endyya committed Dec 8, 2024
1 parent 888722d commit 47c8f30
Showing 1 changed file with 63 additions and 2 deletions.
65 changes: 63 additions & 2 deletions src/SilicaAnimus/discord_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,54 @@ def __init__(self, *args, **kwargs):
'https://voie-du-thalos.org/img/logo.png'),
text = 'Application Discord pour La Voie du Thalos')

class MemberProcessView(discord.ui.View):

def __init__(self, client, *args, **kwargs):
super().__init__(*args, **kwargs)
self.client = client

@discord.ui.button(label = 'Demander le rôle de membre',
style = discord.ButtonStyle.primary)
async def button_get(self, interaction: discord.Interaction,
button: discord.ui.Button):

member_role = interaction.guild.get_role(678922012109963294)
embed = MessageTemplate(
description = f"Vous possédez déjà le rôle {member_role.mention}.")
if not member_role in interaction.user.roles:
membership = MemberProcessModal()
await interaction.response.send_modal(membership)
await membership.wait()

else:
await interaction.response.send_message(embed = embed,
ephemeral = True)

@discord.ui.button(label = 'Signaler un problème',
style = discord.ButtonStyle.danger)
async def button_report(self, interaction: discord.Interaction,
button: discord.ui.Button):
print(await interaction.response.send_message('Contactez un administrateur',
ephemeral = True))

class MemberProcessModal(discord.ui.Modal,
title = 'Devenir membre sur le discord'):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.member_role = 'Membres Thalos'

self.first_name = discord.ui.TextInput(label = 'Nom')
self.last_name = discord.ui.TextInput(label = 'Prénom')
self.add_item(self.first_name)
self.add_item(self.last_name)



async def on_submit(self, interaction: discord.Interaction):


print(self.first_name.value)
print(self.last_name.value)

class CheckModal(discord.ui.Modal, title = 'Informations'):
prenom = discord.ui.TextInput(label = 'Prénom',
Expand Down Expand Up @@ -301,6 +349,19 @@ async def check_member(interaction: discord.Interaction):
await interaction.response.send_modal(modal)
await modal.wait()

@self.tree.command(guild = self.thalos_guild,
description = """Ajoute le membre au groupe des
adhérents sur le discord""")
@logging_command(logger = self.logger)
async def get_membership(interaction: discord.Interaction):
embed = MessageTemplate(
title = 'Obtenir votre role de membre sur le discord',
description = '')
buttons = MemberProcessView(timeout = None, client = self.client)
await interaction.response.send_message(embed = embed,
view = buttons)


@self.tree.command(guild = self.thalos_guild,
description = """
Lance la procédure de mise à jour des adhérents sur
Expand Down Expand Up @@ -419,10 +480,10 @@ async def button_confirm(self, interaction, button):

@discord.ui.button(label = 'Annuler',
style = discord.ButtonStyle.danger,
disabled = True,
disabled = False,
custom_id = 'cancel')
async def button_cancel(self, interaction, button):
pass
print(interaction)


buttons = Buttons()
Expand Down

0 comments on commit 47c8f30

Please sign in to comment.