From aefdd7a72a1c4a85e05a24635b34bb2a6d623191 Mon Sep 17 00:00:00 2001 From: Jia Rong Yee Date: Tue, 14 Nov 2017 19:23:40 +0800 Subject: [PATCH] no idea why modlog isnt wokring here, did for #33 @verixx or @xaos1502, if possible please help :( --- cogs/mod.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cogs/mod.py b/cogs/mod.py index c980853d..e8352bf2 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -31,6 +31,7 @@ import pip import os import io +import json class Mod: @@ -40,7 +41,7 @@ def __init__(self, bot): async def format_mod_embed(self, ctx, user, success, method, duration = None, location=None): '''Helper func to format an embed to prevent extra code''' - emb = discord.Embed() + emb = discord.Embed(timestamp=ctx.message.created_at) emb.set_author(name=method.title(), icon_url=user.avatar_url) emb.color = await ctx.get_dominant_color(user.avatar_url) emb.set_footer(text=f'User ID: {user.id}') @@ -60,7 +61,19 @@ async def format_mod_embed(self, ctx, user, success, method, duration = None, lo emb.description = f"You do not have the permissions to {method} `{location.name}`." else: emb.description = f"You do not have the permissions to {method} {user.name}." - + + with open('data/config.json') as f: + config = json.load(f) + modlog = os.environ.get('MODLOG') or config.get('MODLOG') + if modlog is None: + await ctx.send('You have not set `MODLOG` in your config vars.', delete_after=5) + else: + modlog = discord.utils.get(self.bot.get_all_channels(), id=int(modlog)) + if modlog is None: + await ctx.send('Your `MODLOG` channel ID is invalid.', delete_after=5) + else: + await modlog.send(embed=emb) + return emb @commands.command()