I currently have a program that keeps track of when a person signs on, and when they sign off over discord. The program is given the signing on time, and signing off time in the form of a datetime object, and it subtracts them from each other, giving me the total. The problem is I want it to only give me the hours and minutes, not seconds and milliseconds. Code shown below:
@bot.event
async def on_message(message):
if "on" in message.content:
player = message.author
time = message.timestamp
message_type = 'on'
with open(str(player) + " on", 'w') as f:
f.seek(0)
f.truncate()
f.write(str(time))
elif "off" in message.content:
player = message.author
off_time = message.timestamp
with open(str(player) + " on",'r+') as f:
on_time = f.readline()
f.seek(0)
f.truncate()
on_time = parser.parse(on_time)
total = off_time - on_time
print(total)
Note: The total object is a timedelta object, not a timedate object.