I'm trying to take user inputs through discord and turn them into commands using imported files of my own making. The commands follow a "XX! [object] [function] command. How do I turn an inputted string into a object? Or is there someway that I can use something similar to getattr('x', 'y')?
def function():
x = "XX! profile view"
getattr(x.lower().split(" ")[1], x.lower().split(" ")[2])()
return
I was hoping that would execute as profile.view(), but its giving me the error AttributeError: 'str' object has no attribute 'view'.