コード例 #1
0
        public Task PrintRoles(RolesCommand rolesCommand, Contexts contexts)
        {
            var messagesService = this._messagesServiceFactory.Create(contexts);
            var query           = new GetDiscordServerSafeRolesQuery(contexts.Server.Id);
            var safeRoles       = this._queryBus.Execute(query).SafeRoles.ToList();

            if (!safeRoles.Any())
            {
                return(messagesService.SendResponse(x => x.ServerDoesntHaveAnySafeRoles()));
            }
            var serverRoles = contexts.Server.GetRoles();
            var rolesNames  = safeRoles
                              .Select(x => serverRoles.FirstOrDefault(serverRole => serverRole.Id == x.RoleId)?.Name)
                              .Where(x => x != default);

            return(this.SendRolesAsEmbedMessage(rolesNames, messagesService, contexts.Server.Id));
        }
コード例 #2
0
        public async Task PrintRoles(RolesCommand rolesCommand, Contexts contexts)
        {
            var messageService = this._messagesServiceFactory.Create(contexts);
            var query          = new GetDiscordServerSafeRolesQuery(contexts.Server.Id);
            var safeRoles      = this._queryBus.Execute(query).SafeRoles.ToList();

            if (safeRoles.Count == 0)
            {
                await messageService.SendResponse(x => x.ServerDoesntHaveAnySafeRoles());

                return;
            }

            var output = new StringBuilder();

            output.PrintManyLines(safeRoles.Select(x => x.Name).ToArray(), contentStyleBox: false, spacesBetweenLines: false);
            await messageService.SendResponse(x => x.AvailableSafeRoles(output.ToString()));
        }