Example #1
0
        /// <summary>Generate a new guild with the default settings and add it to the database.
        /// This should never be run if the guild already exists within the database. </summary>
        internal static RavenGuild CreateNewGuild(ulong id, string name)
        {
            if (Guilds.FindIndex(x => x.GuildId == id) != -1)
            {
                return(null);
            }

            RavenGuild guild = new RavenGuild(id, name);

            guild.Save();
            Guilds.Add(guild);
            return(guild);
        }
Example #2
0
        public static void UpdateGuild(RavenGuild oldGuild, RavenGuild newGuild)
        {
            int index = Guilds.FindIndex(x => x == oldGuild);

            if (index != -1)
            {
                Guilds[index] = newGuild;
            }
            else
            {
                Logger.Log($"Unable to update guild: {newGuild.Name ?? newGuild.GuildId.ToString()} ({newGuild.GuildId})",
                           "Raven.cs - UpdateGuild", LogSeverity.Warning, "Index not found.");
            }
        }
Example #3
0
        // Methods

        public void Save()
        {
            RavenGuild old = RavenDb.GetGuild(GuildId);

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

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