From c150526df89f51a861ca332cbf325daa824ca4a1 Mon Sep 17 00:00:00 2001 From: osmarks Date: Sun, 1 Nov 2020 12:05:01 +0000 Subject: [PATCH] minor refactor --- src/telephone.py | 5 +---- src/util.py | 7 ++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/telephone.py b/src/telephone.py index e9d2adb..3a2fe35 100644 --- a/src/telephone.py +++ b/src/telephone.py @@ -20,9 +20,6 @@ def generate_address(ctx): channel_calls_cache = {} def setup(bot): - async def server_mod_check(ctx): - return ctx.author.permissions_in(ctx.channel).manage_channels or (await bot.is_owner(ctx.author)) - @bot.group(name="apiotelephone", aliases=["tel", "tele", "telephone", "apiotel"], brief="ApioTelephone lets you 'call' other servers.", help=f""" Call other (participating) servers with ApioTelephone! To configure a channel for telephony, do `{bot.command_prefix}tel setup` (requires Manage Channels). It's recommended that you give the bot Manage Webhooks permissions in this channel so that it can use webhook calls mode. @@ -78,7 +75,7 @@ def setup(bot): await asyncio.gather(*map(send_to, calls)) @telephone.command() - @commands.check(server_mod_check) + @commands.check(util.server_mod_check(bot)) async def setup(ctx): num = generate_address(ctx) await ctx.send(f"Your address is {num}.") diff --git a/src/util.py b/src/util.py index 65a247c..d904725 100644 --- a/src/util.py +++ b/src/util.py @@ -224,4 +224,9 @@ def unlyric(text): def gen_codeblock(content): return "```\n" + content.replace("```", "\\`\\`\\`")[:1900] + "\n```" -def json_encode(x): return json.dumps(x, separators=(',', ':')) \ No newline at end of file +def json_encode(x): return json.dumps(x, separators=(',', ':')) + +def server_mod_check(bot): + async def check(ctx): + return ctx.author.permissions_in(ctx.channel).manage_channels or (await bot.is_owner(ctx.author)) + return check \ No newline at end of file