func Trade(cmdInfo CommandInfo) {
	user := cmdInfo.Msg.Author

	if _, err := strconv.Atoi(cmdInfo.CmdOps[1]); err == nil {
		// This is a list command - print all currently offered to tradeID
		offers := cmdInfo.Service.Trade.GetAllOffers(cmdInfo.CmdOps[1])
		printTradeList(offers, cmdInfo, cmdInfo.CmdOps[1])
		return
	}

	// if user doesn't exist in rep database, create a new one
	if !cmdInfo.Service.Rep.Exists(user.ID) {
		cmdInfo.newRep(user.ID)
	}

	// If the user currently doesn't exist in server tracking, make a new one
	if !cmdInfo.Service.User.UserExists(user) {
		// Create a user
		cmdInfo.Service.User.AddUser(user)
	}

	if cmdInfo.Service.User.LimitTrade(user.ID) {
		// Max trades created - can't make anymore
		msg := cmdInfo.createMsgEmbed(
			"Error: Couldn't Create Trade", errThumbURL, "You already have the max trade events.", errColor,
			format(
				createFields("Suggestion", "Either end one of your trades or wait until they are finished before creating another.", false),
			))
		cmdInfo.Ses.ChannelMessageSendEmbed(cmdInfo.BotChID, msg)
		return
	}

	// attempt to parse command
	t := parseTradeCmd(strings.Join(cmdInfo.CmdOps[1:], " "))
	if t == nil {
		// error parse failed
		msg := cmdInfo.createMsgEmbed(
			"Error: Couldn't Create Trade", errThumbURL, "Syntax error", errColor,
			format(
				createFields("Suggestion", "Try checking if you input the command correctly.", false),
				createFields("EXAMPLE", cmdInfo.Prefix+"trade item=\"blue mountain coffee\" msg=\"looking for geisha coffee\"", false),
			))
		cmdInfo.Ses.ChannelMessageSendEmbed(cmdInfo.BotChID, msg)
		return
	}

	// generate trade id
	id := generateID(1000, 9999)

	if cmdInfo.Service.Trade.Exists(id) {
		// error - id exists
		msg := cmdInfo.createMsgEmbed(
			"Error: Couldn't Create Trade", errThumbURL, "This ID already exists.", errColor,
			format(
				createFields("Suggestion", "Try re-creating the trade event.", false),
			))
		cmdInfo.Ses.ChannelMessageSendEmbed(cmdInfo.BotChID, msg)
		return
	}

	// Add trade event
	cmdInfo.Service.Trade.AddTrade(id, user)
	// Add trade tracking to user
	expire := cmdInfo.Service.Trade.GetExpiration(id)
	cmdInfo.Service.User.AddTrade(user, id, expire)

	// retrieve reps from database
	reps := cmdInfo.Service.Rep.GetRep(user.ID)

	// Print Trade Offer
	msg := cmdInfo.createMsgEmbed(
		"Trade", tradeThumbURL, "Trade ID: "+id, tradeColor,
		format(
			createFields("Trader", user.Mention(), true),
			createFields("Reputation", strconv.Itoa(reps), true),
			createFields("Trade Listing", strings.Title(t.item), false),
			createFields("Message", strings.Title(t.msg), false),
		),
	)
	cmdInfo.Ses.ChannelMessageSendEmbed(cmdInfo.ListingID, msg)
	cmdInfo.Ses.ChannelMessageSend(cmdInfo.BotChID, "Listing Posted!")
}
// Trade will handle trade options within the server
//
// Trade is meant to be paired along with offer.go in order
// for members to trade and offer items among each other
Trade will handle trade options within the server

