1
+ import os , sys , discord , random , asyncio
2
+ from discord .ext import commands
3
+
4
+ if not os .path .isfile ("config.py" ):
5
+ sys .exit ("'config.py' not found! Please add it and try again." )
6
+ else :
7
+ import config
8
+
9
+ class Fun (commands .Cog , name = "fun" ):
10
+ def __init__ (self , bot ):
11
+ self .bot = bot
12
+
13
+ @commands .command (name = "dick" )
14
+ async def dick (self , context , member : discord .Member = None ):
15
+ """
16
+ Get the dick's length of a user or yourself.
17
+ """
18
+ if not member :
19
+ member = context .author
20
+ length = random .randrange (15 )
21
+ embed = discord .Embed (description = f"8{ '=' * length } D" , color = config .main_color )
22
+ embed .set_author (name = f"{ member .display_name } 's Dick" , icon_url = member .avatar_url )
23
+ await context .send (embed = embed )
24
+
25
+ @commands .command (name = "rps" )
26
+ async def rock_paper_scissors (self , context ):
27
+ choices = {
28
+ 0 : "rock" ,
29
+ 1 : "paper" ,
30
+ 2 : "scissors"
31
+ }
32
+ reactions = {
33
+ "🪨" : 0 ,
34
+ "🧻" : 1 ,
35
+ "✂" : 2
36
+ }
37
+ embed = discord .Embed (title = "Please choose" , color = config .warning )
38
+ embed .set_author (name = context .author .display_name , icon_url = context .author .avatar_url )
39
+ choose_message = await context .send (embed = embed )
40
+ for emoji in reactions :
41
+ await choose_message .add_reaction (emoji )
42
+
43
+ def check (reaction , user ):
44
+ return user == context .message .author and str (reaction ) in reactions
45
+ try :
46
+ reaction , user = await self .bot .wait_for ("reaction_add" , timeout = 10 , check = check )
47
+
48
+ user_choice_emote = reaction .emoji
49
+ user_choice_index = reactions [user_choice_emote ]
50
+
51
+ bot_choice_emote = random .choice (list (reactions .keys ()))
52
+ bot_choice_index = reactions [bot_choice_emote ]
53
+
54
+ result_embed = discord .Embed (color = config .success )
55
+ result_embed .set_author (name = context .author .display_name , icon_url = context .author .avatar_url )
56
+ await choose_message .clear_reactions ()
57
+
58
+ if user_choice_index == bot_choice_index :
59
+ result_embed .description = f"**That's a draw!**\n You've chosen { user_choice_emote } and I've chosen { bot_choice_emote } ."
60
+ result_embed .colour = config .warning
61
+ elif user_choice_index == 0 and bot_choice_index == 2 :
62
+ result_embed .description = f"**You won!**\n You've chosen { user_choice_emote } and I've chosen { bot_choice_emote } ."
63
+ result_embed .colour = config .success
64
+ elif user_choice_index == 1 and bot_choice_index == 0 :
65
+ result_embed .description = f"**You won!**\n You've chosen { user_choice_emote } and I've chosen { bot_choice_emote } ."
66
+ result_embed .colour = config .success
67
+ elif user_choice_index == 2 and bot_choice_index == 1 :
68
+ result_embed .description = f"**You won!**\n You've chosen { user_choice_emote } and I've chosen { bot_choice_emote } ."
69
+ result_embed .colour = config .success
70
+ else :
71
+ result_embed .description = f"**I won!**\n You've chosen { user_choice_emote } and I've chosen { bot_choice_emote } ."
72
+ result_embed .colour = config .error
73
+ await choose_message .add_reaction ("🇱" )
74
+ await choose_message .edit (embed = result_embed )
75
+ except asyncio .exceptions .TimeoutError :
76
+ await choose_message .clear_reactions ()
77
+ timeout_embed = discord .Embed (title = "Too late" , color = config .error )
78
+ timeout_embed .set_author (name = context .author .display_name , icon_url = context .author .avatar_url )
79
+ await choose_message .edit (embed = timeout_embed )
80
+
81
+ def setup (bot ):
82
+ bot .add_cog (Fun (bot ))
0 commit comments