$name = "Hello, " . $player->getName();
$text = "Click the Button!";
$buttons = [SimpleNpcDialogueButton::simple("Click me")];
$update_existing = false;
while(true){
try{
$response = yield from NpcDialogueManager::request($player, $name, $text, buttons: $buttons, update_existing: $update_existing);
}catch(NpcDialogueException){
break; // closed, disconnected, or gave invalid response - see NpcDialogueException::getCode()
}
assert(isset($buttons[$response]));
$update_existing = true;
$text = "You clicked the button on " . (new DateTimeImmutable())->format("Y-m-d H:i:s");
}