Пример #1
0
        public string SetPrefix(IGuild guild, string prefix)
        {
            if (string.IsNullOrWhiteSpace(prefix))
            {
                throw new ArgumentNullException(nameof(prefix));
            }
            if (guild == null)
            {
                throw new ArgumentNullException(nameof(guild));
            }

            prefix = prefix.ToLowerInvariant();

            using (var uow = _db.UnitOfWork)
            {
                var gc = uow.GuildConfigs.For(guild.Id, set => set);
                gc.Prefix = prefix;
                uow.Complete();
            }

            Prefixes.AddOrUpdate(guild.Id, prefix, (key, old) => prefix);

            return(prefix);
        }