aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar AG_1436 <[email protected]>2019-12-05 16:09:17 +0530
committerGravatar GitHub <[email protected]>2019-12-05 16:09:17 +0530
commitef324c0bed4f255c5721658243e99f20e5989afd (patch)
tree82c5bdf20789a58131e27bea32ccffcd12949fe3
parentFixed grammatical errors, and simplified the code a bit. (diff)
Fixed a lot of issues.
Fixed the coding not satisfying `K&R` code styling Fixed most of the grammatical issues Removed unnecessary `try except` code block , not gonna trigger anyways.
-rw-r--r--bot/seasons/evergreen/bookmark.py53
1 files changed, 24 insertions, 29 deletions
diff --git a/bot/seasons/evergreen/bookmark.py b/bot/seasons/evergreen/bookmark.py
index 3e890fcf..662e285a 100644
--- a/bot/seasons/evergreen/bookmark.py
+++ b/bot/seasons/evergreen/bookmark.py
@@ -7,7 +7,7 @@ log = logging.getLogger(__name__)
class Bookmark(commands.Cog):
- """A cog for Bookmarking a message."""
+ """A cog for Bookmarking a message. helps personal pinning a message in a busy server."""
def __init__(self, bot: commands.Bot):
self.bot = bot
@@ -15,62 +15,57 @@ class Bookmark(commands.Cog):
@commands.command(name="bookmark", aliases=("bm", "pin"))
async def bookmark(self, ctx: commands.Context, jump_url: str = None, *args) -> None:
"""Bookmarks a message."""
+ global message_id
if jump_url is not None and jump_url != "*":
if "discordapp.com/channels" not in jump_url:
- await ctx.send("I can't find the associated message,"
- " the command support the following syntax:\n"
- " `.bm [message url] (bookmark name)`")
+ await ctx.send(
+ "I can't find the associated message."
+ " this command supports the following syntax:\n"
+ "`[command alias] [message url] (bookmark name)`"
+ )
return
if jump_url is None or jump_url == "*":
channel = ctx.channel
async for x in channel.history(limit=2):
message_id = x.id
- try:
- message = await channel.fetch_message(message_id)
- except discord.NotFound:
- await ctx.send(">>> Message not in this"
- " channel\n"
- "Or\n"
- "You are trying to Pin"
- " your own message,\n"
- "Please use the channel"
- " where message is.")
- return
- jump_url = f"https://discordapp.com/channels/" \
- f"{ctx.guild.id}/{channel.id}/{message.id}"
+ message = await channel.fetch_message(message_id)
+ jump_url = (
+ "https://discordapp.com/channels/"
+ f"{ctx.guild.id}/{channel.id}/{message.id}"
+ )
embed = discord.Embed(
title="Your bookmark",
description=None,
colour=0x2ecc71
)
- x = args
hint = ""
- for word in x:
+ for word in args:
hint = hint + " " + word
if hint == "":
hint = "No hint provided"
embed.set_footer(text="Why everything so heavy ?")
- embed.set_thumbnail(url="https://emojipedia-us.s3."
- "dualstack.us-west-1.amazonaws.com"
- "/thumbs/240/twitter/"
- "233/incoming-envelope_1f4e8.png")
+ embed.set_thumbnail(
+ url="https://emojipedia-us.s3."
+ "dualstack.us-west-1.amazonaws.com"
+ "/thumbs/240/twitter/"
+ "233/incoming-envelope_1f4e8.png"
+ )
embed.set_author(name=ctx.author)
embed.add_field(name='Hints', value=hint, inline=False)
embed.add_field(name='Link', value=jump_url, inline=False)
try:
await ctx.author.send(embed=embed)
except discord.Forbidden:
- await ctx.send("Something is not right,"
- " you have either blocked me or"
- " you have disabled direct messages "
- "from this server.")
+ await ctx.send(
+ ">>> You have to enable direct messages from this server to receive DM's from me."
+ )
return
- await ctx.send("Sent you that DM")
+ await ctx.send("Sent you a DM!")
def setup(bot: commands.Bot) -> None:
- """Uptime Cog load."""
+ """Bookmark Cog load."""
bot.add_cog(Bookmark(bot))
log.info("Bookmark cog loaded")