From d44424224584b5cfba84869dd3481b1aaafca8ec Mon Sep 17 00:00:00 2001 From: Seaswimmer Date: Tue, 28 May 2024 18:01:35 -0400 Subject: [PATCH] fix(seautils): catch the error that is raised if dig is not installed on the system --- seautils/seautils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/seautils/seautils.py b/seautils/seautils.py index ad22a84..e68f3f3 100644 --- a/seautils/seautils.py +++ b/seautils/seautils.py @@ -8,6 +8,7 @@ import asyncio import inspect import operator +from asyncio.subprocess import Process from functools import partial, partialmethod from typing import Any @@ -97,8 +98,13 @@ class SeaUtils(commands.Cog): command_opts.extend(['-p', port]) command_opts.extend(['+yaml']) - process = await asyncio.create_subprocess_exec(*command_opts, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE) - stdout, stderr = await process.communicate() + try: + process: Process = await asyncio.create_subprocess_exec(*command_opts, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE) + stdout, stderr = await process.communicate() + except (FileNotFoundError): + await ctx.maybe_send_embed(content="The `dig` command is not installed on this system.") + return + if stderr: await ctx.maybe_send_embed(content= "An error was encountered!\n" + cf.box(text=stderr.decode())) else: