From 259d8ea8d69e86ba0eea6fdc2c8901c16a2c49bc Mon Sep 17 00:00:00 2001 From: Paillat Date: Mon, 6 Feb 2023 00:40:06 +0100 Subject: [PATCH] Update main.py --- code/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/main.py b/code/main.py index db302a6..ca91b4f 100644 --- a/code/main.py +++ b/code/main.py @@ -1,7 +1,7 @@ import openai # from openai import api_key import discord -from discord import Intents +from discord import Intents, ApplicationCommandOptionType from discord.commands import slash_command, option from discord.ext import commands import re @@ -163,6 +163,10 @@ async def on_ready(): #if the data directory doesn't exist we create it if not os.path.exists("data"): os.mkdir("data") +@bot.event +async def on_application_command_error(ctx, error): + #if there is an error we send a message to the user + await ctx.respond(f"An error occured: {error}", ephemeral=True) #get the openai key drom he key.env file token = os.getenv("TOKEN") apikey = os.getenv("OPENAI")