From what I understood the answer is les but that seems very weird to me, I learned that: "Je n'aime pas les gâteaux" == "I don't like the cakes" so shouldn't I use des? "Je n'aime pas des gâteaux"?
The use of the article "les" in this context is what you call "générique": it is used to specify a category.
basic example: Je n'aime pas les gâteaux.
If, however, you are at a party and there are cakes, and after having tasted some you don't like them, you can say to a friend
"Je n'aime pas les gâteaux.".
In that case the use of "les" is determinative, that is, it makes precise which cakes you don't like, but only because your friend knows about those cakes; for instance you know he/she has tasted them already. Nevertheless, this is not all that simple; your utterance will truly be free of the risk of misinterpretation only if there exists an understanding in the mind of the person you're talking to, so you might say first
"J'ai gouté un peu à tout et je n'aime pas les gateaux.".
There is then no ambiguity; the listener knows you are talking about the cakes that have been offered you. It's a simple deduction for him/her.
Let's leave aside the context of a party and suppose you are chatting with friends about everything and nothing and that for instance you start off after a moment's silence with "Je n'aime pas les gateaux."; then the generic use will be understood, that is, you don't like cakes generally.
You must however bear in mind that the ambiguity is a cause of misunderstanding now and then even for French speakers, as sometimes they assume too much about what their listener understands. To avoid such little problems you must be aware that there is the possibility of being ambiguous and provide more information. For instance you might choose to say
"Je n'aime pas ces/les gâteaux qu'ils ont mis sur les tables.".
The determinative terms leave no ambiguity. Of course, what you choose to say must be relevant to the particular context - that goes without saying.
There is a last point in your question, the use of "des" in
"Je n'aime pas des gateaux.".
By that, you probably intend to say "I don't like some of the cakes." if you're talking about a certain predetermined number of cakes, or if you're talking about all cakes "I don't like some cakes", which you can say equivalently enough with the sentence "There are cakes (that) I don't like." or maybe "Some cakes, I don't like."
In French, in neither case would you say "Je n'aime pas des gâteaux.". In both cases you might however say
"Il y a des gâteaux que je n'aime pas.",
and of course, again, your speech is liable to be misunderstood, the problem and its remedy being as discussed above.
Another possibility without the partitive "des" would be
"Je n'aime pas tous les gateaux.".
but that is also the same thing in English in the first case: "I don't like all the cakes.". In the second case, that is when you want to say "I don't like all cakes.", you can use the same form ("Je n'aime pas tous les gâteaux."). The lack of zero article forms in French, as in these examples, makes it sometimes less versatile than English.
"I don't like the cakes."
In French, it would translate to: "Je n'aime pas les gâteaux."
"I don't like some cakes."
In French, it would translate to: "Je n'aime pas des gâteaux."
In French, depending upon the context des may mean:
Whereas les literally translates to the of English.
Les is a definite article and is used when the quantity of noun is plural irrespective of its gender. Its singular counterparts are:
(i) le (singular masculine the) [Le bol - The bowl], and
(ii) la (singular feminine the) [La voiture - The car]
Observe the following:
The cars - Les voitures
The bowls - Les bols
Des is used to express plural unspecified quantities and it literally translates to some.
Example: Some cakes - Des gâteaux
For singular unspecified quantities use:
(i) du + masculine word [Du thé - Some tea]
(ii) de la + feminine word [De la glace - Some ice cream]
(iii) de l’ followed by word starting with a vowel. [De l'eau - Some water]