From 2ad34dc392e83325010dea46f69ebe5f63555218 Mon Sep 17 00:00:00 2001 From: KDwevedi Date: Tue, 31 Oct 2023 09:20:56 +0530 Subject: [PATCH] Added Chapter Question --- main.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 768125c..b1125a5 100644 --- a/main.py +++ b/main.py @@ -16,22 +16,84 @@ # def __init__(self, *,userID, title: str = None, timeout: float | None = None, custom_id: str = None) -> None: # super().__init__(title=title, timeout=timeout, custom_id=custom_id) # self.add_item(discord.ui.Button(label='Authenticate Github', style=discord.ButtonStyle.url, url=f'https://github-app.c4gt.samagra.io/authenticate/{userID}')) - class AuthenticationView(discord.ui.View): def __init__(self, discord_userdata): super().__init__() - self.timeout = None button = discord.ui.Button(label='Authenticate Github', style=discord.ButtonStyle.url, url=f'https://github-app.c4gt.samagra.io/authenticate/{discord_userdata}') self.add_item(button) self.message = None +class ChapterSelect(discord.ui.Select): + def __init__(self, affiliation): + collegeOptions = [discord.SelectOption(label=option["label"], emoji=option["emoji"] ) for option in [ + { + "label": "NIT Kurukshetra", + "emoji": "\N{GRADUATION CAP}" + }, + { + "label": "ITER, Siksha 'O' Anusandhan", + "emoji": "\N{GRADUATION CAP}" + }, + { + "label": "IIITDM Jabalpur", + "emoji": "\N{GRADUATION CAP}" + }, + { + "label": "KIIT, Bhubaneswar", + "emoji": "\N{GRADUATION CAP}" + } + + ]] + corporateOptions = [] + super().__init__(placeholder="Please select your institute",max_values=1,min_values=1,options=collegeOptions if affiliation=="College Chapter" else corporateOptions) + async def callback(self, interaction:discord.Interaction): + await interaction.response.send_message("Now please Authenticate using Github so we can start awarding your points!",view=AuthenticationView(interaction.user.id), ephemeral=True) + + + +class AffiliationSelect(discord.ui.Select): + def __init__(self): + options = [discord.SelectOption(label=option["label"], emoji=option["emoji"] ) for option in [ + { + "label": "College Chapter", + "emoji": "\N{OPEN BOOK}" + }, + { + "label": "Corporate Chapter", + "emoji": "\N{OFFICE BUILDING}" + }, + { + "label": "Individual Contributor", + "emoji": "\N{BRIEFCASE}" + } + ]] + super().__init__(placeholder="Please select applicable affliliation",max_values=1,min_values=1,options=options) + async def callback(self, interaction:discord.Interaction): + if self.values[0] == "College Chapter" or self.values[0] == "Corporate Chapter": + chapterView = discord.ui.View() + chapterView.add_item(ChapterSelect(self.values[0])) + await interaction.response.send_message("Please select your institute!", view=chapterView, ephemeral=True) + + + + + + +class AffiliationView(discord.ui.View): + def __init__(self): + super().__init__() + self.timeout = None + self.add_item(AffiliationSelect()) + + class RegistrationModal(discord.ui.Modal): def __init__(self, *, title: str = None, timeout: Union[float, None] = None, custom_id: str = None) -> None: super().__init__(title=title, timeout=timeout, custom_id=custom_id) - name = discord.ui.TextInput(label='Please Enter Your Name', placeholder='To give you the recognition you deserve, could you please share your full name for the certificates!') + + name = discord.ui.TextInput(label='Please Enter Your Name', placeholder='To give you the recognition you deserve, could you please share your full name for the certificates!') async def on_submit(self, interaction: discord.Interaction): - await interaction.response.send_message("Thanks! Now please register using your Github so that we can award you points for solving tickets!",view=AuthenticationView(interaction.user.id), ephemeral=True) + await interaction.response.send_message("Thanks! Now please select your affiliation!",view=AffiliationView(), ephemeral=True) class RegistrationView(discord.ui.View): def __init__(self):