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

46 lines
1.2 KiB
Python
Raw Normal View History

2017-09-24 15:05:28 +00:00
import asyncio
import discord
import json
import traceback
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']
def is_owner():
async def predicate(ctx):
return ctx.message.author.id == owner_id
return commands.check(predicate)
def is_admin():
def predicate(ctx):
return ctx.message.author.guild_permissions.administrator
return commands.check(predicate)
def is_mod():
def predicate(ctx):
return ctx.message.author.guild_permissions.ban_members
return commands.check(predicate)
def owner(ctx):
return ctx.message.author.id == owner_id
def admin(ctx):
return ctx.message.author.guild_permissions.administrator
def mod(ctx):
return ctx.message.author.guild_permissions.ban_members
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)
def del_ctx():
async def predicate(ctx):
if isinstance(ctx.message.channel, discord.TextChannel):
await ctx.message.delete()
return True
return commands.check(predicate)