특정 사용자가 스트리밍 중인지 확인하는 봇을 만들려고했지만 어떤 이유로 확인 3 이상이되지 않습니다.
client.on("presenceUpdate", (oldPresence, newPresence) => {
if(newPresence.user.id === config.LORD_ID) {
console.log("Check 2 passed")
if(newPresence.guild.id === config.STRATZ_SERVER_ID) {
console.log("Check 3 passed")
if (!newPresence.activities) return false;
newPresence.activities.forEach(activity => {
if (activity.type == "STREAMING") {
console.log("Check 4 passed")
if (canNotifyStreaming) {
console.log("Check 5 passed")
if(activity.url.startsWith("www.youtube.com")) {
console.log("Final check passed")
itsYOUTUBESTREAMTIME();
canNotifyStreaming = false;
setTimeout(() => { canNotifyStreaming = true; }, 86400000);
} else if(activity.url.startsWith("www.twitch.tv")) {
console.log("Final check for twitch passed")
itsSTREAMTIME();
canNotifyStreaming = false;
setTimeout(() => { canNotifyStreaming = true; }, 86400000);
}
}
};
});
}
}
});
코드가 체크 3 이상으로 진행하지 않는 이유가 있습니까?
참고 : 문제가 어리 석다면 죄송합니다. 저는 일반적으로 3 개월 동안 만 discord.js 및 node.js로 코딩했습니다.
if (!newPresence.activities) return false;
이것은 코드를 중지하고 다음을 시도하십시오.
if (newPresence.activities) {
newPresence.activities.forEach(activity => {
// ...
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다