diff --git a/cogs/basic.py b/cogs/basic.py index e041e8c..65de67c 100644 --- a/cogs/basic.py +++ b/cogs/basic.py @@ -9,7 +9,7 @@ class Basic(commands.Cog): @commands.command() async def ping(self, ctx): - await ctx.send("pong!") + await ctx.send(f"Pong! **{round(self.client.latency*1000, 1)}ms**") @commands.command(aliases=["cp"], brief="Change the guild-wide bot prefix", usage="") @commands.guild_only() diff --git a/cogs/lydia.py b/cogs/lydia.py index 6eeaa93..5f26499 100644 --- a/cogs/lydia.py +++ b/cogs/lydia.py @@ -14,33 +14,34 @@ class Lydia(commands.Cog): @commands.command(aliases=["lydia"], brief="Have a chat with Lydia", usage="") async def ai(self, ctx, *, quest): - self.cur.execute(f'SELECT * FROM sessions WHERE user_id="{ctx.author.id}"') - query = self.cur.fetchone() + async with ctx.channel.typing(): + self.cur.execute(f'SELECT * FROM sessions WHERE user_id="{ctx.author.id}"') + query = self.cur.fetchone() - if query == None: - session = self.lydia.create_session() - self.cur.execute(f"INSERT INTO sessions VALUES ('{ctx.author.id}','{session.id}','{session.expires}')") - self.conn.commit() - - await ctx.send(session.think_thought(quest)) - else: - #give it a 50 second margin to avoid possible errors - if query[2]-50 < int(time.time()): - self.cur.execute(f'DELETE FROM sessions WHERE session_id = "{query[1]}"') + if query == None: session = self.lydia.create_session() self.cur.execute(f"INSERT INTO sessions VALUES ('{ctx.author.id}','{session.id}','{session.expires}')") self.conn.commit() await ctx.send(session.think_thought(quest)) - #or alternatively - #reply = session.think_thought(quest) - #await ctx.send(reply) - else: - await ctx.send(self.lydia.think_thought(query[1], quest)) - #or alternatively - #reply = self.lydia.think_thought(query[1], quest) - #await ctx.send(reply) + #give it a 50 second margin to avoid possible errors + if query[2]-50 < int(time.time()): + self.cur.execute(f'DELETE FROM sessions WHERE session_id = "{query[1]}"') + session = self.lydia.create_session() + self.cur.execute(f"INSERT INTO sessions VALUES ('{ctx.author.id}','{session.id}','{session.expires}')") + self.conn.commit() + + await ctx.send(session.think_thought(quest)) + #or alternatively + #reply = session.think_thought(quest) + #await ctx.send(reply) + + else: + await ctx.send(self.lydia.think_thought(query[1], quest)) + #or alternatively + #reply = self.lydia.think_thought(query[1], quest) + #await ctx.send(reply) #uncomment this if you use the alternatives #print(f"[<]{ctx.message.author}: {quest}\n[>]{reply}")