1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2025-01-20 14:45:20 +00:00
modufur/src/main/misc/checks.py

65 lines
1.5 KiB
Python
Raw Normal View History

2017-09-24 11:05:28 -04:00
import asyncio
import json
import traceback
2017-10-12 22:26:22 -04:00
import discord
2017-09-24 11:05:28 -04:00
from discord.ext import commands
from discord.ext.commands import errors
2017-10-13 23:39:12 -04:00
from utils import utils as u
2017-09-24 11:05:28 -04:00
2017-10-13 23:39:12 -04:00
owner_id = u.config['owner_id']
listed_ids = u.config['listed_ids']
2017-09-24 11:05:28 -04:00
2017-10-12 22:26:22 -04:00
2017-09-24 11:05:28 -04:00
def is_owner():
async def predicate(ctx):
return ctx.message.author.id == owner_id
return commands.check(predicate)
2017-10-12 22:26:22 -04:00
2017-09-24 11:05:28 -04:00
def is_admin():
def predicate(ctx):
return ctx.message.author.guild_permissions.administrator
return commands.check(predicate)
2017-10-12 22:26:22 -04:00
2017-09-24 11:05:28 -04:00
def is_mod():
def predicate(ctx):
return ctx.message.author.guild_permissions.ban_members
return commands.check(predicate)
2017-10-12 22:26:22 -04:00
2017-10-02 15:20:50 -04:00
def is_listed():
def predicate(ctx):
return ctx.message.author.id in listed_ids
return commands.check(predicate)
2017-09-24 11:05:28 -04:00
2017-10-12 22:26:22 -04:00
2017-09-24 11:05:28 -04:00
def owner(ctx):
return ctx.message.author.id == owner_id
2017-10-12 22:26:22 -04:00
2017-09-24 11:05:28 -04:00
def admin(ctx):
return ctx.message.author.guild_permissions.administrator
2017-10-12 22:26:22 -04:00
2017-09-24 11:05:28 -04:00
def mod(ctx):
return ctx.message.author.guild_permissions.ban_members
2017-10-12 22:26:22 -04:00
2017-09-24 11:05:28 -04: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-12 22:26:22 -04:00
2017-09-24 11:05:28 -04:00
def del_ctx():
async def predicate(ctx):
2017-10-14 23:40:56 -04:00
if ctx.me.permissions_in(ctx.channel).manage_messages is True and isinstance(ctx.message.channel, discord.TextChannel) and ctx.guild.id in u.settings['del_ctx']:
2017-09-24 11:05:28 -04:00
await ctx.message.delete()
return True
return commands.check(predicate)