Beispiel #1
0
        private async Task MinusCommonName(string genus, string species, string commonName)
        {
            Species species_info = await BotUtils.ReplyFindSpeciesAsync(Context, genus, species);

            if (species_info is null)
            {
                return;
            }

            // Ensure that the user has necessary privileges to use this command.
            if (!await BotUtils.ReplyHasPrivilegeOrOwnershipAsync(Context, PrivilegeLevel.ServerModerator, species_info))
            {
                return;
            }

            CommonName[] common_names = await SpeciesUtils.GetCommonNamesAsync(species_info);

            if (!common_names.Any(x => x.Value.ToLower() == commonName.ToLower()))
            {
                // Check if the species actually has this common name before attempting to remove it (for the sake of clarity to the user).

                await BotUtils.ReplyAsync_Warning(Context, string.Format("The common name **{0}** has already been removed.",
                                                                         StringUtils.ToTitleCase(commonName)));
            }
            else
            {
                await SpeciesUtils.RemoveCommonNameAsync(species_info, commonName);

                await BotUtils.ReplyAsync_Success(Context, string.Format("**{0}** is no longer known as the **{1}**.",
                                                                         species_info.ShortName,
                                                                         StringUtils.ToTitleCase(commonName)));
            }
        }