public static void TrackTrades(User user, string userOrItemName) { LinkedUser linkedUser = LinkedUserManager.LinkedUserByEcoUser(user); if (linkedUser == null) { ChatManager.ServerMessageToPlayer(new LocString($"You have not linked your Discord Account to DiscordLink on this Eco Server.\nLog into the game and use the `\\dl-link` command to initialize account linking."), user); return; } int trackedTradesCount = DLStorage.WorldData.GetTrackedTradesCountForUser(ulong.Parse(linkedUser.DiscordId)); if (trackedTradesCount >= DLConfig.Data.MaxTrackedTradesPerUser) { ChatManager.ServerMessageToPlayer(new LocString($"You are already tracking {trackedTradesCount} trades and the limit is {DLConfig.Data.MaxTrackedTradesPerUser} tracked trades per user.\nUse the `\\dl-StopTrackTrades` command to remove a tracked trade to make space if you wish to add a new one."), user); return; } // Fetch trade data using the trades command once to see that the command parameters are valid string result = SharedCommands.Trades(userOrItemName, out string matchedName, out bool isItem, out StoreOfferList groupedBuyOffers, out StoreOfferList groupedSellOffers); if (!string.IsNullOrEmpty(result)) { ChatManager.ServerMessageToPlayer(new LocString(result), user); return; } bool added = DLStorage.WorldData.AddTrackedTradeItem(ulong.Parse(linkedUser.DiscordId), matchedName).Result; result = added ? $"Tracking all trades for {matchedName}." : $"Failed to start tracking trades for {matchedName}"; ChatManager.ServerMessageToPlayer(new LocString(result), user); }
public static void Trades(User user, string userOrItemName) { CallWithErrorHandling <object>((lUser, args) => { // Fetch trade data string result = SharedCommands.Trades(userOrItemName, out string title, out bool isItem, out StoreOfferList groupedBuyOffers, out StoreOfferList groupedSellOffers); if (!string.IsNullOrEmpty(result)) { // Report commmand error ChatManager.ServerMessageToPlayer(new LocString(result), user); return; } MessageBuilder.Eco.FormatTrades(isItem, groupedBuyOffers, groupedSellOffers, out string message); EcoUtil.SendAnnouncementMessage(title, message, user); }, user); }