discord bot命令从文本文件导入文本

时间:2020-09-04 15:11:25

标签: python command discord

我想通过命令在我的Discord Bot中实现该功能,以根据命令发送。更改日志中的信息/更新位于同一文件夹中的.txt文件中。 如何在要发送的文件中获取该文本?

1 个答案:

答案 0 :(得分:0)

示例代码,我想这就是您的意思

client = commands.Bot('!')

@client.command
async def command(ctx):
    open_file_ = open('file.txt', 'r')
    await ctx.send(open_file_.read())

这是你想要的吗?