From 4c6d87c48bc44235a511f9266f986c219ac93f7e Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 13 Feb 2021 15:44:27 +0000 Subject: Raise user input error to reset cd --- bot/exts/valentines/be_my_valentine.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bot/exts/valentines/be_my_valentine.py b/bot/exts/valentines/be_my_valentine.py index d79b28e8..aac38edb 100644 --- a/bot/exts/valentines/be_my_valentine.py +++ b/bot/exts/valentines/be_my_valentine.py @@ -86,17 +86,17 @@ class BeMyValentine(commands.Cog): # This command should only be used in the server msg = "You are supposed to use this command in the server." await ctx.send(msg) - return + raise commands.UserInputError if Lovefest.role_id not in [role.id for role in user.roles]: message = f"You cannot send a valentine to {user} as they do not have the lovefest role!" await ctx.send(message) - return + raise commands.UserInputError if user == ctx.author: # Well a user can't valentine himself/herself. await ctx.send("Come on, you can't send a valentine to yourself :expressionless:") - return + raise commands.UserInputError emoji_1, emoji_2 = self.random_emoji() channel = self.bot.get_channel(Channels.community_bot_commands) @@ -131,12 +131,12 @@ class BeMyValentine(commands.Cog): await ctx.author.send(message) except discord.Forbidden: await ctx.send(message) - return + raise commands.UserInputError if user == ctx.author: # Well a user cant valentine himself/herself. await ctx.send('Come on, you can\'t send a valentine to yourself :expressionless:') - return + raise commands.UserInputError emoji_1, emoji_2 = self.random_emoji() valentine, title = self.valentine_check(valentine_type) @@ -151,6 +151,7 @@ class BeMyValentine(commands.Cog): await ctx.message.delete() except discord.Forbidden: await ctx.send(f"{user} has DMs disabled, so I couldn't send the message. Sorry!") + raise commands.UserInputError else: await ctx.author.send(f"Your message has been sent to {user}") -- cgit v1.2.3 From 2d33d53bf2c3a26e68abdcf2a2f91dac5bd495fc Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 13 Feb 2021 23:12:43 +0000 Subject: Output message in the same embed. --- bot/exts/valentines/be_my_valentine.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/bot/exts/valentines/be_my_valentine.py b/bot/exts/valentines/be_my_valentine.py index aac38edb..fe52936b 100644 --- a/bot/exts/valentines/be_my_valentine.py +++ b/bot/exts/valentines/be_my_valentine.py @@ -84,19 +84,16 @@ class BeMyValentine(commands.Cog): """ if ctx.guild is None: # This command should only be used in the server - msg = "You are supposed to use this command in the server." - await ctx.send(msg) - raise commands.UserInputError + raise commands.UserInputError("You are supposed to use this command in the server.") if Lovefest.role_id not in [role.id for role in user.roles]: - message = f"You cannot send a valentine to {user} as they do not have the lovefest role!" - await ctx.send(message) - raise commands.UserInputError + raise commands.UserInputError( + f"You cannot send a valentine to {user} as they do not have the lovefest role!" + ) if user == ctx.author: # Well a user can't valentine himself/herself. - await ctx.send("Come on, you can't send a valentine to yourself :expressionless:") - raise commands.UserInputError + raise commands.UserInputError("Come on, you can't send a valentine to yourself :expressionless:") emoji_1, emoji_2 = self.random_emoji() channel = self.bot.get_channel(Channels.community_bot_commands) @@ -125,18 +122,14 @@ class BeMyValentine(commands.Cog): Iceman in DM making you anonymous) """ if Lovefest.role_id not in [role.id for role in user.roles]: - message = f"You cannot send a valentine to {user} as they do not have the lovefest role!" await ctx.message.delete() - try: - await ctx.author.send(message) - except discord.Forbidden: - await ctx.send(message) - raise commands.UserInputError + raise commands.UserInputError( + f"You cannot send a valentine to {user}> as they do not have the lovefest role!" + ) if user == ctx.author: # Well a user cant valentine himself/herself. - await ctx.send('Come on, you can\'t send a valentine to yourself :expressionless:') - raise commands.UserInputError + raise commands.UserInputError("Come on, you can't send a valentine to yourself :expressionless:") emoji_1, emoji_2 = self.random_emoji() valentine, title = self.valentine_check(valentine_type) @@ -146,12 +139,11 @@ class BeMyValentine(commands.Cog): description=f'{valentine} \n **{emoji_2}From anonymous{emoji_1}**', color=Colours.pink ) + await ctx.message.delete() try: await user.send(embed=embed) - await ctx.message.delete() except discord.Forbidden: - await ctx.send(f"{user} has DMs disabled, so I couldn't send the message. Sorry!") - raise commands.UserInputError + raise commands.UserInputError(f"{user} has DMs disabled, so I couldn't send the message. Sorry!") else: await ctx.author.send(f"Your message has been sent to {user}") -- cgit v1.2.3 From ab5e00d836a4c01c581a877c2dc992f3fa8d9243 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 13 Feb 2021 23:16:48 +0000 Subject: Remove leftover > from testing. --- bot/exts/valentines/be_my_valentine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/exts/valentines/be_my_valentine.py b/bot/exts/valentines/be_my_valentine.py index fe52936b..f3392bcb 100644 --- a/bot/exts/valentines/be_my_valentine.py +++ b/bot/exts/valentines/be_my_valentine.py @@ -124,7 +124,7 @@ class BeMyValentine(commands.Cog): if Lovefest.role_id not in [role.id for role in user.roles]: await ctx.message.delete() raise commands.UserInputError( - f"You cannot send a valentine to {user}> as they do not have the lovefest role!" + f"You cannot send a valentine to {user} as they do not have the lovefest role!" ) if user == ctx.author: -- cgit v1.2.3