The broader context to these verses is that when they came together as a church they treated the Lord’s Supper as a common matter, like a regular meal. Not only so but in so doing, they treated it as a party where they ignored the poor, injuring them by their actions. There were ‘divisions’ among them v18. Some of them went ahead with ‘private suppers’. As a result, one person remained hungry and another ate and drank to excess even ‘getting drunk’. v22 Therefore the Apostles says: ‘Don’t you have homes to eat and drink in? Or do you despise the church of God by humiliating those who have nothing?’
Therefore to follow the connection of how this ‘unworthy manner’ of practicing the Lords supper with the resulting warning and potential judgment with respect to ‘not discerning’ we do have to decide is the sin principally against the body of believers which has been wounded, the body of Christ in the sacrament which is irrelevantly treated as a common matter, or a combination of both.
The causal conjunction ‘for’ links ‘discerning the body’ to the preceding requirement of ‘self-examination’ that is meant to occur prior to partaking of the elements in the Lord’s Supper. This is our most solid thread that connects self-examination to the Communion. The abuse of the ‘body of Christ’ is only parts of that overall irreverence attached to partaking of the body without discerning the proper meaning of what is being done. In other words their whole conduct was profaning the sacrament. The secondary meaning of the ‘body of Christ’ as the wounded members of the church is not being directly identified as the body from the text. This is why both Catholic and Protestant commentaries generally prefer the meaning as the body of Christ in the sacrament, not the church itself, with exceptions of course.
For example one Roman Catholic Commentary explains the feast being abused was a preliminary meal before Mass but the attitudes were directly linked to how they later partook of the Mass itself. The sin was basically not recognizing the actual body of Christ in the bread and only thinking it was just regular bread (according to the view of transubstantiation):
To convince them that this unchristian supper is no right preparation for Mass, he formally recalls to them the foundation of the Mass and its meaning …‘Not discerning’: ‘not distinguishing’—making no distinction in act between the Body and ordinary bread. Their sin was not unbelief but irreverence. (Rees, W. (1953). 1 and 2 Corinthians. In B. Orchard & E. F. Sutcliffe (Eds.), A Catholic Commentary on Holy Scripture (B. Orchard & E. F. Sutcliffe, Ed.) (1094).)
Calvin says:
He adds the reason—because they distinguish not the Lord’s body, that is, as a sacred thing from a profane. “They handle the sacred body of Christ with unwashen hands, (Mark 7:2,) nay more, as if it were a thing of nought, they consider not how great is the value of it.3 They will therefore pay the penalty of so dreadful a profanation.” (Calvin, J., & Pringle, J. (2010). Vol. 1: Commentaries on the Epistles of Paul the Apostle to the Corinthians (389))
Lange has a similar approach:
not discerning the body.—The verb διακρίνειν is translated either, to distinguish—in this case from ordinary food and drink, or, in order to escape the necessity of adopting a different signification from that in ver. 31, to judge., i. e., in regard to the body of Christ, whose symbol he receives;—in other words, to make a careful estimate of its sanctity and importance (Meyer). (Lange, J. P., Schaff, P., Kling, C. F., & Poor, D. W. (2008). A commentary on the Holy Scriptures: 1 Corinthians (239).)
Perhaps the best explanation is from Hodge:
Let a man examine himself. In other words, let him ascertain whether he has correct views of the nature and design of the ordinance, and whether he has the proper state of mind. That is, whether he desires thankfully to commemorate the Lord’s death, renewedly to partake of the benefits of that death as a sacrifice for his sins, publicly to accept the covenant of grace with all its promises and obligations, and to signify his fellowship with his brethren as joint members with himself of the body of Christ. And so let him eat. That is, after this self-examination, and, as is evidently implied, after having ascertained that he possesses the due preparation. It is not essential, however, to this preparation, as before remarked, that we should be assured of our good estate, but simply that we have the intelligent desire to do what Christ requires of us when we come to his table. If we come humbly seeking him, he will bid us welcome, and feed us with that bread whereof if a man eat, he shall never die….where he who eats unworthily is said to contract guilt in reference to the body of the Lord. Not discerning, i. e. because he does not discern the Lord’s body. The word διακρίνω, translated to discern, means to separate, then to cause to differ, as 4:7; and also, judge of, either in the sense of discriminating one thing from another, or in the sense of estimating aright. This passage may therefore mean, not discriminating the Lord’s body, i. e. making no difference between the bread in the sacrament and ordinary food; or, it may mean, not estimating it aright, not reverencing it as the appointed symbol of the body of the Lord. In either case the offence is the same. The ground of the condemnation incurred is, regarding and treating the elements in the Lord’s supper as though there was nothing to distinguish them from ordinary bread and wine. Here, as before, it is the careless and profane who are warned. There is, therefore, nothing in these passages which should surround the Lord’s table with gloom. We are not called unto the mount covered with clouds and darkness, from which issue the signs of wrath, but unto Mount Zion, to the abode of mercy and grace, where all is love—the dying love of him who never breaks the bruised reed.( Hodge, C. (1857). An exposition of the First epistle to the Corinthians (233). New York: Robert Carter & Brothers.)
An alternate view I do not espouse
Although I have not included the view that this could be principally referring to the body of Christ as the church (because it seem to be a minority view and I am not persuaded that view is directly taken from the text) here is an example of how it can be taken that way:
In this context it refers specifically to the disunity and factious spirits of some in the church at Corinth (cf. II Cor. 13:5)…“His body” seems to refer not to the physical body (1) of Jesus or (2) the participants, but to the Church as a group (cf. 10:17; 12:12–13, 27). Disunity is the problem. A spirit of superiority or class distinctions destroys the fellowship. (Utley, R. J. (2002). Vol. Volume 6: Paul’s Letters to a Troubled Church: I and II Corinthians. Study Guide Commentary Series (135). Marshall, TX: Bible Lessons International.)
I do not agree with this ‘from the context’ approach since the context is the Lord’s Supper as has been understood by the majority. Of course the majority is not always right, I only mention them when siding with them as it does put a certain amount of weight that a minority must take greater effort to lift when attempting to correct.