#How can I get the ban duration...
1 messages · Page 1 of 1 (latest)
oban is offline banning iirc
the Duration given is time in seconds iirc
DateTime expiration = DateTime.Now.Add(TimeSpan.FromSeconds(ev.Duration));```
this is what i've done for one of my plugins, from there you'll have to style the output yourself
This works for OnPlayerBanned, but it doesn’t register offline bans (oban), and in the method that supposedly handles offline bans, there is no Duration.
Yes
Look at the ban details
yeah BanDetails might give information
I tried this method with BanDetails.Expires and Details.IssuanceTime, but in both cases it gives an error. I’m not sure what it’s related to.
Ok so IssuanceTime is the current time
Expires is when the time actually expires
Expires is just DateTime.UtcNow.AddSeconds(time).Ticks, so you'll just need to reverse that
So to get the actual duration you will need to do
long duration = (new DateTime(Expires) - DateTime.UtcNow).Duration()```
might be the other way around, im unsure, but yeah
Thanks! I’ll give it a try.
Tf is .Duration()
Format extension method?
idk, im just reading stack overflow
Btw im pretty sure there's helper methods for these scenarios in BanPlayer or some related class
😭
Why would TimeSpan have Duration()
BanPlayer doesn't have a method for this
Derails
The ban storage maybe
but no, ban details doesn't have it
The class that manages the bam file
i might ask if it's allowed to put the actual duration in seconds in BanDetails tbh, but there is probably some bad implications to doing that somewhere
That is the BanHandler class, and it seems to have nothing for it either
ig maybe I could introduce a new static method for it and then use it for the labapi events or smth