Closed MrHedmad closed 1 year ago
I asked on Pydis for how to make this module better. A suggestion was to use prompt-toolkit
(perhaps instead of aioconsole?).
Another useful tip is to wrap stdout to not override the CLI prompt on message:
class WrappedStdout:
def __init__(self, stream):
self.stream = stream
def write(self, message):
# handle it
pass
sys.stdout = WrappedStdout(sys.stdout)
The CLI module (
cli.py
) should be overhauled.discord.py
)A possible solution would be to use an appropriate library such as
click
or similar, but they would need to be capable of async.It is best to move the CLI out of the cogs and into the bot itself, and schedule its execution with
asyncio.Loop.create_task
as the bot starts (run
) and stop it as the bot closes (close
).