示例#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);
        }
示例#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.");
            }
        }
示例#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();
            }
        }