Skip to content

Commit 27d0fd5

Browse files
committed
db api
1 parent 6dc2ef5 commit 27d0fd5

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ ENV/
108108
#MacOS
109109
.DS_Store
110110

111+
# custom
112+
.vscode/
113+
111114
# Modmail
112115
config.json
113116
plugins/

bot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from motor.motor_asyncio import AsyncIOMotorClient
4141

4242
from core.changelog import ChangeLog
43-
from core.clients import ModmailApiClient, SelfHostedClient
43+
from core.clients import ModmailApiClient, SelfHostedClient, PluginDatabaseClient
4444
from core.config import ConfigManager
4545
from core.models import Bot
4646
from core.thread import ThreadManager
@@ -65,6 +65,7 @@ def __init__(self):
6565
self._api = SelfHostedClient(self)
6666
else:
6767
self._api = ModmailApiClient(self)
68+
self.plugin_db = PluginDatabaseClient(self)
6869

6970
self.data_task = self.loop.create_task(self.data_loop())
7071
self.autoupdate_task = self.loop.create_task(self.autoupdate_loop())

cogs/plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def download_initial_plugins(self):
5252
async def download_plugin_repo(username, repo):
5353
try:
5454
cmd = f'git clone https://github.com/{username}/{repo} '
55-
cmd += 'plugins/{username}-{repo} -q'
55+
cmd += f'plugins/{username}-{repo} -q'
5656
subprocess.run(cmd, check=True, capture_output=True)
5757
# -q (quiet) so there's no terminal output unless there's an error
5858
except subprocess.CalledProcessError as exc:

core/checks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from discord.ext import commands
22

3+
34
def has_permissions(**perms):
45
"""Check if the author has required permissions.
56
This will always return ``True`` if the author is a bot owner, or

core/clients.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,12 @@ async def get_user_info(self):
381381
'url': user.url
382382
}
383383
}
384+
385+
386+
class PluginDatabaseClient:
387+
def __init__(self, bot: Bot):
388+
self.bot = bot
389+
390+
def get_partition(self, cog_cls):
391+
cls_name = cog_cls.__class__.__name__
392+
return self.bot.db.plugins[cls_name]

0 commit comments

Comments
 (0)