refactor contest to bot folder, work on generic sqlite update query generator, work on new submissions/voting period logic commands, get away from get_submission_channel

This commit is contained in:
Xevion
2021-02-12 17:46:46 -06:00
parent 5defafa36e
commit 89b16fdc04
7 changed files with 100 additions and 22 deletions

15
bot/checks.py Normal file
View File

@@ -0,0 +1,15 @@
from discord.ext import commands
def check_permissions(ctx, perms, *, check=all):
resolved = ctx.channel.permissions_for(ctx.author)
return check(getattr(resolved, name, None) == value for name, value in perms.items())
def privileged():
def predicate(ctx):
return (ctx.guild is not None and ctx.guild.owner_id == ctx.author.id) \
or check_permissions(ctx, {'manage_guild': True}) \
or check_permissions(ctx, {'administrator': True})
return commands.check(predicate)