Skip to content

Duration

Yiping Su edited this page Apr 13, 2020 · 1 revision

Overview

All event types have an expiration time set when the Event or Trade are first created.

Event types:

  • Hosting Events
  • Queues
  • Trade

Events and Queues have a default duration of ~2 hours, and Trades have a duration of ~4 hours.

Customizing Duration

Expiration calculation can be changed inside the event and trade source files under the Expiration parameter located in models.

  • models/event.go
  • models/trade.go
// AddEvent creates a new event on the server
func (es eventStore) AddEvent(User *discordgo.User, MsgID string, limit int) {
	es.m.Lock()
	defer es.m.Unlock()
	newQ := make([]QueueUser, 0)
	new := &EventData{
		DiscordUser: User,
		Limit:       limit,
		Queue:       newQ,
		Expiration:  time.Now().Add(2 * time.Hour),
	}
	es.eb[MsgID] = new
}
// AddTrade will add a new trade event to tracking
func (ts tradeStore) AddTrade(tradeID string, user *discordgo.User) {
	ts.m.Lock()
	defer ts.m.Unlock()
	o := make([]TradeOfferer, 0)
	new := TradeData{
		DiscordUser: user,
		Expiration:  time.Now().Add(4 * time.Hour),
		Offers:      o,
	}
	ts.ts[tradeID] = &new
}

A full list of Go's Duration options can be found here.