Repository navigation
Expand file tree
/
Copy pathprogram_test.py
More file actions
57 lines (46 loc) · 1.54 KB
/
Copy pathprogram_test.py
File metadata and controls
57 lines (46 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import nextcord
import os
import sys
import json
import traceback
from motor import motor_asyncio
from util import nira
from util.settings import BotSettings
SETTING = json.load(open(f"{sys.path[0]}/setting.json", "r"))
_MONGO_CLIENT = motor_asyncio.AsyncIOMotorClient(SETTING["database_url"])
bot = nira.NIRA(
help_command=None,
mongo=_MONGO_CLIENT, # mongo_db
database_name=SETTING["database_name"],
shard_id=SETTING["shard_id"],
shard_count=SETTING["shard_count"],
settings=BotSettings.model_validate(SETTING),
)
print("NIRA Test")
print(f"nextcord version: {nextcord.__version__}")
cogs = [cog for cog in os.listdir("cogs") if cog != "__pycache__"]
print(f"Cog(s) under test: {cogs}")
print("##### Starting test... #####")
success = 0
for cog in cogs:
print(f"? {cog}", end="")
if os.path.isdir(f"cogs/{cog}"):
if os.path.exists(f"cogs/{cog}/__init__.py"):
print(f"\rD {cog}")
print(f" ? {cog}/__init__.py", end="")
try:
bot.load_extension(f"cogs.{cog}")
success += 1
print(f"\r O {cog}/__init__.py")
except Exception as err:
print(f"\r ! {cog}/__init__.py\n{err}")
traceback.print_exc()
continue
try:
bot.load_extension(f"cogs.{'.'.join(cog.split('.')[:-1])}")
success += 1
print(f"\rO {cog}")
except Exception as err:
print(f"\r! {cog}\n{err}")
traceback.print_exc()
print(f"##### Test finished. {success}/{len(cogs)} succeeded. #####")