From 74d1b6cb9b63484ad7be8db2283d89adc16a1ff5 Mon Sep 17 00:00:00 2001 From: Dylan Dizon Date: Tue, 6 Nov 2018 16:28:19 -0500 Subject: [PATCH] Add newline switch for different formatting logic --- src/cogs/owner.py | 2 +- src/utils/formatter.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cogs/owner.py b/src/cogs/owner.py index af6a3c2..d832c92 100644 --- a/src/cogs/owner.py +++ b/src/cogs/owner.py @@ -95,7 +95,7 @@ class Bot: if v: permissions[member.mention].append(k) - await ctx.send(f'**Permissions:**\n\n{formatter.dict_tostring(permissions, f=False)}') + await ctx.send(f'**Permissions:**\n\n{formatter.dict_tostring(permissions, f=False, newline=True)}') @cmds.command(name=',tasks', aliases=[',task']) @cmds.is_owner() diff --git a/src/utils/formatter.py b/src/utils/formatter.py index d6fe811..024054f 100644 --- a/src/utils/formatter.py +++ b/src/utils/formatter.py @@ -20,17 +20,21 @@ def tostring_commas(i): return '' -def dict_tostring(i, f=True): +def dict_tostring(i, f=True, newline=False): o = '' if f: if i: for k, v in i.items(): o += '**' + k + ':** `' + tostring(v) + '`\n' + elif newline is True: + if i: + for k, v in i.items(): + o += k + ': ```' + tostring(v, newline=newline) + '```\n' else: if i: for k, v in i.items(): - o += k + ': ```' + tostring(v, newline=True) + '```\n' + o += k + ': ```' + tostring(v) + '```\n' return o