'My google apps script will show a error that I can't fix

I coded a bot a few months ago and recently has been showing an error that goes 'TypeError: Cannot read property 'getId' of undefined' I have just tried to fix it, but I can't get it to work. The bug is at line 16: Possibly the back of the variable. This is posted on Github, but not all the code is exact: https://github.com/Puuumkkiinnss/GmailBot/blob/main/Code.gs is the link for the code

//The source code for the bot 

//Create draft
var createDraft = GmailApp.createDraft[1];

//The date for the draft w/timestamp
var now = new Date();

//Get the users draft folder 
var userDraft = GmailApp.getDrafts();

//Get the first draft message in the draft folder
var draft = GmailApp.getDrafts()[0]; 

 //Gets the draft id 
 var draftId = draft.getId();

//Gets the users draft id
var draftById = GmailApp.getDraft(draftId)

  //I have no clue what this does send help
 Logger.log(draft.getMessage().getSubject() == draftById.getMessage().getSubject());
//Get the inbox threads 
var thread = GmailApp.getInboxThreads();

//Get the first 50 subjects 
var firstThread = GmailApp.getInboxThreads(0, 50);

GmailApp.createDraft("[email protected]", "current time", "The time is: " + now.toString());

Console.Log(InboxThreads);
//What happens if the bot sends the draft
function send (){
 if (userDraft == true) {
   send(draft);
  } 
}

//Makes a copy of the sent draft that was sent to the selected user
var get = draft.getMessage();

//Send the draft to the selected user (The send function shows what happens)
var msg = draft.send();
function subject() {
  //Log subject line
  Logger.log(message.getSubject());
}

//Code that helps the thread variable
function threads () {
  for (var i = 0; i < threads.length; i++) {
    Logger.log(threads[i].getFirstMessageSubject());
  } 
}

//Function that helps the userDraft variable 
function drafts() {
  for (var i = 0; i < drafts.length; i++) {
   Logger.log(drafts[i].getId());
  }
}

//Make the whole enitre sent html work like normal 
function doGet() {
  return HtmlService.createHtmlOutputFromFile("sent");
}

//Code that helps the draftById Variable
function draftById() {
  if (draftById == true) {
    Logger.log('We have the draft ID!');
  }

  if (draftById == false) {
    Logger.Log('We do not have the draft id!');
  }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source