当我移动功能时,发送()'在此函数中,代码停止工作。
我没有收到任何错误,程序变得没有反应。我不明白为什么,花了半个小时才弄明白如何解决这个问题。我想知道这是什么导致以及将来如何防止它。
提前致谢。
工作代码:
function warn(channelID, userID, reason){
if(!userExists(channelID, userID)) return;
var warnings = players[userID].warnings;
var today = new Date().getTime();
var active = 0;
for (key in warnings){
date = warnings[key].date;
if(today - date < 60*1000){
active++;
}
}
if (active >= 3){
kick(channelID, userID, "You have been automatically kicked after 3 (active) warnings.");
log("Bot", userID, "kick", "3 warnings");
}
send(channelID, reason); //this function
}
移动&#39; send()&#39;代码停止工作功能:
function warn(channelID, userID, reason){
if(!userExists(channelID, userID)) return;
var warnings = players[userID].warnings;
var today = new Date().getTime();
var active = 0;
for (key in warnings){
date = warnings[key].date;
if(today - date < 60*1000){
active++;
}
}
send(channelID, reason); //this function
if (active >= 3){
kick(channelID, userID, "You have been automatically kicked after 3 (active) warnings.");
log("Bot", userID, "kick", "3 warnings");
}
}
在我添加&#39; return之后,代码又开始工作了;&#39;添加函数的结尾。
function warn(channelID, userID, reason){
if(!userExists(channelID, userID)) return;
var warnings = players[userID].warnings;
var today = new Date().getTime();
var active = 0;
for (key in warnings){
date = warnings[key].date;
if(today - date < 60*1000){
active++;
}
}
send(channelID, reason);
if (active >= 3){
kick(channelID, userID, "You have been automatically kicked after 3 (active) warnings.");
log("Bot", userID, "kick", "3 warnings");
}
return;
}