From 3543d205f270395ae569346bdcbf1cbea0722d11 Mon Sep 17 00:00:00 2001 From: phxntxm Date: Tue, 7 Mar 2017 17:18:18 -0600 Subject: [PATCH] Update for rewrite: Batch 3 --- bot.py | 4 ++-- cogs/disabled_playlist.py | 2 +- cogs/mod.py | 2 +- cogs/music.py | 2 +- cogs/utils/config.py | 15 +++------------ 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/bot.py b/bot.py index abd5043..f5d5265 100644 --- a/bot.py +++ b/bot.py @@ -94,10 +94,10 @@ async def on_command_error(error, ctx): if isinstance(error, commands.BadArgument): fmt = "Please provide a valid argument to pass to the command: {}".format(error) - await bot.send_message(ctx.message.channel, fmt) + await ctx.message.channel.send(fmt) elif isinstance(error, commands.CheckFailure): fmt = "You can't tell me what to do!" - await bot.send_message(ctx.message.channel, fmt) + await ctx.message.channel.send(fmt) elif isinstance(error, commands.CommandOnCooldown): m, s = divmod(error.retry_after, 60) fmt = "This command is on cooldown! Hold your horses! >:c\nTry again in {} minutes and {} seconds" \ diff --git a/cogs/disabled_playlist.py b/cogs/disabled_playlist.py index 3ec748f..ee33192 100644 --- a/cogs/disabled_playlist.py +++ b/cogs/disabled_playlist.py @@ -30,7 +30,7 @@ class Music: @commands.command(no_pm=True, enabled=False) @checks.custom_perms(send_messages=True) - async def join(self, ctx, *, channel: discord.Channel): + async def join(self, ctx, *, channel: discord.TextChannel): """Joins a voice channel. EXAMPLE: !join Music diff --git a/cogs/mod.py b/cogs/mod.py index d6a6461..7b24449 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -101,7 +101,7 @@ class Mod: @commands.command(no_pm=True) @utils.custom_perms(kick_members=True) - async def alerts(self, ctx, channel: discord.Channel): + async def alerts(self, ctx, channel: discord.TextChannel): """This command is used to set a channel as the server's 'notifications' channel Any notifications (like someone going live on Twitch, or Picarto) will go to that channel diff --git a/cogs/music.py b/cogs/music.py index eda1086..6bc2847 100644 --- a/cogs/music.py +++ b/cogs/music.py @@ -376,7 +376,7 @@ class Music: @commands.command(no_pm=True) @utils.custom_perms(send_messages=True) - async def join(self, *, channel: discord.Channel): + async def join(self, *, channel: discord.TextChannel): """Joins a voice channel.""" try: await self.create_voice_client(channel) diff --git a/cogs/utils/config.py b/cogs/utils/config.py index 2e9c3ab..efa71a3 100644 --- a/cogs/utils/config.py +++ b/cogs/utils/config.py @@ -9,7 +9,7 @@ global_config = {} # Ensure that the required config.yml file actually exists try: with open("config.yml", "r") as f: - global_config = yaml.load(f) + global_config = yaml.safe_load(f) except FileNotFoundError: print("You have no config file setup! Please use config.yml.sample to setup a valid config file") quit() @@ -70,10 +70,6 @@ user_agent = global_config.get('user_agent', "") # The extensions to load extensions = global_config.get('extensions', []) -# The variables needed for sharding -shard_count = global_config.get('shard_count', 1) -shard_id = global_config.get('shard_id', 0) - # The default status the bot will use default_status = global_config.get("default_status", None) # The URL that will be used to link to for the help command @@ -124,14 +120,9 @@ def command_prefix(bot, message): # But it is not worth a query for every single message the bot detects, to fix try: values = cache['prefixes'].values - try: - prefix = [data['prefix'] for data in values if message.server.id == data['server_id']][0] - except IndexError: - prefix = None - except AttributeError: - prefix = None + prefix = [data['prefix'] for data in values if message.server.id == data['server_id']][0] return prefix or default_prefix - except KeyError: + except (KeyError, TypeError, IndexError, AttributeError): return default_prefix