Skip to content

Commit

Permalink
Added Chapter Question
Browse files Browse the repository at this point in the history
  • Loading branch information
KDwevedi committed Oct 31, 2023
1 parent fa0a2ae commit 2ad34dc
Showing 1 changed file with 66 additions and 4 deletions.
70 changes: 66 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 2ad34dc

Please sign in to comment.