Skip to content

Commit

Permalink
changed some names, commented check member HA link
Browse files Browse the repository at this point in the history
  • Loading branch information
Endyya committed Nov 28, 2024
1 parent 7ba9b42 commit 455d707
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/SilicaAnimus/discord_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,33 @@

load_dotenv()

class Template(discord.Embed):
class MessageTemplate(discord.Embed):
def __init__(self, *args, **kwargs):

super().__init__(*args, **kwargs)
self.colour = discord.Colour.dark_red()

class IDModal(discord.ui.Modal, title = 'Informations'):
class CheckModal(discord.ui.Modal, title = 'Informations'):
nom = discord.ui.TextInput(label = 'Nom')
prenom = discord.ui.TextInput(label = 'Prénom')

async def on_submit(self, interaction: discord.Interaction):
nom = self.nom
prenom = self.prenom
ha_client = self.parent_client.helloasso_client
is_member = await ha_client.get_membership(
first_name = prenom,
last_name = nom
)
# ha_client = client.helloasso_client
# is_member = await ha_client.get_membership(
# first_name = prenom,
# last_name = nom
# )
is_member = True
if is_member:
return_message = f"{prenom} {nom} is a member"
else:
return_message = f"{prenom} {nom} is not a member"
await interaction.response.send_message(return_message,
embed = MessageTemplate(
title = 'Vérification du membre :',
description = return_message)
await interaction.response.send_message(embed = embed,
ephemeral = True)


Expand Down Expand Up @@ -78,7 +81,7 @@ def __init__(
@self.tree.command(guild = self.thalos_guild)
async def ping(interaction: discord.Interaction):

embed = Template(
embed = MessageTemplate(
title = 'Pong !',
description = f'Bot ping is {round(1000*self.client.latency)} ms',
)
Expand All @@ -88,15 +91,15 @@ async def ping(interaction: discord.Interaction):

@self.tree.command(guild = self.thalos_guild)
async def echo(interaction: discord.Interaction, text: str):
embed = Template(
embed = MessageTemplate(
description = text,
)
await interaction.response.send_message(embed = embed)


@self.tree.command(guild = self.thalos_guild)
async def my_roles(interaction: discord.Interaction):
embed = Template(
embed = MessageTemplate(
title = 'Your roles are : ',
description = ''.join(
[role.mention + '\n' for role in interaction.user.roles[::-1]]
Expand All @@ -109,7 +112,7 @@ async def my_roles(interaction: discord.Interaction):
async def whois(interaction: discord.Interaction,
role: discord.Role):

embed = Template(
embed = MessageTemplate(
description = f'Les membres ayant le role {role.mention} sont :',
)
max_fields = 25
Expand Down Expand Up @@ -138,7 +141,7 @@ async def pin(interaction: discord.Interaction,
message: discord.Message):
try:
await message.pin()
embed = Template(description = 'Message épinglé !')
embed = MessageTemplate(description = 'Message épinglé !')
await interaction.response.send_message(embed = embed,
ephemeral = True)
except discord.errors.HTTPException as e:
Expand All @@ -163,14 +166,14 @@ async def give_role(interaction: discord.Interaction,

except Exception as e:
message += str(e)
embed = Template(
embed = MessageTemplate(
title = 'Une erreur est survenue...',
description = message
)
await interaction.response.send_message(embed = embed)
raise

embed = Template(
embed = MessageTemplate(
title = 'Affectation de roles :',
description = message)
await interaction.response.send_message(embed = embed)
Expand All @@ -179,7 +182,9 @@ async def give_role(interaction: discord.Interaction,
@app_commands.checks.has_role('Administrateurs')
@self.tree.command(guild = self.thalos_guild)
async def check_member(interaction: discord.Interaction):
modal = IDModal()
data = {'prenom' : '',
'nom' : ''}
modal = CheckModal()
await interaction.response.send_modal(modal)


Expand Down

0 comments on commit 455d707

Please sign in to comment.