Esempio n. 1
0
 private void UpdateEvent(object sender, UpdateTickedEventArgs e)
 {
     try
     {
         discord.RunCallbacks();
         if (e.IsMultipleOf(30))
         {
             activityManager.UpdateActivity(SPFunctions.GetActivity(), (result) =>
             {
                 if (result != Result.Ok)
                 {
                     Monitor.Log($"Discord update activity: {result.ToString()}");
                 }
             });
         }
     }
     catch (Exception ex) { /*Monitor.Log($"Exception caught: {ex.Message}", StardewModdingAPI.LogLevel.Error);*/ }
 }
Esempio n. 2
0
        private void RegisterEvents(IModHelper helper)
        {
            // Register Discord events
            activityManager.OnActivityJoin += (string secret) =>
            {
                Monitor.Log("Attempting to join game");
                SPFunctions.JoinGame(secret);
            };

            activityManager.OnActivityJoinRequest += (ref User user) =>
            {
                string discordUser = $"{user.Username}#{user.Discriminator}";
                Monitor.Log($"{discordUser} is requesting to join your game. Respond in the Discord overlay!", StardewModdingAPI.LogLevel.Alert);
                Game1.chatBox.addInfoMessage($"{discordUser} is requesting to join your game. Respond in the Discord overlay!");
            };

            // Register game events
            helper.Events.GameLoop.UpdateTicked += UpdateEvent;
            helper.Events.GameLoop.SaveLoaded   += SaveLoadedEvent;
        }