Finished log command #44
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import os
|
||||
from datetime import datetime
|
||||
from zipfile import ZipFile
|
||||
|
||||
import discord
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_core.logging import LoggingSettings
|
||||
from cpl_discord.command import DiscordCommandABC
|
||||
@@ -51,7 +53,7 @@ class LogCommand(DiscordCommandABC):
|
||||
@commands.guild_only()
|
||||
@CommandChecks.check_is_ready()
|
||||
@CommandChecks.check_is_member_technician()
|
||||
async def log(self, ctx: Context, date_from: datetime = datetime.now()):
|
||||
async def log(self, ctx: Context):
|
||||
self._logger.debug(__name__, f'Received command log {ctx}')
|
||||
|
||||
possible_log_paths = List(str)
|
||||
@@ -79,7 +81,6 @@ class LogCommand(DiscordCommandABC):
|
||||
possible_log_paths.append(path)
|
||||
|
||||
files = List(str)
|
||||
now = datetime.now()
|
||||
for possible_path in possible_log_paths:
|
||||
for r, d, f in os.walk(possible_path):
|
||||
for file in f:
|
||||
@@ -92,4 +93,10 @@ class LogCommand(DiscordCommandABC):
|
||||
|
||||
files.append(os.path.join(r, file))
|
||||
|
||||
zip_file = ZipFile('logs.zip', 'w')
|
||||
files.for_each(lambda x: zip_file.write(x))
|
||||
zip_file.close()
|
||||
await self._message_service.send_interaction_msg(ctx.interaction, self._t.transform('modules.technician.log_message'), file=discord.File(zip_file.filename, 'logs.zip'), ephemeral=True)
|
||||
os.remove(zip_file.filename)
|
||||
|
||||
self._logger.trace(__name__, f'Finished log command')
|
||||
|
Reference in New Issue
Block a user