mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 19:28:54 -05:00
* Fix #1326 Checks to see if `author` is a `valid_user` (of `Member` class) before checking to see if the bot `is_mod_or_superior` to the `author`. * Fix #1202 Raises `TypeError` when `User` objects are passed into `is_mod_or_superior` or `is_admin_or_superior`, as only `Member` objects have a `guild` attribute. * Fixes #1202 Checks to see if `author` is a `valid_user` (of `Member` class) before checking to see if the bot `is_mod_or_superior` to the `author`.
This commit is contained in:
parent
d20724d7b2
commit
b5c71bc59c
@ -249,10 +249,12 @@ class Filter:
|
||||
return
|
||||
author = message.author
|
||||
valid_user = isinstance(author, discord.Member) and not author.bot
|
||||
if not valid_user:
|
||||
return
|
||||
|
||||
# Bots and mods or superior are ignored from the filter
|
||||
mod_or_superior = await is_mod_or_superior(self.bot, obj=author)
|
||||
if not valid_user or mod_or_superior:
|
||||
if mod_or_superior:
|
||||
return
|
||||
|
||||
await self.check_filter(message)
|
||||
@ -261,10 +263,13 @@ class Filter:
|
||||
author = message.author
|
||||
if message.guild is None or self.bot.user == author:
|
||||
return
|
||||
|
||||
valid_user = isinstance(author, discord.Member) and not author.bot
|
||||
if not valid_user:
|
||||
return
|
||||
|
||||
# Bots and mods or superior are ignored from the filter
|
||||
mod_or_superior = await is_mod_or_superior(self.bot, obj=author)
|
||||
if not valid_user or mod_or_superior:
|
||||
if mod_or_superior:
|
||||
return
|
||||
|
||||
await self.check_filter(message)
|
||||
|
||||
@ -1241,10 +1241,12 @@ class Mod:
|
||||
if message.guild is None or self.bot.user == author:
|
||||
return
|
||||
valid_user = isinstance(author, discord.Member) and not author.bot
|
||||
if not valid_user:
|
||||
return
|
||||
|
||||
# Bots and mods or superior are ignored from the filter
|
||||
mod_or_superior = await is_mod_or_superior(self.bot, obj=author)
|
||||
if not valid_user or mod_or_superior:
|
||||
if mod_or_superior:
|
||||
return
|
||||
deleted = await self.check_duplicates(message)
|
||||
if not deleted:
|
||||
|
||||
@ -124,7 +124,7 @@ async def is_mod_or_superior(
|
||||
user = None
|
||||
if isinstance(obj, discord.Message):
|
||||
user = obj.author
|
||||
elif isinstance(obj, discord.Member) or isinstance(obj, discord.User):
|
||||
elif isinstance(obj, discord.Member):
|
||||
user = obj
|
||||
elif isinstance(obj, discord.Role):
|
||||
pass
|
||||
@ -214,7 +214,7 @@ async def is_admin_or_superior(
|
||||
user = None
|
||||
if isinstance(obj, discord.Message):
|
||||
user = obj.author
|
||||
elif isinstance(obj, discord.Member) or isinstance(obj, discord.User):
|
||||
elif isinstance(obj, discord.Member):
|
||||
user = obj
|
||||
elif isinstance(obj, discord.Role):
|
||||
pass
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user