-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
1577 lines (1295 loc) · 74.4 KB
/
main.py
File metadata and controls
1577 lines (1295 loc) · 74.4 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
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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import discord
from discord import app_commands
from discord.ext import commands, tasks
from dotenv import load_dotenv
import os
import json
from io import BytesIO
from datetime import datetime, timedelta
from collections import defaultdict
import random
import asyncio
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
# ID of your feedback channel
FEEDBACK_CHANNEL_ID = 1377545068298108958
# ID of your Giveaway channel - YOU NEED TO CREATE THIS CHANNEL
GIVEAWAY_CHANNEL_ID = 1402833507373551666 # Replace with actual giveaway channel ID
# Role IDs - YOU NEED TO CREATE THESE ROLES IN YOUR SERVER
MILESTONE_5_VOUCHES_ROLE = 1381622660861006025 # Replace with actual role ID for 5+ vouches
# Vouch tracking data
vouch_data_file = "vouch_tracking.json"
giveaway_data_file = "giveaway_data.json"
def load_vouch_data():
try:
with open(vouch_data_file, 'r') as f:
return json.load(f)
except FileNotFoundError:
return {
"monthly_vouches": {},
"total_vouches": {},
"user_products": {}, # Track products purchased by each user
"last_reset": datetime.now().strftime("%Y-%m")
}
def load_giveaway_data():
try:
with open(giveaway_data_file, 'r') as f:
return json.load(f)
except FileNotFoundError:
return {
"active_giveaways": {},
"giveaway_history": []
}
def save_giveaway_data(data):
with open(giveaway_data_file, 'w') as f:
json.dump(data, f, indent=2)
def save_vouch_data(data):
with open(vouch_data_file, 'w') as f:
json.dump(data, f, indent=2)
def create_progress_bar(current_step, total_steps, completed_color="🟢", incomplete_color="⚪"):
"""Create a visual progress bar with colored dots"""
progress = ""
for i in range(1, total_steps + 1):
if i <= current_step:
progress += completed_color
else:
progress += incomplete_color
percentage = round((current_step / total_steps) * 100)
return f"{progress} {percentage}% Complete"
def get_step_description(step, language="english"):
"""Get step descriptions in the selected language"""
steps_en = {
1: "🌐 Language Selection",
2: "📚 Product Selection",
3: "👤 User Selection",
4: "⭐ Rating Selection",
5: "📝 Comment Writing",
6: "📸 Proof Upload"
}
steps_ar = {
1: "🌐 اختيار اللغة",
2: "📚 اختيار المنتج",
3: "👤 اختيار المستخدم",
4: "⭐ اختيار التقييم",
5: "📝 كتابة التعليق",
6: "📸 رفع الإثبات"
}
return steps_ar[step] if language == "arabic" else steps_en[step]
vouch_tracking = load_vouch_data()
giveaway_tracking = load_giveaway_data()
# Product category images for Customer of the Month announcements
PRODUCT_CATEGORY_IMAGES = {
"valorant-points": ["https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSFd5QOQemfaEc61dMFLEkxl0fswvcqWCtaOWcvgucyXRq1dKjZsGVzgHRocq8g9cRkQFc&usqp=CAU"],
"callofduty-cp": ["https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ6xgv_M-tH5qMOdIFwY-t_fZ3ikBk4F_z1Dg&s"],
"overwatch-coins": [
"https://blz-contentstack-images.akamaized.net/v3/assets/bltf408a0557f4e4998/blt5387d7cefaf9923d/6334e1997e84e17596f9c816/Coins_960x540.png"],
"discord-nitro": [
"https://cdn1.epicgames.com/offer/5f3c898b2a3244af99e9900e015717f8/EGS_Discord_Nitro_2560x1440_withlogo_2560x1440-944994658df3b04d0c4940be832da19e_2560x1440-944994658df3b04d0c4940be832da19e",
],
"gamepass": [
"https://www.stuff.tv/wp-content/uploads/sites/2/2023/04/Game-Pass.png",
]
}
intents = discord.Intents.default()
intents.message_content = True # Enable message content intent
intents.members = True # Enable members intent for user operations
bot = commands.Bot(command_prefix="!", intents=intents)
class GiveawayProductSelectionView(discord.ui.View):
def __init__(self):
super().__init__(timeout=300)
@discord.ui.select(
placeholder="🎁 Choose the product category...",
options=[
discord.SelectOption(label="Valorant Points", value="valorant-points",
emoji="<:Valorant_Points:1386806798610337864>"),
discord.SelectOption(label="Call of Duty CP", value="callofduty-cp",
emoji="<:COD_Point_BOCW2:1395768016255586376>"),
discord.SelectOption(label="Overwatch Coins", value="overwatch-coins",
emoji="<:Overwatch_Coin:1395787416509485087>"),
discord.SelectOption(label="Discord Nitro", value="discord-nitro",
emoji="<:icons8discordnitro:1395950198915727512>"),
discord.SelectOption(label="Gamepass", value="gamepass", emoji="<:xbox:1395953046688890962>"),
discord.SelectOption(label="Others", value="others", emoji="<:netflix:1395956599092150282>"),
discord.SelectOption(label="Buy Accounts", value="buy-accounts"),
discord.SelectOption(label="FIFA Coins", value="fifa-coins"),
]
)
async def product_select(self, interaction: discord.Interaction, select: discord.ui.Select):
product_category = select.values[0]
# Show specific product options based on category
specific_product_view = GiveawaySpecificProductView(product_category)
embed = discord.Embed(
title="🎁 Select Specific Product",
description=f"**Category:** {product_category.replace('-', ' ').title()}\n\n"
"Please select the specific product you want to giveaway:",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=specific_product_view)
class GiveawaySpecificProductView(discord.ui.View):
def __init__(self, product_category):
super().__init__(timeout=300)
self.product_category = product_category
# Define specific products for each category
product_options = {
"valorant-points": [
discord.SelectOption(label="5350 VP", value="5350-vp"),
discord.SelectOption(label="11,000 VP", value="11,000-vp"),
discord.SelectOption(label="16,350 VP", value="16,350-vp"),
discord.SelectOption(label="22,000 VP", value="22,000-vp"),
],
"callofduty-cp": [
discord.SelectOption(label="2,400 CP", value="2,400-cp"),
discord.SelectOption(label="5,000 CP", value="5,000-cp"),
discord.SelectOption(label="9,500 CP", value="9,500-cp"),
discord.SelectOption(label="13,000 CP", value="13,000-cp"),
],
"overwatch-coins": [
discord.SelectOption(label="2,200 Coins", value="2,200-coins"),
discord.SelectOption(label="4,500 Coins", value="2000-coins"),
discord.SelectOption(label="6,900 Coins", value="6,900-coins"),
discord.SelectOption(label="11,800 Coins", value="11,800-coins"),
],
"discord-nitro": [
discord.SelectOption(label="1 Month Nitro", value="1-month-nitro"),
discord.SelectOption(label="12 Months Nitro", value="12-Months-nitro"),
],
"gamepass": [
discord.SelectOption(label="3 Months Gamepass", value="Ultimate 3 months"),
],
"others": [
discord.SelectOption(label="Netflix 1 Month", value="netflix-1m"),
discord.SelectOption(label="Spotify Premium", value="spotify-premium"),
discord.SelectOption(label="Amazon Prime", value="amazon-prime"),
discord.SelectOption(label="Custom Prize", value="custom-prize"),
],
"fifa-coins": [
discord.SelectOption(label="100K Coins", value="100k-coins"),
discord.SelectOption(label="500K Coins", value="500k-coins"),
discord.SelectOption(label="1M Coins", value="1m-coins"),
]
}
options = product_options.get(product_category, [discord.SelectOption(label="Default Prize", value="default")])
self.specific_select = discord.ui.Select(
placeholder="🎁 Choose specific product...",
options=options
)
self.specific_select.callback = self.specific_product_callback
self.add_item(self.specific_select)
async def specific_product_callback(self, interaction: discord.Interaction):
specific_product = self.specific_select.values[0]
# Auto-generate title and description based on product
def generate_giveaway_content(category, specific):
titles = {
"valorant-points": f" {specific.upper().replace('-', ' ')} GIVEAWAY!🎁",
"callofduty-cp": f" {specific.upper().replace('-', ' ')} GIVEAWAY!🎁",
"overwatch-coins": f" {specific.upper().replace('-', ' ')} GIVEAWAY!🎁",
"discord-nitro": f" {specific.upper().replace('-', ' ')} GIVEAWAY!🎁",
"gamepass": f" {specific.upper().replace('-', ' ')} GIVEAWAY! 🎁",
"others": f" {specific.upper().replace('-', ' ')} GIVEAWAY! 🎁",
"buy-accounts": f" {specific.upper().replace('-', ' ')} GIVEAWAY! 🎁",
"fifa-coins": f" {specific.upper().replace('-', ' ')} GIVEAWAY! 🎁"
}
descriptions = {
"valorant-points": f"🎉 We're giving away {specific.replace('-', ' ')}!\n\n Enter now for your chance to win Valorant Points !",
"callofduty-cp": f"🎉 We're giving away {specific.replace('-', ' ')} !\n\n Enter now for your chance to win Call of Duty Points and unlock epic content!",
"overwatch-coins": f"🎉 We're giving away {specific.replace('-', ' ')} !\n\n Enter now for your chance to win Overwatch Coins and get amazing skins!",
"discord-nitro": f"🎉 We're giving away {specific.replace('-', ' ')} !\n\n Enter now for your chance to win Discord Nitro and enjoy premium features!",
"gamepass": f"🎉 We're giving away {specific.replace('-', ' ')} !\n\n Enter now for your chance to win Xbox Game Pass and play hundreds of games!",
"others": f"🎉 We're giving away {specific.replace('-', ' ')} !\n\n Enter now for your chance to win this amazing prize!",
"buy-accounts": f"🎉 We're giving away a {specific.replace('-', ' ')} !\n\n Enter now for your chance to win a premium account!",
"fifa-coins": f"🎉 We're giving away {specific.replace('-', ' ')}!\n\n Enter now for your chance to win FIFA Coins and build your ultimate team!"
}
return titles.get(category, f"🎁 FREE {specific.upper()} GIVEAWAY! 🎁"), descriptions.get(category, f"Win {specific} for free!")
title, description = generate_giveaway_content(self.product_category, specific_product)
giveaway_data = {
"title": title,
"description": description,
"product": f"{self.product_category}:{specific_product}"
}
duration_view = GiveawayDurationSelectionView(giveaway_data)
embed = discord.Embed(
title="🎁 Select Giveaway Duration",
description=f"**Title:** {title}\n"
f"**Description:** {description[:100]}...\n\n"
"Please select how long the giveaway should run:",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=duration_view)
class GiveawayDurationSelectionView(discord.ui.View):
def __init__(self, giveaway_data):
super().__init__(timeout=300)
self.giveaway_data = giveaway_data
@discord.ui.select(
placeholder="⏰ Choose duration...",
options=[
discord.SelectOption(label="1 Hour", value="1", emoji="⏰"),
discord.SelectOption(label="3 Hours", value="3", emoji="⏰"),
discord.SelectOption(label="6 Hours", value="6", emoji="⏰"),
discord.SelectOption(label="12 Hours", value="12", emoji="⏰"),
discord.SelectOption(label="16 Hours", value="16", emoji="⏰"),
discord.SelectOption(label="24 Hours", value="24", emoji="⏰"),
]
)
async def duration_select(self, interaction: discord.Interaction, select: discord.ui.Select):
self.giveaway_data["duration"] = int(select.values[0])
confirm_view = GiveawayConfirmationView(self.giveaway_data)
embed = discord.Embed(
title="🎁 Confirm Giveaway Details",
description=f"**Title:** {self.giveaway_data['title']}\n"
f"**Description:** {self.giveaway_data['description'][:100]}...\n"
f"**Product:** {self.giveaway_data['product']}\n"
f"**Duration:** {self.giveaway_data['duration']} hours\n\n"
"Click **Post Giveaway** to publish it to the giveaway channel!",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=confirm_view)
class GiveawayConfirmationView(discord.ui.View):
def __init__(self, giveaway_data):
super().__init__(timeout=300)
self.giveaway_data = giveaway_data
@discord.ui.button(label="🎉 Post Giveaway", style=discord.ButtonStyle.green)
async def post_giveaway(self, interaction: discord.Interaction, button: discord.ui.Button):
await create_giveaway(interaction, self.giveaway_data)
@discord.ui.button(label="❌ Cancel", style=discord.ButtonStyle.red)
async def cancel_giveaway(self, interaction: discord.Interaction, button: discord.ui.Button):
embed = discord.Embed(
title="❌ Giveaway Cancelled",
description="The giveaway creation has been cancelled.",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=None)
async def create_giveaway(interaction: discord.Interaction, giveaway_data):
"""Create and post a giveaway"""
giveaway_channel = bot.get_channel(GIVEAWAY_CHANNEL_ID)
if not giveaway_channel:
await interaction.response.send_message("❌ Giveaway channel not found!", ephemeral=True)
return
# Calculate end time
end_time = datetime.now() + timedelta(hours=giveaway_data['duration'])
# Create giveaway embed with countdown timeline
duration_hours = giveaway_data['duration']
# Create visual timeline
timeline_emoji = "🟩" * min(duration_hours, 12) # Show up to 12 blocks
if duration_hours > 12:
timeline_emoji += f" (+{duration_hours - 12}h more)"
# Get specific product with emoji and channel link
def get_product_display(product_string):
category, specific = product_string.split(':')
# Define specific product emojis and displays
product_displays = {
# Valorant Points
"valorant-points:5350-vp": "<:Valorant_Points:1386806798610337864> 5350 VP",
"valorant-points:11,000-vp": "<:Valorant_Points:1386806798610337864> 11,000 VP",
"valorant-points:16,350-vp": "<:Valorant_Points:1386806798610337864> 16,350 VP",
"valorant-points:22,000-vp": "<:Valorant_Points:1386806798610337864> 22,000 VP",
# Call of Duty CP
"callofduty-cp:2,400-cp": "<:COD_Point_BOCW2:1395768016255586376>> 2,400 CP",
"callofduty-cp:5,000-cp": "<:COD_Point_BOCW2:1395768016255586376> 5,000 CP",
"callofduty-cp:9,500-cp": "<:COD_Point_BOCW2:1395768016255586376> 9,500 CP",
"callofduty-cp:13,000-cp": "<:COD_Point_BOCW2:1395768016255586376> 13,000 CP",
# Overwatch Coins
"overwatch-coins:2,200-coins": "<:Overwatch_Coin:1395787416509485087> 2,200 Coins",
"overwatch-coins:2000-coins": "<:Overwatch_Coin:1395787416509485087> 4,500 Coins",
"overwatch-coins:6,900-coins": "<:Overwatch_Coin:1395787416509485087> 6,900 Coins",
"overwatch-coins:11,800-coins": "<:Overwatch_Coin:1395787416509485087> 11,800 Coins",
# Discord Nitro
"discord-nitro:1-month-nitro": "<:discordnitro:1395949499704283166> 1 Month Nitro",
"discord-nitro:12-Months-nitro": "<:discordnitro:1395949499704283166> 12 Months Nitro",
# Gamepass
"gamepass:Ultimate 3 months": "<:xbox:1395953046688890962> 3 Months Gamepass Ultimate",
# Others
"others:netflix-1m": "<:netflix:1395956599092150282> Netflix 1 Month",
"others:spotify-premium": "<:spotify:1395958371244314795> Spotify Premium",
"others:custom-prize": "🎁 Custom Prize",
# FIFA Coins
"fifa-coins:100k-coins": "<:100KCoins:YOUR_EMOJI_ID> 100K FIFA Coins",
"fifa-coins:500k-coins": "<:500KCoins:YOUR_EMOJI_ID> 500K FIFA Coins",
"fifa-coins:1m-coins": "<:1MCoins:YOUR_EMOJI_ID> 1M FIFA Coins",
}
# Get channel links
channel_links = {
"valorant-points": "<#1377608623525728366>",
"callofduty-cp": "<#1386423140464201909>",
"overwatch-coins": "<#1395764822255210506>",
"discord-nitro": "<#1395949111412392068>",
"gamepass": "<#1395765771161960489>",
"others": "<#1395956006734925897>",
"buy-accounts": "<#1396249701866541107>",
"fifa-coins": "<#1386423375169064990>"
}
product_display = product_displays.get(product_string, specific.replace('-', ' ').title())
channel_link = channel_links.get(category, "")
if channel_link:
return f"{product_display} {channel_link}"
else:
return product_display
product_link = get_product_display(giveaway_data['product'])
embed = discord.Embed(
title=f"🎉 {giveaway_data['title']} 🎉",
description=f"**{giveaway_data['description']}**\n\n"
f"🎁 **Prize:** {product_link}\n -"
f"⏰ **Ends:** <t:{int(end_time.timestamp())}:R> (<t:{int(end_time.timestamp())}:f>)\n"
f"🎪 **Duration:** {duration_hours} hours\n"
f"📊 **Timeline:** {timeline_emoji}\n\n"
f"**How to enter:**\n"
f"🔸 React with ANY emoji to join the giveaway!\n"
f"🔸 Winners will be selected randomly\n"
f"🔸 **BONUS:** Invite friends !\n"
f"🔸 Good luck everyone! 🍀",
color=0xFF00001396249701866541107
)
embed.set_image(url="https://cdn.discordapp.com/attachments/1367317832093667483/1402853905599168543/standard.gif?ex=68956d02&is=68941b82&hm=75d2999e17ad6a4c60a4b81e01ac7ac381c82ae7307d91867b7f49043b7d351e&")
embed.set_footer(text="Developed by: RxxD")
embed.timestamp = datetime.now()
# Post giveaway
try:
giveaway_message = await giveaway_channel.send(f"🎊 **NEW GIVEAWAY!** @everyone 🎊", embed=embed)
await giveaway_message.add_reaction("🎉")
# Store giveaway data
global giveaway_tracking
giveaway_id = str(giveaway_message.id)
giveaway_tracking["active_giveaways"][giveaway_id] = {
"message_id": giveaway_message.id,
"channel_id": giveaway_channel.id,
"title": giveaway_data['title'],
"description": giveaway_data['description'],
"product": giveaway_data['product'],
"creator_id": interaction.user.id,
"start_time": datetime.now().isoformat(),
"end_time": end_time.isoformat(),
"duration_hours": giveaway_data['duration'],
"winners": []
}
save_giveaway_data(giveaway_tracking)
# Schedule winner selection
asyncio.create_task(schedule_giveaway_end(giveaway_id, giveaway_data['duration']))
# Confirm to admin
success_embed = discord.Embed(
title="✅ Giveaway Posted!",
description=f"Your giveaway **{giveaway_data['title']}** has been posted successfully!\n\n"
f"📍 Posted in: {giveaway_channel.mention}\n"
f"⏰ Will end in: {giveaway_data['duration']} hours\n"
f"🎁 Prize: {giveaway_data['product'].replace('-', ' ').title()}",
color=0xFF0000
)
await interaction.response.edit_message(embed=success_embed, view=None)
except Exception as e:
await interaction.response.send_message(f"❌ Error creating giveaway: {str(e)}", ephemeral=True)
async def schedule_giveaway_end(giveaway_id: str, duration_hours: int):
"""Schedule the end of a giveaway"""
await asyncio.sleep(duration_hours * 3600) # Convert hours to seconds
await end_giveaway(giveaway_id)
async def end_giveaway(giveaway_id: str):
"""End a giveaway and select winner"""
global giveaway_tracking
if giveaway_id not in giveaway_tracking["active_giveaways"]:
return
giveaway_data = giveaway_tracking["active_giveaways"][giveaway_id]
try:
channel = bot.get_channel(giveaway_data["channel_id"])
if not channel:
return
message = await channel.fetch_message(giveaway_data["message_id"])
if not message:
return
# Get users who reacted with ANY emoji
participants = []
total_reactions = 0
for reaction in message.reactions:
total_reactions += reaction.count
async for user in reaction.users():
if not user.bot and user not in participants: # Exclude bots and avoid duplicates
participants.append(user)
if not participants:
# Get specific product with emoji and channel link
def get_product_display_no_participants(product_string):
category, specific = product_string.split(':')
# Define specific product emojis and displays
product_displays = {
# Valorant Points
"valorant-points:5350-vp": "<:Valorant_Points:1386806798610337864> 5350 VP",
"valorant-points:11,000-vp": "<:Valorant_Points:1386806798610337864> 11,000 VP",
"valorant-points:16,350-vp": "<:Valorant_Points:1386806798610337864> 16,350 VP",
"valorant-points:22,000-vp": "<:Valorant_Points:1386806798610337864> 22,000 VP",
# Call of Duty CP
"callofduty-cp:2,400-cp": "<:COD_Point_BOCW2:1395768016255586376> 2,400 CP",
"callofduty-cp:5,000-cp": "<:COD_Point_BOCW2:1395768016255586376> 5,000 CP",
"callofduty-cp:9,500-cp": "<:COD_Point_BOCW2:1395768016255586376> 9,500 CP",
"callofduty-cp:13,000-cp": "<:COD_Point_BOCW2:1395768016255586376> 13,000 CP",
# Overwatch Coins
"overwatch-coins:2,200-coins": "<:Overwatch_Coin:1395787416509485087> 2,200 Coins",
"overwatch-coins:2000-coins": "<:Overwatch_Coin:1395787416509485087> 4,500 Coins",
"overwatch-coins:6,900-coins": "<:Overwatch_Coin:1395787416509485087> 6,900 Coins",
"overwatch-coins:11,800-coins": "<:Overwatch_Coin:1395787416509485087> 11,800 Coins",
# Discord Nitro
"discord-nitro:1-month-nitro": "<:discordnitro:1395949499704283166> 1 Month Nitro",
"discord-nitro:12-Months-nitro": "<:discordnitro:1395949499704283166> 12 Months Nitro",
# Gamepass
"gamepass:Ultimate 3 months": "<:xbox:1395953046688890962> 3 Months Gamepass Ultimate",
# Others
"others:netflix-1m": "<:netflix:1395956599092150282> Netflix 1 Month",
"others:spotify-premium": "<:spotify:1395958371244314795> Spotify Premium",
"others:custom-prize": "🎁 Custom Prize",
# FIFA Coins
"fifa-coins:100k-coins": "<:100KCoins:YOUR_EMOJI_ID> 100K FIFA Coins",
"fifa-coins:500k-coins": "<:500KCoins:YOUR_EMOJI_ID> 500K FIFA Coins",
"fifa-coins:1m-coins": "<:1MCoins:YOUR_EMOJI_ID> 1M FIFA Coins",
}
# Get channel links
channel_links = {
"valorant-points": "<#1377608623525728366>",
"callofduty-cp": "<#1386423140464201909>",
"overwatch-coins": "<#1395764822255210506>",
"discord-nitro": "<#1395949111412392068>",
"gamepass": "<#1395765771161960489>",
"others": "<#1395956006734925897>",
"buy-accounts": "<#1396249701866541107>",
"fifa-coins": "<#1386423375169064990>"
}
product_display = product_displays.get(product_string, specific.replace('-', ' ').title())
channel_link = channel_links.get(category, "")
if channel_link:
return f"{product_display} {channel_link}"
else:
return product_display
product_link = get_product_display_no_participants(giveaway_data['product'])
# No participants
embed = discord.Embed(
title="😢 Giveaway Ended - No Participants",
description=f"**{giveaway_data['title']}** has ended with no participants.\n\n"
f"🎁 **Prize:** {product_link}\n"
f"📅 **Ended:** <t:{int(datetime.now().timestamp())}:R>",
color=0xFF0000
)
await channel.send(embed=embed)
else:
# Select random winner from participants
winner = random.choice(participants)
# Get specific product with emoji and channel link
def get_product_display_end(product_string):
category, specific = product_string.split(':')
# Define specific product emojis and displays
product_displays = {
# Valorant Points
"valorant-points:5350-vp": "<:Valorant_Points:1386806798610337864> 5350 VP",
"valorant-points:11,000-vp": "<:Valorant_Points:1386806798610337864> 11,000 VP",
"valorant-points:16,350-vp": "<:Valorant_Points:1386806798610337864> 16,350 VP",
"valorant-points:22,000-vp": "<:Valorant_Points:1386806798610337864> 22,000 VP",
# Call of Duty CP
"callofduty-cp:2,400-cp": "<:COD_Point_BOCW2:1395768016255586376> 2,400 CP",
"callofduty-cp:5,000-cp": "<:COD_Point_BOCW2:1395768016255586376> 5,000 CP",
"callofduty-cp:9,500-cp": "<:COD_Point_BOCW2:1395768016255586376> 9,500 CP",
"callofduty-cp:13,000-cp": "<:COD_Point_BOCW2:1395768016255586376> 13,000 CP",
# Overwatch Coins
"overwatch-coins:2,200-coins": "<:Overwatch_Coin:1395787416509485087> 2,200 Coins",
"overwatch-coins:2000-coins": "<:Overwatch_Coin:1395787416509485087> 4,500 Coins",
"overwatch-coins:6,900-coins": "<:Overwatch_Coin:1395787416509485087> 6,900 Coins",
"overwatch-coins:11,800-coins": "<:Overwatch_Coin:1395787416509485087> 11,800 Coins",
# Discord Nitro
"discord-nitro:1-month-nitro": "<:discordnitro:1395949499704283166> 1 Month Nitro",
"discord-nitro:12-Months-nitro": "<:discordnitro:1395949499704283166> 12 Months Nitro",
# Gamepass
"gamepass:Ultimate 3 months": "<:xbox:1395953046688890962> 3 Months Gamepass Ultimate",
# Others
"others:netflix-1m": "<:netflix:1395956599092150282> Netflix 1 Month",
"others:spotify-premium": "<:spotify:1395958371244314795> Spotify Premium",
"others:custom-prize": "🎁 Custom Prize",
# FIFA Coins
"fifa-coins:100k-coins": "<:100KCoins:YOUR_EMOJI_ID> 100K FIFA Coins",
"fifa-coins:500k-coins": "<:500KCoins:YOUR_EMOJI_ID> 500K FIFA Coins",
"fifa-coins:1m-coins": "<:1MCoins:YOUR_EMOJI_ID> 1M FIFA Coins",
}
# Get channel links
channel_links = {
"valorant-points": "<#1377608623525728366>",
"callofduty-cp": "<#1386423140464201909>",
"overwatch-coins": "<#1395764822255210506>",
"discord-nitro": "<#1395949111412392068>",
"gamepass": "<#1395765771161960489>",
"others": "<#1395956006734925897>",
"buy-accounts": "<#1396249701866541107>", # No channel
"fifa-coins": "<#1386423375169064990>" # No channel
}
product_display = product_displays.get(product_string, specific.replace('-', ' ').title())
channel_link = channel_links.get(category, "")
if channel_link:
return f"{product_display} {channel_link}"
else:
return product_display
product_link = get_product_display_end(giveaway_data['product'])
# Winner announcement
embed = discord.Embed(
title="🎊 GIVEAWAY WINNER! 🎊",
description=f"**{giveaway_data['title']}** has ended!\n\n"
f"🏆 **Winner:** {winner.mention}\n"
f"🎁 **Prize:** {product_link}\n"
f"👥 **Participants:** {len(participants)}\n"
f"📅 **Ended:** <t:{int(datetime.now().timestamp())}:R>\n\n"
f"🎉 Congratulations {winner.display_name}! 🎉\n"
f"Please open a ticket in <#1377633537506672690> to claim your prize!",
color=0xFF0000
)
embed.set_thumbnail(url=winner.avatar.url if winner.avatar else None)
embed.set_footer(text="Developed by: RxxD")
await channel.send(f"🎊 Congratulations {winner.mention}! 🎊", embed=embed)
# Update giveaway data
giveaway_data["winners"] = [winner.id]
giveaway_data["participants"] = len(participants)
# Move to history
giveaway_tracking["giveaway_history"].append(giveaway_data)
del giveaway_tracking["active_giveaways"][giveaway_id]
save_giveaway_data(giveaway_tracking)
except Exception as e:
print(f"Error ending giveaway {giveaway_id}: {e}")
class LanguageSelectionView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.select(
placeholder="🌐 Select your language / اختر اللغة",
options=[
discord.SelectOption(label="English", value="english", emoji="🇺🇸"),
discord.SelectOption(label="العربية", value="arabic", emoji="🇸🇦"),
]
)
async def language_select(self, interaction: discord.Interaction, select: discord.ui.Select):
vouch_data = {
'language': select.values[0],
'submitter': interaction.user
}
product_view = ProductSelectionView(vouch_data)
current_step = 2
total_steps = 6
progress_bar = create_progress_bar(current_step, total_steps, "🟩", "⬜")
if select.values[0] == "arabic":
embed = discord.Embed(
title="✅ تم اختيار اللغة!",
description=f"**اللغة المختارة:** العربية\n\n"
f"**📊 التقدم:** {progress_bar}\n\n"
"📚 **الخطوة 2: اختر المنتج**\n"
"يرجى اختيار المنتج/الخدمة التي تريد تقييمها:",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=product_view, content=None)
else:
embed = discord.Embed(
title="✅ Language Selected!",
description=f"**Selected:** English\n\n"
f"**📊 Progress:** {progress_bar}\n\n"
"📚 **Step 2: Select Product**\n"
"Please select the product/service you're vouching for:",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=product_view, content=None)
class ProductSelectionView(discord.ui.View):
def __init__(self, vouch_data):
super().__init__(timeout=None)
self.vouch_data = vouch_data
# Set placeholder based on language
if vouch_data['language'] == "arabic":
placeholder = "📚 اختر منتجك أو خدمتك..."
else:
placeholder = "📚 Choose your product/service..."
# Update the select placeholder after initialization
self.product_select.placeholder = placeholder
@discord.ui.select(
placeholder="temp", # Will be set in __init__
options=[
discord.SelectOption(label="Valorant Points", value="valorant-points",
emoji="<:Valorant_Points:1386806798610337864> "),
discord.SelectOption(label="Call of Duty CP", value="callofduty-cp",
emoji="<:COD_Point_BOCW2:1395768016255586376> "),
discord.SelectOption(label="Overwatch Coins", value="overwatch-coins",
emoji="<:Overwatch_Coin:1395787416509485087>"),
discord.SelectOption(label="Discord Nitro", value="discord-nitro",
emoji="<:icons8discordnitro:1395950198915727512>"),
discord.SelectOption(label="Gamepass", value="gamepass", emoji="<:xbox:1395953046688890962> "),
discord.SelectOption(label="Others", value="others", emoji="<:netflix:1395956599092150282>"),
discord.SelectOption(label="Buy Accounts", value="buy-accounts"),
discord.SelectOption(label="FIFA Coins", value="fifa-coins"),
]
)
async def product_select(self, interaction: discord.Interaction, select: discord.ui.Select):
self.vouch_data['product'] = select.values[0]
user_view = UserSelectionView(self.vouch_data)
current_step = 3
total_steps = 6
progress_bar = create_progress_bar(current_step, total_steps, "🟩", "⬜")
if self.vouch_data['language'] == "arabic":
embed = discord.Embed(
title="✅ تم اختيار المنتج!",
description=f"**المنتج المختار:** {select.values[0]}\n\n"
f"**📊 التقدم:** {progress_bar}\n\n"
"👤 **الخطوة 3: اختر المستخدم**\n"
"اختر المستخدم الذي أكمل طلبك:",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=user_view, content=None)
else:
embed = discord.Embed(
title="✅ Product Selected!",
description=f"**Selected:** {select.values[0]}\n\n"
f"**📊 Progress:** {progress_bar}\n\n"
"👤 **Step 3: Select User**\n"
"Choose the user who completed your order:",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=user_view, content=None)
class UserSelectionView(discord.ui.View):
def __init__(self, vouch_data):
super().__init__(timeout=None)
self.vouch_data = vouch_data
# Set placeholder based on language
if vouch_data['language'] == "arabic":
placeholder = "👤 اختر المستخدم..."
else:
placeholder = "👤 Choose the user..."
# Update the select placeholder after initialization
self.user_select.placeholder = placeholder
@discord.ui.select(
placeholder="temp", # Will be set in __init__
options=[
discord.SelectOption(label="Owner", value="owner", emoji="<:Radiant:1378395701808992286>"),
discord.SelectOption(label="Moderator", value="moderator", emoji="<:manager:1402163552994984019>"),
]
)
async def user_select(self, interaction: discord.Interaction, select: discord.ui.Select):
self.vouch_data['vouched_user'] = select.values[0]
rating_view = RatingSelectionView(self.vouch_data)
current_step = 4
total_steps = 6
progress_bar = create_progress_bar(current_step, total_steps, "🟩", "⬜")
if self.vouch_data['language'] == "arabic":
embed = discord.Embed(
title="✅ تم اختيار المنتج والمستخدم!",
description=f"**المنتج:** {self.vouch_data['product']}\n"
f"**المستخدم:** {select.values[0]}\n\n"
f"**📊 التقدم:** {progress_bar}\n\n"
"⭐ **الخطوة 4: قيم تجربتك**\n"
"اختر تقييمك بالنجوم:",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=rating_view, content=None)
else:
embed = discord.Embed(
title="✅ Product & User Selected!",
description=f"**Product:** {self.vouch_data['product']}\n"
f"**User:** {select.values[0]}\n\n"
f"**📊 Progress:** {progress_bar}\n\n"
"⭐ **Step 4: Rate Your Experience**\n"
"Choose your star rating:",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=rating_view, content=None)
class RatingSelectionView(discord.ui.View):
def __init__(self, vouch_data):
super().__init__(timeout=None)
self.vouch_data = vouch_data
# Set placeholder based on language
if vouch_data['language'] == "arabic":
placeholder = "⭐ اختر تقييمك..."
else:
placeholder = "⭐ Choose your rating..."
# Update the select placeholder after initialization
self.rating_select.placeholder = placeholder
@discord.ui.select(
placeholder="temp", # Will be set in __init__
options=[
discord.SelectOption(label="⭐", value="1"),
discord.SelectOption(label="⭐⭐", value="2"),
discord.SelectOption(label="⭐⭐⭐", value="3"),
discord.SelectOption(label="⭐⭐⭐⭐", value="4"),
discord.SelectOption(label="⭐⭐⭐⭐⭐", value="5"),
]
)
async def rating_select(self, interaction: discord.Interaction, select: discord.ui.Select):
self.vouch_data['rating'] = select.values[0]
comment_view = CommentInputView(self.vouch_data)
star_count = int(select.values[0])
stars_display = "⭐" * star_count
current_step = 5
total_steps = 6
progress_bar = create_progress_bar(current_step, total_steps, "🟩", "⬜")
if self.vouch_data['language'] == "arabic":
embed = discord.Embed(
title="✅ تم اختيار المنتج والمستخدم والتقييم!",
description=f"**المنتج:** {self.vouch_data['product']}\n"
f"**المستخدم:** {self.vouch_data['vouched_user']}\n"
f"**التقييم:** {stars_display}\n\n"
f"**📊 التقدم:** {progress_bar}\n\n"
"📝 **الخطوة 5: اكتب تعليقك**\n"
"انقر على الزر أدناه لكتابة تقييمك:",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=comment_view, content=None)
else:
embed = discord.Embed(
title="✅ Product, User & Rating Selected!",
description=f"**Product:** {self.vouch_data['product']}\n"
f"**User:** {self.vouch_data['vouched_user']}\n"
f"**Rating:** {stars_display}\n\n"
f"**📊 Progress:** {progress_bar}\n\n"
"📝 **Step 5: Write Your Comment**\n"
"Click the button below to write your feedback:",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=comment_view, content=None)
class CommentModal(discord.ui.Modal):
def __init__(self, vouch_data):
self.vouch_data = vouch_data
if vouch_data['language'] == "arabic":
super().__init__(title="اكتب تقييمك")
self.feedback = discord.ui.TextInput(
label="التعليقات",
style=discord.TextStyle.paragraph,
placeholder="أخبرنا عن تجربتك، هل كانت الخدمة سريعة؟ هل تنصح بنا؟",
required=True,
max_length=4000
)
else:
super().__init__(title="Write Your Feedback")
self.feedback = discord.ui.TextInput(
label="Comments",
style=discord.TextStyle.paragraph,
placeholder="Tell us about your experience, was the service fast? Would you recommend us?",
required=True,
max_length=4000
)
self.add_item(self.feedback)
async def on_submit(self, interaction: discord.Interaction):
self.vouch_data['feedback'] = self.feedback.value
proof_view = ProofUploadView(self.vouch_data)
star_count = int(self.vouch_data['rating'])
stars_display = "⭐" * star_count
current_step = 6
total_steps = 6
progress_bar = create_progress_bar(current_step, total_steps, "🟩", "⬜")
if self.vouch_data['language'] == "arabic":
embed = discord.Embed(
title="✅ تم جمع جميع التفاصيل!",
description=f"**المنتج:** {self.vouch_data['product']}\n"
f"**المستخدم:** {self.vouch_data['vouched_user']}\n"
f"**التقييم:** {stars_display}\n"
f"**التعليق:** {self.vouch_data['feedback'][:100]}{'...' if len(self.vouch_data['feedback']) > 100 else ''}\n\n"
f"**📊 التقدم:** {progress_bar}\n\n"
"📸 **الخطوة الأخيرة: ارفع الإثبات**\n"
"يرجى النقر على الزر أدناه وإرفاق صورة كإثبات للمعاملة.",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=proof_view, content=None)
else:
embed = discord.Embed(
title="✅ All Details Collected!",
description=f"**Product:** {self.vouch_data['product']}\n"
f"**User:** {self.vouch_data['vouched_user']}\n"
f"**Rating:** {stars_display}\n"
f"**Comment:** {self.vouch_data['feedback'][:100]}{'...' if len(self.vouch_data['feedback']) > 100 else ''}\n\n"
f"**📊 Progress:** {progress_bar}\n\n"
"📸 **Final Step: Upload Proof**\n"
"Please click the button below and attach an image as proof of your transaction.",
color=0xFF0000
)
await interaction.response.edit_message(embed=embed, view=proof_view, content=None)
class CommentInputView(discord.ui.View):
def __init__(self, vouch_data):
super().__init__(timeout=None)
self.vouch_data = vouch_data
# Set button label based on language
if vouch_data['language'] == "arabic":
button_label = "📝 اكتب تعليق"
else:
button_label = "📝 Write Comment"
# Update the button label after initialization
self.write_comment.label = button_label
@discord.ui.button(label="temp", style=discord.ButtonStyle.primary)
async def write_comment(self, interaction: discord.Interaction, button: discord.ui.Button):
modal = CommentModal(self.vouch_data)
await interaction.response.send_modal(modal)
class ProofUploadView(discord.ui.View):
def __init__(self, vouch_data):
super().__init__(timeout=None)
self.vouch_data = vouch_data
# Set button label based on language
if vouch_data['language'] == "arabic":
button_label = "📎 ارفع الإثبات"
else:
button_label = "📎 Upload Proof"
# Update the button label after initialization
self.upload_proof.label = button_label
@discord.ui.button(label="temp", style=discord.ButtonStyle.primary, emoji="📸")
async def upload_proof(self, interaction: discord.Interaction, button: discord.ui.Button):
if self.vouch_data['language'] == "arabic":
embed = discord.Embed(
title="📸 ارفع صورة الإثبات",
description="**لديك طريقتان لرفع الصورة:**\n\n"