Advertisement
OtKashix

Untitled

Jan 16th, 2021
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports = (client, messageReaction, user) => {
  2.     const mysql = require('mysql');
  3.     require('dotenv').config();
  4.  
  5.     const connection = mysql.createConnection({
  6.         host: 'localhost',
  7.         user: 'bot_user',
  8.         password: process.env.DB_PASS,
  9.         database: 'discord'
  10.     });        
  11.  
  12.     connection.connect();
  13.  
  14.     connection.query(
  15.         'SELECT role_id FROM role_reaction WHERE message_id = "' + messageReaction.message.id + '";',
  16.         function(error, results, fields){
  17.             if(error) return console.log(error);
  18.  
  19.             if(results[0] === undefined){
  20.                 connection.end();
  21.                 return;
  22.             } else{
  23.                 for(let i = 0; i < results.length; i++){
  24.                     user.roles.add(Object.values(results[0])[i]);
  25.                 }
  26.                 connection.end();
  27.             }
  28.         }
  29.     );
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement