@bot.slash_command(name="closeticket", description="Close the support ticket")
async def closeticket(ctx):
await ctx.send("Processing...")
try:
# Check if the command is invoked in a ticket channel
if ctx.channel.category and ctx.channel.category.name == "Support Tickets":
# Create a transcript
transcript = await create_transcript(ctx.channel)
# Save the transcript to a local file
transcript_filename = f"ticket_transcript-{ctx.channel.name}.html"
with open(transcript_filename, "w", encoding="utf-8") as transcript_file:
transcript_file.write(transcript)
# Send the transcript to the "transcripts" channel
transcripts_channel_name = "transcripts"
transcripts_channel = discord.utils.get(ctx.guild.text_channels, name=transcripts_channel_name)
if transcripts_channel:
# Send the file
with open(transcript_filename, "rb") as transcript_file:
print(transcript_filename)
await transcripts_channel.send(file=discord.File(f"{transcript_filename}"))
print(file)
# Delete the local file
os.remove(transcript_filename)
else:
await ctx.send("Transcripts channel not found. Please contact an administrator to store the transcript.")
# Rename the ticket channel with "closed"
await ctx.channel.edit(name=f"closed-{ctx.channel.name}")
else:
await ctx.send("This command can only be used in a Support Tickets channel.")
except Exception as e:
await ctx.send(f"An error occurred: {str(e)}")``` I *thought* I was following discord docs properly, but clearly I am not....
#error: file parameter must be file
6 messages · Page 1 of 1 (latest)
it's supposed to send the transcript.html from the local files, then delete it, but uh.....can't seem to figure out why it won't send....
so far I've tried 107 variations
it's not making any sense, I've got other functions that can send files just fine......
yeah no, even passing the file path directly still gives the "file parameter must be File" error, looks like the only possible option left is mail delivery from what I can tell........
You're passing the file path to File, aren't you supposed to pass a file object?