Advertisement
Guest User

Hello Motley!

a guest
Nov 3rd, 2017
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.74 KB | None | 0 0
  1. const BotGame = "with ARSEnic";
  2. const Prefix = '.'
  3. const DateSeparator = '/';
  4. const TimeSeparator = ':';
  5.  
  6.  
  7.  
  8.  
  9.  
  10. const Discord = require('discord.js');
  11. const MySQL = require('mysql');
  12. const Bot = new Discord.Client();
  13. Bot.login('Mjk0NzI3MTA1NjI1NzE4Nzg2.DNR90g.G0nb9TzY61LwmPL34BnjCSOftfU');
  14. //Bot.login("kaixinang99@gmail.com", "90149556")
  15. var Connection = MySQL.createConnection({
  16. host:'localhost',
  17. user:'ChinaBot',
  18. password:'90149556',
  19. database:'chinabot'
  20. });
  21. Connection.connect();
  22.  
  23. Bot.on("ready", function(){
  24. for(var Count in Bot.users.array()){
  25. var User = Bot.users.array()[Count];
  26. //User.client.guilds
  27. }
  28.  
  29. })
  30.  
  31. Bot.on("guildMemberAdd", function(Member){
  32.  
  33. console.log("test");
  34. })
  35.  
  36. Bot.on("message", function(Message) {
  37.  
  38.  
  39. var date = new Date();
  40. //var Month = ;
  41. var DateString = date.getDate() + "/" + (date.getMonth()+1) + "/" + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
  42. var MessageString = Message.content;
  43. if(Message.author != Bot.user)
  44. {
  45. var BlockedMessages = ["k", "k can", ":l"]
  46. for(var Msg in BlockedMessages){
  47. var MessageString = Message.content;
  48. if((MessageString.search(BlockedMessages[Msg]) == 0)||(MessageString.toLowerCase == BlockedMessages[Msg]))
  49. {
  50. Message.delete(1);
  51. Message.channel.send("Message has been deleted because it contains annoying characters/words");
  52. console.log( "[" + DateString + "](" + Message.guild.name + "/" + Message.channel.name + ") Deleted " + Message.author.username + "'s Message (" + MessageString + "), contains annoying characters/words")
  53. break;
  54. }
  55. }
  56. }
  57.  
  58. if(MessageString[0] == Prefix){
  59. var Length = MessageString.length;
  60. var String = MessageString.slice(Prefix.length,Length).split(" ");
  61. Command = String[0].toLowerCase();
  62. if(Command)
  63. {
  64. var Arguments = String.slice(1);
  65. if( Command == "bulkdel" )
  66. {
  67. // let Role = Message.guild.roles.find("name", "Indian");
  68. if((Message.member.roles.find("name", "African Whore"))||(Message.member.roles.find("name", "Indian Whore")))
  69. {
  70. if(Arguments[0])
  71. {
  72. var Count = Arguments[0];
  73. if(isNaN(Count) == false)
  74. {
  75. try{
  76. Message.channel.bulkDelete(Number(Count));
  77. }
  78. catch(e)
  79. {
  80. Message.channel.sendMessage("Man, you fucked up: " + e);
  81. }
  82. }
  83. else Message.reply("The parameter has to be a number")
  84. }
  85. else Message.reply("Invalid command format, ``" + Prefix + " " + Command + " <Number of messages to Delete>``")
  86. }
  87. else Message.reply("You do not have permissions to use this command");
  88. }
  89. else if( Command == "checkmessage" )
  90. {
  91. // let Role = Message.guild.roles.find("name", "Indian");
  92. if((Message.member.roles.find("name", "African Whore"))||(Message.member.roles.find("name", "Indian Whore")))
  93. {
  94. if(Arguments[0])
  95. {
  96. var DateArgument = Arguments[0];
  97. var PureNumber
  98. PureNumber = DateArgument.replace(DateSeparator, "").replace(DateSeparator, "");
  99. if(isNaN(PureNumber) == false)
  100. {
  101. var Count
  102. Count = 0;
  103. var Mark = true;
  104. while(Count <=2)
  105. {
  106. try{
  107. if((Count == 1)||(Count == 0)){
  108. var DateLength = DateArgument.split(DateSeparator)[Count].length;
  109. if((DateLength != 1)&&(DateLength != 2)){
  110. Mark = false;
  111. }
  112. }
  113. else{
  114. var DateLength = DateArgument.split(DateSeparator)[Count].length;
  115. if(DateLength != 4){
  116. Mark = false;
  117. }
  118. }}
  119. catch(e){
  120. if(e)Mark = false;
  121. }
  122. Count++;
  123. }
  124. if(Mark == true)
  125. {
  126. if(Arguments[1])
  127. {
  128. var TimeArgument = Arguments[1];
  129. PureNumber = TimeArgument.replace(TimeSeparator, "").replace(TimeSeparator, "");
  130. if(isNaN(PureNumber) == false)
  131. {
  132. Count = 0;
  133. Mark = true;
  134. while(Count <=2)
  135. {
  136. try{
  137. var TimeLength = TimeArgument.split(TimeSeparator)[Count].length;
  138. if((TimeLength != 1)&&(TimeLength != 2)){
  139. Mark = false;
  140. }
  141. }
  142. catch(e){
  143. if(e)Mark = false;
  144. }
  145. Count++;
  146. }
  147. if(Mark == true)
  148. {
  149. var TimeDate = DateArgument + " " + TimeArgument;
  150. Connection.query("SELECT * FROM chatlog WHERE Time='" + TimeDate + "'", function (e, Result){
  151. try{
  152. //Message.channel.send("*[" + TimeDate + ", " + Result[0].MessageID + "]* **" + Result[0].Sender + "**: ``" + Result[0].Message + "``");
  153. for(var Count in Result)
  154. {
  155. var Embed = new Discord.RichEmbed()
  156. .setAuthor(
  157. name = Result[Count].Sender + " - " + TimeDate,
  158. icon = Message.client.user.avatarURL
  159. )
  160. .setColor("#ff0000")
  161. .addField("Message ID", Result[Count].MessageID)
  162. .addField("Message", Result[Count].Message)
  163. Message.channel.sendEmbed(Embed);
  164. }
  165. }
  166. catch(e){
  167. Message.reply("Either no messages were sent at that time or something went wrong.")
  168. }
  169. })
  170. }
  171. else Message.reply("Invalid time format, ``DD/MM/YYYY``, no **0**s are required")
  172. }
  173. else Message.reply("Invalid time format, ``DD/MM/YYYY``, use numbers and '" + TimeSeparator + "'s only")
  174. }
  175. else Message.reply("Invalid command format, ``" + Prefix + " " + Command + " <Date> <Time>``")
  176. }
  177. else Message.reply("Invalid date format, ``DD/MM/YYYY``, no **0**s are required")
  178. }
  179. else Message.reply("Invalid time format, ``DD/MM/YYYY``, use numbers and '" + DateSeparator + "'s only")
  180. }
  181. else Message.reply("Invalid command format, ``" + Prefix + " " + Command + " <Date> <Time>``")
  182. }
  183. else Message.reply("You do not have permissions to use this command");
  184. }
  185. else if(Command == "givmeme"){
  186. var Num = Math.floor(Math.random()*3)+1;
  187. if(Num == 1)Message.channel.sendMessage("https://cbsnews1.cbsistatic.com/hub/i/r/2017/02/10/4c74e6db-726b-4e29-b400-5337fba57d36/resize/620x465/72cc1f488437598c53964120aed108ca/screen-shot-2017-02-10-at-2-36-50-pm.png");
  188. if(Num == 2)Message.channel.sendMessage("https://cbsnews3.cbsistatic.com/hub/i/r/2017/02/10/86e3ce87-8511-4828-97cc-673d9cac7e00/resize/620x465/22448b9e570bc8cdf5e19a079387bb08/screen-shot-2017-02-10-at-2-07-33-pm.png")
  189. if(Num == 3)Message.channel.sendMessage("https://www.humortimes.com/wp-content/uploads/2017/01/the-only-way-2lj213.jpg")
  190. }
  191. else if(Command == "h"){
  192. Message.reply(Message.channel.nsfw);
  193. }
  194. else{
  195. Message.reply("This command does not exist")
  196. }
  197. }
  198. else Message.reply("Invalid command format, ``" + Prefix + " <Command> <Parameters>``")
  199. }
  200. else{
  201.  
  202. if(Message.author != Bot.user){
  203. console.log("[" + DateString + "](" + Message.guild.name + "/" + Message.channel.name + ") Ningen " + Message.author.username + " says: " + Message);
  204.  
  205. var info = {
  206. "Time": DateString,
  207. "Server": Message.guild.name,
  208. "Channel": Message.channel.name,
  209. "Sender": Message.author.username,
  210. "SenderID": Message.author.id,
  211. "MessageID": Message.id,
  212. "Message": Message
  213. }
  214. Connection.query("INSERT INTO chatlog SET ?", info, function(error) {
  215. if (error) {
  216. console.log(error);
  217. return;
  218. }
  219. })
  220. }
  221.  
  222. }
  223. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement