@@ -41,19 +41,19 @@ async def lovefest_role(self, ctx: commands.Context) -> None:
41
41
"""
42
42
raise MovedCommandError (MOVED_COMMAND )
43
43
44
- @commands .cooldown (1 , 1800 , commands .BucketType .user )
44
+ # @commands.cooldown(1, 1800, commands.BucketType.user)
45
45
@commands .group (name = "bemyvalentine" , invoke_without_command = True )
46
46
async def send_valentine (
47
- self , ctx : commands .Context , user : discord .Member , * , valentine_type : str | None = None
47
+ self , ctx : commands .Context , user : discord .Member , privacy_type : str | None = None , valentine_type : str | None = None
48
48
) -> None :
49
49
"""
50
50
Send a valentine to a specified user with the lovefest role.
51
51
52
- syntax: .bemyvalentine [user] [p/poem/c/compliment/or you can type your own valentine message]
52
+ syntax: .bemyvalentine [user] [public/private] [ p/poem/c/compliment/or you can type your own valentine message]
53
53
(optional)
54
54
55
- example: .bemyvalentine Iceman#6508 p (sends a poem to Iceman)
56
- example: .bemyvalentine Iceman Hey I love you, wanna hang around ? (sends the custom message to Iceman)
55
+ example: .bemyvalentine private Iceman#6508 p (sends a private poem to Iceman)
56
+ example: .bemyvalentine public Iceman Hey I love you, wanna hang around ? (sends the custom message publicly to Iceman)
57
57
NOTE : AVOID TAGGING THE USER MOST OF THE TIMES.JUST TRIM THE '@' when using this command.
58
58
"""
59
59
if ctx .guild is None :
@@ -64,10 +64,18 @@ async def send_valentine(
64
64
raise commands .UserInputError (
65
65
f"You cannot send a valentine to { user } as they do not have the lovefest role!"
66
66
)
67
+
68
+ if privacy_type not in ["public" , "private" ]:
69
+ # Privacy type wrongfully specified.
70
+ raise commands .UserInputError (
71
+ f"Specify if you want the message to be sent privately or publicly!"
72
+ )
73
+
74
+ # COMMENTED FOR TESTING PURPOSES
67
75
68
- if user == ctx .author :
69
- # Well a user can't valentine himself/herself.
70
- raise commands .UserInputError ("Come on, you can't send a valentine to yourself :expressionless:" )
76
+ # if user == ctx.author:
77
+ # # Well a user can't valentine himself/herself.
78
+ # raise commands.UserInputError("Come on, you can't send a valentine to yourself :expressionless:")
71
79
72
80
emoji_1 , emoji_2 = self .random_emoji ()
73
81
channel = self .bot .get_channel (Channels .sir_lancebot_playground )
@@ -78,7 +86,20 @@ async def send_valentine(
78
86
description = f"{ valentine } \n **{ emoji_2 } From { ctx .author } { emoji_1 } **" ,
79
87
color = Colours .pink
80
88
)
81
- await channel .send (user .mention , embed = embed )
89
+
90
+ if privacy_type .lower () == "private" :
91
+ # Send the message privately if "private" was speicified
92
+ try :
93
+ await user .send (embed = embed )
94
+ await user .send (f"Your valentine has been **privately** delivered to { user .display_name } !" )
95
+ except discord .Forbidden :
96
+ await ctx .send (f"I couldn't send a private message to { user .display_name } . They may have DMs disabled." )
97
+ else :
98
+ # Send the message publicly if "public" was speicified
99
+ try :
100
+ await ctx .send (user .mention , embed = embed )
101
+ except discord .Forbidden :
102
+ await ctx .send (f"I couldn't send a private message to { user .display_name } . They may have DMs disabled." )
82
103
83
104
@commands .cooldown (1 , 1800 , commands .BucketType .user )
84
105
@send_valentine .command (name = "secret" )
0 commit comments