From eb0973799bc16f73396d3e672998e576a2890ea9 Mon Sep 17 00:00:00 2001 From: Paillat Date: Tue, 6 Dec 2022 21:38:56 +0100 Subject: [PATCH] Update code.py --- code/code.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/code/code.py b/code/code.py index f3ab5ad..2f71e8b 100644 --- a/code/code.py +++ b/code/code.py @@ -427,7 +427,8 @@ async def disable_tts(ctx): #send a message await ctx.respond("TTS has been disabled", ephemeral=True) @bot.command(name="transcript", description="Get a transcript of the messages that have been sent in this channel intoa text file") -async def transcript(ctx): +@discord.commands.options(name="channel", description="The channel to send the transcript to", type=3, required=False) +async def transcript(ctx, channel: discord.TextChannel = None): debug(f"The user {ctx.author.display_name} ran the transcript command command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}") #save all the messages in the channel in a txt file and send it messages = await ctx.channel.history(limit=None).flatten() @@ -457,8 +458,13 @@ async def transcript(ctx): f.write(transcript) f.close() #send the file in a private message to the user who ran the command + if channel is None: + await ctx.respond(file=discord.File("transcript.txt")) + else: + await channel.send(file=discord.File("transcript.txt")) await ctx.author.send(file=discord.File("transcript.txt")) - await ctx.respond(file=discord.File("transcript.txt")) +#delete the file + os.remove("transcript.txt") #these are debug commands and should not be used in production @bot.command(name="say", description="Say a message") async def say(ctx, message: str):