From e91b9b696315f310a0419406ea7a0e1636af2f6f Mon Sep 17 00:00:00 2001 From: Dev Khant Date: Tue, 5 Sep 2023 21:24:17 +0530 Subject: [PATCH] Handle if no module found for bots --- embedchain/bots/discord.py | 15 +++++++++++---- embedchain/bots/poe.py | 9 +++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/embedchain/bots/discord.py b/embedchain/bots/discord.py index fd6716ec36..24c3094536 100644 --- a/embedchain/bots/discord.py +++ b/embedchain/bots/discord.py @@ -2,14 +2,21 @@ import logging import os -import discord -from discord import app_commands -from discord.ext import commands - from embedchain.helper_classes.json_serializable import register_deserializable from .base import BaseBot +try: + import discord + from discord import app_commands + from discord.ext import commands +except ModuleNotFoundError: + raise ModuleNotFoundError( + "The required dependencies for Discord are not installed." + 'Please install with `pip install "embedchain[discord]"`' + ) from None + + intents = discord.Intents.default() intents.message_content = True client = discord.Client(intents=intents) diff --git a/embedchain/bots/poe.py b/embedchain/bots/poe.py index 17938217a5..83e1145377 100644 --- a/embedchain/bots/poe.py +++ b/embedchain/bots/poe.py @@ -3,12 +3,17 @@ import os from typing import List, Optional -from fastapi_poe import PoeBot, run - from embedchain.helper_classes.json_serializable import register_deserializable from .base import BaseBot +try: + from fastapi_poe import PoeBot, run +except ModuleNotFoundError: + raise ModuleNotFoundError( + "The required dependencies for Poe are not installed." 'Please install with `pip install "embedchain[poe]"`' + ) from None + def start_command(): parser = argparse.ArgumentParser(description="EmbedChain PoeBot command line interface")