コード例 #1
0
        // Private members

        public async Task _plusZone(Species species, string zoneList, string notes, bool onlyShowErrors = false)
        {
            // Get the zones from user input.
            ZoneListResult zones = await ZoneUtils.GetZonesByZoneListAsync(zoneList);

            // Add the zones to the species.
            await SpeciesUtils.AddZonesAsync(species, zones.Zones, notes);

            if (zones.InvalidZones.Count() > 0)
            {
                // Show a warning if the user provided any invalid zones.

                await BotUtils.ReplyAsync_Warning(Context, string.Format("{0} {1} not exist.",
                                                                         StringUtils.ConjunctiveJoin(", ", zones.InvalidZones.Select(x => string.Format("**{0}**", ZoneUtils.FormatZoneName(x))).ToArray()),
                                                                         zones.InvalidZones.Count() == 1 ? "does" : "do"));
            }

            if (zones.Zones.Count() > 0 && !onlyShowErrors)
            {
                // Show a confirmation of all valid zones.

                await BotUtils.ReplyAsync_Success(Context, string.Format("**{0}** now inhabits {1}.",
                                                                         species.ShortName,
                                                                         StringUtils.ConjunctiveJoin(", ", zones.Zones.Select(x => string.Format("**{0}**", x.GetFullName())).ToArray())));
            }
        }