public async Task <RuntimeResult> SetRoleplayIsPublic
            (
                bool isPublic,
                [RequireEntityOwnerOrPermission(typeof(EditRoleplay), PermissionTarget.Other)]
                Roleplay roleplay
            )
            {
                var result = await _discordRoleplays.SetRoleplayIsPublicAsync(roleplay, isPublic);

                if (!result.IsSuccess)
                {
                    return(result.ToRuntimeResult());
                }

                var getDedicatedChannelResult = await _dedicatedChannels.GetDedicatedChannelAsync
                                                (
                    this.Context.Guild,
                    roleplay
                                                );

                if (!getDedicatedChannelResult.IsSuccess)
                {
                    return(RuntimeCommandResult.FromSuccess
                           (
                               $"Roleplay set to {(isPublic ? "public" : "private")}"
                           ));
                }

                var dedicatedChannel = getDedicatedChannelResult.Entity;
                var everyoneRole     = this.Context.Guild.EveryoneRole;

                var setVisibility = await _dedicatedChannels.SetChannelVisibilityForRoleAsync
                                    (
                    dedicatedChannel,
                    everyoneRole,
                    isPublic
                                    );

                if (!setVisibility.IsSuccess)
                {
                    return(setVisibility.ToRuntimeResult());
                }

                return(RuntimeCommandResult.FromSuccess
                       (
                           $"Roleplay set to {(isPublic ? "public" : "private")}"
                       ));
            }
        public async Task <Result <FeedbackMessage> > SetRoleplayIsPublic
        (
            bool isPublic,
            [RequireEntityOwner]
            [AutocompleteProvider("roleplay::owned")]
            Roleplay roleplay
        )
        {
            var result = await _discordRoleplays.SetRoleplayIsPublicAsync(roleplay, isPublic);

            if (!result.IsSuccess)
            {
                return(Result <FeedbackMessage> .FromError(result));
            }

            return(new FeedbackMessage
                   (
                       $"Roleplay set to {(isPublic ? "public" : "private")}",
                       _feedback.Theme.Secondary
                   ));
        }
Esempio n. 3
0
            public async Task SetRoleplayIsPublic
            (
                bool isPublic,
                [RequireEntityOwnerOrPermission(typeof(EditRoleplay), PermissionTarget.Other)]
                Roleplay roleplay
            )
            {
                var result = await _discordRoleplays.SetRoleplayIsPublicAsync(roleplay, isPublic);

                if (!result.IsSuccess)
                {
                    await _feedback.SendErrorAsync(this.Context, result.ErrorReason);

                    return;
                }

                var getDedicatedChannelResult = await _dedicatedChannels.GetDedicatedChannelAsync
                                                (
                    this.Context.Guild,
                    roleplay
                                                );

                if (getDedicatedChannelResult.IsSuccess)
                {
                    var dedicatedChannel = getDedicatedChannelResult.Entity;
                    var everyoneRole     = this.Context.Guild.EveryoneRole;

                    await _dedicatedChannels.SetChannelVisibilityForRoleAsync
                    (
                        dedicatedChannel,
                        everyoneRole,
                        isPublic
                    );
                }

                await _feedback.SendConfirmationAsync(this.Context, $"Roleplay set to {(isPublic ? "public" : "private")}");
            }