better error handling
This commit is contained in:
@@ -19,6 +19,10 @@ async def on_message(message):
|
|||||||
if message.author == discord_client.user:
|
if message.author == discord_client.user:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if message.content.isspace():
|
||||||
|
await message.channel.send('### Empty message')
|
||||||
|
return
|
||||||
|
|
||||||
response = chat_client.input(message.content)
|
response = chat_client.input(message.content)
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
|||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(json.dumps(response).encode("utf-8"))
|
self.wfile.write(json.dumps(response).encode("utf-8"))
|
||||||
except:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user