Advertisement
Guest User

NomBot~Dev~V3.5

a guest
Jul 23rd, 2017
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.89 KB | None | 0 0
  1. using Discord.Commands;
  2. using Discord;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Discord.Modules;
  9. using System.Media;
  10. using System.Windows.Input;
  11. using System.IO;
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. //ExecutionEngineException
  19.  
  20. /*/ HOW TO CREATE A COMMAND
  21. * commands.CreateCommand("")
  22. .Do(async (e) =>
  23. {
  24. if (isprivate == false)
  25. {
  26.  
  27. }
  28. });
  29. /*/
  30.  
  31. namespace NomBotV2
  32. {
  33.  
  34. class NomBotV2
  35. {
  36. DiscordClient discord;
  37.  
  38.  
  39. bool isprivate;
  40.  
  41. bool ConsoleChatOn = false;
  42. string Page;
  43. string MessageOld;
  44. string MessageNew;
  45. string console;
  46. string ConsoleServerUser;
  47. string YandereTest;
  48. string Server;
  49.  
  50. string FilterUserNew;
  51. string FilterUserOld;
  52. string FilterServerNew;
  53. string FilterServerOld;
  54. int Clear;
  55.  
  56.  
  57. // Realm of NomBot Server ID: 299653823503400960
  58. // Paradox Infinity Server ID: 233717585605033984
  59. // Nom's Server ID: 254302003188989953
  60.  
  61. public NomBotV2()
  62. {
  63.  
  64. discord = new DiscordClient(x => { x.LogHandler = Log; x.LogLevel = LogSeverity.Info; });
  65.  
  66. discord.UsingCommands(x =>
  67. {
  68. x.PrefixChar = '~';
  69. x.AllowMentionPrefix = true;
  70. });
  71. var commands = discord.GetService<CommandService>();
  72.  
  73. discord.Ready += async (s, e) =>
  74. {
  75. Console.WriteLine("BOT IS READY");
  76. };
  77. discord.ServerAvailable += async (s, e) => { e.Server.DefaultChannel.SendMessage("NomBot has been enabled.");
  78. isprivate=false;
  79. ConsoleChatOn = false;
  80. Page = "";
  81. MessageOld = "";
  82. MessageNew = "";
  83. console = "";
  84. ConsoleServerUser = "";
  85. YandereTest = "";
  86. Server = "";
  87. FilterUserNew = "";
  88. FilterUserOld = "";
  89. FilterServerNew = "";
  90. FilterServerOld="";
  91. Clear=0;
  92. };
  93.  
  94. //Test for PM
  95.  
  96. discord.UserIsTyping += async (s, e) => //If a user is typing
  97. {
  98. if (e.Channel.IsPrivate == false) //And it's not in a private channel
  99.  
  100. { isprivate = false; } //Then it'll be updated so the channel isn't private
  101.  
  102. else // But if the channel *is* private
  103.  
  104. { isprivate = true; }
  105. }; //Then the variable will be set to recognize it
  106.  
  107.  
  108. discord.MessageReceived += async (s, e) =>
  109. {
  110. if (e.User.IsBot != true)
  111. { //If it's true that the user isn't a bot
  112. if (e.Channel.IsPrivate == true)
  113. { //And the channel is private
  114. //e.Message.Channel.SendMessage("Private Messaging is not enabled.");
  115. }
  116. }
  117.  
  118. // Spam Filter
  119. if (isprivate == false)
  120. {
  121. FilterUserOld = FilterUserNew;
  122. FilterServerOld = FilterServerNew;
  123. MessageOld = MessageNew;
  124. Message[] messagesToObtain;
  125. messagesToObtain = await e.Channel.DownloadMessages(2);
  126. MessageNew = messagesToObtain[0].Text; // Sets MessageNew to the downloaded messages,
  127. MessageNew = MessageNew.ToString(); // Converts MessageNew to a string
  128. MessageNew = MessageNew.ToLower(); // Converts MessageNew to standart lowercase
  129. YandereTest = MessageNew.ToString(); // Defines Yandere test, and sets to standard lowercase
  130. YandereTest = YandereTest.ToLower();
  131. FilterUserNew = e.User.ToString();
  132. FilterServerNew = e.Server.Name.ToString();
  133.  
  134. // Will relay messages and names if console chat is set to true
  135. if (ConsoleChatOn == true) {
  136. ConsoleServerUser = messagesToObtain[0].Server.Name + ": " + messagesToObtain[0].User.Name + ": ";
  137. Console.WriteLine(ConsoleServerUser);
  138. Console.WriteLine(MessageNew);
  139. Console.WriteLine(" ");
  140. }
  141.  
  142. if (MessageNew == MessageOld && FilterUserNew==FilterUserOld && FilterServerNew == FilterServerOld) {
  143. Message[] messagesToDelete;
  144. messagesToDelete = await e.Channel.DownloadMessages(1);
  145. await e.Channel.DeleteMessages(messagesToDelete);
  146. }
  147.  
  148.  
  149. if (YandereTest.Contains("files.yande.re") == true) {
  150. if (isprivate == false) { Message[] messagesToDelete;
  151. messagesToDelete = await e.Channel.DownloadMessages(1);
  152. await e.Channel.DeleteMessages(messagesToDelete);
  153. }
  154.  
  155. if (isprivate == true) {
  156.  
  157. }
  158. } ;
  159. }};
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167. //
  168. //YANDERE FILTER
  169. //
  170.  
  171. discord.MessageUpdated += async (s, e) =>
  172. {
  173. Message[] messagesToObtain;
  174. messagesToObtain = await e.Channel.DownloadMessages(2);
  175. MessageNew = messagesToObtain[0].Text; // Sets MessageNew to the downloaded messages,
  176. MessageNew = MessageNew.ToString(); // Converts MessageNew to a string
  177. MessageNew = MessageNew.ToLower(); // Converts MessageNew to standart lowercase
  178. YandereTest = MessageNew.ToString(); // Defines Yandere test, and sets to standard lowercase
  179. YandereTest = YandereTest.ToLower();
  180. if (YandereTest.Contains("files.yande.re") == true)
  181. {
  182. if (isprivate == false)
  183. {
  184. Message[] messagesToDelete;
  185. messagesToDelete = await e.Channel.DownloadMessages(1);
  186. await e.Channel.DeleteMessages(messagesToDelete);
  187. }
  188. }
  189. };
  190.  
  191.  
  192.  
  193. {
  194. //
  195. // Begin code block for Commands
  196. //
  197. // Aid commands
  198. commands.CreateCommand("help")// IS PM FRIENDLY
  199. .Do(async (e) =>
  200. {
  201. if (isprivate == false)
  202. {
  203. await e.Channel.SendMessage("You're currently using NomBot Version 3.5! \n NomBot is a utility bot that was originially a joke made by Zomon333! \n To add NomBot to your server, please contact Zomon333. \n Use ~features, ~info, or ~commands to start using this bot effectively! \n As a side note, ~version displays the currently running NomBot version.");
  204. }
  205. else {
  206. await e.Channel.SendMessage("You're currently using NomBot Version 3.5! \n NomBot is a utility bot that was originially a joke made by Zomon333! \n To add NomBot to your server, please contact Zomon333. \n Use ~features, ~info, or ~commands to start using this bot effectively! \n As a side note, ~version displays the currently running NomBot version.");
  207. }
  208. });
  209. commands.CreateCommand("info")// IS PM FRIENDLY
  210. .Do(async (e) =>
  211. {
  212. if (isprivate == false)
  213. {
  214. e.Channel.SendMessage("NomBot was originally created by Zomon333 with heavy infulence from others as a comedy bot with dark humor and insulting jokes. \n In between versions 3.4 and 3.5, Zomon333 decided to re-write NomBot's code to fix numerous bugs and make the bot compliant with Discord's Terms of Service. \n This left NomBot as a blank utility bot, ready to be rewritten properly to avoid bugs. \n NomBot is written in C# Using Microsoft Visual Studio. \n In the event of a bug, please join Zomon333's Bot Testing discord server, Realm of Bots, and report it there! Invite: [REDACTED TO AVOID ABUSE] \n Due to the amateur programming capabilities of Zomon in C#, any and all advice on Bugfixing and or new features, please consult him on his bot server!");
  215. }
  216. else {
  217. e.User.SendMessage("NomBot was originally created by Zomon333 with heavy infulence from others as a comedy bot with dark humor and insulting jokes. \n In between versions 3.4 and 3.5, Zomon333 decided to re-write NomBot's code to fix numerous bugs and make the bot compliant with Discord's Terms of Service. \n This left NomBot as a blank utility bot, ready to be rewritten properly to avoid bugs. \n NomBot is written in C# Using Microsoft Visual Studio. \n In the event of a bug, please join Zomon333's Bot Testing discord server, Realm of Bots, and report it there! Invite: [REDACTED TO AVOID ABUSE] \n Due to the amateur programming capabilities of Zomon in C#, any and all advice on Bugfixing and or new features, please consult him on his bot server!");
  218. }
  219. });
  220. commands.CreateCommand("features")// IS PM FRIENDLY
  221. .Do(async (e) =>
  222. {
  223. if (isprivate == false)
  224. {
  225. e.Channel.SendMessage("**Features** \nChat monitoring services\nSpam detection and deletion filter (WIP)\nServer based User Join messages\nPM Integration");
  226. }
  227. else {
  228. e.User.SendMessage("**Features** \nChat monitoring services\nSpam detection and deletion filter (WIP)\nServer based User Join messages\nPM Integration");
  229. }
  230. });
  231. commands.CreateCommand("commands")// IS PM FRIENDLY
  232. .Parameter("Page", ParameterType.Optional)
  233. .Do(async (e) =>
  234. {
  235. if (isprivate == false)
  236. {
  237. Page = e.GetArg("Page");
  238. if (Page == "")
  239. {
  240. e.Channel.SendMessage("You require a page number between 1-3 to use this command!");
  241. };
  242. if (Page == "1")
  243. {
  244. e.Channel.SendMessage("**Commands (1/3):** \nShowing Commands 1-5 \n~help Displays generic information about NomBot and it's informative commands.\n~info Displays a brief history of NomBot and how to bug report.\n~features Displays NomBot's currently functional features.\n~commands Displays the commands that can be used with NomBot, and what they do.\n~version Displays the latest version of NomBot.");
  245. };
  246. if (Page == "2")
  247. {
  248. e.Channel.SendMessage("**Commands (2/3):** \nShowing Commands 6-10 \n~\n~\n~\n~\n~");
  249. };
  250. if (Page == "3")
  251. {
  252. e.Channel.SendMessage("**Commands (3/3):** \nShowing Commands 11-15 \n~\n~\n~\n~\n~");
  253. };
  254. if (Page == "debug")
  255. {
  256. e.Channel.SendMessage("**Warning: Admin Commands Only** \n **Exclusively for Debug Purposes** \n ~console \n ~consolechat");
  257. }
  258. }
  259. else
  260. {
  261. Page = e.GetArg("Page");
  262. if (Page == "")
  263. {
  264. e.User.SendMessage("You require a page number between 1-3 to use this command!");
  265. };
  266. if (Page == "1")
  267. {
  268. e.User.SendMessage("**Commands (1/3):** \nShowing Commands 1-5 \n~help Displays generic information about NomBot and it's informative commands.\n~info Displays a brief history of NomBot and how to bug report.\n~features Displays NomBot's currently functional features.\n~commands Displays the commands that can be used with NomBot, and what they do.\n~version Displays the latest version of NomBot.");
  269. };
  270. if (Page == "2")
  271. {
  272. e.User.SendMessage("**Commands (2/3):** \nShowing Commands 6-10 \n~\n~\n~\n~\n~");
  273. };
  274. if (Page == "3")
  275. {
  276. e.User.SendMessage("**Commands (3/3):** \nShowing Commands 11-15 \n~\n~\n~\n~\n~");
  277. };
  278. if (Page == "debug")
  279. {
  280. e.User.SendMessage("**Warning: Admin Commands Only** \n **Exclusively for Debug Purposes** \n ~console \n ~consolechat");
  281. }
  282. }
  283. });
  284. commands.CreateCommand("consolechat")// IS PM FRIENDLY
  285. .Parameter("status", ParameterType.Optional)
  286. .Do(async (e) =>
  287. {
  288. if (e.User.Id == 204441911489069056) {
  289. if (e.GetArg("status") == "") { e.Channel.SendMessage("Set true or false to enable/disable console eavesdropping."); }
  290. if (e.GetArg("status") == "true") { e.Channel.SendMessage("Console messages enabled"); ConsoleChatOn = true; }
  291. if (e.GetArg("status") == "false")
  292. {
  293. e.Channel.SendMessage("Console messages disabled");
  294. ConsoleChatOn = false;
  295. ;
  296. }
  297. }
  298. if (e.User.Id == 308946843642101761) {
  299. if (e.GetArg("status") == "") { e.Channel.SendMessage("Set true or false to enable/disable console eavesdropping."); }
  300. if (e.GetArg("status") == "true") { e.Channel.SendMessage("Console messages enabled"); ConsoleChatOn = true; }
  301. if (e.GetArg("status") == "false")
  302. {
  303. e.Channel.SendMessage("Console messages disabled");
  304. ConsoleChatOn = false;
  305. ;
  306. }
  307. }
  308.  
  309. });
  310. commands.CreateCommand("version")// IS PM FRIENDLY
  311. .Do(async (e) =>
  312. {
  313. if (isprivate == false)
  314. {
  315. e.Channel.SendMessage("You're currently running NomBot version 3.5!");
  316. }
  317. else {
  318. e.User.SendMessage("You're currently running NomBot version 3.5!");
  319. }
  320. });
  321. commands.CreateCommand("console")
  322. .Parameter("Console", ParameterType.Multiple) // IS SOMEWHAT PM FRIENDLY
  323. .Do(async (e) =>
  324. {
  325. if (isprivate == false)
  326. {
  327. if (e.User.Id == 204441911489069056)
  328. {
  329. console = e.GetArg("Console").ToString();
  330. ConsoleServerUser = e.Server.Name + ": " + e.User.Name + ": ";
  331. Console.WriteLine(ConsoleServerUser);
  332. Console.WriteLine(console);
  333. Console.WriteLine(" ");
  334. }
  335. else
  336. {
  337. if (e.User.Id == 308946843642101761)
  338. {
  339. console = e.GetArg("Console").ToString();
  340. ConsoleServerUser = e.Server.Name + ": " + e.User.Name + ": ";
  341. Console.WriteLine(ConsoleServerUser);
  342. Console.WriteLine(console);
  343. Console.WriteLine(" ");
  344. }
  345. else
  346. {
  347. e.Channel.SendMessage("You do not have permission to send console messages");
  348. }
  349. }
  350.  
  351. }
  352. else
  353. {
  354. if (e.User.Id == 204441911489069056)
  355. {
  356. console = e.GetArg("Console").ToString();
  357. ConsoleServerUser = "PM" + ": " + e.User.Name + ": ";
  358. Console.WriteLine(ConsoleServerUser);
  359. Console.WriteLine(console);
  360. Console.WriteLine(" ");
  361. }
  362. else
  363. {
  364. if (e.User.Id == 308946843642101761)
  365. {
  366. console = e.GetArg("Console").ToString();
  367. ConsoleServerUser = "PM" + ": " + e.User.Name + ": ";
  368. Console.WriteLine(ConsoleServerUser);
  369. Console.WriteLine(console);
  370. Console.WriteLine(" ");
  371. }
  372. else
  373. {
  374. e.Channel.SendMessage("You do not have permission to send console messages");
  375. }
  376.  
  377.  
  378.  
  379. };
  380. }
  381. }
  382.  
  383. );}
  384. commands.CreateCommand("invite")// IS PM FRIENDLY
  385. .Do(async (e) => {
  386. if (isprivate == false)
  387. {
  388. e.User.SendMessage("Add NomBot to your server here! [REDACTED TO AVOID ABUSE]");
  389. e.Channel.SendMessage(e.User.Mention + " Check your Private Messages for a NomBot invite link!" );
  390. }
  391. else {
  392. e.User.SendMessage("Add NomBot to your server here! [REDACTED TO AVOID ABUSE]");
  393. }
  394. });
  395. commands.CreateCommand("servers") // IS PM FRIENDLY
  396. .Do(async (e) =>
  397. {
  398. if (isprivate == false) {
  399. e.Channel.SendMessage("Join Zomon's personal server! [REDACTED TO AVOID ABUSE] \nJoin Zomon's development server! https://discord.gg/P42MkN9");
  400. }
  401. else {
  402. e.User.SendMessage("Join Zomon's personal server! [REDACTED TO AVOID ABUSE] \nJoin Zomon's development server! https://discord.gg/P42MkN9");
  403. }
  404. });
  405.  
  406. discord.UserJoined += async (s, e) => {
  407. if (isprivate == false)
  408. {
  409. if (e.User.IsBot != true)
  410. {
  411. Server = e.Server.Name;
  412. e.Server.DefaultChannel.SendMessage("Welcome to " + Server + " " + e.User.Mention + "!");
  413. }
  414. else {
  415. if (e.User.Id != 299346271687278592) {
  416. Server = e.Server.Name;
  417. e.Server.DefaultChannel.SendMessage("Bot " + e.User.Name + " has joined " + e.Server.Name + "!"); }; }
  418. }
  419. };
  420. discord.UserIsTyping += async (s, e) => { discord.SetGame("with chemicals."); };
  421.  
  422. //
  423. // CLEAR SYSTEM
  424. //
  425. commands.CreateCommand("clear")
  426. .Parameter("Linecount", ParameterType.Required)
  427. .Do(async (e) =>
  428. {
  429. Clear = int.Parse(e.GetArg("Linecount"))+1;
  430.  
  431. Message[] messagesToClear;
  432. messagesToClear = await e.Channel.DownloadMessages(Clear);
  433. await e.Channel.DeleteMessages(messagesToClear);
  434. Console.WriteLine(Clear + " messages have been deleted from "+ e.Server.Name+" by " + e.User.Name+".");
  435. });
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444. // Channel Join
  445. discord.ExecuteAndWait(async () =>
  446. {
  447. await discord.Connect("[REDACTED TO AVOID ABUSE]", TokenType.Bot);
  448. });
  449. }
  450.  
  451.  
  452.  
  453.  
  454. // Message Logging for Bot Access
  455. private void Log(object sender, LogMessageEventArgs e)
  456. {
  457. Console.WriteLine(e.Message);
  458. }
  459.  
  460. }
  461. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement