Exemple #1
0
        private async Task _deleteTaxonAsync(Taxon[] taxa)
        {
            // Ensure that the user has necessary privileges to use this command.
            if (!await BotUtils.ReplyHasPrivilegeAsync(Context, PrivilegeLevel.ServerModerator))
            {
                return;
            }

            if (await BotUtils.ReplyAsync_ValidateTaxa(Context, taxa))
            {
                if ((await TaxonUtils.GetSpeciesAsync(taxa[0])).Count() > 0)
                {
                    // If the taxon still has species underneath of it, don't allow it to be deleted.
                    await BotUtils.ReplyAsync_Error(Context, "Taxa containing species cannot be deleted.");
                }
                else
                {
                    // The taxon is empty, so delete the taxon.

                    await TaxonUtils.DeleteTaxonAsync(taxa[0]);

                    await BotUtils.ReplyAsync_Success(Context, string.Format("{0} **{1}** was successfully deleted.", StringUtils.ToTitleCase(taxa[0].GetTypeName()), taxa[0].GetName()));
                }
            }
        }