In case anybody is wondering how to do the same thing in Strapi v4
This is how my lifecycles file looks like:
async beforeCreate(event) {
event.params.data.slug = await strapi.service('plugin::content-manager.uid').generateUIDField({
contentTypeUID: "api::category.category",
field: "slug",
data: event.params.data
})
}
}