\(B=\left(x-y\right)^3-\left(x-y\right)\left(x^2+xy+y^2\right)+3xy\left(x-y\right)+2023\\ =\left(x^3-3x^2y+3xy^2-y^3\right)-\left(x^3-y^3\right)+3xy\left(x-y\right)+2023\\ =x^3-3x^2y+3xy^2-y^3-x^3+y^3+3x^2y-3xy^2+2023\\ =\left(x^3-x^3\right)+\left(y^3-y^3\right)+\left(3x^2y-3x^2y\right)+\left(3xy^2-3xy^2\right)+2023\\ \\ =0+0+0+0+2023\\ =2023\)