我正在用discord.py构建一个机器人,当我使用context发送东西时,它将首先发送所有txt文件,然后发送带有照片的txt文件。我确实做了一个函数,然后才发送txt数据,但是我完全删除了它,因此应该没有理由调用它。
#----------------------------------------------------main
TOKEN = get_token()
client = commands.Bot(command_prefix='!')
#------------------------------------------------
@client.command()
async def free(ctx):
result = ''
free_deals = get_data()
free_deals = free_deals['free']
for i in range(0,len(free_deals)):
result = '\nTitle: ' + free_deals['title'][i] + '\n' + 'Details: ' + free_deals['details'][i] + '\n' + 'Link: ' + free_deals['link'][i] + '\n'
with open('img/free'+str(i)+'.jpeg', 'rb') as f:
await ctx.send('------------------------------------------------------------------------------------------------------------------------------')
await ctx.send(result)
await ctx.send(file=discord.File(f))
await ctx.send('------------------------------------------------------------------------------------------------------------------------------')
await ctx.send('END')
log(str(ctx.author),'Command:!free')
client.run(TOKEN)