-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
182 lines (156 loc) Β· 6.55 KB
/
main.py
File metadata and controls
182 lines (156 loc) Β· 6.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import discord
from discord.ext import commands
from discord import app_commands
SELECT_OPTIONS = [
discord.SelectOption(
label="PA - 1", value="1", description="Periodic Assessment 1", emoji="π"
),
discord.SelectOption(
label="PA - 2", value="2", description="Periodic Assessment 2", emoji="π"
),
discord.SelectOption(
label="HALF YEARLY", value="3", description="Half Yearly", emoji="π"
),
discord.SelectOption(
label="PA - 3", value="4", description="Periodic Assessment 3", emoji="π"
),
discord.SelectOption(label="FINALS", value="5", description="Annuals", emoji="π"),
]
class Client(commands.Bot):
async def on_ready(self):
print(f"Logged on as {self.user}!")
try:
guild = discord.Object(id=1152174166385111040)
synced = await self.tree.sync(guild=guild)
print(f"Synced {len(synced)} commands to guild {guild.id}")
except Exception as e:
print(f"error syncing commands: {e}")
async def on_message(self, message):
if message.author == self.user:
return
if message.content.lower().startswith("hello"):
await message.channel.send(f"Hi there {message.author}")
intents = discord.Intents.default()
intents.message_content = True
client = Client(command_prefix="!", intents=intents)
GUILD_ID = discord.Object(id=1152174166385111040)
@client.tree.command(name="hello", description="testing purposes", guild=GUILD_ID)
async def sayHello(interaction: discord.Interaction):
await interaction.response.send_message("Hi there!")
@client.tree.command(name="printer", description="print text", guild=GUILD_ID)
async def sayHello(interaction: discord.Interaction, printer: str):
await interaction.response.send_message(f'the message was "{printer}"')
@client.tree.command(name="embed", description="embed demo", guild=GUILD_ID)
async def sayHello(interaction: discord.Interaction):
embed = discord.Embed(
title="this is a title",
url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
description="this is the description",
color=discord.Colour.teal(),
)
embed.set_thumbnail(
url="https://letsenhance.io/static/73136da51c245e80edc6ccfe44888a99/1015f/MainBefore.jpg"
)
embed.add_field(name="bleh bleh", value="bleh bleh bleh")
embed.add_field(name="yada yada", value="bleh fleh bleh")
embed.set_footer(text="terms and conditions applied")
embed.set_author(name=interaction.user.name)
await interaction.response.send_message(embed=embed)
class View(discord.ui.View):
@discord.ui.button(
label="ritvik has a skill issue", style=discord.ButtonStyle.danger, emoji="πΏ"
)
async def button_callback(self, button, interaction):
await button.response.send_message(f"yes")
@client.tree.command(name="buttons", description="displaying a button", guild=GUILD_ID)
async def button(interaction: discord.Interaction):
await interaction.response.send_message(view=View())
class Dropdown(discord.ui.View):
answer1 = None
@discord.ui.select(
placeholder="Select a category", options=SELECT_OPTIONS, max_values=1
)
async def select_option_callback(
self, interaction: discord.Interaction, select: discord.ui.Select
):
self.answer1 = select.values
exam_data = {
"1": {
"title": "PA-1 Exams",
"color": discord.Colour.dark_teal(),
"fields": [
("Science", "28th April"),
("Social Science", "5th May"),
("II Language", "13th May"),
("Mathematics", "19th May"),
("English", "23rd May"),
("AI", "26th May"),
],
},
"2": {
"title": "PA-2 Exams",
"color": discord.Colour.purple(),
"fields": [
("Science", "14th July"),
("Social Science", "21st July"),
("II Language", "28th July"),
("Mathematics", "4th August"),
("English", "11th August"),
("AI", "14th August"),
],
},
"3": {
"title": "Half Yearly Exams",
"color": discord.Colour.dark_magenta(),
"fields": [
("II Language", "2nd September"),
("Mathematics", "4th September"),
("Social Science", "8th September"),
("English", "10th September"),
("Science", "12th September"),
("AI", "15th September"),
],
},
"4": {
"title": "PA-3 Exams",
"color": discord.Colour.yellow(),
"fields": [
("Science", "13th October"),
("Social Science", "17th October"),
("II Language", "27th October (Rachit's birthday)"),
("Mathematics", "30th October"),
("English", "3rd November"),
("AI", "10th November"),
],
},
"5": {
"title": "Annual Exams",
"color": discord.Colour.dark_blue(),
"fields": [
("Social Science", "2nd February"),
("II Language", "4th February"),
("Mathematics", "6th February"),
("English", "9th February"),
("Science", "11th February"),
("AI", "13th February"),
],
},
}
if select.values[0] not in ["1", "2", "3", "4", "5"]:
await interaction.response.send_message(
f"Invalid option: {select.values[0]}"
)
embed = discord.Embed(
title=exam_data[select.values[0]]["title"],
description="",
color=exam_data[select.values[0]]["color"],
)
for field in exam_data[select.values[0]]["fields"]:
embed.add_field(name=field[0], value=field[1])
embed.set_footer(text="terms and conditions applied")
embed.set_author(name=interaction.user.name)
await interaction.response.send_message(embed=embed)
@client.tree.command(name="exams", description="List dates for exams", guild=GUILD_ID)
async def button(interaction: discord.Interaction):
await interaction.response.send_message(view=Dropdown())
client.run("private info")