discord.py将发送我不告诉的消息

时间:2020-03-26 01:46:29

标签: python discord.py

我正在用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)

0 个答案:

没有答案