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
Weitere Inhalte können nur Nutzer sehen, die bei uns eingeloggt sind.