Validate that user exists, and validate context arguments, closes #143
This commit is contained in:
parent
57f21cd3e4
commit
f4da3dd5c9
1 changed files with 12 additions and 1 deletions
|
@ -11,7 +11,12 @@ from naff.models.discord.embed import EmbedField
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
|
|
||||||
MODLOG_LOOKUP = {"Ban": Ban, "Kick": Kick, "Mute": Mute, "Warning": Warning}
|
MODLOG_LOOKUP = {"Ban": Ban, "Kick": Kick, "Mute": Mute, "Warning": Warning}
|
||||||
IGNORE_COMMANDS = {"Ban": ["bans"], "Kick": [], "Mute": ["unmute"], "Warning": ["warnings"]}
|
IGNORE_COMMANDS = {
|
||||||
|
"Ban": ["bans", "unban"],
|
||||||
|
"Kick": [],
|
||||||
|
"Mute": ["unmute"],
|
||||||
|
"Warning": ["warnings"],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class ModcaseCog(Extension):
|
class ModcaseCog(Extension):
|
||||||
|
@ -36,6 +41,12 @@ class ModcaseCog(Extension):
|
||||||
if not user and not ctx.target_id:
|
if not user and not ctx.target_id:
|
||||||
self.logger.warning("Admin action %s missing user, exiting", name)
|
self.logger.warning("Admin action %s missing user, exiting", name)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if isinstance(user, str):
|
||||||
|
user = await self.bot.fetch_user(user)
|
||||||
|
if not user:
|
||||||
|
self.logger.warning("User does not exist")
|
||||||
|
return
|
||||||
if ctx.target_id:
|
if ctx.target_id:
|
||||||
user = ctx.target
|
user = ctx.target
|
||||||
coll = MODLOG_LOOKUP.get(name, None)
|
coll = MODLOG_LOOKUP.get(name, None)
|
||||||
|
|
Loading…
Add table
Reference in a new issue