【发布时间】:2020-12-04 22:46:39
【问题描述】:
在解决问题后从客户端创建票证后,我如何保存该聊天以进一步证明,甚至将副本发送到客户端? 1.成绩单的使用。 2.将消息保存为html格式 3.使用node js语言
【问题讨论】:
标签: javascript node.js discord discord.js
在解决问题后从客户端创建票证后,我如何保存该聊天以进一步证明,甚至将副本发送到客户端? 1.成绩单的使用。 2.将消息保存为html格式 3.使用node js语言
【问题讨论】:
标签: javascript node.js discord discord.js
我不确定 html 部分,但这是我个人用来将任意数量的消息保存在 .txt 文件中的频道中的代码 - (discord.py rewrite v1.4.1)
@client.command(aliases=['transcript', 'save'])
@commands.has_permissions(administrator=True)
async def history(ctx, limit: int = 100):
channel = ctx.message.channel
messages = await ctx.channel.history(limit=limit).flatten()
with open(f"{channel}_messages.txt", "a+", encoding="utf-8") as f:
print(f"\nTranscript Saved by - {ctx.author.display_name}.\n\n", file=f)
for message in messages:
embed = ""
if len(message.embeds) != 0:
embed = message.embeds[0].description
print(f"{message.author.name} - {embed}", file=f)
print(f"{message.author.name} - {message.content}", file=f)
await ctx.message.add_reaction("✅")
await ctx.send(f"{ctx.author.mention}, Transcript saved.")
history = discord.File(fp=f'{channel}_messages.txt', filename=None)
await ctx.send(file=history)
【讨论】: