Advertisement
Guest User

Untitled

a guest
Feb 16th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. var Discordie = require("discordie");
  2. var XMLHttpRequest = require('w3c-xmlhttprequest').XMLHttpRequest;
  3. var client = new Discordie();
  4.  
  5. client.connect({
  6. // replace this sample token
  7. token: 'MjgxNjAxMjY5OTAxMTY0NTQ0.C4aVYA.Wd7gIWKlm1m1Tv2xh3rTHlp1DRc'
  8. });
  9.  
  10. client.Dispatcher.on("GATEWAY_READY", e => {
  11. console.log("Connected as: " + client.User.username);
  12. });
  13.  
  14. client.Dispatcher.on("MESSAGE_CREATE", e => {
  15. if (e.message.content == "king")
  16. e.message.channel.sendMessage("brutus");
  17. if (e.message.content == "fuck")
  18. e.message.channel.sendMessage("geren");
  19. if (e.message.content == "test")
  20. e.message.channel.sendMessage("start");
  21. postJSON("http://geist-ro.shivtr.com/users/sign_in.json",
  22. function(err,data){
  23. if (err != null) {
  24. //alert("Something went wrong: " + err);
  25. e.message.channel.sendMessage("miss");
  26. } else {
  27. //alert("Your query count: " + data.query.count);
  28. e.message.channel.sendMessage("hit");
  29. getJSON("http://enmity.shivtr.com/characters.json ",
  30. function(err, data) {
  31. if (err != null) {
  32. //alert("Something went wrong: " + err);
  33. e.message.channel.sendMessage("wrong");
  34. } else {
  35. //alert("Your query count: " + data.query.count);
  36. e.message.channel.sendMessage("right");
  37. e.message.channel.sendMessage(data.characters[0].id);
  38. //e.message.channel.sendMessage(data.query.created);
  39.  
  40. }
  41. });
  42. //e.message.channel.sendMessage(data.characters[0].id);
  43.  
  44. }
  45.  
  46. });
  47.  
  48.  
  49. //e.message.channel.sendMessage(":girlgeist:");
  50.  
  51.  
  52. });
  53.  
  54. var getJSON = function(url, callback) {
  55. var xhr = new XMLHttpRequest();
  56. xhr.open("get", url, true);
  57. xhr.responseType = "json";
  58. xhr.onload = function() {
  59. var status = xhr.status;
  60. if (status == 200) {
  61. callback(null, xhr.response);
  62. } else {
  63. callback(status);
  64. }
  65. };
  66. xhr.send();
  67. };
  68.  
  69. var postJSON = function(url, callback) {
  70. //e.message.channel.sendMessage("startpost");
  71. var xhr = new XMLHttpRequest();
  72. xhr.open("POST", url, true);
  73. //Send the proper header information along with the request
  74. xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  75.  
  76. xhr.onreadystatechange = function() {//Call a function when the state changes.
  77. var status = xhr.status;
  78. if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
  79. // Request finished. Do processing here.
  80. //var json = JSON.parse(xhr.responseText);
  81. e.message.channel.sendMessage("hit");
  82. e.message.channel.sendMessage(xhr.responseText);
  83. //console.log(json.email + ", " + json.password)
  84. }
  85. }
  86. // xhr.send('user:email=alyssamdev@gmail.com&password=deathnote');
  87. // xhr.send(JSON.stringify({user:{email:alyssamdev@gmail.com,password:deathnote}}
  88. //xhr.send('email=alyssamdev@gmail.com&password=deathnote');
  89. //xhr.send('{"user":{"email":"alyssamdev@gmail.com","password":"deathnote"}}');
  90. xhr.send('{"user":{"email":"alyssamdeb@gmail.com","password":"deathnote"}}');
  91. //'user":{"email":"alyssamdev@gmail.com","password":"deathnote'
  92.  
  93.  
  94. //user":{"email":"snafzg@email.com","password":"xyz789
  95.  
  96. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement