-
-
Notifications
You must be signed in to change notification settings - Fork 246
Bemyvalentine patch #1657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Bemyvalentine patch #1657
Changes from all commits
1e14def
f8b6401
b422b75
197a45a
760522d
72bccd8
e116917
62fab9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,21 +41,39 @@ async def lovefest_role(self, ctx: commands.Context) -> None: | |
""" | ||
raise MovedCommandError(MOVED_COMMAND) | ||
|
||
@commands.cooldown(1, 1800, commands.BucketType.user) | ||
# @commands.cooldown(1, 1800, commands.BucketType.user) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this was done while testing, but should be reverted now. To keep git history clean, avoid committing temporary changes. |
||
@commands.group(name="bemyvalentine", invoke_without_command=True) | ||
async def send_valentine( | ||
self, ctx: commands.Context, user: discord.Member, *, valentine_type: str | None = None | ||
self, ctx: commands.Context, user: discord.Member, privacy_type: str | None = None, anon: str | None = None, valentine_type: str | None = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This would simplify the logic later on. |
||
) -> None: | ||
""" | ||
Send a valentine to a specified user with the lovefest role. | ||
|
||
syntax: .bemyvalentine [user] [p/poem/c/compliment/or you can type your own valentine message] | ||
syntax: .bemyvalentine [user] [public/private] [anon/signed] [p/poem/c/compliment/or you can type your own valentine message] | ||
(optional) | ||
|
||
example: .bemyvalentine Iceman#6508 p (sends a poem to Iceman) | ||
example: .bemyvalentine Iceman Hey I love you, wanna hang around ? (sends the custom message to Iceman) | ||
example: .bemyvalentine Iceman#6508 private anon p (sends an anonymous private poem through DM to Iceman) | ||
example: .bemyvalentine Iceman public signed Hey I love you, wanna hang around ? (sends the custom message publicly and signed to Iceman in the current channel) | ||
NOTE : AVOID TAGGING THE USER MOST OF THE TIMES.JUST TRIM THE '@' when using this command. | ||
""" | ||
|
||
|
||
if anon.lower() == "anon": | ||
# Delete the message containing the command right after it was sent to enforce anonymity. | ||
try: | ||
await ctx.message.delete() | ||
except discord.Forbidden: | ||
await ctx.send("I can't delete your message! Please check my permissions.") | ||
|
||
|
||
if anon not in ["anon", "signed"]: | ||
# Anonymity type wrongfully specified. | ||
raise commands.UserInputError( | ||
f"Specify if you want the message to be anonymous or not!" | ||
) | ||
|
||
|
||
|
||
if ctx.guild is None: | ||
# This command should only be used in the server | ||
raise commands.UserInputError("You are supposed to use this command in the server.") | ||
|
@@ -64,6 +82,13 @@ async def send_valentine( | |
raise commands.UserInputError( | ||
f"You cannot send a valentine to {user} as they do not have the lovefest role!" | ||
) | ||
|
||
if privacy_type not in ["public", "private"]: | ||
# Privacy type wrongfully specified. | ||
raise commands.UserInputError( | ||
f"Specify if you want the message to be sent privately or publicly!" | ||
) | ||
|
||
|
||
if user == ctx.author: | ||
# Well a user can't valentine himself/herself. | ||
|
@@ -73,12 +98,33 @@ async def send_valentine( | |
channel = self.bot.get_channel(Channels.sir_lancebot_playground) | ||
valentine, title = self.valentine_check(valentine_type) | ||
|
||
embed = discord.Embed( | ||
title=f"{emoji_1} {title} {user.display_name} {emoji_2}", | ||
description=f"{valentine} \n **{emoji_2}From {ctx.author}{emoji_1}**", | ||
color=Colours.pink | ||
) | ||
await channel.send(user.mention, embed=embed) | ||
if anon.lower() == "anon": | ||
embed = discord.Embed( | ||
title=f"{emoji_1} {title} {user.display_name} {emoji_2}", | ||
description=f"{valentine} \n **{emoji_2}From an anonymous admirer{emoji_1}**", | ||
color=Colours.pink | ||
) | ||
|
||
else: | ||
embed = discord.Embed( | ||
title=f"{emoji_1} {title} {user.display_name} {emoji_2}", | ||
description=f"{valentine} \n **{emoji_2}From {ctx.author}{emoji_1}**", | ||
color=Colours.pink | ||
) | ||
Comment on lines
+101
to
+113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is unnecessary duplication here, you could just have something like from_user = "an anonymous admirer" if anon.lower() == "anon" else ctx.author and format that into a single embed call. |
||
|
||
if privacy_type.lower() == "private": | ||
# Send the message privately if "private" was speicified | ||
try: | ||
await user.send(embed=embed) | ||
await ctx.author.send(f"Your valentine has been **privately** delivered to {user.display_name}!") | ||
except discord.Forbidden: | ||
await ctx.send(f"I couldn't send a private message to {user.display_name}. They may have DMs disabled.") | ||
else: | ||
# Send the message publicly if "public" was speicified | ||
try: | ||
await ctx.send(user.mention, embed=embed) | ||
except discord.Forbidden: | ||
await ctx.send(f"I couldn't send a private message to {user.display_name}. They may have DMs disabled.") | ||
|
||
@commands.cooldown(1, 1800, commands.BucketType.user) | ||
@send_valentine.command(name="secret") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything changes made just for testing should be reverted (though I'm not really sure why this would be needed, when you can just use a channel that is already configured as whitelisted)