Ejemplo n.º 1
0
        public async Task DeleteBanAsync(long banID)
        {
            var getBan = await _bans.GetBanAsync(this.Context.Guild, banID);

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

                return;
            }

            var ban = getBan.Entity;

            var deleteBan = await _bans.DeleteBanAsync(ban);

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

                return;
            }

            await this.Context.Guild.RemoveBanAsync((ulong)ban.User.DiscordID);

            await _feedback.SendConfirmationAsync(this.Context, "Ban rescinded.");

            var rescinder = await this.Context.Guild.GetUserAsync(this.Context.User.Id);

            await _logging.NotifyUserUnbanned(ban, rescinder);
        }
Ejemplo n.º 2
0
        public async Task <RuntimeResult> DeleteBanAsync(long banID)
        {
            var getBan = await _bans.GetBanAsync(this.Context.Guild, banID);

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

            var ban = getBan.Entity;

            // This has to be done before the warning is actually deleted - otherwise, the lazy loader is removed and
            // navigation properties can't be evaluated
            var rescinder = await this.Context.Guild.GetUserAsync(this.Context.User.Id);

            var notifyResult = await _logging.NotifyUserUnbannedAsync(ban, rescinder);

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

            var deleteBan = await _bans.DeleteBanAsync(ban);

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

            await this.Context.Guild.RemoveBanAsync((ulong)ban.User.DiscordID);

            return(RuntimeCommandResult.FromSuccess("Ban rescinded."));
        }
Ejemplo n.º 3
0
    public async Task <IResult> DeleteBanAsync(long banID)
    {
        var getBan = await _bans.GetBanAsync(_context.GuildID.Value, banID);

        if (!getBan.IsSuccess)
        {
            return(getBan);
        }

        var ban = getBan.Entity;

        // This has to be done before the warning is actually deleted - otherwise, the lazy loader is removed and
        // navigation properties can't be evaluated
        var notifyResult = await _logging.NotifyUserUnbannedAsync(ban, _context.User.ID);

        if (!notifyResult.IsSuccess)
        {
            return(notifyResult);
        }

        var deleteBan = await _bans.DeleteBanAsync(ban);

        if (!deleteBan.IsSuccess)
        {
            return(deleteBan);
        }

        return(await _guildAPI.RemoveGuildBanAsync(_context.GuildID.Value, ban.User.DiscordID));
    }
Ejemplo n.º 4
0
        public async Task <Result <FeedbackMessage> > SetBanReasonAsync(long banID, string newReason)
        {
            var getBan = await _bans.GetBanAsync(_context.GuildID.Value, banID);

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

            var ban = getBan.Entity;

            var setContents = await _bans.SetBanReasonAsync(ban, newReason);

            return(setContents.IsSuccess
                ? new FeedbackMessage("Ban reason updated.", _feedback.Theme.Secondary)
                : Result <FeedbackMessage> .FromError(setContents));
        }
Ejemplo n.º 5
0
            public async Task <RuntimeResult> SetBanReasonAsync(long banID, string newReason)
            {
                var getBan = await _bans.GetBanAsync(this.Context.Guild, banID);

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

                var ban = getBan.Entity;

                var setContents = await _bans.SetBanReasonAsync(ban, newReason);

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

                return(RuntimeCommandResult.FromSuccess("Ban reason updated."));
            }
Ejemplo n.º 6
0
            public async Task SetBanReasonAsync(long banID, string newReason)
            {
                var getBan = await _bans.GetBanAsync(this.Context.Guild, banID);

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

                    return;
                }

                var ban = getBan.Entity;

                var setContents = await _bans.SetBanReasonAsync(ban, newReason);

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

                    return;
                }

                await _feedback.SendConfirmationAsync(this.Context, "Ban reason updated.");
            }