【发布时间】:2014-09-14 11:29:30
【问题描述】:
我的脚本有点问题。
if (msg.indexOf('!addcom') === 0) {
if (typeof args[1,2] !== 'undefined' && args[1].trim() !== '') {
if(_.indexOf(modlist, user.username) >= 0) {
msg.split(" ");
check = connection.query('SELECT 1 FROM commands WHERE channel = "'+channel+'" AND command = "'+args[1]+'"');
args[2] = args.slice(2).join(" ");
if (check === null) {
connection.query('INSERT INTO commands (channel, command, message) VALUES ("'+channel+'","'+args[1]+'","'+args[2]+'")');
}
else if (check === 1) {
client.say(channel, "Der Befehl " +args[1]+ " existiert bereits!");
}
else {
client.say(channel, "Ein Fehler ist aufgetreten!");
}
}
else {
client.say(channel, user.username+", du bist kein Moderator und kannst diesen Befehl daher nicht ausführen!");
}
}
else {
client.say(channel, "Syntax Fehler: !addcom [!Befehl] [Nachricht]");
}
}
我想检查是否已经有 channel = "'+channel'" AND command = "'args[1]'" 的记录,因为它们在一起是独一无二的,但由于某种原因它无法正常工作。
要么因为重复条目而崩溃,要么只是跳转到最后一个 else 子句else { client.say(channel, "Ein Fehler ist aufgetreten!"); }
有谁知道我哪里出错了?
真诚的和人
【问题讨论】:
标签: mysql node.js record exists