Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Discord.Commands;
- using Discord;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Discord.Modules;
- using System.Media;
- using System.Windows.Input;
- using System.IO;
- //ExecutionEngineException
- /*/ HOW TO CREATE A COMMAND
- * commands.CreateCommand("")
- .Do(async (e) =>
- {
- if (isprivate == false)
- {
- }
- });
- /*/
- namespace NomBotV2
- {
- class NomBotV2
- {
- DiscordClient discord;
- bool isprivate;
- bool ConsoleChatOn = false;
- string Page;
- string MessageOld;
- string MessageNew;
- string console;
- string ConsoleServerUser;
- string YandereTest;
- string Server;
- string FilterUserNew;
- string FilterUserOld;
- string FilterServerNew;
- string FilterServerOld;
- int Clear;
- // Realm of NomBot Server ID: 299653823503400960
- // Paradox Infinity Server ID: 233717585605033984
- // Nom's Server ID: 254302003188989953
- public NomBotV2()
- {
- discord = new DiscordClient(x => { x.LogHandler = Log; x.LogLevel = LogSeverity.Info; });
- discord.UsingCommands(x =>
- {
- x.PrefixChar = '~';
- x.AllowMentionPrefix = true;
- });
- var commands = discord.GetService<CommandService>();
- discord.Ready += async (s, e) =>
- {
- Console.WriteLine("BOT IS READY");
- };
- discord.ServerAvailable += async (s, e) => { e.Server.DefaultChannel.SendMessage("NomBot has been enabled.");
- isprivate=false;
- ConsoleChatOn = false;
- Page = "";
- MessageOld = "";
- MessageNew = "";
- console = "";
- ConsoleServerUser = "";
- YandereTest = "";
- Server = "";
- FilterUserNew = "";
- FilterUserOld = "";
- FilterServerNew = "";
- FilterServerOld="";
- Clear=0;
- };
- //Test for PM
- discord.UserIsTyping += async (s, e) => //If a user is typing
- {
- if (e.Channel.IsPrivate == false) //And it's not in a private channel
- { isprivate = false; } //Then it'll be updated so the channel isn't private
- else // But if the channel *is* private
- { isprivate = true; }
- }; //Then the variable will be set to recognize it
- discord.MessageReceived += async (s, e) =>
- {
- if (e.User.IsBot != true)
- { //If it's true that the user isn't a bot
- if (e.Channel.IsPrivate == true)
- { //And the channel is private
- //e.Message.Channel.SendMessage("Private Messaging is not enabled.");
- }
- }
- // Spam Filter
- if (isprivate == false)
- {
- FilterUserOld = FilterUserNew;
- FilterServerOld = FilterServerNew;
- MessageOld = MessageNew;
- Message[] messagesToObtain;
- messagesToObtain = await e.Channel.DownloadMessages(2);
- MessageNew = messagesToObtain[0].Text; // Sets MessageNew to the downloaded messages,
- MessageNew = MessageNew.ToString(); // Converts MessageNew to a string
- MessageNew = MessageNew.ToLower(); // Converts MessageNew to standart lowercase
- YandereTest = MessageNew.ToString(); // Defines Yandere test, and sets to standard lowercase
- YandereTest = YandereTest.ToLower();
- FilterUserNew = e.User.ToString();
- FilterServerNew = e.Server.Name.ToString();
- // Will relay messages and names if console chat is set to true
- if (ConsoleChatOn == true) {
- ConsoleServerUser = messagesToObtain[0].Server.Name + ": " + messagesToObtain[0].User.Name + ": ";
- Console.WriteLine(ConsoleServerUser);
- Console.WriteLine(MessageNew);
- Console.WriteLine(" ");
- }
- if (MessageNew == MessageOld && FilterUserNew==FilterUserOld && FilterServerNew == FilterServerOld) {
- Message[] messagesToDelete;
- messagesToDelete = await e.Channel.DownloadMessages(1);
- await e.Channel.DeleteMessages(messagesToDelete);
- }
- if (YandereTest.Contains("files.yande.re") == true) {
- if (isprivate == false) { Message[] messagesToDelete;
- messagesToDelete = await e.Channel.DownloadMessages(1);
- await e.Channel.DeleteMessages(messagesToDelete);
- }
- if (isprivate == true) {
- }
- } ;
- }};
- //
- //YANDERE FILTER
- //
- discord.MessageUpdated += async (s, e) =>
- {
- Message[] messagesToObtain;
- messagesToObtain = await e.Channel.DownloadMessages(2);
- MessageNew = messagesToObtain[0].Text; // Sets MessageNew to the downloaded messages,
- MessageNew = MessageNew.ToString(); // Converts MessageNew to a string
- MessageNew = MessageNew.ToLower(); // Converts MessageNew to standart lowercase
- YandereTest = MessageNew.ToString(); // Defines Yandere test, and sets to standard lowercase
- YandereTest = YandereTest.ToLower();
- if (YandereTest.Contains("files.yande.re") == true)
- {
- if (isprivate == false)
- {
- Message[] messagesToDelete;
- messagesToDelete = await e.Channel.DownloadMessages(1);
- await e.Channel.DeleteMessages(messagesToDelete);
- }
- }
- };
- {
- //
- // Begin code block for Commands
- //
- // Aid commands
- commands.CreateCommand("help")// IS PM FRIENDLY
- .Do(async (e) =>
- {
- if (isprivate == false)
- {
- 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.");
- }
- else {
- 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.");
- }
- });
- commands.CreateCommand("info")// IS PM FRIENDLY
- .Do(async (e) =>
- {
- if (isprivate == false)
- {
- 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!");
- }
- else {
- 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!");
- }
- });
- commands.CreateCommand("features")// IS PM FRIENDLY
- .Do(async (e) =>
- {
- if (isprivate == false)
- {
- e.Channel.SendMessage("**Features** \nChat monitoring services\nSpam detection and deletion filter (WIP)\nServer based User Join messages\nPM Integration");
- }
- else {
- e.User.SendMessage("**Features** \nChat monitoring services\nSpam detection and deletion filter (WIP)\nServer based User Join messages\nPM Integration");
- }
- });
- commands.CreateCommand("commands")// IS PM FRIENDLY
- .Parameter("Page", ParameterType.Optional)
- .Do(async (e) =>
- {
- if (isprivate == false)
- {
- Page = e.GetArg("Page");
- if (Page == "")
- {
- e.Channel.SendMessage("You require a page number between 1-3 to use this command!");
- };
- if (Page == "1")
- {
- 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.");
- };
- if (Page == "2")
- {
- e.Channel.SendMessage("**Commands (2/3):** \nShowing Commands 6-10 \n~\n~\n~\n~\n~");
- };
- if (Page == "3")
- {
- e.Channel.SendMessage("**Commands (3/3):** \nShowing Commands 11-15 \n~\n~\n~\n~\n~");
- };
- if (Page == "debug")
- {
- e.Channel.SendMessage("**Warning: Admin Commands Only** \n **Exclusively for Debug Purposes** \n ~console \n ~consolechat");
- }
- }
- else
- {
- Page = e.GetArg("Page");
- if (Page == "")
- {
- e.User.SendMessage("You require a page number between 1-3 to use this command!");
- };
- if (Page == "1")
- {
- 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.");
- };
- if (Page == "2")
- {
- e.User.SendMessage("**Commands (2/3):** \nShowing Commands 6-10 \n~\n~\n~\n~\n~");
- };
- if (Page == "3")
- {
- e.User.SendMessage("**Commands (3/3):** \nShowing Commands 11-15 \n~\n~\n~\n~\n~");
- };
- if (Page == "debug")
- {
- e.User.SendMessage("**Warning: Admin Commands Only** \n **Exclusively for Debug Purposes** \n ~console \n ~consolechat");
- }
- }
- });
- commands.CreateCommand("consolechat")// IS PM FRIENDLY
- .Parameter("status", ParameterType.Optional)
- .Do(async (e) =>
- {
- if (e.User.Id == 204441911489069056) {
- if (e.GetArg("status") == "") { e.Channel.SendMessage("Set true or false to enable/disable console eavesdropping."); }
- if (e.GetArg("status") == "true") { e.Channel.SendMessage("Console messages enabled"); ConsoleChatOn = true; }
- if (e.GetArg("status") == "false")
- {
- e.Channel.SendMessage("Console messages disabled");
- ConsoleChatOn = false;
- ;
- }
- }
- if (e.User.Id == 308946843642101761) {
- if (e.GetArg("status") == "") { e.Channel.SendMessage("Set true or false to enable/disable console eavesdropping."); }
- if (e.GetArg("status") == "true") { e.Channel.SendMessage("Console messages enabled"); ConsoleChatOn = true; }
- if (e.GetArg("status") == "false")
- {
- e.Channel.SendMessage("Console messages disabled");
- ConsoleChatOn = false;
- ;
- }
- }
- });
- commands.CreateCommand("version")// IS PM FRIENDLY
- .Do(async (e) =>
- {
- if (isprivate == false)
- {
- e.Channel.SendMessage("You're currently running NomBot version 3.5!");
- }
- else {
- e.User.SendMessage("You're currently running NomBot version 3.5!");
- }
- });
- commands.CreateCommand("console")
- .Parameter("Console", ParameterType.Multiple) // IS SOMEWHAT PM FRIENDLY
- .Do(async (e) =>
- {
- if (isprivate == false)
- {
- if (e.User.Id == 204441911489069056)
- {
- console = e.GetArg("Console").ToString();
- ConsoleServerUser = e.Server.Name + ": " + e.User.Name + ": ";
- Console.WriteLine(ConsoleServerUser);
- Console.WriteLine(console);
- Console.WriteLine(" ");
- }
- else
- {
- if (e.User.Id == 308946843642101761)
- {
- console = e.GetArg("Console").ToString();
- ConsoleServerUser = e.Server.Name + ": " + e.User.Name + ": ";
- Console.WriteLine(ConsoleServerUser);
- Console.WriteLine(console);
- Console.WriteLine(" ");
- }
- else
- {
- e.Channel.SendMessage("You do not have permission to send console messages");
- }
- }
- }
- else
- {
- if (e.User.Id == 204441911489069056)
- {
- console = e.GetArg("Console").ToString();
- ConsoleServerUser = "PM" + ": " + e.User.Name + ": ";
- Console.WriteLine(ConsoleServerUser);
- Console.WriteLine(console);
- Console.WriteLine(" ");
- }
- else
- {
- if (e.User.Id == 308946843642101761)
- {
- console = e.GetArg("Console").ToString();
- ConsoleServerUser = "PM" + ": " + e.User.Name + ": ";
- Console.WriteLine(ConsoleServerUser);
- Console.WriteLine(console);
- Console.WriteLine(" ");
- }
- else
- {
- e.Channel.SendMessage("You do not have permission to send console messages");
- }
- };
- }
- }
- );}
- commands.CreateCommand("invite")// IS PM FRIENDLY
- .Do(async (e) => {
- if (isprivate == false)
- {
- e.User.SendMessage("Add NomBot to your server here! [REDACTED TO AVOID ABUSE]");
- e.Channel.SendMessage(e.User.Mention + " Check your Private Messages for a NomBot invite link!" );
- }
- else {
- e.User.SendMessage("Add NomBot to your server here! [REDACTED TO AVOID ABUSE]");
- }
- });
- commands.CreateCommand("servers") // IS PM FRIENDLY
- .Do(async (e) =>
- {
- if (isprivate == false) {
- e.Channel.SendMessage("Join Zomon's personal server! [REDACTED TO AVOID ABUSE] \nJoin Zomon's development server! https://discord.gg/P42MkN9");
- }
- else {
- e.User.SendMessage("Join Zomon's personal server! [REDACTED TO AVOID ABUSE] \nJoin Zomon's development server! https://discord.gg/P42MkN9");
- }
- });
- discord.UserJoined += async (s, e) => {
- if (isprivate == false)
- {
- if (e.User.IsBot != true)
- {
- Server = e.Server.Name;
- e.Server.DefaultChannel.SendMessage("Welcome to " + Server + " " + e.User.Mention + "!");
- }
- else {
- if (e.User.Id != 299346271687278592) {
- Server = e.Server.Name;
- e.Server.DefaultChannel.SendMessage("Bot " + e.User.Name + " has joined " + e.Server.Name + "!"); }; }
- }
- };
- discord.UserIsTyping += async (s, e) => { discord.SetGame("with chemicals."); };
- //
- // CLEAR SYSTEM
- //
- commands.CreateCommand("clear")
- .Parameter("Linecount", ParameterType.Required)
- .Do(async (e) =>
- {
- Clear = int.Parse(e.GetArg("Linecount"))+1;
- Message[] messagesToClear;
- messagesToClear = await e.Channel.DownloadMessages(Clear);
- await e.Channel.DeleteMessages(messagesToClear);
- Console.WriteLine(Clear + " messages have been deleted from "+ e.Server.Name+" by " + e.User.Name+".");
- });
- // Channel Join
- discord.ExecuteAndWait(async () =>
- {
- await discord.Connect("[REDACTED TO AVOID ABUSE]", TokenType.Bot);
- });
- }
- // Message Logging for Bot Access
- private void Log(object sender, LogMessageEventArgs e)
- {
- Console.WriteLine(e.Message);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement