-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButtons.py
597 lines (489 loc) · 26.8 KB
/
Buttons.py
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
import nextcord
from nextcord.ext.commands.context import Context
async def testinter(interaction, ctx):
if interaction.user != ctx.author:
await interaction.response.send_message("Du kannst dieses Dialogfeld nicht benutzen", ephemeral=True)
return False
return True
class TestButtons(nextcord.ui.View):
"""Dieses Objekt dient nur als Beispiel und wird nirgends verwendet."""
def __init__(self, ctx):
"""Weis nonid so ganz was das macht, aber es bruuchts zum ä button z kreiere. Wenis richtig verstande ha de
heisst z super() eifach, dass me ds __init__ vor Superlass (ä class a mitere superclass b heisst, a isch ä
subclass vo b. Üsi superclass isch d class nextcord.ui.View)"""
super().__init__(timeout=120.0)
self.ctx = ctx
if self.ctx.message.content.startswith("bababooey"):
self.MyButton.disabled = True
""" Hie heimer jetz ä attribute vomne button gänderet. Wie genau das geit gsehmer unge."""
"""Ds dört unge isch ä decorator. Dä nimmt die funkion womer unge definiert hei, und macht när sozäge dass des imne button
integriert isch. Wie genau ds funktioniert isch nid so wichtig, wichtig si d argumänt wome cha drigäh:
- ds label definiert, was när ufem button wird stah.
- weme statt text es emoji möcht, chame ds mitem argumänt 'emoji' mache.
- mitem 'style' chame d farbe bestimme. D farbe si immer nextcord.ButtonStyle.[COLOR]. es git 6 farbe:
- red/danger: Rot
- green/success: grüen
- blurple/primary: blau
- grey/gray/secondary: grau
- url/link: Isch spezieu wöuses nid ä farb isch, sondern ä link, heisst, weme dä chnopf drückt,
dass die URL göffnet wird (ka wie genau me ds när implementiert tbh).
- mit custom_id
- disabled: disabled nimmt ä boolean value. We ä button disabled isch, de chame nä nümme drücke.
mä cha aber ä button nid ire button-funkion disable. Mä cha aber buttons usserhaub disable, wiemer obe hei gseh.
mä cha ou ä button usserhaub vor class disable, aso wemer es buttonobject Button=TestButtons(ctx) hei, de
chöimer mit
Button.nameofbutton.disabled = True
dr button nameofbutton disable.
- mit row chame die jewilige buttons vomne buttonobject ordne. hani nie bruucht.
Fyi, mä cha i decorator nid argumänt inegäh wo ir buttonclass definiert si."""
@nextcord.ui.button(label="A", emoji="😶", style=nextcord.ButtonStyle.red, custom_id="ID", disabled=False, row=1)
async def MyButton(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
"""interaction funkioniert praktisch so wie ctx. mä cha drvo usefinge wär ses drückt het, wo etc. """
if await testinter(ctx=self.ctx, interaction=interaction):
"""d funkion testinter teschtet eifach öb dr button vom gliiche mönsch isch drückt worde wo het dr button
verlangt."""
self.stop()
"""self.stop() heisst, d class höret uf z runne, aso nimmt keni inputs meh. Ds isch hiufriich weme
usserhaub vor class sitzet. Wöu weme es Buttonobject Button kreiert, de chame mit
await Button.wait()
druf warte, dass dr button stoppet. Mä chönnti zwar vilech es attribute self.ispressed oder so mache,
de muesme dr button ou nid neu generiere weme dr button mehrmaus bruucht."""
class PageButtons(nextcord.ui.View): # buttons für d siitene
""""Diese Buttons sind für den outlook-command. Dabei hat es 5 select-buttons (mit welchen man ein bestimmtes
Element vom Outlook auswählen kann), sowie 4 Buttons fürs blättern. Dabei gibt es jeweils einen knopf für 1 Seite
weiter zurück, sowie je einen Knopf für ganz nach hinten/vorne."""
def __init__(self, results, currentpage, ctx):
super().__init__(timeout=None) # timeout macht eifach das d buttons nach 2 minute nümme chöi drückt wärde.
self.currentpage = currentpage
self.ctx = ctx
self.results = results
self.left = False
self.right = False
self.select = 0
self.bigleft.disabled = self.currentpage == 0
self.leftbutton.disabled = self.currentpage == 0
self.rightbutton.disabled = (self.currentpage + 1) >= len(results) / 5
self.bigright.disabled = (self.currentpage + 1) >= len(results) / 5
# mit [BUTTON].disabled chame d disability vomne button wächsle.
# das machi hie für dasme nit cha out of bounds gah.
for button in self.children:
label = button.__str__().split(" ")[5].split("=")[1][1:-1]
if label not in ["<<", "<", ">", ">>"] and int(label) > len(results) - (currentpage * 5):
button.disabled = True
# wider zum prevente das me out of bounds geit,
# i däm fau das me nid iwie ds item 4 selected wo gar nid da isch.
@nextcord.ui.button(label="1", style=nextcord.ButtonStyle.primary)
async def Select1(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.select = 0
self.stop()
@nextcord.ui.button(label="2", style=nextcord.ButtonStyle.primary)
async def Select2(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.select = 1
self.stop()
@nextcord.ui.button(label="3", style=nextcord.ButtonStyle.primary)
async def Select3(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.select = 2
self.stop()
@nextcord.ui.button(label="4", style=nextcord.ButtonStyle.primary)
async def Select4(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.select = 3
self.stop()
@nextcord.ui.button(label="5", style=nextcord.ButtonStyle.primary)
async def Select5(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.select = 4
self.stop()
@nextcord.ui.button(label="<<", style=nextcord.ButtonStyle.primary)
async def bigleft(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.currentpage = 0
self.left = True
self.stop()
@nextcord.ui.button(label="<", style=nextcord.ButtonStyle.primary)
async def leftbutton(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.currentpage -= 1
self.left = True
self.stop()
@nextcord.ui.button(label=">", style=nextcord.ButtonStyle.primary)
async def rightbutton(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.currentpage += 1
self.right = True
self.stop()
@nextcord.ui.button(label=">>", style=nextcord.ButtonStyle.primary)
async def bigright(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.currentpage = int(len(self.results) / 5) + (len(self.results) % 5 > 0) - 1
self.right = True
self.stop()
class Selectionmode(nextcord.ui.View):
"""
Wenn man ein Item mit den obrigen knöpfen ausgewählt hat, kann man hier auswählen, was man mite dem Item tun will.
Es gibt einen Knopf, um das Element zu löschen, einen um es zu editieren und einen zum wieder zur outlook-sicht
zurückzugelangen."""
def __init__(self, ctx):
super().__init__(timeout=120.0)
self.edit = False
self.delete = False
self.goback = False
self.ctx = ctx
@nextcord.ui.button(label="Edit", style=nextcord.ButtonStyle.primary)
async def edit(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.edit = True
self.stop()
@nextcord.ui.button(label="Delete", style=nextcord.ButtonStyle.red)
async def delete(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.delete = True
self.stop()
@nextcord.ui.button(label="Go back", style=nextcord.ButtonStyle.grey)
async def goback(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.goback = True
self.stop()
class Confirm(nextcord.ui.View):
"""
Fragt nach einer Bestätigung für etw.
"""
def __init__(self, ctx):
super().__init__(timeout=120.0)
self.confirm = False
self.ctx = ctx
@nextcord.ui.button(label="Ja", style=nextcord.ButtonStyle.green)
async def confirmbtn(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.confirm = True
self.stop()
@nextcord.ui.button(label="Nein", style=nextcord.ButtonStyle.red)
async def cancelbtn(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.confirm = False
self.stop()
class EditButtons(nextcord.ui.View):
"""Das ist für das Editieren eines Items. Mit den unteren Knöpfen fragt man nach, was man genau editieren möchte."""
def __init__(self, ctx):
super().__init__(timeout=120.0)
self.edit = []
self.goback = False
self.ctx = ctx
@nextcord.ui.button(label="Kategorie", style=nextcord.ButtonStyle.primary)
async def kategorie(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.edit.append("kategorie")
self.stop()
@nextcord.ui.button(label="Aufgabe", style=nextcord.ButtonStyle.primary)
async def aufgabe(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.edit.append("aufgabe")
self.stop()
@nextcord.ui.button(label="Datum", style=nextcord.ButtonStyle.primary)
async def datum(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.edit.append("datum")
self.stop()
@nextcord.ui.button(label="Fach", style=nextcord.ButtonStyle.primary)
async def fach(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.edit.append("fach")
self.stop()
@nextcord.ui.button(label="Zugriff", style=nextcord.ButtonStyle.primary)
async def access(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.edit.append("access")
self.stop()
@nextcord.ui.button(label="Zurück", style=nextcord.ButtonStyle.gray)
async def goback(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.goback = True
self.stop()
class TestOrHA(nextcord.ui.View):
"""Diese Knöpfe sind da für wenn man ein neues Item erstellen will. Diese beiden Buttons fragen nach, ob man einen
Test oder eine Hausaufgabe eintragen will."""
def __init__(self, ctx):
super().__init__(timeout=120.0)
self.choice = "Hausaufgabe"
self.ctx = ctx
@nextcord.ui.button(label="Hausaufgabe", style=nextcord.ButtonStyle.primary)
async def Hausaufgabe(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice = "Hausaufgabe"
self.stop()
@nextcord.ui.button(label="Test", style=nextcord.ButtonStyle.primary)
async def Test(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice = "Test"
self.stop()
@nextcord.ui.button(label="Unspezifisch", style=nextcord.ButtonStyle.primary)
async def Nocateg(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice = ""
self.stop()
class ManageItemAccess(nextcord.ui.View):
"""Wird geregelt wer dieses Item sehen kann, aka ob es privat ist,
für alle, oder nur für die jeweiligen SF oder EF."""
def __init__(self, ctx):
super().__init__(timeout=120.0)
self.ctx = ctx
self.access = "all"
# wede diräkt mitem bot redisch, de chaner d ufgab nid uf SF oder EF restricte wöuer d serverdate nid het.
if self.ctx.channel.__str__().startswith("Direct Message"):
self.OnlyEF.disabled = True
self.OnlySF.disabled = True
self.OnlyKF.disabled = True
@nextcord.ui.button(label="Für Alle", style=nextcord.ButtonStyle.primary)
async def All(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.access = "all"
self.stop()
@nextcord.ui.button(label="Für mein SF", style=nextcord.ButtonStyle.primary)
async def OnlySF(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
sf = "all"
for role in self.ctx.author.roles:
if role.name.lower().startswith("sf"):
sf = role.name
self.access = sf
self.stop()
@nextcord.ui.button(label="Für mein EF", style=nextcord.ButtonStyle.primary)
async def OnlyEF(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
ef = "all"
for role in self.ctx.author.roles:
if role.name.lower().startswith("ef"):
ef = role.name
self.access = ef
self.stop()
@nextcord.ui.button(label="Für mein KF", style=nextcord.ButtonStyle.primary)
async def OnlyKF(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
kf = "all"
for role in self.ctx.author.roles:
if role.name.lower().startswith("kf"):
kf = role.name
self.access = kf
self.stop()
@nextcord.ui.button(label="Nur für mich", style=nextcord.ButtonStyle.primary)
async def Private(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.access = "private"
self.stop()
class ChooseWeekdays(nextcord.ui.View):
def __init__(self, ctx: Context, confirmbtn:bool = False):
super().__init__(timeout=120.0)
self.ctx = ctx
self.choice = []
self.confirm = False
self.confirmbtn.disabled = confirmbtn
@nextcord.ui.button(label="Mo", style=nextcord.ButtonStyle.primary, row=1)
async def Montag(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice="mo"
self.stop()
@nextcord.ui.button(label="Di", style=nextcord.ButtonStyle.primary, row=1)
async def Dienstag(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice="di"
self.stop()
@nextcord.ui.button(label="Mi", style=nextcord.ButtonStyle.primary, row=1)
async def Mittwoch(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice="mi"
self.stop()
@nextcord.ui.button(label="Do", style=nextcord.ButtonStyle.primary, row=1)
async def Donnerstag(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice="do"
self.stop()
@nextcord.ui.button(label="Fr", style=nextcord.ButtonStyle.primary, row=1)
async def Freitag(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice="fr"
self.stop()
@nextcord.ui.button(label="Sa", style=nextcord.ButtonStyle.primary, row=2)
async def Samstag(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice= "sa"
self.stop()
@nextcord.ui.button(label="So", style=nextcord.ButtonStyle.primary, row=2)
async def Sonntag(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice = "so"
self.stop()
@nextcord.ui.button(label="Bestätigen", style=nextcord.ButtonStyle.red, row=3)
async def confirmbtn(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.confirm = True
self.stop()
class ChooseTime(nextcord.ui.View):
def __init__(self, ctx, choice):
super().__init__(timeout=120.0)
self.ctx = ctx
self.confirm= False
self.choice=None
@nextcord.ui.button(label="7:00", style=nextcord.ButtonStyle.primary, row=1)
async def hour_7(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice=button.label
self.stop()
@nextcord.ui.button(label="8:00", style=nextcord.ButtonStyle.primary, row=1)
async def hour_8(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice=button.label
self.stop()
@nextcord.ui.button(label="9:00", style=nextcord.ButtonStyle.primary, row=1)
async def hour_9(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice=button.label
self.stop()
@nextcord.ui.button(label="10:00", style=nextcord.ButtonStyle.primary, row=1)
async def hour_10(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice=button.label
self.stop()
@nextcord.ui.button(label="11:00", style=nextcord.ButtonStyle.primary, row=1)
async def hour_11(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice=button.label
self.stop()
@nextcord.ui.button(label="12:00", style=nextcord.ButtonStyle.primary, row=2)
async def hour_12(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice=button.label
self.stop()
@nextcord.ui.button(label="13:00", style=nextcord.ButtonStyle.primary, row=2)
async def hour_13(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice=button.label
self.stop()
@nextcord.ui.button(label="14:00", style=nextcord.ButtonStyle.primary, row=2)
async def hour_14(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice=button.label
self.stop()
@nextcord.ui.button(label="15:00", style=nextcord.ButtonStyle.primary, row=2)
async def hour_15(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice=button.label
self.stop()
@nextcord.ui.button(label="16:00", style=nextcord.ButtonStyle.primary, row=2)
async def hour_16(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.choice=button.label
self.stop()
@nextcord.ui.button(label="Bestätigen", style=nextcord.ButtonStyle.red, row=3)
async def confirmbtn(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.confirm = True
self.stop()
class choose_SF(nextcord.ui.View):
def __init__(self, ctx):
super().__init__(timeout=120.0)
self.ctx = ctx
self.sf = 'all'
@nextcord.ui.button(label="PAM", style=nextcord.ButtonStyle.primary)
async def pam(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.sf = 'SF PAM'
self.stop()
@nextcord.ui.button(label="BC", style=nextcord.ButtonStyle.primary)
async def bc(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.sf = 'SF BC'
self.stop()
@nextcord.ui.button(label="PPP", style=nextcord.ButtonStyle.primary)
async def ppp(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.sf = 'SF PPP'
self.stop()
@nextcord.ui.button(label="WR", style=nextcord.ButtonStyle.primary)
async def wr(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.sf = 'SF WR'
self.stop()
class choose_EF(nextcord.ui.View):
def __init__(self, ctx):
super().__init__(timeout=120.0)
self.ctx = ctx
self.ef = 'all'
@nextcord.ui.button(label="Info", style=nextcord.ButtonStyle.primary)
async def info(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.ef = 'EF Info'
self.stop()
@nextcord.ui.button(label="Geschichte", style=nextcord.ButtonStyle.primary)
async def history(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.ef = 'EF Geschichte'
self.stop()
@nextcord.ui.button(label="PP", style=nextcord.ButtonStyle.primary)
async def pp(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.ef = 'EF PP'
self.stop()
@nextcord.ui.button(label="Smeder (Chemie)", style=nextcord.ButtonStyle.primary)
async def smedi(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.ef = 'EF Chemie'
self.stop()
@nextcord.ui.button(label="Musik", style=nextcord.ButtonStyle.primary)
async def musik(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.ef = 'EF Musik'
self.stop()
@nextcord.ui.button(label="Sport", style=nextcord.ButtonStyle.primary)
async def sport(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.ef = 'EF Sport'
self.stop()
class choose_KF(nextcord.ui.View):
def __init__(self, ctx):
super().__init__(timeout=120.0)
self.ctx = ctx
self.kf = 'all'
@nextcord.ui.button(label="Musik", style=nextcord.ButtonStyle.primary)
async def musik(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.kf = 'KF Musik'
self.stop()
@nextcord.ui.button(label="BG", style=nextcord.ButtonStyle.primary)
async def bg(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if await testinter(ctx=self.ctx, interaction=interaction):
self.kf = 'KF BG'
self.stop()
class VoteButtons(nextcord.ui.View):
def __init__(self, timeout):
super().__init__(timeout=timeout)
self.votes = {}
@nextcord.ui.button(label="A", style=nextcord.ButtonStyle.primary)
async def OptA(self, button:nextcord.ui.Button, interaction:nextcord.Interaction):
if not interaction.user.id in self.votes.keys():
self.votes[interaction.user.id] = button.label
else:
await interaction.response.send_message("Du hast schon gewählt", ephemeral=True)
@nextcord.ui.button(label="B", style=nextcord.ButtonStyle.primary)
async def OptB(self, button:nextcord.ui.Button, interaction:nextcord.Interaction):
if not interaction.user.id in self.votes.keys():
self.votes[interaction.user.id] = button.label
else:
await interaction.response.send_message("Du hast schon gewählt", ephemeral=True)
class BriefingSettings(nextcord.ui.View):
def __init__(self, ctx):
super().__init__(timeout = None)
self.ctx = ctx
self.choice = None
@nextcord.ui.button(label="Zeiten ändern", style=nextcord.ButtonStyle.primary)
async def edit_time(self, button:nextcord.ui.Button, interaction:nextcord.Interaction):
if await testinter(interaction, self.ctx):
self.choice = "time"
self.stop()
@nextcord.ui.button(label="Fächer ändern", style=nextcord.ButtonStyle.primary)
async def edit_classes(self, button:nextcord.ui.Button, interaction:nextcord.Interaction):
if await testinter(interaction, self.ctx):
self.choice = "classes"
self.stop()