Compare commits

...

4 commits

View file

@ -11,14 +11,16 @@ class ExportChannels(commands.Cog):
self.bot = bot
self.config = Config.get_conf(self, identifier=48258471944753312)
self.config.register_global(
bot_token = "0"
bot_token = None
)
def export(self, ctx, channel, token):
async def export(self, channels: list):
token = await self.config.bot_token()
self.data_path = data_manager.cog_data_path(self)
self.bundled_data_path = data_manager.bundled_data_path(self)
out = f'{self.data_path}/Exported Channels'
out = f'{self.data_path}{os.sep}Exported Channels'
channel = channels[0]
try:
os.mkdir(out)
except FileExistsError:
@ -34,8 +36,6 @@ class ExportChannels(commands.Cog):
'--media',
'--fuck_russia', 'true',
]
if bot:
args += '--bot'
os.chdir(self.bundled_data_path)
subprocess.call(args)
args = [
@ -45,13 +45,11 @@ class ExportChannels(commands.Cog):
'--format', 'Json',
'--output', f'/{out}/%G (%g)/%C (%c)/DCE-f.json',
'--token', f'{token}',
'--channel', {channel},
'--channel', {channels},
'--reuse_media',
'--media',
'--fuck_russia', 'true',
]
if bot:
args += '--bot'
os.chdir(self.bundled_data_path)
subprocess.call(args)
@ -67,7 +65,7 @@ class ExportChannels(commands.Cog):
await self.config.bot_token.set({token})
await ctx.send(content="Token set!")
await ctx.delete()
@exportset.command()
@checks.is_owner()
async def checkoutputpath(self, ctx):
@ -77,12 +75,14 @@ class ExportChannels(commands.Cog):
@commands.command()
@commands.admin()
async def exportchannel(self, ctx, channel: discord.Channel):
async def exportchannel(self, ctx, channel: discord.TextChannel):
"""Exports a channel using Discord Chat Exporter."""
token = await self.config.bot_token
token = await self.config.bot_token()
dce_install = data_manager.bundled_data_path(self)
if token == 0:
await ctx.send(content="Please set your token with the ``exportset token`` command!")
if token is None:
await ctx.send(content=f"Please set your token with the ``{ctx.prefix}exportset token`` command!")
return
else:
await self.export(channel.id, token)
id_list = [thread.id for thread in channel.threads]
id_list.insert(0, channel.id)
await self.export(id_list)