Advertisement
LH_Lawliet

Untitled

Aug 21st, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.62 KB | None | 0 0
  1. const Discord = require('discord.js')
  2. const bot = new Discord.Client()
  3.  
  4.  
  5. var mysql = require('mysql');
  6.  
  7. var con = mysql.createConnection({
  8. host: "127.0.0.1",
  9. user: "root",
  10. password: "",
  11. database: "discord"
  12. });
  13.  
  14. bot.on('ready', function () {
  15. console.log("Je suis connecté !")
  16. })
  17.  
  18. bot.login('MzQ4NDg5MTQ1NDAxODY4Mjg5.DHo9LA.u_YUrrfF__7vFR-ksKGX4LcFhOc')
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. bot.on('message', message => {
  26. if (message.content === '!help') {
  27. message.reply('Il y a énormément de commande comme !')
  28. message.reply('!ping')
  29. message.reply('!random')
  30. message.reply('!bonjour')
  31. message.reply('!info')
  32. message.reply('plein d autre en dev')
  33. }
  34. })
  35.  
  36.  
  37. bot.on('message', message => {
  38. if (message.content === '!ping') {
  39. message.reply('pong !')
  40. }
  41. })
  42.  
  43.  
  44.  
  45. // Create an event listener for messages
  46. bot.on('message', message => {
  47. // If the message is "what is my avatar"
  48. if (message.content === '!info') {
  49. // Send the user's avatar URL
  50. message.reply('ton avatar est '+message.author.avatarURL);
  51. message.reply('ton id est '+message.author.id);
  52. message.reply('ton pseudo est '+message.author.username);
  53. }
  54. });
  55.  
  56. // Create an event listener for messages
  57. bot.on('message', message => {
  58. // If the message is "ping"
  59. if (message.content === '!bonjour') {
  60. // Send "pong" to the same channel
  61. message.reply('aurevoir');
  62. }
  63. });
  64.  
  65.  
  66.  
  67. bot.on('message', message => {
  68. // If the message is "what is my avatar"
  69. if (message.content === '!addmoney') {
  70. discordid=message.author.id
  71. var sql = "INSERT INTO user (id, money) VALUES ("+discordid+", '2000')";
  72. con.query(sql, function (err, result) {
  73. if (err) throw err;
  74. console.log("money inserted");
  75. });
  76. };
  77. })
  78.  
  79.  
  80. bot.on('message', message => {
  81.  
  82. if (message.content === '!bankbalance') {
  83. discordid=message.author.id
  84. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  85. if (err) throw err;
  86. console.log(result);
  87. message.reply("tu a "+result[0].money+" points");
  88. });
  89. };
  90.  
  91. })
  92.  
  93.  
  94.  
  95. bot.on('message', message => {
  96. if (message.content === '!random') {
  97.  
  98. var random = Math.floor((Math.random() * 14) + 1);
  99.  
  100. if (random == 1) {
  101.  
  102. discordid=message.author.id
  103. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  104. if (err) throw err;
  105. console.log(result);
  106. moneyofuser=result[0].money
  107. console.log(result[0].money);
  108. moneyofuser=moneyofuser*5
  109. message.reply('As (money*5)')
  110. message.reply(moneyofuser)
  111. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  112. con.query(sql, function (err, result) {
  113. if (err) throw err;
  114. console.log(result.affectedRows + " record(s) updated");
  115. });
  116.  
  117. });
  118. }
  119. else if (random == 2) {
  120.  
  121. discordid=message.author.id
  122. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  123. if (err) throw err;
  124. console.log(result);
  125. moneyofuser=result[0].money
  126. console.log(result[0].money);
  127. moneyofuser=moneyofuser/10
  128. message.reply('tu a eu un 2 (money/10)')
  129. message.reply(moneyofuser)
  130. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  131. con.query(sql, function (err, result) {
  132. if (err) throw err;
  133. console.log(result.affectedRows + " record(s) updated");
  134. });
  135. });
  136. }
  137. else if (random == 3) {
  138.  
  139. discordid=message.author.id
  140. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  141. if (err) throw err;
  142. console.log(result);
  143. moneyofuser=result[0].money
  144. console.log(result[0].money);
  145. moneyofuser=moneyofuser/2
  146. message.reply('tu a eu un 3 (money/2)')
  147. message.reply(moneyofuser)
  148. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  149. con.query(sql, function (err, result) {
  150. if (err) throw err;
  151. console.log(result.affectedRows + " record(s) updated");
  152. });
  153. });
  154. }
  155. else if (random == 4) {
  156.  
  157. discordid=message.author.id
  158. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  159. if (err) throw err;
  160. console.log(result);
  161. moneyofuser=result[0].money
  162. console.log(result[0].money);
  163. moneyofuser=moneyofuser/2
  164. message.reply('tu a eu un 4 (money/2)')
  165. message.reply(moneyofuser)
  166. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  167. con.query(sql, function (err, result) {
  168. if (err) throw err;
  169. console.log(result.affectedRows + " record(s) updated");
  170. });
  171. });
  172. }
  173. else if (random == 5) {
  174.  
  175. discordid=message.author.id
  176. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  177. if (err) throw err;
  178. console.log(result);
  179. moneyofuser=result[0].money
  180. console.log(result[0].money);
  181. moneyofuser=moneyofuser/2
  182. message.reply('tu a eu un 5 (money/2)')
  183. message.reply(moneyofuser)
  184. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  185. con.query(sql, function (err, result) {
  186. if (err) throw err;
  187. console.log(result.affectedRows + " record(s) updated");
  188. });
  189. });
  190. }
  191. else if (random == 6) {
  192.  
  193. discordid=message.author.id
  194. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  195. if (err) throw err;
  196. console.log(result);
  197. moneyofuser=result[0].money
  198. console.log(result[0].money);
  199. moneyofuser=moneyofuser/2
  200. message.reply('tu a eu un 6 (money/2)')
  201. message.reply(moneyofuser)
  202. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  203. con.query(sql, function (err, result) {
  204. if (err) throw err;
  205. console.log(result.affectedRows + " record(s) updated");
  206. });
  207. });
  208. }
  209. else if (random == 7) {
  210.  
  211. discordid=message.author.id
  212. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  213. if (err) throw err;
  214. console.log(result);
  215. moneyofuser=result[0].money
  216. console.log(result[0].money);
  217. moneyofuser=moneyofuser/2
  218. message.reply('tu a eu un 7 (money/2)')
  219. message.reply(moneyofuser)
  220. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  221. con.query(sql, function (err, result) {
  222. if (err) throw err;
  223. console.log(result.affectedRows + " record(s) updated");
  224. });
  225. });
  226. }
  227. else if (random == 8) {
  228.  
  229. discordid=message.author.id
  230. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  231. if (err) throw err;
  232. console.log(result);
  233. moneyofuser=result[0].money
  234. console.log(result[0].money);
  235. moneyofuser=moneyofuser*2
  236. message.reply('tu a eu un 8 (money*2)')
  237. message.reply(moneyofuser)
  238. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  239. con.query(sql, function (err, result) {
  240. if (err) throw err;
  241. console.log(result.affectedRows + " record(s) updated");
  242. });
  243. });
  244. }
  245.  
  246. else if (random == 9) {
  247.  
  248. discordid=message.author.id
  249. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  250. if (err) throw err;
  251. console.log(result);
  252. moneyofuser=result[0].money
  253. console.log(result[0].money);
  254. moneyofuser=moneyofuser*2
  255. message.reply('tu a eu un 9 (money*2)')
  256. message.reply(moneyofuser)
  257. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  258. con.query(sql, function (err, result) {
  259. if (err) throw err;
  260. console.log(result.affectedRows + " record(s) updated");
  261. });
  262. });
  263. }
  264. else if (random == 10) {
  265.  
  266. discordid=message.author.id
  267. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  268. if (err) throw err;
  269. console.log(result);
  270. moneyofuser=result[0].money
  271. console.log(result[0].money);
  272. moneyofuser=moneyofuser*2
  273. message.reply('tu a eu un 10 (money*2)')
  274. message.reply(moneyofuser)
  275. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  276. con.query(sql, function (err, result) {
  277. if (err) throw err;
  278. console.log(result.affectedRows + " record(s) updated");
  279. });
  280. });
  281. }
  282. else if (random == 11) {
  283.  
  284. discordid=message.author.id
  285. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  286. if (err) throw err;
  287. console.log(result);
  288. moneyofuser=result[0].money
  289. console.log(result[0].money);
  290. moneyofuser=moneyofuser*2
  291. message.reply('tu a eu un VALET (money*2)')
  292. message.reply(moneyofuser)
  293. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  294. con.query(sql, function (err, result) {
  295. if (err) throw err;
  296. console.log(result.affectedRows + " record(s) updated");
  297. });
  298. });
  299. }
  300. else if (random == 12) {
  301.  
  302. discordid=message.author.id
  303. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  304. if (err) throw err;
  305. console.log(result);
  306. moneyofuser=result[0].money
  307. console.log(result[0].money);
  308. moneyofuser=moneyofuser*2
  309. message.reply('tu a eu une DAMME (money*2)')
  310. message.reply(moneyofuser)
  311. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  312. con.query(sql, function (err, result) {
  313. if (err) throw err;
  314. console.log(result.affectedRows + " record(s) updated");
  315. });
  316. });
  317. }
  318. else if (random == 13) {
  319.  
  320. discordid=message.author.id
  321. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  322. if (err) throw err;
  323. console.log(result);
  324. moneyofuser=result[0].money
  325. console.log(result[0].money);
  326. moneyofuser=moneyofuser*2
  327. message.reply('tu a eu un ROI (money*2)')
  328. message.reply(moneyofuser)
  329. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  330. con.query(sql, function (err, result) {
  331. if (err) throw err;
  332. console.log(result.affectedRows + " record(s) updated");
  333. });
  334. });
  335. }
  336. else if (random == 14) {
  337.  
  338. discordid=message.author.id
  339. con.query("SELECT money FROM user WHERE id="+discordid+"", function (err, result, fields) {
  340. if (err) throw err;
  341. console.log(result);
  342. moneyofuser=result[0].money
  343. console.log(result[0].money);
  344. moneyofuser=moneyofuser*10
  345. message.reply('tu a eu un JOKER (money*10)')
  346. message.reply(moneyofuser)
  347. message.reply('C`est incroyable tu a eu un JOKER @here')
  348. var sql = "UPDATE user SET money = "+moneyofuser+" WHERE id ="+discordid+"";
  349. con.query(sql, function (err, result) {
  350. if (err) throw err;
  351. console.log(result.affectedRows + " record(s) updated");
  352. });
  353. });
  354. }
  355. }
  356. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement