Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Mari-W committed Jul 6, 2023
1 parent 09a1df1 commit 5c4c45f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def offtopic_channel_request_modal(interaction: Interaction):
)
await interaction.response.send_modal(offtopic_channel_request_input)

# sends the rquest to admin channel
# sends the request to admin channel
async def on_request(
input: ChannelRequestInput | OffTopicChannelRequestInput,
interaction: Interaction,
Expand Down Expand Up @@ -360,7 +360,7 @@ async def on_accept(
category=utils.get(
accept_interaction.user.guild.categories, name="channels"
),
topic=f"**[{channel_request_accept_input.kind_of_lecture}]** {channel_request_accept_input.name_of_lecture}",
topic=f"**[{channel_request_accept_input.kind_of_event}]** {channel_request_accept_input.name_of_lecture}",
)

await request_interaction.user.send(
Expand Down
62 changes: 29 additions & 33 deletions src/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ class AuthTokenInput(Modal, title="Enter Authentication Token"):
token = TextInput(label="Token", placeholder="Authentication Token")


auth_token_button = Button(label="Authenticate", style=ButtonStyle.primary)
auth_link_button = Button(label="Get Token", url=env.url + "auth/token")
auth_token_button = Button(label="Enter Auth Token", style=ButtonStyle.primary)
auth_link_button = Button(label="Get Auth Token", url=env.url + "token")
auth_view = (
lambda: View(timeout=None).add_item(auth_link_button).add_item(auth_token_button)
)

auth_embed = Embed(
type="rich",
title="Login using University Account",
title="Authenticate using University Account",
url=env.url + "token",
colour=Colour.blurple(),
timestamp=datetime.now(),
Expand All @@ -68,22 +68,19 @@ class AuthTokenInput(Modal, title="Enter Authentication Token"):
account_embed_sync = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer vehicula pulvinar urna quis hendrerit. In hendrerit odio ac molestie sagittis. In fermentum nulla ac fringilla finibus. Fusce non mi porta, cursus urna id, tempor nibh. Morbi vitae turpis iaculis, imperdiet ex vitae, rhoncus ex. Phasellus congue odio eget pellentesque sagittis. Donec metus enim, molestie sit amet rutrum quis, vehicula eget diam."
account_embed_name = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer vehicula pulvinar urna quis hendrerit. In hendrerit odio ac molestie sagittis. In fermentum nulla ac fringilla finibus. Fusce non mi porta, cursus urna id, tempor nibh. Morbi vitae turpis iaculis, imperdiet ex vitae, rhoncus ex. Phasellus congue odio eget pellentesque sagittis. Donec metus enim, molestie sit amet rutrum quis, vehicula eget diam."

account_logout_button = Button(label="Logout", style=ButtonStyle.danger)


class AccountTokenInput(Modal, title="Enter Authorization Token"):
token = TextInput(label="Token", placeholder="Paste Authorization Token Here")


account_update_button = Button(label="Sync Account", style=ButtonStyle.primary)
account_token_button = Button(label="Get Token", url=env.url + "token")
class AccountTokenInput(Modal, title="Enter Authentication Token"):
token = TextInput(label="Token", placeholder="Paste Authentication Token Here")


class AccountNameInput(Modal, title="Change Nickname"):
name = TextInput(label="New Nickname")


account_name_button = Button(label="Set Name", style=ButtonStyle.secondary)
account_logout_button = Button(label="Disconnect", style=ButtonStyle.danger)
account_name_button = Button(label="Update Nickname", style=ButtonStyle.secondary)
account_token_button = Button(label="Get Sync Token", url=env.url + "token")
account_update_button = Button(label="Enter Sync Token", style=ButtonStyle.primary)

account_view = lambda: (
View(timeout=None)
Expand Down Expand Up @@ -130,25 +127,27 @@ class AccountNameInput(Modal, title="Change Nickname"):


class ChannelRequestInput(Modal, title="Text Channel Request"):
name_of_lecture = TextInput(label="Name of Lecture", placeholder="eg. SAT-Solving")
kind_of_lecture = TextInput(
name_of_lecture = TextInput(label="Name of Lecture", placeholder="eg. SAT solving")
kind_of_event = TextInput(
label="Kind of Event", placeholder="Lecture / Seminar / BOK / Lab / ..."
)
name_of_channel = TextInput(
label="Suggested Name of Channel", placeholder="eg. SAT-Solving", required=False
label="Suggested Name of Channel", placeholder="eg. sat-solving", required=False
)


class OffTopicChannelRequestInput(Modal, title="Offtopic Channel Request"):
name_of_channel = TextInput(label="Name of Channel", placeholder="Volleyball")
description = TextInput(
label="Description",
placeholder="A Channel to find people for playing volleyball",
placeholder="A place to find people for playing volleyball",
)


channels_request_button = Button(label="Request", style=ButtonStyle.danger)
offtopic_request_button = Button(label="Offtopic", style=ButtonStyle.blurple)
channels_request_button = Button(label="Request Channel", style=ButtonStyle.danger)
offtopic_request_button = Button(
label="Request Offtopic Channel", style=ButtonStyle.blurple
)

channel_view = lambda: (
View(timeout=None)
Expand All @@ -168,15 +167,15 @@ class OffTopicChannelRequestInput(Modal, title="Offtopic Channel Request"):

## #accept channels #############################################################################

accept_channel_send = "Accepted channel request successfully"
decline_channel_send = "Declined channel request successfully"
accept_channel_send = "Accepted channel request"
decline_channel_send = "Declined channel request"

accept_channel_request_send = "Request submitted successfully"
accept_channel_request_send = "Request submitted"


class ChannelRequestAcceptInput(Modal, title="Accept Text Channel Request"):
name_of_lecture = TextInput(label="Name of Lecture")
kind_of_lecture = TextInput(label="Kind of Lecture")
kind_of_event = TextInput(label="Kind of Event")
name_of_channel = TextInput(label="Name of Channel")


Expand All @@ -196,9 +195,7 @@ async def channel_request_accept_modal(modal_interaction: Interaction):
channel_request_accept_input.name_of_channel.default = (
input.name_of_channel.value
)
channel_request_accept_input.kind_of_lecture.default = (
input.kind_of_lecture.value
)
channel_request_accept_input.kind_of_event.default = input.kind_of_event.value
channel_request_accept_input.name_of_lecture.default = (
input.name_of_lecture.value
)
Expand Down Expand Up @@ -243,9 +240,7 @@ async def channel_request_decline_modal(modal_interaction: Interaction):
accept_channel_request_embed.add_field(
"Name of Lecture", input.name_of_lecture.value
)
accept_channel_request_embed.add_field(
"Kind of Lecture", input.kind_of_lecture.value
)
accept_channel_request_embed.add_field("Kind of Lecture", input.kind_of_event.value)
accept_channel_request_embed.add_field(
"Name of Channel", input.name_of_channel.value
)
Expand All @@ -258,18 +253,19 @@ async def channel_request_decline_modal(modal_interaction: Interaction):

# offtopic channel request #############################################################################

accept_offtopic_channel_send = "Accepted offtopic channel request successfully"
decline_offtopic_channel_send = "Declined offtopic channel request Successfully"

accept_channel_request_send = "Request sent successfully"
accept_offtopic_channel_send = "Accepted offtopic channel request"
decline_offtopic_channel_send = "Declined offtopic channel request"
accept_channel_request_send = "Request sent"


class OffTopicChannelRequestAcceptInput(Modal, title="Accept Offtopic Channel Request"):
name_of_channel = TextInput(label="Name of Channel")
description = TextInput(label="Description")


class OffTopicChannelRequestDeclineInput(Modal, title="Decline Offtopic Channel Request"):
class OffTopicChannelRequestDeclineInput(
Modal, title="Decline Offtopic Channel Request"
):
declined_massage = TextInput(label="Reason")


Expand Down
5 changes: 2 additions & 3 deletions templates/token.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>UFR TF Discord Authorization Token</title>
<title>Discord Authentication Token</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
</head>

<body style="overflow-y:hidden;">
<div class="card" style="height: 100vh;">
<header class="card-header">
<p class="card-header-title">
Discord Authorization Token
Discord Authentication Token
</p>
</header>
<div class="card-content">
Expand All @@ -23,7 +23,6 @@
</div>
</div>
<div class="content">

<button id="token" onclick="copy()" class="button is-success">
{{token}}
</button>
Expand Down

0 comments on commit 5c4c45f

Please sign in to comment.