I am using Node.js (discord.js specifically) to make a Discord bot. I have a command called !add which takes 2+ arguments. !add Name This is the reply (Name would be args[0]). This is my code I use to check if the Name they input has already been created by a user:
var info = {
"commandname": args[0],
"commandreply": args.join(" ").slice(1),
"username": message.author.name,
"userid": message.author.id
}
connection.query("SELECT * FROM commands WHERE commandname = " + args[0], info, function(error) {
if (error) throw error;
// should only fireif that command name already exists as a command.
return message.channel.sendMessage("A command with command name " + args[0] + " already exists.");
});
// SHOULD fire - as no commands in my database yet. Especially not with that name.
console.log("Trying to insert command " + args[0] + " into Database.");
But I am getting an error when I run this command:
Error: ER_BAD_FIELD_ERROR: Unknown column 'Name' in 'where clause'
This is my full code for the add command if you want to take a look:https://hastebin.com/qulivabeko.js
This is how my database currently looks: http://imgur.com/a/L7fYI
I am really new to SQL.
via Rusty
No comments:
Post a Comment