Skip to content

Commit

Permalink
[Mod] Allow external custom case creation (#1391)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebj authored and Twentysix26 committed Mar 17, 2018
1 parent b21bb9a commit 0dafcfa
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cogs/mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,14 +1356,16 @@ def is_allowed_by_hierarchy(self, server, mod, user):
else:
return mod.top_role.position > user.top_role.position or is_special

async def new_case(self, server, *, action, mod=None, user, reason=None, until=None, channel=None):
async def new_case(self, server, *, action, mod=None, user, reason=None, until=None, channel=None, force_create=False):
action_type = action.lower() + "_cases"
if not self.settings[server.id].get(action_type, default_settings[action_type]):
return

enabled_case = self.settings.get(server.id, {}).get(action_type, default_settings.get(action_type))
if not force_create and not enabled_case:
return False

mod_channel = server.get_channel(self.settings[server.id]["mod-log"])
if mod_channel is None:
return
return None

if server.id not in self.cases:
self.cases[server.id] = {}
Expand All @@ -1384,7 +1386,7 @@ async def new_case(self, server, *, action, mod=None, user, reason=None, until=N
"amended_by" : None,
"amended_id" : None,
"message" : None,
"until" : None,
"until" : until.timestamp() if until else None,
}

case_msg = self.format_case_msg(case)
Expand All @@ -1402,6 +1404,8 @@ async def new_case(self, server, *, action, mod=None, user, reason=None, until=N

dataIO.save_json("data/mod/modlog.json", self.cases)

return case_n

async def update_case(self, server, *, case, mod=None, reason=None,
until=False):
channel = server.get_channel(self.settings[server.id]["mod-log"])
Expand Down

0 comments on commit 0dafcfa

Please sign in to comment.