Trade is meant to be paired along with offer.go in order
for members to trade and offer items among each other
// Trade will handle trade options within the server // // Trade is meant to be paired along with offer . go in order // for members to trade and offer items among each other
func Trade(cmdInfo CommandInfo) {
	user := cmdInfo.Msg.Author
	if _, err := strconv.Atoi(cmdInfo.CmdOps[1]); err == nil {
		offers := cmdInfo.Service.Trade.GetAllOffers(cmdInfo.CmdOps[1])
		printTradeList(offers, cmdInfo, cmdInfo.CmdOps[1])
		return
	}
	if !cmdInfo.Service.Rep.Exists(user.ID) {
		cmdInfo.newRep(user.ID)
	}
	if !cmdInfo.Service.User.UserExists(user) {
		cmdInfo.Service.User.AddUser(user)
	}
	if cmdInfo.Service.User.LimitTrade(user.ID) {
		msg := cmdInfo.createMsgEmbed(
			"Error: Couldn't Create Trade", errThumbURL, "You already have the max trade events.", errColor,
			format(
				createFields("Suggestion", "Either end one of your trades or wait until they are finished before creating another.", false),
			))
		cmdInfo.Ses.ChannelMessageSendEmbed(cmdInfo.BotChID, msg)
		return
	}
	t := parseTradeCmd(strings.Join(cmdInfo.CmdOps[1:], " "))
	if t == nil {
		msg := cmdInfo.createMsgEmbed(
			"Error: Couldn't Create Trade", errThumbURL, "Syntax error", errColor,
			format(
				createFields("Suggestion", "Try checking if you input the command correctly.", false),
				createFields("EXAMPLE", cmdInfo.Prefix+"trade item=\"blue mountain coffee\" msg=\"looking for geisha coffee\"", false),
			))
		cmdInfo.Ses.ChannelMessageSendEmbed(cmdInfo.BotChID, msg)
		return
	}
	id := generateID(1000, 9999)
	if cmdInfo.Service.Trade.Exists(id) {
		msg := cmdInfo.createMsgEmbed(
			"Error: Couldn't Create Trade", errThumbURL, "This ID already exists.", errColor,
			format(
				createFields("Suggestion", "Try re-creating the trade event.", false),
			))
		cmdInfo.Ses.ChannelMessageSendEmbed(cmdInfo.BotChID, msg)
		return
	}
	cmdInfo.Service.Trade.AddTrade(id, user)
	expire := cmdInfo.Service.Trade.GetExpiration(id)
	cmdInfo.Service.User.AddTrade(user, id, expire)
	reps := cmdInfo.Service.Rep.GetRep(user.ID)
	msg := cmdInfo.createMsgEmbed(
		"Trade", tradeThumbURL, "Trade ID: "+id, tradeColor,
		format(
			createFields("Trader", user.Mention(), true),
			createFields("Reputation", strconv.Itoa(reps), true),
			createFields("Trade Listing", strings.Title(t.item), false),
			createFields("Message", strings.Title(t.msg), false),
		),
	)
	cmdInfo.Ses.ChannelMessageSendEmbed(cmdInfo.ListingID, msg)
	cmdInfo.Ses.ChannelMessageSend(cmdInfo.BotChID, "Listing Posted!")
}
func Trade ( cmdInfo CommandInfo ) { user := cmdInfo . Msg . Author if _ , err := strconv . Atoi ( cmdInfo . CmdOps [ 1 ] ) ; err == nil { offers := cmdInfo . Service . Trade . GetAllOffers ( cmdInfo . CmdOps [ 1 ] ) printTradeList ( offers , cmdInfo , cmdInfo . CmdOps [ 1 ] ) return } if ! cmdInfo . Service . Rep . Exists ( user . ID ) { cmdInfo . newRep ( user . ID ) } if ! cmdInfo . Service . User . UserExists ( user ) { cmdInfo . Service . User . AddUser ( user ) } if cmdInfo . Service . User . LimitTrade ( user . ID ) { msg := cmdInfo . createMsgEmbed ( " " , errThumbURL , " " , errColor , format ( createFields ( " " , " " , false ) , ) ) cmdInfo . Ses . ChannelMessageSendEmbed ( cmdInfo . BotChID , msg ) return } t := parseTradeCmd ( strings . Join ( cmdInfo . CmdOps [ 1 : ] , " " ) ) if t == nil { msg := cmdInfo . createMsgEmbed ( " " , errThumbURL , " " , errColor , format ( createFields ( " " , " " , false ) , createFields ( " " , cmdInfo . Prefix + " \" \" \" \" " , false ) , ) ) cmdInfo . Ses . ChannelMessageSendEmbed ( cmdInfo . BotChID , msg ) return } id := generateID ( 1000 , 9999 ) if cmdInfo . Service . Trade . Exists ( id ) { msg := cmdInfo . createMsgEmbed ( " " , errThumbURL , " " , errColor , format ( createFields ( " " , " " , false ) , ) ) cmdInfo . Ses . ChannelMessageSendEmbed ( cmdInfo . BotChID , msg ) return } cmdInfo . Service . Trade . AddTrade ( id , user ) expire := cmdInfo . Service . Trade . GetExpiration ( id ) cmdInfo . Service . User . AddTrade ( user , id , expire ) reps := cmdInfo . Service . Rep . GetRep ( user . ID ) msg := cmdInfo . createMsgEmbed ( " " , tradeThumbURL , " " + id , tradeColor , format ( createFields ( " " , user . Mention ( ) , true ) , createFields ( " " , strconv . Itoa ( reps ) , true ) , createFields ( " " , strings . Title ( t . item ) , false ) , createFields ( " " , strings . Title ( t . msg ) , false ) , ) , ) cmdInfo . Ses . ChannelMessageSendEmbed ( cmdInfo . ListingID , msg ) cmdInfo . Ses . ChannelMessageSend ( cmdInfo . BotChID , " " ) }
Trade will handle trade options within the server
Trade will handle trade options within the server
// This is a list command - print all currently offered to tradeID // if user doesn't exist in rep database, create a new one // If the user currently doesn't exist in server tracking, make a new one // Create a user // Max trades created - can't make anymore // attempt to parse command // error parse failed // generate trade id // error - id exists // Add trade event // Add trade tracking to user // retrieve reps from database // Print Trade Offer