diff --git a/README.md b/README.md index e728946..c38cc17 100644 --- a/README.md +++ b/README.md @@ -80,14 +80,14 @@ These commands are grouped, so each group has a prefix but you can easily tab co # Configuration -All the model parameters are configurable inside discord. Type `/settings` to view all the configurable parameters, and use `/settings ` to set parameters. For example, if I wanted to change the number of images generated by DALL-E by default to 4, I can type the following command in discord: `/settings num_images 4` +All the model parameters are configurable inside discord. Type `/system settings` to view all the configurable parameters, and use `/system settings ` to set parameters. + +For example, if I wanted to change the number of images generated by DALL-E by default to 4, I can type the following command in discord: `/system settings num_images 4` # Requirements `python3.9 -m pip install -r requirements.txt` -This project uses openai-async rewrite by Andrew Chen Wang, https://github.com/Andrew-Chen-Wang/openai-python/tree/async-support - **I recommend using python 3.9!** OpenAI API Key (https://beta.openai.com/docs/api-reference/introduction) diff --git a/models/check_model.py b/models/check_model.py index f9b2e74..04931e5 100644 --- a/models/check_model.py +++ b/models/check_model.py @@ -12,6 +12,8 @@ ALLOWED_GUILDS = EnvService.get_allowed_guilds() class Check: def check_admin_roles() -> Callable: async def inner(ctx: discord.ApplicationContext): + if ADMIN_ROLES == [None]: return True + if not any(role.name.lower() in ADMIN_ROLES for role in ctx.user.roles): await ctx.defer(ephemeral=True) await ctx.respond( @@ -26,6 +28,7 @@ class Check: def check_dalle_roles() -> Callable: async def inner(ctx: discord.ApplicationContext): + if DALLE_ROLES == [None]: return True if not any(role.name.lower() in DALLE_ROLES for role in ctx.user.roles): await ctx.defer(ephemeral=True) await ctx.respond( @@ -40,6 +43,7 @@ class Check: def check_gpt_roles() -> Callable: async def inner(ctx: discord.ApplicationContext): + if GPT_ROLES == [None]: return True if not any(role.name.lower() in GPT_ROLES for role in ctx.user.roles): await ctx.defer(ephemeral=True) await ctx.respond( diff --git a/models/env_service_model.py b/models/env_service_model.py index e3bfbd5..520c253 100644 --- a/models/env_service_model.py +++ b/models/env_service_model.py @@ -43,11 +43,13 @@ class EnvService: admin_roles = None if admin_roles is None: - raise ValueError( + print( "ADMIN_ROLES is not defined properly in the environment file!" "Please copy your server's role and put it into ADMIN_ROLES in the .env file." 'For example a line should look like: `ADMIN_ROLES="Admin"`' ) + print("Defaulting to allowing all users to use admin commands...") + return [None] admin_roles = ( admin_roles.lower().split(",") @@ -67,11 +69,13 @@ class EnvService: dalle_roles = None if dalle_roles is None: - raise ValueError( + print( "DALLE_ROLES is not defined properly in the environment file!" "Please copy your server's role and put it into DALLE_ROLES in the .env file." 'For example a line should look like: `DALLE_ROLES="Dalle"`' ) + print("Defaulting to allowing all users to use Dalle commands...") + return [None] dalle_roles = ( dalle_roles.lower().split(",") @@ -91,11 +95,13 @@ class EnvService: gpt_roles = None if gpt_roles is None: - raise ValueError( + print( "GPT_ROLES is not defined properly in the environment file!" "Please copy your server's role and put it into GPT_ROLES in the .env file." 'For example a line should look like: `GPT_ROLES="Gpt"`' ) + print("Defaulting to allowing all users to use GPT commands...") + return [None] gpt_roles = ( gpt_roles.lower().strip().split(",") diff --git a/sample.env b/sample.env index e63ba5d..337a640 100644 --- a/sample.env +++ b/sample.env @@ -1,11 +1,16 @@ OPENAI_TOKEN="" DISCORD_TOKEN="" -DEBUG_GUILD="" -DEBUG_CHANNEL="" -# make sure not to include an id the bot doesn't have access to -ALLOWED_GUILDS="," -# no spaces, case sensitive, these define which roles have access to what. E.g if GPT_ROLES="gpt", then anyone with the "gpt" role can use GPT3 commands. -ADMIN_ROLES="admin,owner" -DALLE_ROLES="admin,openai,dalle" -GPT_ROLES="admin,openai,gpt" -WELCOME_MESSAGE="Hi There! Welcome to our Discord server. We hope you'll enjoy our server and we look forward to engaging with you!" +DEBUG_GUILD="974519864045756446" #discord_server_id +DEBUG_CHANNEL="977697652147892304" #discord_chanel_id +ALLOWED_GUILDS="971268468148166697,971268468148166697" + +# People with the roles in ADMIN_ROLES can use admin commands like /clear-local, and etc +ADMIN_ROLES="Admin,Owner" + +# People with the roles in DALLE_ROLES can use commands like /dalle draw or /dalle imgoptimize +DALLE_ROLES="Admin,Openai,Dalle,gpt" + +# People with the roles in GPT_ROLES can use commands like /gpt ask or /gpt converse +GPT_ROLES="openai,gpt" + +WELCOME_MESSAGE="Hi There! Welcome to our Discord server. We hope you'll enjoy our server and we look forward to engaging with you!" # This is a fallback message if gpt3 fails to generate a welcome message. \ No newline at end of file