diff --git a/CHANGELOG.md b/CHANGELOG.md index dd09d5b..be14afa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ All notable changes to this project will be documented in this file. you will need to modify manually if you had changed it * Configuration files containing string IDs will have to be changed to numeric (integer) IDs -* Cleaner Markdown doc files +* Better convention compliance for Python and Markdown files #### Removed diff --git a/TODO.md b/TODO.md index cf8369e..d2b6760 100644 --- a/TODO.md +++ b/TODO.md @@ -7,8 +7,7 @@ which may or may not be implemented in future versions. #### Next things to work on -1. Better PEP8/Pylint correctness -2. Additional permissions (bot owner/admin & bots) +1. Additional permissions (bot owner/admin & bots) ### Might be implemented @@ -38,4 +37,4 @@ Special arguments: - annotation for pip requirements - ability to hide from a server (func->bool) -- per server/channel data/config files (FDs) \ No newline at end of file +- per server/channel data/config files (FDs) diff --git a/core.py b/core.py index d001b78..d0fe9b5 100755 --- a/core.py +++ b/core.py @@ -103,7 +103,7 @@ async def process(self, command, command_only, message, guild_ex): for cog in cogs: cog.on_exit() logging.info("All cogs unloaded.") - await self.change_presence(game=None) + await self.change_presence(activity=None) await self.logout() return # Getting command arguments (or not) @@ -178,7 +178,7 @@ def load_dir(path='cogs', base_name='', parent_cog=None): parent_cog.subcogs[name] = cogs.cogs[name] cogs.cogs[name].cog.parent = parent_cog # If a directory containing `__init__.py` is found, load the init and the directory - elif os.path.isdir(full) and gearbox.is_valid(name) and name not in cogs.cogs and name not in cogs.fail: + elif os.path.isdir(full) and gearbox.is_valid(name) and not (name in cogs.cogs or name in cogs.fail): if parent_cog is not None and name in parent_cog.aliases: logging.critical("Sub-cog %s from cog %s couldn't be loaded because " "a command with the same name exists", name, parent_cog.name) @@ -206,18 +206,18 @@ def load_dir(path='cogs', base_name='', parent_cog=None): if name in cogs.cogs: valid_cogs.add(name) for name in valid_cogs: - cogs.cogs.remove(name) + cogs.cogs.pop(name, None) await asyncio.sleep(2) async def on_ready(self): """Initialization.""" self.loop.create_task(websockets.serve(self.on_socket, 'localhost', CFG['port']['websocket'])) - version = discord.Game() - version.name = 'v' + gearbox.version + version = 'v' + gearbox.version if gearbox.version_is_dev: - version.name += ' [dev]' - await super(Bot, self).change_presence(status=discord.Status.idle, game=version) + version += ' [dev]' + game = discord.Game(version) + await super(Bot, self).change_presence(status=discord.Status.idle, activity=game) logging.info('Client started.') @@ -253,9 +253,9 @@ def main(): token = open(CFG['path']['token'], 'r').read().strip() - master = open(CFG['path']['master'], 'r').read().strip() - admins = open(CFG['path']['admins'], 'r').read().splitlines() - banned = open(CFG['path']['banned'], 'r').read().splitlines() + master = int(open(CFG['path']['master'], 'r').read().strip()) + admins = list(map(int, open(CFG['path']['admins'], 'r').read().splitlines())) + banned = list(map(int, open(CFG['path']['banned'], 'r').read().splitlines())) bot = Bot(master, admins, banned) bot.run(token) diff --git a/gearbox.py b/gearbox.py index 9e53adf..8bbd51b 100644 --- a/gearbox.py +++ b/gearbox.py @@ -320,8 +320,8 @@ def __init__(self, func, flags='', *, fulltext=False, delete_message=False, perm self.flags = {c: '' for c in flags} if isinstance(flags, str) else flags # Minimum argument count self.min_arg = len([arg for arg, val in self.params.items() - if arg not in SPECIAL_ARGS and isinstance(val.default, type) - and self.params[arg].kind.name is not 'VAR_POSITIONAL']) + if arg not in SPECIAL_ARGS and isinstance(val.default, type) and + self.params[arg].kind.name is not 'VAR_POSITIONAL']) # Permissions, can be indicated as a string, (string, bool) tuple, or array of any # Ends up being stored as an array of (string, bool) tuples self.permissions = []