2017-09-24 15:05:28 +00:00
|
|
|
import asyncio
|
|
|
|
import json
|
|
|
|
import traceback
|
2017-10-16 06:07:15 +00:00
|
|
|
from contextlib import suppress
|
2017-10-13 02:26:22 +00:00
|
|
|
|
2017-10-16 06:07:15 +00:00
|
|
|
import discord as d
|
2017-10-15 05:35:20 +00:00
|
|
|
from discord import errors as err
|
2017-09-24 15:05:28 +00:00
|
|
|
from discord.ext import commands
|
2017-10-15 05:35:20 +00:00
|
|
|
from discord.ext.commands import errors as errext
|
2017-09-24 15:05:28 +00:00
|
|
|
|
2017-10-14 03:39:12 +00:00
|
|
|
from utils import utils as u
|
2017-09-24 15:05:28 +00:00
|
|
|
|
2017-10-14 03:39:12 +00:00
|
|
|
owner_id = u.config['owner_id']
|
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-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):
|
2017-10-16 06:07:15 +00:00
|
|
|
if isinstance(ctx.message.channel, d.TextChannel):
|
2017-09-24 15:05:28 +00:00
|
|
|
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):
|
2017-10-17 05:49:52 +00:00
|
|
|
with suppress(AttributeError):
|
|
|
|
if ctx.guild.id in u.settings['del_ctx'] and ctx.me.permissions_in(ctx.channel).manage_messages and isinstance(ctx.message.channel, d.TextChannel):
|
|
|
|
with suppress(err.NotFound):
|
|
|
|
await ctx.message.delete()
|
2017-09-24 15:05:28 +00:00
|
|
|
return True
|
|
|
|
return commands.check(predicate)
|