You use it primary, if you know you will have something more times, for example getting member information, you will do it in multiple commands, then use function.
There are 2 types of functions
Normal function
This function will do something, and won´t return any value
Example of using functionT
This will send a message to channel saying that user bought a potato