コード例 #1
0
        public async Task FixUserNames(ulong guildId, Dictionary <ulong, string> usernameDictionary)
        {
            using var context = new RPGContext(_options);

            var members = GetAllGuildProfiles(guildId);

            foreach (var profile in members)
            {
                try
                {
                    profile.UserName = usernameDictionary[usernameDictionary.Keys.Where(x => x == profile.DiscordId).Single()];
                }
                catch { }
            }

            context.UpdateRange(members);

            await context.SaveChangesAsync();
        }