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
|
return
|
||||||
author = message.author
|
author = message.author
|
||||||
valid_user = isinstance(author, discord.Member) and not author.bot
|
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
|
# Bots and mods or superior are ignored from the filter
|
||||||
mod_or_superior = await is_mod_or_superior(self.bot, obj=author)
|
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
|
return
|
||||||
|
|
||||||
await self.check_filter(message)
|
await self.check_filter(message)
|
||||||
@ -261,10 +263,13 @@ class Filter:
|
|||||||
author = message.author
|
author = message.author
|
||||||
if message.guild is None or self.bot.user == author:
|
if message.guild is None or self.bot.user == author:
|
||||||
return
|
return
|
||||||
|
|
||||||
valid_user = isinstance(author, discord.Member) and not author.bot
|
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)
|
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
|
return
|
||||||
|
|
||||||
await self.check_filter(message)
|
await self.check_filter(message)
|
||||||
|
|||||||
@ -1241,10 +1241,12 @@ class Mod:
|
|||||||
if message.guild is None or self.bot.user == author:
|
if message.guild is None or self.bot.user == author:
|
||||||
return
|
return
|
||||||
valid_user = isinstance(author, discord.Member) and not author.bot
|
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
|
# Bots and mods or superior are ignored from the filter
|
||||||
mod_or_superior = await is_mod_or_superior(self.bot, obj=author)
|
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
|
return
|
||||||
deleted = await self.check_duplicates(message)
|
deleted = await self.check_duplicates(message)
|
||||||
if not deleted:
|
if not deleted:
|
||||||
@ -1382,4 +1384,4 @@ mute_unmute_issues = {
|
|||||||
"permissions_issue": "Failed to mute user. I need the manage roles "
|
"permissions_issue": "Failed to mute user. I need the manage roles "
|
||||||
"permission and the user I'm muting must be "
|
"permission and the user I'm muting must be "
|
||||||
"lower than myself in the role hierarchy."
|
"lower than myself in the role hierarchy."
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,7 +124,7 @@ async def is_mod_or_superior(
|
|||||||
user = None
|
user = None
|
||||||
if isinstance(obj, discord.Message):
|
if isinstance(obj, discord.Message):
|
||||||
user = obj.author
|
user = obj.author
|
||||||
elif isinstance(obj, discord.Member) or isinstance(obj, discord.User):
|
elif isinstance(obj, discord.Member):
|
||||||
user = obj
|
user = obj
|
||||||
elif isinstance(obj, discord.Role):
|
elif isinstance(obj, discord.Role):
|
||||||
pass
|
pass
|
||||||
@ -214,7 +214,7 @@ async def is_admin_or_superior(
|
|||||||
user = None
|
user = None
|
||||||
if isinstance(obj, discord.Message):
|
if isinstance(obj, discord.Message):
|
||||||
user = obj.author
|
user = obj.author
|
||||||
elif isinstance(obj, discord.Member) or isinstance(obj, discord.User):
|
elif isinstance(obj, discord.Member):
|
||||||
user = obj
|
user = obj
|
||||||
elif isinstance(obj, discord.Role):
|
elif isinstance(obj, discord.Role):
|
||||||
pass
|
pass
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user