TypeError: Cannot read property 'fetch' of undefined Was tun?

Hallo Leute!

Ich programmiere derzeit meinen eigenen Discord Bot und versuche nun, Nachrichten aus DM's zu kopieren. Allerdings komme ich da nicht weit.

Ich habe es nun einmal mit messages.fetch ausprobiert, aber da gibt die Konsole nur TypeError: Cannot read property 'fetch' of undefined aus.

  1. Frage: Komme ich überhaupt mit diesem Befehl weit, um die Nachrichten zu kopieren?
  2. Frage: Wie kann ich den Fehler beheben?

Hier das Skript:

let userApplications = {}

client.on("message", function(message) {
  if (message.author.equals(client.user)) return;

  let authorId = message.author.id;
  authorId.messages.fetch('dm.author.id')
    .then(message => console.log(message.content))
    .catch(console.error);

  if (message.content === "!bewerben") {
    console.log(Apply begin for authorId ${authorId}); // User is not already in a registration process

  if (!(authorId in userApplications)) {
    userApplications[authorId] = { "step" : 1 }
    message.author.send("`Dein Ingamename, Vorname");
  }
}
else {
  if (message.channel.type === "dm" && authorId in userApplications) {
    let authorApplication = userApplications[authorId];

    if (authorApplication.step == 1) {
      message.author.send("Alter");
      authorApplication.step++;
    }
    else if (authorApplication.step == 2) {
      message.author.send("Citybuild?");
      authorApplication.step++;
    }
    else if (authorApplication.step == 3) {
      message.author.send("Seit wann spielst du auf Bausucht? (Start, Onlinetime)");
    authorApplication.step++;
  }
  else if (authorApplication.step == 4) {
    message.author.send("Du hast dich erfolgreich beworben.`");
    delete userApplications[authorId];
  }
}
}
});

Danke im Voraus!

Computer, programmieren, JavaScript, Discord
JavaScript: Schachbrett Schleifen?

Leute, bitte, ich brauche Hilfe, wer programmieren kann.

Ich habe es versucht, aber keine Ahnung warum, es funktioniert nicht.

Ich wäre sehr dankbar, wenn ich Tipps oder so hier bekommen würde.

Was fehlt? Was ist falsch?

JavaScript:

"use strict";

window.addEventListener("load", init);

let i;
let t;
let tr;
let td;

function init() {
  console.log("Fenster ist geladen");

  let btn = document.getElementById("btn");
  btn.addEventListener("click", btn_angeklickt);
}

function btn_angeklickt() {
  console.log("btn angecklickt");

  let zeilen = document.getElementById("zeilen").value;
  console.log(zeilen);

  let spalten = document.getElementById("spalten").value;
  console.log(spalten);

  let table = document.getElementById("bratan");
  
  for (i = 0; i < spalten.value; i++);
  {
    tr = document.createElement("tr");
    table.appendChild(tr);

    for (t = 0; t < zeilen.value; t++);
    {
      td = document.createElement("td");

      if (i % 2 == t % 2) {
        td.style.backgroundColor = colors[0];
        td.style.height = "60px";
        td.style.width = "60px";
      }
      else {
        td.style.backgroundColor = colors[1];
        td.style.height = "60px";
        td.style.width = "60px";
      }
    }
  }

  tr.appendChild(td);
}

let colors = ["#044272", "#80AB52"];

HTML:

  <label for="Anzahl">Zeilen</label>
  <input type="number" id="zeilen">
  <br><br>
  <label for="Anzahl">Spalten</label>
  <input type="number" id="spalten">
</form>
<br>
<button type="button" id="btn" value="btn">erstelle Schachbrett</button>
<table id="bratan"></table>
Bild zum Beitrag
PC, Computer, HTML, programmieren, JavaScript

Meistgelesene Beiträge zum Thema JavaScript