mirror of
https://github.com/LuisMayo/ace-attorney-discord-bot.git
synced 2025-06-18 14:25:36 -04:00
fix: avoid clutter from command not found statements (#55)
Also added dependencies
This commit is contained in:
parent
3dc47c8360
commit
4472ca087e
15
Pipfile
Normal file
15
Pipfile
Normal file
@ -0,0 +1,15 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
"discord.py" = "==1.7.3"
|
||||
emoji = "*"
|
||||
pyyaml = "*"
|
||||
objection-engine = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.10"
|
2295
Pipfile.lock
generated
Normal file
2295
Pipfile.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
21
main.py
21
main.py
@ -1,11 +1,10 @@
|
||||
import discord
|
||||
import os
|
||||
import random
|
||||
import requests
|
||||
import traceback
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import json
|
||||
import yaml
|
||||
import gc
|
||||
sys.path.append("./objection_engine")
|
||||
@ -356,6 +355,24 @@ def renderThread():
|
||||
except Exception as exception:
|
||||
print(f"Error: {exception}")
|
||||
|
||||
@courtBot.event
|
||||
async def on_command_error(ctx, error):
|
||||
# Source: https://gist.github.com/EvieePy/7822af90858ef65012ea500bcecf1612
|
||||
ignored = (commands.CommandNotFound, )
|
||||
|
||||
# Allows us to check for original exceptions raised and sent to CommandInvokeError.
|
||||
# If nothing is found. We keep the exception passed to on_command_error.
|
||||
error = getattr(error, 'original', error)
|
||||
|
||||
# Anything in ignored will return and prevent anything happening.
|
||||
if isinstance(error, ignored):
|
||||
return
|
||||
|
||||
# All other Errors not returned come here. And we can just print the default TraceBack.
|
||||
print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
|
||||
traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
|
||||
|
||||
|
||||
backgroundThread = threading.Thread(target=renderThread, name="RenderThread")
|
||||
backgroundThread.start()
|
||||
# Even while threads in python are not concurrent in CPU, the rendering process may use a lot of disk I/O so having two threads
|
||||
|
Loading…
Reference in New Issue
Block a user