From: jweigele Date: Fri, 23 Jul 2021 17:49:00 +0000 (-0700) Subject: Better guild fetching for user, and don't spam quite as many exceptions to chat X-Git-Url: http://git.hexthepla.net/?a=commitdiff_plain;h=ca56622ca678f58278b70a958fec9574ed00b267;p=grahbot Better guild fetching for user, and don't spam quite as many exceptions to chat --- diff --git a/grahbot.py b/grahbot.py index 84e64bd..f45ae83 100755 --- a/grahbot.py +++ b/grahbot.py @@ -490,22 +490,25 @@ class GrahDiscordBot(discord.Client, HornClient, HornProm): log.debug(guilds) potential_command = message.content[1:].split(' ')[0] - if potential_command == 'selectguild': + try: + if potential_command == 'selectguild': + func = self.get_command_func(potential_command) + await func(message, guild=None) + return + + if len(guilds) == 0: + return + elif len(guilds) >1: + await message.channel.send('Too many guilds!!!\n{}'.format('\n'.join([str(x) for x in guilds]))) + return + elif len(guilds) == 1: + log.debug('Guild is {}'.format(guilds[0])) + guild = guilds[0] + func = self.get_command_func(potential_command) - await func(message, guild=None) - return - - if len(guilds) == 0: - return - elif len(guilds) >1: - await message.channel.send('Too many guilds!!!\n{}'.format('\n'.join([str(x) for x in guilds]))) - return - elif len(guilds) == 1: - log.debug('Guild is {}'.format(guilds[0])) - guild = guilds[0] - - func = self.get_command_func(potential_command) - await func(message, guild) + await func(message, guild) + except GrahDiscordException as e: + traceback.print_exc() async def on_message(self, message):