Esempio n. 1
0
        public async Task Roles(string arg0)
        {
            // Possible cases:
            // 1. <role>
            // 2. <species>

            // If a role with this name exists, that's what we'll prioritize (users can use the genus + species overload if they need to).
            // If no such role exists, check for a species with this name instead.

            Common.Roles.IRole role = await Db.GetRoleAsync(arg0);

            if (role.IsValid())
            {
                // The role is valid.
                // List all extant species with this role.

                IEnumerable <ISpecies> species = (await Db.GetSpeciesAsync(role))
                                                 .Where(s => !s.IsExtinct())
                                                 .OrderBy(s => s.GetShortName());

                IEnumerable <Discord.Messaging.IEmbed> pages =
                    EmbedUtilities.CreateEmbedPages($"Extant species with this role ({species.Count()}):", species, options: EmbedPaginationOptions.AddPageNumbers);

                foreach (Discord.Messaging.IEmbed page in pages)
                {
                    page.Title       = $"Role: {role.GetName()}";
                    page.Description = role.GetDescriptionOrDefault();
                }

                await ReplyAsync(new Discord.Messaging.PaginatedMessage(pages));
            }
            else
            {
                // The role is not valid.

                IEnumerable <ISpecies> matchingSpecies = await Db.GetSpeciesAsync(string.Empty, arg0);

                if (matchingSpecies.Count() > 0)
                {
                    ISpecies species = await ReplyValidateSpeciesAsync(matchingSpecies);

                    if (species.IsValid())
                    {
                        await ReplyRolesAsync(matchingSpecies.First());
                    }
                }
                else
                {
                    // There were no matching species, so just say that the role is invalid.

                    await this.ReplyValidateRoleAsync(role);
                }
            }
        }
Esempio n. 2
0
        public async Task SetRoleDescription(string roleName, string description)
        {
            Common.Roles.IRole role = await this.GetRoleOrReplyAsync(roleName);

            if (role.IsValid())
            {
                role.Description = description;

                await Db.UpdateRoleAsync(role);

                await ReplySuccessAsync($"Successfully updated description for role {role.GetName().ToBold()}.");
            }
        }