Skip to content

Commit 1201f21

Browse files
committed
Moved db query to core/client;py
1 parent 3137598 commit 1201f21

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

bot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,9 @@ async def process_commands(self, message):
872872
self.config["anon_reply_without_command"]
873873
)
874874
except ValueError:
875-
anon_reply_without_command = self.config.remove("anon_reply_without_command")
875+
anon_reply_without_command = self.config.remove(
876+
"anon_reply_without_command"
877+
)
876878

877879
if anon_reply_without_command:
878880
await thread.reply(message, anonymous=True)

cogs/modmail.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -737,19 +737,7 @@ async def logs_responded(self, ctx, *, user: User = None):
737737
"""
738738
user = user if user is not None else ctx.author
739739

740-
entries = []
741-
async for l in self.bot.db.logs.find(
742-
{
743-
"messages": {
744-
"$elemMatch": {
745-
"author.id": str(user.id),
746-
"author.mod": True,
747-
"type": {"$in": ["anonymous", "thread_message"]},
748-
}
749-
}
750-
}
751-
):
752-
entries.append(l)
740+
entries = await self.bot.api.get_responded_logs(user.id)
753741

754742
embeds = self.format_log_embeds(entries, avatar_url=self.bot.guild.icon_url)
755743

core/clients.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ async def get_user_logs(self, user_id: Union[str, int]) -> list:
9292

9393
return await self.logs.find(query, projection).to_list(None)
9494

95+
async def get_responded_logs(self, user_id: Union[str, int]) -> list:
96+
entries = []
97+
async for l in self.bot.db.logs.find(
98+
{
99+
"open": False,
100+
"messages": {
101+
"$elemMatch": {
102+
"author.id": str(user_id),
103+
"author.mod": True,
104+
"type": {"$in": ["anonymous", "thread_message"]},
105+
}
106+
}
107+
}
108+
):
109+
entries.append(l)
110+
return entries
111+
95112
async def get_log(self, channel_id: Union[str, int]) -> dict:
96113
logger.debug("Retrieving channel %s logs.", channel_id)
97114
return await self.logs.find_one({"channel_id": str(channel_id)})

0 commit comments

Comments
 (0)