1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-02 13:12:40 +00:00
modufur/src/main/misc/checks.py

66 lines
1.4 KiB
Python
Raw Normal View History

2017-09-24 15:05:28 +00:00
import asyncio
import json
import traceback
2017-10-13 02:26:22 +00:00
import discord
2017-09-24 15:05:28 +00:00
from discord.ext import commands
from discord.ext.commands import errors
with open('config.json') as infile:
config = json.load(infile)
owner_id = config['owner_id']
2017-10-02 19:20:50 +00:00
listed_ids = config['listed_ids']
2017-09-24 15:05:28 +00:00
2017-10-13 02:26:22 +00:00
2017-09-24 15:05:28 +00:00
def is_owner():
async def predicate(ctx):
return ctx.message.author.id == owner_id
return commands.check(predicate)
2017-10-13 02:26:22 +00:00
2017-09-24 15:05:28 +00:00
def is_admin():
def predicate(ctx):
return ctx.message.author.guild_permissions.administrator
return commands.check(predicate)
2017-10-13 02:26:22 +00:00
2017-09-24 15:05:28 +00:00
def is_mod():
def predicate(ctx):
return ctx.message.author.guild_permissions.ban_members
return commands.check(predicate)
2017-10-13 02:26:22 +00:00
2017-10-02 19:20:50 +00:00
def is_listed():
def predicate(ctx):
return ctx.message.author.id in listed_ids
return commands.check(predicate)
2017-09-24 15:05:28 +00:00
2017-10-13 02:26:22 +00:00
2017-09-24 15:05:28 +00:00
def owner(ctx):
return ctx.message.author.id == owner_id
2017-10-13 02:26:22 +00:00
2017-09-24 15:05:28 +00:00
def admin(ctx):
return ctx.message.author.guild_permissions.administrator
2017-10-13 02:26:22 +00:00
2017-09-24 15:05:28 +00:00
def mod(ctx):
return ctx.message.author.guild_permissions.ban_members
2017-10-13 02:26:22 +00:00
2017-09-24 15:05:28 +00:00
def is_nsfw():
def predicate(ctx):
if isinstance(ctx.message.channel, discord.TextChannel):
return ctx.message.channel.is_nsfw()
return True
return commands.check(predicate)
2017-10-13 02:26:22 +00:00
2017-09-24 15:05:28 +00:00
def del_ctx():
async def predicate(ctx):
if isinstance(ctx.message.channel, discord.TextChannel):
await ctx.message.delete()
return True
return commands.check(predicate)