From ca56622ca678f58278b70a958fec9574ed00b267 Mon Sep 17 00:00:00 2001 From: jweigele Date: Fri, 23 Jul 2021 10:49:00 -0700 Subject: [PATCH] Better guild fetching for user, and don't spam quite as many exceptions to chat --- grahbot.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) 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): -- 2.30.2