小编iro*_*roL的帖子

如何在 Discord.py 中获取消息的时间戳?

所以我一直在尝试做一个机器人,它在发送消息并将其上传到数据库时获取。我就是想不通这个对象。

这是我的一些代码:

'{datetime.datetime.fromtimestamp(discord.Message.created_at)}'
Run Code Online (Sandbox Code Playgroud)

我知道这是错误的,因为 discord.Message 给出了一个对象。我怎样才能得到一个整数或时间?

编辑:

@client.command()
async def belep(message, url, felhasz, jelsz):
    if isinstance(message.channel, discord.DMChannel):
        for i in c:
            if i['Url'] == url:
                db = MySQLdb.connect(xxxxx)
                cursor = db.cursor()
                print(url + " " + felhasz + " " + jelsz)
                icode = i["InstituteCode"]
                headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'}
                payload = {'institute_code': f'{icode}', 'userName': f'{felhasz}', 'password': f'{jelsz}',
                           'grant_type': 'password', 'client_id': '919e0c1c-76a2-4646-a2fb-7085bbbf3c56'}

                response = requests.get(f"""https://{icode}.e-kreta.hu/idp/api/v1/Token""", headers=headers, data=payload)

                rjson = response.json()
                print()
                cursor.execute(
                    f"INSERT INTO token (mauthor, access_token, token_type, expires_in, refresh_token, …
Run Code Online (Sandbox Code Playgroud)

python datetime object discord discord.py

2
推荐指数
1
解决办法
9148
查看次数

标签 统计

datetime ×1

discord ×1

discord.py ×1

object ×1

python ×1