public static void ResetWorldData(User user)
 {
     CallWithErrorHandling <object>((lUser, args) =>
     {
         ChatManager.ServerMessageToPlayer(new LocString(SharedCommands.ResetWorldData()), user);
     }, user);
 }
        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 BroadcastAnnouncement(User user, string title, string message)
 {
     CallWithErrorHandling <object>((lUser, args) =>
     {
         string result = SharedCommands.SendAnnouncement(title, message, user.Name, string.Empty);
         ChatManager.ServerMessageToPlayer(new LocString(result), user);
     },
                                    user);
 }
 public static void SendPopup(User user, string message, string recipientUserName)
 {
     CallWithErrorHandling <object>((lUser, args) =>
     {
         string result = SharedCommands.SendPopup(message, user.Name, recipientUserName);
         ChatManager.ServerMessageToPlayer(new LocString(result), user);
     },
                                    user);
 }
 public static void BroadcastServerMessage(User user, string message, string persistanceType = "temporary")
 {
     CallWithErrorHandling <object>((lUser, args) =>
     {
         string result = SharedCommands.SendServerMessage(message, user.Name, string.Empty, persistanceType);
         ChatManager.ServerMessageToPlayer(new LocString(result), user);
     },
                                    user);
 }
 public static void Invite(User user, string ecoChannel = "")
 {
     CallWithErrorHandling <object>((lUser, args) =>
     {
         string result = SharedCommands.Invite(ecoChannel);
         ChatManager.ServerMessageToPlayer(new LocString(result), user);
     },
                                    user);
 }
 public static void Restart(User user)
 {
     CallWithErrorHandling <object>((lUser, args) =>
     {
         string result = SharedCommands.Restart();
         ChatManager.ServerMessageToPlayer(new LocString(result), user);
     },
                                    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);
        }