如何在不和谐的服务器中获取消息作者的时区? (discord.py)

时间:2020-03-26 21:03:44

标签: python python-3.x discord.py

如何根据人所在的时区添加在邮件发送时显示的页脚?

Image Example

例如

import discord
import datetime

client = discord.Client()

@client.event
async def on_ready():
    await client.change_presence(activity=discord.Game('Exodus Hub | !cmds'))
    print('Logged in as {0.user}'.format(client))


@client.event
async def on_message(msg):
    print(msg.created_at)
    print(msg.author)
    if msg.author == client.user:
        return
    if msg.content.lower() == '!getscript':
        if str(msg.channel) == 'bot-cmds':
            if 'Developers' in str(msg.author.roles):
                richembed = discord.Embed(title='Exodus Server Bot',colour=0xff0000, description='Sending....')
                date = datetime.datetime.now()
                richembed.set_footer(text=f'{date:%b} at {date:%H:%M}') #<--- Footer
                await msg.channel.send(content=None,embed=richembed)

client.run('redacted')

1 个答案:

答案 0 :(得分:0)

Discord嵌入具有一个timestamp字段,可以将其设置为datetime对象。不幸的是,无法通过Discord提供的API确定用户的时区。

您可以查看documentation中discord.py的嵌入数据类。