Compare commits
4 commits
d38535a35e
...
eddf871203
Author | SHA1 | Date | |
---|---|---|---|
eddf871203 | |||
ff8bf341c4 | |||
7054a3e181 | |||
84b11bf28b |
1 changed files with 14 additions and 14 deletions
|
@ -11,14 +11,16 @@ class ExportChannels(commands.Cog):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.config = Config.get_conf(self, identifier=48258471944753312)
|
self.config = Config.get_conf(self, identifier=48258471944753312)
|
||||||
self.config.register_global(
|
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.data_path = data_manager.cog_data_path(self)
|
||||||
self.bundled_data_path = data_manager.bundled_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:
|
try:
|
||||||
os.mkdir(out)
|
os.mkdir(out)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
|
@ -34,8 +36,6 @@ class ExportChannels(commands.Cog):
|
||||||
'--media',
|
'--media',
|
||||||
'--fuck_russia', 'true',
|
'--fuck_russia', 'true',
|
||||||
]
|
]
|
||||||
if bot:
|
|
||||||
args += '--bot'
|
|
||||||
os.chdir(self.bundled_data_path)
|
os.chdir(self.bundled_data_path)
|
||||||
subprocess.call(args)
|
subprocess.call(args)
|
||||||
args = [
|
args = [
|
||||||
|
@ -45,13 +45,11 @@ class ExportChannels(commands.Cog):
|
||||||
'--format', 'Json',
|
'--format', 'Json',
|
||||||
'--output', f'/{out}/%G (%g)/%C (%c)/DCE-f.json',
|
'--output', f'/{out}/%G (%g)/%C (%c)/DCE-f.json',
|
||||||
'--token', f'{token}',
|
'--token', f'{token}',
|
||||||
'--channel', {channel},
|
'--channel', {channels},
|
||||||
'--reuse_media',
|
'--reuse_media',
|
||||||
'--media',
|
'--media',
|
||||||
'--fuck_russia', 'true',
|
'--fuck_russia', 'true',
|
||||||
]
|
]
|
||||||
if bot:
|
|
||||||
args += '--bot'
|
|
||||||
os.chdir(self.bundled_data_path)
|
os.chdir(self.bundled_data_path)
|
||||||
subprocess.call(args)
|
subprocess.call(args)
|
||||||
|
|
||||||
|
@ -67,7 +65,7 @@ class ExportChannels(commands.Cog):
|
||||||
await self.config.bot_token.set({token})
|
await self.config.bot_token.set({token})
|
||||||
await ctx.send(content="Token set!")
|
await ctx.send(content="Token set!")
|
||||||
await ctx.delete()
|
await ctx.delete()
|
||||||
|
|
||||||
@exportset.command()
|
@exportset.command()
|
||||||
@checks.is_owner()
|
@checks.is_owner()
|
||||||
async def checkoutputpath(self, ctx):
|
async def checkoutputpath(self, ctx):
|
||||||
|
@ -77,12 +75,14 @@ class ExportChannels(commands.Cog):
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.admin()
|
@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."""
|
"""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)
|
dce_install = data_manager.bundled_data_path(self)
|
||||||
if token == 0:
|
if token is None:
|
||||||
await ctx.send(content="Please set your token with the ``exportset token`` command!")
|
await ctx.send(content=f"Please set your token with the ``{ctx.prefix}exportset token`` command!")
|
||||||
return
|
return
|
||||||
else:
|
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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue