Ejemplo n.º 1
0
    async def convert(self, ctx, argument: str):
        faction_roles = dataIO.get_Info('config.json').faction_roles

        if argument.lower() in ('random', 'rand'):
            role = random.choice(faction_roles)
            while role in tuple(r.id for r in ctx.author.roles):
                role = random.choice(faction_roles)
            return role

        if argument.lower() in ('nightcats', 'nightcat'):
            return 749263980840747061

        if argument.isdigit():
            faction_role = faction_roles[
                int(argument) - 1] if int(argument) <= len(
                    faction_roles) else 9999999999999999999999999999
            return faction_role

        args = argument.split(' ')
        ret = ''.join((
            args[0][0].upper() + args[0][1:].lower() + ' ' +
            args[1][0].upper() +
            args[1][1:].lower()) if len(args) > 1 else args[0][0].upper() +
                      args[0][1:].lower())
        try:
            r = await commands.RoleConverter().convert(ctx, ret)
        except commands.BadArgument:
            try:
                return int(argument, base=10)
            except ValueError:
                raise commands.BadArgument(
                    f"{argument} is not a valid role.") from None
        else:
            return r.id
Ejemplo n.º 2
0
    def __init__(self, bot):
        self.bot = bot
        self.config = dataIO.get_Info("config.json")
        self.process = psutil.Process(os.getpid())

        self.__old_on_error = bot.on_error
        bot.on_error = self.on_error
Ejemplo n.º 3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.config = dataIO.get_Info('config.json')
        self.to_load: typing.List[str] = None

        self.ww = WebWorker(self)
        self.iw = InternalWorker(self)

        self.ww.dbh.set_db("kyo_server")
Ejemplo n.º 4
0
async def main():
    config = dataIO.get_Info('config.json')

    intents = discord.Intents.all()

    bot = NianBot(command_prefix=config.prefix,
                  prefix=config.prefix,
                  command_attrs=dict(hidden=True),
                  case_insensitive=True,
                  help_command=HelpFormat(),
                  intents=intents)

    bot.discover_exts('cogs')
    # bot.load_extension('jishaku')
    await bot.start(os.getenv('token'))
Ejemplo n.º 5
0
 def __init__(self, bot):
     self.bot = bot
     self.config = dataIO.get_Info("config.json")
Ejemplo n.º 6
0
 def __init__(self, bot):
     self.bot = bot
     self.config = dataIO.get_Info("config.json")
     self.auto_answers = dataIO.get_Info("auto_answers.json")
     self.answers_counter = 0
Ejemplo n.º 7
0
import discord
from utils import utils, dataIO
from discord.ext import commands

data = dataIO.get_Info('config.json')

# possible to shorten this?


def is_owner():
    def predicate(ctx: commands.Context) -> bool:
        if not ctx.guild:
            return False

        return ctx.author.id in data.owners

    return commands.check(predicate)


def is_admin():
    async def predicate(ctx: commands.Context) -> bool:
        if not ctx.guild:
            return False

        if any(role.id in data.admin_roles
               for role in ctx.author.roles) or await check_guild_permissions(
                   ctx, {'manage_guild': True}):
            return True

        # await ctx.send(f'you don\'t have permission to {ctx.command}')
        return False
Ejemplo n.º 8
0
Archivo: fun.py Proyecto: yyj3/nianbot
 def __init__(self, bot):
     self.bot = bot
     self.config = dataIO.get_Info("config.json")
     self.trans = googletrans.Translator()
Ejemplo n.º 9
0
 def __init__(self, bot):
     self.bot = bot
     self.config = dataIO.get_Info("config.json")
     self.process = psutil.Process(os.getpid())