fix(seautils): catch the error that is raised if dig is not installed on the system
This commit is contained in:
parent
7a2ee0a655
commit
d444242245
1 changed files with 8 additions and 2 deletions
|
@ -8,6 +8,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import inspect
|
import inspect
|
||||||
import operator
|
import operator
|
||||||
|
from asyncio.subprocess import Process
|
||||||
from functools import partial, partialmethod
|
from functools import partial, partialmethod
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
@ -97,8 +98,13 @@ class SeaUtils(commands.Cog):
|
||||||
command_opts.extend(['-p', port])
|
command_opts.extend(['-p', port])
|
||||||
command_opts.extend(['+yaml'])
|
command_opts.extend(['+yaml'])
|
||||||
|
|
||||||
process = await asyncio.create_subprocess_exec(*command_opts, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
try:
|
||||||
|
process: Process = await asyncio.create_subprocess_exec(*command_opts, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
||||||
stdout, stderr = await process.communicate()
|
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:
|
if stderr:
|
||||||
await ctx.maybe_send_embed(content= "An error was encountered!\n" + cf.box(text=stderr.decode()))
|
await ctx.maybe_send_embed(content= "An error was encountered!\n" + cf.box(text=stderr.decode()))
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue