Just to note, changing the query as follows:
updateOne(
{ userId: "100", guilds: { $elemMatch: { guildId: { $eq: '1' } } } },
{
$set: {
"guilds.$.xp": 5,
},
},
);
Does update the database, however it deletes the array and replaces it with an empty Object named guilds