def main(): config = default.get_from_env("CONFIG") if config is None: exit(3) print("機器人登入中 ...") bot = Bot(command_prefix=config.prefix, prefix=config.prefix, command_attrs=dict(hidden=True), help_command=HelpFormat()) for file in os.listdir("cogs"): if file.endswith(".py"): name = file[:-3] bot.load_extension(f"cogs.{name}") token = os.environ.get("TOKEN") if token is None: exit(2) bot.run(token)
import discord from utils import default from discord.ext import commands owners = default.get_from_env("CONFIG").owners def is_owner(ctx): return ctx.author.id in owners async def check_permissions(ctx, perms, *, check=all): if ctx.author.id in owners: return True resolved = ctx.channel.permissions_for(ctx.author) return check( getattr(resolved, name, None) == value for name, value in perms.items()) def has_permissions(*, check=all, **perms): async def pred(ctx): return await check_permissions(ctx, perms, check=check) return commands.check(pred) async def check_priv(ctx, member): try:
def __init__(self, bot): self.bot = bot self.config = default.get_from_env("CONFIG") self.process = psutil.Process(os.getpid())
def __init__(self, bot): self.bot = bot self.config = default.get_from_env("CONFIG")
def __init__(self, bot): self.bot = bot self.config = default.get_from_env("CONFIG") self._last_result = None