Skip to content

Commit

Permalink
[V3 Mod/Modlog] prevent self-casing the bot + feedback for heirarchy (#…
Browse files Browse the repository at this point in the history
…1777)

* prevent the bot from being a modlog target

* prevent heirarchy issues in mod

* modify this comparison to avoid more complex mocking of the guild object in mod test

* spelling
  • Loading branch information
Michael H authored and tekulvw committed Jun 9, 2018
1 parent e15815c commit 8b15053
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions redbot/cogs/mod/mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ async def kick(self, ctx: commands.Context, user: discord.Member, *, reason: str
)
)
return
elif ctx.guild.me.top_role <= user.top_role or user == ctx.guild.owner:
await ctx.send(_("I cannot do that due to discord hierarchy rules"))
return
audit_reason = get_audit_reason(author, reason)
try:
await guild.kick(user, reason=audit_reason)
Expand Down Expand Up @@ -369,6 +372,9 @@ async def ban(
)
)
return
elif ctx.guild.me.top_role <= user.top_role or user == ctx.guild.owner:
await ctx.send(_("I cannot do that due to discord hierarchy rules"))
return

if days:
if days.isdigit():
Expand Down
3 changes: 3 additions & 0 deletions redbot/core/modlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ async def create_case(
if not await case_type.is_enabled():
return None

if user == bot.user:
return None

next_case_number = int(await get_next_case_number(guild))

case = Case(
Expand Down

0 comments on commit 8b15053

Please sign in to comment.