Exemplo n.º 1
0
 async def adminError(self, ctx, error):
     if isinstance(error, commands.CheckFailure):
         if ctx.message.author.id in BotState.PERMS.keys():
             if not BotState.PERMS[ctx.message.author.id]["banned"]:
                 await ctx.send(getMessage("notOwner"))
         else:
             await ctx.send(getMessage("notOwner"))
Exemplo n.º 2
0
    async def nick(self, ctx, nickname):

        nickname = "🢒 " + nickname

        BotState.STATUS["nickname"] = nickname
        await ctx.send(getMessage("nickChanged", nickname))
        await ctx.guild.get_member(self.bot.user.id).edit(nick=nickname)
        writeToYAML("application/status.yml", BotState.STATUS)
Exemplo n.º 3
0
    async def reload(self, ctx, ext):

        # if "all" as the argument, reload all enabled cogs
        if ext == "all":
            for extension in BotState.STATUS["availableCogs"]:
                if extension not in BotState.STATUS["disabledCogs"]:
                    self.bot.reload_extension(f'application.{extension}')

            await ctx.send(getMessage("reloadAll"))

        # reload the cog given as the argument
        elif f"cogs.{ext}" not in BotState.STATUS["disabledCogs"]:
            self.bot.reload_extension(f"application.cogs.{ext}")
            await ctx.send(getMessage("reloadCog", ext))

        # write status to file
        writeToYAML("application/status.yml", BotState.STATUS)
Exemplo n.º 4
0
    async def status(self, ctx, game, mode):
        playing = discord.Game(game)
        online = checkStatusMode(mode)

        BotState.STATUS["playingStatus"] = str(playing)
        BotState.STATUS["onlineStatus"] = str(online)
        await ctx.send(getMessage("statusChanged", str(playing), str(online)))
        await self.bot.change_presence(status=online, activity=playing)
        writeToYAML("application/status.yml", BotState.STATUS)
Exemplo n.º 5
0
    async def unban(self, ctx, userid):

        if not isUserid(userid):
            await ctx.send("Give me a userid")
            return

        userid = int(userid)

        # if no permissions set for the userid, set them to default
        if userid not in BotState.PERMS.keys():
            BotState.PERMS[userid] = BotState.DEF_PERMS.copy()

        # if user banned, unban them
        # if user not banned, do nothing
        if BotState.PERMS[userid]["banned"]:
            BotState.PERMS[userid]["banned"] = False
            await ctx.send(getMessage("unBanned", userid))
        else:
            await ctx.send(getMessage("isNotBanned", userid))

        writeToYAML("application/permissions.yml", BotState.PERMS)
Exemplo n.º 6
0
    async def togglePm(self, ctx, userid):

        if not isUserid(userid):
            await ctx.send("Give me a userid")
            return

        userid = int(userid)

        # if no permissions set for the userid, set them to default
        if userid not in BotState.PERMS.keys():
            BotState.PERMS[userid] = BotState.DEF_PERMS.copy()

        # if the user has pm permissions, disable them
        # and if they don't, enable them
        if BotState.PERMS[userid]["pm_user"]:
            BotState.PERMS[userid]["pm_user"] = False
            await ctx.send(getMessage("disablePm", userid))
        else:
            BotState.PERMS[userid]["pm_user"] = True
            await ctx.send(getMessage("enablePm", userid))

        writeToYAML("application/permissions.yml", BotState.PERMS)
Exemplo n.º 7
0
    async def disable(self, ctx, ext):

        # if "all" as the argument, unload all cogs
        if ext == "all":
            for extension in BotState.STATUS["availableCogs"]:
                if extension != "cogs.admin" and extension not in BotState.STATUS["disabledCogs"]:
                    self.bot.unload_extension(f'application.{extension}')
                    BotState.STATUS["disabledCogs"].append(extension)

            await ctx.send(getMessage("disableAll"))

        # unload the cog given as the argument
        elif f"cogs.{ext}" in BotState.STATUS["availableCogs"]:
            if ext != "admin" and ext not in BotState.STATUS["disabledCogs"]:
                self.bot.unload_extension(f"application.cogs.{ext}")
                BotState.STATUS["disabledCogs"].append(f"cogs.{ext}")
                await ctx.send(getMessage("disableCog", ext))

        else:
            await ctx.send(getMessage("cogNotFound", ext))

        # write status to file
        writeToYAML("application/status.yml", BotState.STATUS)
Exemplo n.º 8
0
    async def ban(self, ctx, userid):

        if not isUserid(userid):
            await ctx.send("Give me a userid")
            return

        userid = int(userid)

        # if no permissions set for the userid, set them to default
        if userid not in BotState.PERMS.keys():
            BotState.PERMS[userid] = BotState.DEF_PERMS.copy()

        # if user already banned, do nothing
        # if user not banned, ban them (if not admin)
        if BotState.PERMS[userid]["banned"]:
            await ctx.send(getMessage("alreadyBanned", userid))
        elif not BotState.PERMS[userid]["admin"] and userid != 76579685995118592:
            BotState.PERMS[userid]["banned"] = True
            await ctx.send(getMessage("banned", userid))
        else:
            await ctx.send(getMessage("isAdmin", userid))

        writeToYAML("application/permissions.yml", BotState.PERMS)
Exemplo n.º 9
0
 async def logout(self, ctx):
     await ctx.send(getMessage("logout"))
     await ctx.bot.logout()
Exemplo n.º 10
0
 async def ownerError(self, ctx, error):
     if isinstance(error, commands.NotOwner):
         await ctx.send(getMessage("notOwner"))