Update code.py

This commit is contained in:
Paillat
2022-12-06 21:38:56 +01:00
parent d638dea7ac
commit eb0973799b

View File

@@ -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):