Skip to content

Commit

Permalink
Fixed several rewrite issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeroji committed Jun 17, 2018
1 parent 6024b2a commit 17daa62
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
- per server/channel data/config files (FDs)
20 changes: 10 additions & 10 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.')


Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions gearbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit 17daa62

Please sign in to comment.