Help with discord.js and SQL intregation

Status
This thread has been locked.

HypeArts

Graphics Designer & Hobbyist Developer
Banned
Feedback score
3
Posts
435
Reactions
123
Resources
0
I have a discord.js bot and I need some huge help here by someone really experienced: https://cdn.discordapp.com/attachments/561619607115399178/561620807584055296/unknown.png (so this is my database)

I assume that I need to create the tables in order to really get started

My objective is, is that when someone is banned using my bot they are stored in this database with 3 entries: ["USERNAME"] ["CLIEND_ID"] ["REASON"]

https://gyazo.com/14ed3e0123fe854c7edc805923e2b093 (is the ban success code)

How can I make it so whenever someone is banned with my bot, they are stored in a database?
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

LillianA

beep boop
Premium
Feedback score
7
Posts
347
Reactions
259
Resources
0
Use https://github.com/eslachance/enmap with one of the extentions for it she has made, I use it and it runs perfectly with TypeScript (of course will work with javascript aswell) and once they are banned just input them into the db.

Not going to spoonfeed you but if you have any sort of knowledge of how to actually program with TypeScript or JavaScript you can figure it out with the documentation she wrote up on it aswell
 

CerealKillahh

Feedback score
2
Posts
43
Reactions
7
Resources
0
https://www.npmjs.com/package/mysql

var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret',
database : 'my_db'
});

connection.connect();

connection.query('
INSERT INTO `banned_users` (`client_id`, `reason`, `username`) VALUES ('$IDVAR', '$REASONVAR', '$USERNAMEVAR')
', post, function (error, results, fields) {
if (error) throw error;
});


connection.end();
 

birthdates

Premium
Feedback score
1
Posts
87
Reactions
38
Resources
0
https://www.npmjs.com/package/mysql

var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret',
database : 'my_db'
});

connection.connect();

connection.query('
INSERT INTO `banned_users` (`client_id`, `reason`, `username`) VALUES ('$IDVAR', '$REASONVAR', '$USERNAMEVAR')
', post, function (error, results, fields) {
if (error) throw error;
});


connection.end();
Also, remember with mysql.js every time you end a connection you must set the "connection" variable function.
 

Function

Minecraft Plugin Developer
Supreme
Feedback score
38
Posts
938
Reactions
332
Resources
0
If you need help with enmap you can always contact me hype, it's your old business partner.

~ Onfrow
 
Status
This thread has been locked.
Top