It isn’t being used as a term of endearment, It’s being used mockingly. Replace nigger with dumbass and you’ll see. In the case of the first message, replace it with “dumbass friend”. Even the hard “er” is intentional to purposely differentiate and ensure there is none of the endearment variation “nigga”.