'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?
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')
Solution 1:[1]
The timestamp field in the embed will actually show in the user's local time. However, you can also use Timestamp Styles to put local time elsewhere in the embed and/messsage. It needs to be in EPOCH seconds, not milliseconds:
// one hour from now
<t:${Math.floor(new Date(new Date().getTime() + 60 * 60000).getTime() / 1000)}:t>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tukool |
