List manipulation idea

I think a slight confusion about what d refers to has crept into your script.

In the first line, you are binding the name d to a string value (d.content), but the name you have chosen suggests that you may have thought it was a reference to the draft object.

by the time you get down to

d.update;
editor.focus(d);

You are trying to call a draft object method on a String.

d.update() fails because Strings don’t have an update method.

The impression that it ‘works’ when you remove the trailing parentheses is just created by the fact that nothing is happening at all, not even an error message.

The draft is not being updated.

editor.focus(d) also looks a bit unlikely to have much effect.

Javascript types are quite slippery – the automatic coercions, and silent failures with undefined can easily leave one with a slightly vague sense of what is happening.

Time wasted tracking down bugs can be reduced (both for you and for those you share code with) by depending less on automatic type conversion, and by using a slightly more defensive approach to staying clear about the type of values that names are bound to.

// UNFIXED SOURCE CODE OF https://actions.getdrafts.com/a/1Ec
// BEST NOT TO RUN THIS CODE – BUGS AHEAD

// Move lines containing a completed markdown task (“- [x]”) to the bottom of the current draft.

var d = draft.content;
var lines = d.split("\n");
var begin = '';
var end = '';
var c ="- [x]";

for (var line of lines) {
  var check = line.includes(c);
  //if line contains "- [x]"… 
  if (check) {
  //add it to var end
    end += line + "\n";
  }
  else {
    begin += line + "\n";
  }
}
begin = begin.slice(0,-1);
end = end.slice(0,-1);
editor.setText(begin + "\n" + end);
d.update;
editor.focus(d);