让脚本为discord.py b找到gspread的起始列

2024-05-01 21:31:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在制作一个bot,它可以让用户在服务器上计时,例如当他们使用“.clock-in”时,bot跟踪他们在工作表中执行命令的时间,然后当执行“.clock-out”时,bot将他们使用该命令的时间记录到电子表格的同一行中。我遇到的问题是让机器人把时间记录在同一行。我正在考虑通过让bot找到以用户id开头的行,然后将其放入该行来解决这个问题,但是idk如何

我尝试过的主要代码:

        if message.content.startswith('.clock in'):
            embed = discord.Embed(title='BCSO', description='Succesfully Clocked In', color=0x5ed623)
            embed.add_field(name='.clock out', value='Clocks out')
            await message.channel.send(content=None, embed=embed,)
            row = ['"%s"' % {message.author.id}, '"%s"' % now]
            index = 3
            sheet.insert_row(row, index)


        if message.content.startswith('.clock out'):
            embed = discord.Embed(title='BCSO', description='Succesfully Clocked Out', color=0xef210a)
            embed.add_field(name='.clock in', value='Clocks In')
            embed.add_field(name='Total Time', value='totalt' )
            await message.channel.send(content=None, embed=embed,)

Tags: 用户nameinaddfieldmessagevaluebot