Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the timezone of the message author in my discord server? (discord.py)

How would I add a footer that displays when the message was sent according to the persons time zone?

Image Example

For 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')
like image 712
Exploiter _ Avatar asked Nov 28 '25 00:11

Exploiter _


1 Answers

Discord embeds have a timestamp field which can be set to a datetime object. Unfortunately, there is no way to determine a user's timezone through the API that Discord provides.

You can view the documentation for discord.py's embed data class.

like image 71
David Katz Avatar answered Nov 29 '25 13:11

David Katz