fix(seautils): catch the error that is raised if dig is not installed on the system

This commit is contained in:
Seaswimmer 2024-05-28 18:01:35 -04:00
parent 7a2ee0a655
commit d444242245
Signed by untrusted user: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -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: