예제 #1
0
        public async Task DroneAsync(IGuildUser user)
        {
            if (!(this.Context.User is IGuildUser target))
            {
                await _feedback.SendErrorAsync(this.Context, "The target user wasn't a guild user.");

                return;
            }

            var droneMessage = user == target
                ? _content.GetRandomSelfDroneMessage()
                : _content.GetRandomTurnTheTablesMessage();

            await _feedback.SendConfirmationAsync(this.Context, droneMessage);

            var droneResult = await _drone.DroneUserAsync(target);

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

                return;
            }

            await _feedback.SendConfirmationAsync(this.Context, _content.GetRandomConfirmationMessage());
        }
예제 #2
0
    public async Task <Result <FeedbackMessage> > DroneAsync(IGuildMember member)
    {
        if (!member.User.IsDefined(out var user))
        {
            throw new InvalidOperationException();
        }

        var droneMessage = user.ID == _context.User.ID
            ? _content.GetRandomSelfDroneMessage()
            : _content.GetRandomTurnTheTablesMessage();

        var sendMessage = await _feedback.SendContextualNeutralAsync
                          (
            droneMessage,
            _context.User.ID,
            ct : this.CancellationToken
                          );

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

        var droneResult = await _drone.DroneUserAsync
                          (
            _context.GuildID.Value,
            _context.User.ID,
            this.CancellationToken
                          );

        return(!droneResult.IsSuccess
            ? Result <FeedbackMessage> .FromError(droneResult)
            : new FeedbackMessage(_content.GetRandomConfirmationMessage(), _feedback.Theme.Secondary));
    }
예제 #3
0
        public async Task <RuntimeResult> DroneAsync(IGuildUser user)
        {
            if (!(this.Context.User is IGuildUser target))
            {
                return(RuntimeCommandResult.FromError("The target user wasn't a guild user."));
            }

            var droneMessage = user == target
                ? _content.GetRandomSelfDroneMessage()
                : _content.GetRandomTurnTheTablesMessage();

            await _feedback.SendConfirmationAsync(this.Context, droneMessage);

            var droneResult = await _drone.DroneUserAsync(target);

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

            return(RuntimeCommandResult.FromSuccess(_content.GetRandomConfirmationMessage()));
        }