Ich bin nicht wirklich sicher, aber ich denke, Sie etwas anderes gemeint. Sag mir, wenn ich dich falsch verstanden habe. Aber wie ich deine Frage verstanden habe, ist das der richtige Weg.
in Anbetracht dieser Nachricht = "-say Something Here"; und Ihr Ergebnis sollte sein: "Jemand sagt: Etwas Here"
Ermöglicht durch die Linie auf den Code Zeile aussehen:
if(message === "-say") // I am 100% sure "-say" and
//"-say something here" are different. correct me if i am wrong.
//so we need to check for the first word, or first element in our array of words.
//lets first create array than check: if(message.split(" ")[0] == "-say")
var code = message.split(' ')[1]; //now, we don't have 2 spaces together
//anywhere in our message, so array == nothing.
//I guess it should be more like: message.split(" ").shift().join(" ");
// this will return you: "Something Here".
bot.action("stankotomic", "someone says: " + code);
Ihre endgültige Code:
bot.on("chat", function (channel, user, message, self) {
if(message.split(" ")[0] == "-say")
var code = message.split(" ").shift().join(" ");
bot.action("stankotomic", "someone says: " + code);
});
PS:
Split Dokumentation.
Join Dokumentation.
Shift Dokumentation.