Failing commands

I am on Kithgard Brawl 4 and my code is giving me an error: Hero placeholder needs something to command.

# Survive the waves of ogres.
# If you win, the level gets harder, and gives more rewards.
# If you lose, you must wait a day to re-submit.
# Each time you submit gives a new random seed.
self.cast("invisibility", self)
self.summon("peasant")
def commandSoldiers(enemies):
    for friend in self.findFriends():
        nearest=friend.findNearest(enemies)
        if friend and nearest:
            self.command(friend, "attack", nearest)

loop:
    palisades=[{"x":45,"y":36},{"x":40,"y":32},{"x":37,"y":35},{"x":38,"y":36}]
    for palisade in palisades:
        peasant=self.findByType("peasant")
        if peasant:
            self.command(peasant, "buildXY", palisade)
    commandSoldiers(self.findEnemies())
    item = self.findNearest(self.findItems())
    if item:
        self.move(item.pos)
        continue
    if self.gold>=20:
        self.summon("soldier")
    nearest = self.findNearest(self.findEnemies())
    if self.isReady("invisibility"):
        self.cast("invisibility", self)
        continue
    if self.hasEffect("hide"):
        continue
    if nearest:
        if self.isReady("chain-lightning"):
            self.cast("chain-lightning", nearest)
            continue
        distance=self.distanceTo(nearest)
        if (distance > 6):
             self.move(nearest.pos)
        else:
             if self.isReady("cleave"):
                  self.cleave(nearest)
                  continue
            self.attack(nearest)


    

peasant=self.findByType("peasant")
Returns an array of peasant objects (even if there is only 1)
You need to command peasant[0]

maby

self.command(peasant, ‘buildXY’, “palisade”, palisade.x, palisade.y)