Skip to content

Commit

Permalink
Merge pull request #1 from python-discord/master
Browse files Browse the repository at this point in the history
merge back new changes
  • Loading branch information
hedyhli authored Oct 2, 2020
2 parents f791bc3 + eb851ce commit 2bfa1c2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 104 deletions.
87 changes: 0 additions & 87 deletions bot/exts/backend/alias.py

This file was deleted.

13 changes: 13 additions & 0 deletions bot/exts/fun/duck_pond.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ async def on_raw_reaction_add(self, payload: RawReactionActionEvent) -> None:
amount of ducks specified in the config under duck_pond/threshold, it will
send the message off to the duck pond.
"""
# Ignore other guilds and DMs.
if payload.guild_id != constants.Guild.id:
return

# Was this reaction issued in a blacklisted channel?
if payload.channel_id in constants.DuckPond.channel_blacklist:
return
Expand All @@ -154,6 +158,9 @@ async def on_raw_reaction_add(self, payload: RawReactionActionEvent) -> None:
return

channel = discord.utils.get(self.bot.get_all_channels(), id=payload.channel_id)
if channel is None:
return

message = await channel.fetch_message(payload.message_id)
member = discord.utils.get(message.guild.members, id=payload.user_id)

Expand All @@ -175,7 +182,13 @@ async def on_raw_reaction_add(self, payload: RawReactionActionEvent) -> None:
@Cog.listener()
async def on_raw_reaction_remove(self, payload: RawReactionActionEvent) -> None:
"""Ensure that people don't remove the green checkmark from duck ponded messages."""
# Ignore other guilds and DMs.
if payload.guild_id != constants.Guild.id:
return

channel = discord.utils.get(self.bot.get_all_channels(), id=payload.channel_id)
if channel is None:
return

# Prevent the green checkmark from being removed
if payload.emoji.name == "✅":
Expand Down
18 changes: 3 additions & 15 deletions bot/exts/info/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,8 @@ def get_source_link(self, source_item: SourceType) -> Tuple[str, str, Optional[i
Raise BadArgument if `source_item` is a dynamically-created object (e.g. via internal eval).
"""
if isinstance(source_item, commands.Command):
if source_item.cog_name == "Alias":
cmd_name = source_item.callback.__name__.replace("_alias", "")
cmd = self.bot.get_command(cmd_name.replace("_", " "))
src = cmd.callback.__code__
filename = src.co_filename
else:
src = source_item.callback.__code__
filename = src.co_filename
src = source_item.callback.__code__
filename = src.co_filename
elif isinstance(source_item, str):
tags_cog = self.bot.get_cog("Tags")
filename = tags_cog._cache[source_item]["location"]
Expand Down Expand Up @@ -113,13 +107,7 @@ async def build_embed(self, source_object: SourceType) -> Optional[Embed]:
title = "Help Command"
description = source_object.__doc__.splitlines()[1]
elif isinstance(source_object, commands.Command):
if source_object.cog_name == "Alias":
cmd_name = source_object.callback.__name__.replace("_alias", "")
cmd = self.bot.get_command(cmd_name.replace("_", " "))
description = cmd.short_doc
else:
description = source_object.short_doc

description = source_object.short_doc
title = f"Command: {source_object.qualified_name}"
elif isinstance(source_object, str):
title = f"Tag: {source_object}"
Expand Down
2 changes: 1 addition & 1 deletion bot/exts/moderation/modlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def upload_log(
'id': message.id,
'author': message.author.id,
'channel_id': message.channel.id,
'content': message.content,
'content': message.content.replace("\0", ""), # Null chars cause 400.
'embeds': [embed.to_dict() for embed in message.embeds],
'attachments': attachment,
}
Expand Down
6 changes: 5 additions & 1 deletion bot/utils/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ async def wait_for_deletion(

if attach_emojis:
for emoji in deletion_emojis:
await message.add_reaction(emoji)
try:
await message.add_reaction(emoji)
except discord.NotFound:
log.trace(f"Aborting wait_for_deletion: message {message.id} deleted prematurely.")
return

def check(reaction: discord.Reaction, user: discord.Member) -> bool:
"""Check that the deletion emoji is reacted by the appropriate user."""
Expand Down

0 comments on commit 2bfa1c2

Please sign in to comment.