Exemple #1
0
        /// <summary>Generate a new user with the default settings and add it to the database.
        /// This should never be run if the user already exists within the database. </summary>
        internal static RavenUser CreateNewUser(ulong id, string name, ushort discrim, string avatarUrl)
        {
            if (Users.FindIndex(x => x.UserId == id) != -1)
            {
                return(null);
            }

            RavenUser user = new RavenUser(id, name, discrim, avatarUrl);

            user.Save();
            Users.Add(user);
            return(user);
        }
Exemple #2
0
        public RavenUser CreateNewUser(ulong id, string name, ushort discrim)
        {
            if (Users.FindIndex(x => x.UserId == id) != -1)
            {
                return(null);
            }

            RavenUser user = new RavenUser(id, name, discrim);

            Users.Add(user);
            this.Save();
            return(user);
        }
Exemple #3
0
        internal static void UpdateUser(RavenUser oldUser, RavenUser newUser)
        {
            int index = Users.FindIndex(x => x == oldUser);

            if (index != -1)
            {
                Users[index] = newUser;
            }
            else
            {
                Logger.Log($"Unable to update user: {(newUser.Username + "#" + newUser.Discriminator)} ({newUser.UserId})",
                           "Raven.cs - UpdateGuild", LogSeverity.Warning, "Index not found.");
            }
        }
Exemple #4
0
        public void Save()
        {
            RavenUser old = RavenDb.GetUser(UserId);

            if (old != null)
            {
                RavenDb.UpdateUser(old, this);
            }

            using (var session = RavenStore.Store.OpenSession())
            {
                session.Store(this, UserId.ToString());
                session.SaveChanges();
            }
        }