예제 #1
0
 def load_module(self, module):
     try:
         self.load_extension("cogs.{}".format(module))
         cOut("Loaded module: {}".format(module))
         return True
     except Exception as e:
         cOut("Failed to load module {}: {}".format(module, e))
         return False
예제 #2
0
    def load_all(self):
        success, total = 0, 0

        for i in [
                f.replace(".py", "") for f in os.listdir("cogs")
                if os.path.isfile("cogs/" + f)
        ]:
            total += 1
            if self.load_module(i):
                success += 1
        cOut("Finished loading modules. ({}/{} Successful)".format(
            success, total))
예제 #3
0
파일: owner.py 프로젝트: xxcodianxx/Sparks
    async def sudo(self, ctx, user:discord.Member, *, cmd):
        sudo_msg = ctx.message

        if user is None:
            raise commands.BadArgument("Invalid user.")

        sudo_msg.author = user
        sudo_msg.content = cmd

        sudo_ctx = await self.bot.get_context(sudo_msg)
        response = await self.bot.invoke(sudo_ctx)

        cOut("SUDO: User '{0}' (ID {0.id}) executed '{1}' as '{2}' (ID {2.id}). RESULT: {3}".format(ctx.author, sudo_msg.content, sudo_ctx.author, response))
예제 #4
0
    def __init__(self):
        super().__init__(command_prefix=None,
                         description=bd.conf["description"])

        if not os.path.isdir("cogs"):
            os.mkdir("cogs")

        try:
            print("\n-----")
            cOut("Starting bot session...")
            self.maintenance = False

            self.add_check(self.maintenance_mode)
            self.run(bd.conf["token"])

        except discord.LoginFailure as e:
            cOut("Authentication error: {}".format(e))

            # RESET TOKEN
            bd.conf["token"] = ""
            with open("config.json", "w") as f:
                json.dump(bd.conf, f, indent=4)

            raise end()

        except ClientConnectionError as e:
            cOut("Connection error: {}".format(e))
            raise end()

        except Exception as e:
            cOut("Launch error: {}".format(e))
            raise end()
예제 #5
0
    async def on_ready(self):
        cOut("Bot is now accepting commands.\n-----")
        cOut("USERNAME: {}".format(self.user))
        cOut("ID: {}".format(self.user.id))
        cOut("Connected to {} guilds.\n-----".format(len(self.guilds)))

        self.load_all()
        self.startTime = time.time()

        self.loop.create_task(self.presence_changer())
예제 #6
0
 async def on_resumed(self):
     cOut("Client has regained connection.")
예제 #7
0
 async def on_disconnect(self):
     cOut("Client has lost connection.")
예제 #8
0
 async def on_connect(self):
     cOut("Connection established with latency: {}ms".format(
         int(self.latency * 1000)))