Beispiel #1
0
    static void Main(string[] args)
    {
        var client = new DiscordClient();

        //Display all log messages in the console
        client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");

        //Echo back any message received, provided it didn't come from the bot itself
        client.MessageReceived += async(s, e) =>
        {
            if (!e.Message.IsAuthor)
            {
                await client.SendMessage(e.Channel, e.Message.Text);
            }
        };

        //Convert our sync method to an async one and block the Main function until the bot disconnects
        client.Run(async() =>
        {
            //Connect to the Discord server using our email and password
            await client.Connect("*****@*****.**", "Password123");

            //If we are not a member of any server, use our invite code (made beforehand in the official Discord Client)
            if (!client.AllServers.Any())
            {
                await client.AcceptInvite(client.GetInvite("aaabbbcccdddeee"));
            }
        });
    }
	static void Main(string[] args)
	{
		var client = new DiscordClient();

		//Display all log messages in the console
		client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");

		//Echo back any message received, provided it didn't come from the bot itself
		client.MessageReceived += async (s, e) =>
		{
			if (!e.Message.IsAuthor)
				await client.SendMessage(e.Channel, e.Message.Text);
		};

		//Convert our sync method to an async one and block the Main function until the bot disconnects
		client.Run(async () =>
		{
			//Connect to the Discord server using our email and password
			await client.Connect("*****@*****.**", "Password123");

			//If we are not a member of any server, use our invite code (made beforehand in the official Discord Client)
			if (!client.AllServers.Any())
				await client.AcceptInvite(client.GetInvite("aaabbbcccdddeee"));
		});
	}
Beispiel #3
0
    static void Main(string[] args)
    {
        var client = new DiscordClient();

        //Log some info to console
        client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");

        //Echo any message received, provided it didn't come from us
        client.MessageCreated += async(s, e) =>
        {
            if (!e.Message.IsAuthor)
            {
                await client.SendMessage(e.Message.ChannelId, e.Message.Text);
            }
        };

        //Convert our sync method to an async one and blocks this function until the client disconnects
        client.Run(async() =>
        {
            //Connect to the Discord server usinotng our email and password
            await client.Connect("*****@*****.**", "Password123");

            //If we are not a member of any server, use our invite code
            if (!client.Servers.Any())
            {
                await client.AcceptInvite("aaabbbcccdddeee");
            }
        });
    }
    static void Main(string[] args)
    {
        var client = new DiscordClient();
        
        //Log some info to console
		client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");
        
        //Echo any message received, provided it didn't come from us
        client.MessageCreated += async (s, e) =>
        {
            if (!e.Message.IsAuthor)
                await client.SendMessage(e.Message.ChannelId, e.Message.Text);
        };
        
        //Convert our sync method to an async one and blocks this function until the client disconnects
        client.Run(async () =>
        {
            //Connect to the Discord server usinotng our email and password
            await client.Connect("*****@*****.**", "Password123");
            
            //If we are not a member of any server, use our invite code
            if (!client.Servers.Any())
                await client.AcceptInvite("aaabbbcccdddeee");
        });
    }
Beispiel #5
0
        public static void Initialize(TestContext testContext)
        {
            var settings = Settings.Instance;

            _random = new Random();

            _hostClient  = new DiscordClient();
            _targetBot   = new DiscordClient();
            _observerBot = new DiscordClient();

            _hostClient.Connect(settings.User1.Email, settings.User1.Password).Wait();
            _targetBot.Connect(settings.User2.Email, settings.User2.Password).Wait();
            _observerBot.Connect(settings.User3.Email, settings.User3.Password).Wait();

            //Cleanup existing servers
            WaitMany(
                _hostClient.Servers.Select(x => _hostClient.LeaveServer(x)),
                _targetBot.Servers.Select(x => _targetBot.LeaveServer(x)),
                _observerBot.Servers.Select(x => _observerBot.LeaveServer(x)));

            //Create new server and invite the other bots to it
            _testServer        = _hostClient.CreateServer("Discord.Net Testing", Regions.US_East).Result;
            _testServerChannel = _testServer.DefaultChannel;
            Invite invite = _hostClient.CreateInvite(_testServer, 60, 1, false, false).Result;

            WaitAll(
                _targetBot.AcceptInvite(invite),
                _observerBot.AcceptInvite(invite));
        }
Beispiel #6
0
    static void Main(string[] args)
    {
        var client = new DiscordClient(new DiscordClientConfig {
			//Warning: Debug mode should only be used for identifying problems. It _will_ slow your application down.
			LogLevel = LogMessageSeverity.Debug
		});		
		client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");
                
        client.Run(async () =>
        {
            await client.Connect("*****@*****.**", "Password123");
            if (!client.Servers.Any())
                await client.AcceptInvite("aaabbbcccdddeee");
        });
    }
Beispiel #7
0
    static void Main(string[] args)
    {
        var client = new DiscordClient(new DiscordClientConfig {
            //Warning: Debug mode should only be used for identifying problems. It _will_ slow your application down.
            LogLevel = LogMessageSeverity.Debug
        });

        client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");

        client.Run(async() =>
        {
            await client.Connect("*****@*****.**", "Password123");
            if (!client.Servers.Any())
            {
                await client.AcceptInvite("aaabbbcccdddeee");
            }
        });
    }
Beispiel #8
0
        static void Start()
        {
            try
            {
                Console.WriteLine("Started Login!");
                Login();
            }
            catch (Exception e)
            {
                Console.WriteLine("================= ERRORRRR CRASHH ===================");
                Console.WriteLine("================= ERRORRRR CRASHH ===================");
                Console.WriteLine("================= ERRORRRR CRASHH ===================");
                Console.WriteLine(e.Message);
                Console.WriteLine("================= ERRORRRR CRASHH ===================");
                Console.WriteLine("================= ERRORRRR CRASHH ===================");
                Console.WriteLine("================= ERRORRRR CRASHH ===================");
                new Thread(() => ConsoleBeep()).Start();
            }

            //Console commands Menu
            while (true)
            {
                string crl = Console.ReadLine();
                string Cmd = crl.Split(' ')[0];
                crl = Utils.ReplaceFirstOccurrence(crl, Cmd, "");
                switch (Cmd)
                {
                case "help":
                    Log("Try typing '1231'!", LogType.Console);
                    Log("Try typing 'hel123p'!", LogType.Console);
                    break;

                case "join":
                    string substring = crl.Substring(crl.LastIndexOf('/') + 1);
                    client.AcceptInvite(substring);
                    Log("Joined, " + substring, LogType.Misc);
                    break;

                default:
                    Log("Try typing 'help'!", LogType.Console);
                    break;
                }
            }
        }
Beispiel #9
0
        private void SetupCommands()
        {
            #region Old Commands
            CommandsManager.AddCommand(new CommandStub("invite", "Makes an invite to specified server given its ID", "Pass ID douchebag.", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    if (cmdArgs.Args[0].Length > 0)
                    {
                        DiscordServer server   = client.GetServersList().Find(x => x.ID == cmdArgs.Args[0]);
                        DiscordChannel channel = server.Channels.Find(x => x.Name == "general");
                        cmdArgs.Channel.SendMessage(client.CreateInvite(channel));
                    }
                    else
                    {
                        cmdArgs.Channel.SendMessage("kek");
                    }
                }
                else
                {
                    cmdArgs.Channel.SendMessage("kek");
                }
            }));

            CommandsManager.AddCommand(new CommandStub("statusof", "`Status` test", "", PermissionType.Owner, 1, cmdArgs =>
            {
                string id = cmdArgs.Args[0].Trim(new char[] { '<', '@', '>' });
                if (!string.IsNullOrEmpty(id))
                {
                    DiscordMember member = cmdArgs.Channel.Parent.GetMemberByKey(id);
                    if (member != null)
                    {
                        string msg = $"Status of `{member.Username}`\n{member.Status}";
                        if (!string.IsNullOrEmpty(member.CurrentGame))
                        {
                            msg += $"\nPlaying: *{member.CurrentGame}*";
                        }
                        cmdArgs.Channel.SendMessage(msg);
                    }
                }
            }));
            CommandsManager.AddCommand(new CommandStub("changepic", "Changes the bot's guild pic test.", "Test", PermissionType.Owner, 1, cmdArgs =>
            {
                Regex linkParser = new Regex(@"\b(?:https?://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                string rawString = $"{cmdArgs.Args[0]}";
                if (linkParser.Matches(rawString).Count > 0)
                {
                    string url = linkParser.Matches(rawString)[0].ToString();
                    using (WebClient wc = new WebClient())
                    {
                        byte[] data = wc.DownloadData(url);
                        using (MemoryStream mem = new MemoryStream(data))
                        {
                            using (var image = System.Drawing.Image.FromStream(mem))
                            {
                                client.ChangeClientAvatar(new Bitmap(image));
                            }
                        }
                    }
                }
            }));
            CommandsManager.AddCommand(new CommandStub("serverstats", "Server stats", "help me", PermissionType.Owner, cmdArgs =>
            {
                if (cmdArgs.Channel != null && cmdArgs.Channel.Parent != null)
                {
                    DiscordServer guild = cmdArgs.Channel.Parent;
                    string msg          = $"Stats for **{guild.Name}**\n```\n";
                    msg += $"{guild.Members.Count} members\n";
                    msg += $"{guild.Roles.Count} roles\n";
                    msg += $"Owned by {guild.Owner.Username}#{guild.Owner.Discriminator}\n";
                    msg += $"{guild.Region}\n```";
                    cmdArgs.Channel.SendMessage(msg);
                }
            }));
            CommandsManager.AddCommand(new CommandStub("listroles", "Lists rolls", "help me", PermissionType.Owner, cmdArgs =>
            {
                if (cmdArgs.Channel != null && cmdArgs.Channel.Parent != null)
                {
                    DiscordServer guild = cmdArgs.Channel.Parent;
                    string msg          = $"Roles for **{guild.Name}**, per your request.\n```\n";
                    foreach (var role in guild.Roles)
                    {
                        msg += $"{role.Position} - {role.Name} - {role.ID} - {role.Permissions.GetRawPermissions()}\n";
                    }
                    msg += "\n```";
                    try
                    {
                        owner.SlideIntoDMs(msg);
                    }
                    catch { }
                    cmdArgs.Channel.SendMessage($"DMed to you ;)");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("sendchanneltest", "`Client.SendMessageToChannel` Test", "", PermissionType.Owner, cmdArgs =>
            {
                client.SendMessageToChannel("Works!", cmdArgs.Channel);
            }));
            CommandsManager.AddCommand(new CommandStub("setplaying", "Sets the current game the bot is playing.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                client.UpdateCurrentGame(cmdArgs.Args[0], true, "http://www.google.com/");
            }));
            CommandsManager.AddCommand(new CommandStub("join", "Joins a specified server", "", PermissionType.Owner, 1, cmdArgs =>
            {
                string substring = cmdArgs.Args[0].Substring(cmdArgs.Args[0].LastIndexOf('/') + 1);
                client.AcceptInvite(substring);
            }));
            CommandsManager.AddCommand(new CommandStub("cmdinfo", "Displays help for a command.", "Help", PermissionType.User, 2, e =>
            {
                if (!String.IsNullOrEmpty(e.Args[0]))
                {
                    ICommand stub = CommandsManager.Commands.Find(x => x.CommandName == e.Args[0]);
                    if (stub != null)
                    {
                        string msg = "**Help for " + stub.CommandName + "**";
                        msg       += $"\n{stub.Description}";
                        if (!String.IsNullOrEmpty(stub.HelpTag))
                        {
                            msg += $"\n\n{stub.HelpTag}";
                        }
                        if (stub.Parent != null)
                        {
                            msg += $"\nFrom module `{stub.Parent.Name}`";
                        }
                        if (stub.ID != null)
                        {
                            msg += $"\n`{stub.ID}`";
                        }
                        e.Channel.SendMessage(msg);
                    }
                    else
                    {
                        e.Channel.SendMessage("What command?");
                    }
                }
                else
                {
                    e.Channel.SendMessage("What command?");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("about", "Shows bot information", "", cmdArgs =>
            {
                string message = "**About Luigibot**\n";
                message       += $"Owner: {owner.Username}#{owner.Discriminator}\n";
                message       += $"Library: DiscordSharp {typeof(DiscordClient).Assembly.GetName().Version.ToString()}\n";
                message       += $"WebSocket: " + (UseBuiltInWebsocket ? "`System.Net.WebSockets`" : "`WebSocketSharp`") + "\n";
                message       += $"Gateway Version: {client.DiscordGatewayVersion}\n";
                var uptime     = (DateTime.Now - loginDate);
                message       += $"Uptime: {uptime.Days} days, {uptime.Hours} hours, {uptime.Minutes} minutes.\n";
                message       += "Runtime: ";

                if (runningOnMono)
                {
                    message += "Mono\n";
                }
                else
                {
                    message += ".Net\n";
                }

                message      += $"OS: {osString}\n";
                long memUsage = GetMemoryUsage();
                if (memUsage > 0)
                {
                    message += "Memory Usage: " + (memUsage / 1024) + "mb\n";
                }
                message += "Commands: " + CommandsManager.Commands.Count + "\n";
                message += "Command Prefix: " + config.CommandPrefix + "\n";
                message += "Total Servers: " + client.GetServersList().Count + "\n";
                cmdArgs.Channel.SendMessage(message);
            }));
            CommandsManager.AddCommand(new CommandStub("moduleinfo", "Shows information about a specific module.", "", PermissionType.User, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0 && cmdArgs.Args[0].Length > 0)
                {
                    foreach (var module in CommandsManager.Modules.ToList())
                    {
                        if (module.Key.Name.ToLower().Trim() == cmdArgs.Args[0].ToLower().Trim())
                        {
                            string msg = $"**About Module {module.Key.Name}**";

                            msg += $"\n{module.Key.Description}\nEnabled: {module.Value}";
                            msg += $"\nCommands: ";
                            module.Key.Commands.ForEach(x => msg += $"{x.CommandName}, ");

                            cmdArgs.Channel.SendMessage(msg);
                            break;
                        }
                    }
                }
            }));
            #endregion

            var OwnerModules = new BaseOwnerModules(this);
            OwnerModules.Install(CommandsManager);

            var funModule = new NoFunAllowedModule();
            funModule.Install(CommandsManager);

            var serverAdminModules = new ServerAdminModules(this);
            serverAdminModules.Install(CommandsManager);

            var evalModules = new EvalModules();
            evalModules.Install(CommandsManager);

            var yugiohModules = new YugiohModules();
            yugiohModules.Install(CommandsManager);

            var serverLogs = new TestServerLog(client);
            serverLogs.Install(CommandsManager);

            var voice = new Voice(this);
            voice.Install(CommandsManager);

            var holupholup = new Holup();
            holupholup.Install(CommandsManager);

            var testingModule = new TestingModule();
            testingModule.Install(CommandsManager);
        }
Beispiel #10
0
        private void SetupCommands()
        {
            #region Owner only
            CommandsManager.AddCommand(new CommandStub("selfdestruct", "Shuts the bot down.", "", PermissionType.Owner, cmdArgs =>
            {
                Exit();
            }));
            CommandsManager.AddCommand(new CommandStub("setplaying", "Sets the current game the bot is playing.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                client.UpdateCurrentGame(cmdArgs.Args[0]);
            }));
            CommandsManager.AddCommand(new CommandStub("join", "Joins a specified server", "", PermissionType.Owner, 1, cmdArgs =>
            {
                string substring = cmdArgs.Args[0].Substring(cmdArgs.Args[0].LastIndexOf('/') + 1);
                client.AcceptInvite(substring);
            }));
            CommandsManager.AddCommand(new CommandStub("changeprefix", "Changes the command prefix to a specified character.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    char newPrefix       = cmdArgs.Args[0][0];
                    config.CommandPrefix = newPrefix;
                    cmdArgs.Channel.SendMessage($"Command prefix changed to **{config.CommandPrefix}** successfully!");
                }
                else
                {
                    cmdArgs.Channel.SendMessage("What prefix?");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("giveperm", "Gives the perm to the specified user (bot scope)", "", PermissionType.Owner, 2, e =>
            {
                //giveperm Admin <@2309208509852>
                if (e.Args.Count > 1)
                {
                    string permString   = e.Args[0];
                    PermissionType type = PermissionType.User;
                    switch (permString.ToLower())
                    {
                    case "admin":
                        type = PermissionType.Admin;
                        break;

                    case "mod":
                        type = PermissionType.Mod;
                        break;

                    case "none":
                        type = PermissionType.None;
                        break;

                    case "user":
                        type = PermissionType.User;
                        break;
                    }
                    string id = e.Args[1].Trim(new char[] { '<', '@', '>' });
                    CommandsManager.AddPermission(id, type);
                    e.Channel.SendMessage($"Given permission {type.ToString().Substring(type.ToString().IndexOf('.') + 1)} to <@{id}>!");
                }
            }));
            #endregion
            #region Admin
            CommandsManager.AddCommand(new CommandStub("eval", "Evaluates real-time C# code. Be careful with this",
                                                       "Evaluates C# code that is dynamically compiled.\n\nThe following namespaces are available for use:\n * DiscordSharp\n * System.Threading\n * DiscordSharp.Objects\n\n\nMake sure your function returns a string value.\nYou can reference the DiscordSharp client by using `discordClient`.", PermissionType.Admin, 1, e =>
            {
                string whatToEval = e.Args[0];
                if (whatToEval.StartsWith("`") && whatToEval.EndsWith("`"))
                {
                    whatToEval = whatToEval.Trim('`');
                }
                try
                {
                    var eval   = EvalProvider.CreateEvalMethod <DiscordClient, string>(whatToEval, new string[] { "DiscordSharp", "System.Threading", "DiscordSharp.Objects" }, new string[] { "DiscordSharp.dll" });
                    string res = "";
                    Thread.Sleep(1000);
                    Thread executionThread = null;
                    Task evalTask          = new Task(() =>
                    {
                        executionThread = Thread.CurrentThread;
                        if (eval != null)
                        {
                            res = eval(client);
                        }
                        else
                        {
                            string errors = "Errors While Compiling: \n";
                            if (EvalProvider.errors != null)
                            {
                                if (EvalProvider.errors.Count > 0)
                                {
                                    foreach (var error in EvalProvider.errors)
                                    {
                                        errors += $"{error.ToString()}\n\n";
                                    }
                                }
                                e.Channel.SendMessage($"```\n{errors}\n```");
                            }
                            else
                            {
                                e.Channel.SendMessage("Errors!");
                            }
                        }
                    });
                    evalTask.Start();
                    evalTask.Wait(10 * 1000);
                    if (executionThread != null)
                    {
                        executionThread.Abort();
                    }
                    if (res == null || res == "")
                    {
                        e.Channel.SendMessage("Terminated after 10 second timeout.");
                    }
                    else
                    {
                        e.Channel.SendMessage($"**Result**\n```\n{res}\n```");
                    }
                }
                catch (Exception ex)
                {
                    string errors = "Errors While Compiling: \n";
                    if (EvalProvider.errors != null)
                    {
                        if (EvalProvider.errors.Count > 0)
                        {
                            foreach (var error in EvalProvider.errors)
                            {
                                errors += $"{error.ToString()}\n\n";
                            }
                        }
                        else
                        {
                            errors += ex.Message;
                        }
                        e.Channel.SendMessage($"```\n{errors}\n```");
                    }
                    else
                    {
                        e.Channel.SendMessage("Errors!");
                    }
                }
            }));
            #endregion
            #region Anyone, but limited to server mods
            CommandsManager.AddCommand(new CommandStub("gtfo", "Makes the bot leave the server", "", PermissionType.User, cmdArgs =>
            {
                bool canExecute = false;
                foreach (var roll in cmdArgs.Author.Roles)
                {
                    if (roll.permissions.HasPermission(DiscordSpecialPermissions.ManageServer))
                    {
                        canExecute = true;
                    }
                }
                if (canExecute)
                {
                    client.LeaveServer(cmdArgs.Channel.parent);
                }
                else
                {
                    cmdArgs.Channel.SendMessage("You don't have the proper permissions to do this! You need the ManagerServer permission.");
                }
            }));
            #endregion
            #region Literally anyone
            CommandsManager.AddCommand(new CommandStub("cmdinfo", "Displays help for a command.", "Help", PermissionType.User, 2, e =>
            {
                if (!String.IsNullOrEmpty(e.Args[0]))
                {
                    ICommand stub = CommandsManager.Commands.Find(x => x.CommandName == e.Args[0]);
                    if (stub != null)
                    {
                        string msg = "**Help for " + stub.CommandName + "**";
                        msg       += $"\n{stub.Description}";
                        if (!String.IsNullOrEmpty(stub.HelpTag))
                        {
                            msg += $"\n\n{stub.HelpTag}";
                        }
                        e.Channel.SendMessage(msg);
                    }
                    else
                    {
                        e.Channel.SendMessage("What command?");
                    }
                }
                else
                {
                    e.Channel.SendMessage("What command?");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("about", "Shows bot information", "", cmdArgs =>
            {
                string message = "**About Luigibot**\n";
                message       += "Owner: " + owner.Username + "\n";
                message       += "Library: DiscordSharp\n";
                message       += "Uptime: " + (DateTime.Now - loginDate).ToString() + "\n";
                message       += "Compiled Under: ";
                if (Mono())
                {
                    message += "Mono\n";
                }
                else
                {
                    message += ".Net\n";
                }
                long memUsage = GetMemoryUsage();
                if (memUsage > 0)
                {
                    message += "Memory Usage: " + (memUsage / 1024) / 2 + "mb\n";
                }
                message += "Commands: " + CommandsManager.Commands.Count + "\n";
                message += "Command Prefix: " + config.CommandPrefix + "\n";
                message += "Total Servers: " + client.GetServersList().Count + "\n";
                cmdArgs.Channel.SendMessage(message);
            }));
            #endregion
        }
Beispiel #11
0
        public static void Main(string[] args)
        {
            Console.WriteLine("DiscordSharp Tester");
            client.ClientPrivateInformation = new DiscordUserInformation();
            Console.Write("Please enter your email: ");
            string email = Console.ReadLine();

            client.ClientPrivateInformation.email = email;

            Console.Write("Now, your password (visible): ");
            string pass = Console.ReadLine();

            client.ClientPrivateInformation.password = pass;

            Console.WriteLine("Attempting login..");

            var worker = new Thread(() =>
            {
                client.DebugMessageReceived += (sender, e) =>
                {
                    client.SendMessageToUser("[DEBUG MESSAGE]: " + e.message, client.GetServersList().Find(x => x.members.Find(y => y.user.username == "Axiom") != null).members.Find(x => x.user.username == "Axiom"));
                };
                client.UnknownMessageTypeReceived += (sender, e) =>
                {
                    using (var sw = new StreamWriter(e.RawJson["t"].ToString() + ".txt"))
                    {
                        sw.WriteLine(e.RawJson);
                    }
                    client.SendMessageToUser("Heya, a new message type, '" + e.RawJson["t"].ToString() + "', has popped up!", client.GetServersList().Find(x => x.members.Find(y => y.user.username == "Axiom") != null).members.Find(x => x.user.username == "Axiom"));
                };
                client.VoiceStateUpdate += (sender, e) =>
                {
                    Console.WriteLine("***Voice State Update*** User: "******"Server Created: " + e.server.name);
                };
                client.MessageEdited += (sender, e) =>
                {
                    if (e.author.user.username == "Axiom")
                    {
                        client.SendMessageToChannel("What the f**k, <@" + e.author.user.id + "> you can't event type your message right. (\"" + e.MessageEdited.content + "\")", e.Channel);
                    }
                };
                client.ChannelCreated += (sender, e) =>
                {
                    var parentServer = client.GetServersList().Find(x => x.channels.Find(y => y.id == e.ChannelCreated.id) != null);
                    if (parentServer != null)
                    {
                        Console.WriteLine("Channel {0} created in {1}!", e.ChannelCreated.name, parentServer.name);
                    }
                };
                client.PrivateChannelCreated += (sender, e) =>
                {
                    Console.WriteLine("Private channel started with {0}", e.ChannelCreated.recipient.username);
                };
                client.PrivateMessageReceived += (sender, e) =>
                {
                    client.SendMessageToUser("Pong!", e.author);
                };
                client.MentionReceived += (sender, e) =>
                {
                    if (e.author.user.id != client.Me.user.id)
                    {
                        client.SendMessageToChannel("Heya, @" + e.author.user.username, e.Channel);
                    }
                };
                client.MessageReceived += (sender, e) =>
                {
                    DiscordServer fromServer = client.GetServersList().Find(x => x.channels.Find(y => y.id == e.Channel.id) != null);
                    Console.WriteLine("[- Message from {0} in {1} on {2}: {3}", e.author.user.username, e.Channel.name, fromServer.name, e.message.content);
                    if (e.message.content.StartsWith("?status"))
                    {
                        client.SendMessageToChannel("I work ;)", e.Channel);
                    }
                    else if (e.message.content.StartsWith("?notify"))
                    {
                        string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                    }
                    else if (e.message.content.StartsWith("?whereami"))
                    {
                        DiscordServer server = client.GetServersList().Find(x => x.channels.Find(y => y.id == e.Channel.id) != null);
                        string owner         = "";
                        foreach (var member in server.members)
                        {
                            if (member.user.id == server.owner_id)
                            {
                                owner = member.user.username;
                            }
                        }
                        string whereami = String.Format("I am currently in *#{0}* ({1}) on server *{2}* ({3}) owned by {4}. The channel's topic is: {5}", e.Channel.name, e.Channel.id, server.name, server.id, owner, e.Channel.topic);
                        client.SendMessageToChannel(whereami, e.Channel);
                    }
                    else if (e.message.content.StartsWith("?test_game"))
                    {
                        string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                        if (split.Length > 0)
                        {
                            client.UpdateCurrentGame(int.Parse(split[1]));
                        }
                    }
                    else if (e.message.content.StartsWith("?gtfo"))
                    {
                        string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                        if (split.Length > 1)
                        {
                            DiscordServer curServer = client.GetServersList().Find(x => x.channels.Find(y => y.id == split[1]) != null);
                            if (curServer != null)
                            {
                                client.SendMessageToChannel("Leaving server " + curServer.name, e.Channel);
                                client.LeaveServer(curServer.id);
                            }
                        }
                        else
                        {
                            DiscordServer curServer = client.GetServersList().Find(x => x.channels.Find(y => y.id == e.Channel.id) != null);
                            client.SendMessageToChannel("Bye!", e.Channel);
                            client.LeaveServer(curServer.id);
                        }
                    }
                    else if (e.message.content.StartsWith("?everyone"))
                    {
                        DiscordServer server = client.GetServersList().Find(x => x.channels.Find(y => y.id == e.Channel.id) != null);
                        string[] split       = e.message.content.Split(new char[] { ' ' }, 2);
                        if (split.Length > 1)
                        {
                            string message = "";
                            foreach (var user in server.members)
                            {
                                if (user.user.id == client.Me.user.id)
                                {
                                    continue;
                                }
                                if (user.user.username == "Blank")
                                {
                                    continue;
                                }
                                message += "@" + user.user.username + " ";
                            }
                            message += ": " + split[1];
                            client.SendMessageToChannel(message, e.Channel);
                        }
                    }
                    else if (e.message.content.StartsWith("?lastfm"))
                    {
#if __MONOCS__
                        client.SendMessageToChannel("Sorry, not on Mono :(", e.Channel);
#else
                        string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                        if (split.Length > 1)
                        {
                            using (var lllfclient = new LastfmClient("4de0532fe30150ee7a553e160fbbe0e0", "0686c5e41f20d2dc80b64958f2df0f0c", null, null))
                            {
                                try
                                {
                                    var recentScrobbles = lllfclient.User.GetRecentScrobbles(split[1], null, 1, 1);
                                    LastTrack lastTrack = recentScrobbles.Result.Content[0];
                                    client.SendMessageToChannel(string.Format("*{0}* last listened to _{1}_ by _{2}_", split[1], lastTrack.Name, lastTrack.ArtistName), e.Channel);
                                }
                                catch
                                {
                                    client.SendMessageToChannel(string.Format("User _*{0}*_ not found!", split[1]), e.Channel);
                                }
                            }
                        }
                        else
                        {
                            client.SendMessageToChannel("Who??", e.Channel);
                        }
#endif
                    }
                    else if (e.message.content.StartsWith("?rename"))
                    {
                        string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                        if (split.Length > 0)
                        {
                            //client.ChangeBotUsername(split[1]);
                            DiscordUserInformation newUserInfo = client.ClientPrivateInformation;
                            newUserInfo.username = split[1].ToString();
                            client.ChangeBotInformation(newUserInfo);
                        }
                    }
                    else if (e.message.content.StartsWith("?changepic"))
                    {
                        string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                        if (split.Length > 0)
                        {
                            Regex linkParser = new Regex(@"\b(?:https?://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                            string rawString = $"{split[1]}";
                            if (linkParser.Matches(rawString).Count > 0)
                            {
                                string url = linkParser.Matches(rawString)[0].ToString();
                                using (WebClient wc = new WebClient())
                                {
                                    byte[] data = wc.DownloadData(url);
                                    using (MemoryStream mem = new MemoryStream(data))
                                    {
                                        using (var image = System.Drawing.Image.FromStream(mem))
                                        {
                                            client.ChangeBotPicture(new Bitmap(image));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else if (e.message.content.StartsWith("?whois"))
                    {
                        //?whois <@01393408>
                        Regex r = new Regex("\\d+");
                        Match m = r.Match(e.message.content);
                        Console.WriteLine("WHOIS INVOKED ON: " + m.Value);
                        var foundServer = client.GetServersList().Find(x => x.channels.Find(y => y.id == e.Channel.id) != null);
                        if (foundServer != null)
                        {
                            var foundMember = foundServer.members.Find(x => x.user.id == m.Value);
                            client.SendMessageToChannel(string.Format("<@{0}>: {1}, {2}", foundMember.user.id, foundMember.user.id, foundMember.user.username), e.Channel);
                        }
                    }
                    else if (e.message.content.StartsWith("?prune"))
                    {
                        string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                        if (split.Length > 0)
                        {
                            if (split[1].Trim() == "all")
                            {
                                int messagesDeleted = client.DeleteAllMessages();
                                if (split.Length > 1 && split[2] != "nonotice")
                                {
                                    client.SendMessageToChannel(messagesDeleted + " messages deleted across all channels.", e.Channel);
                                }
                            }
                            else if (split[1].Trim() == "here")
                            {
                                int messagesDeleted = client.DeleteAllMessagesInChannel(e.Channel);
                                if (split.Length > 1 && split[2] != "nonotice")
                                {
                                    client.SendMessageToChannel(messagesDeleted + " messages deleted in channel '" + e.Channel.name + "'.", e.Channel);
                                }
                            }
                            else
                            {
                                DiscordChannel channelToPrune = client.GetChannelByName(split[1].Trim());
                                if (channelToPrune != null)
                                {
                                    int messagesDeleted = client.DeleteAllMessagesInChannel(channelToPrune);
                                    if (split.Length > 1 && split[2] != "nonotice")
                                    {
                                        client.SendMessageToChannel(messagesDeleted + " messages deleted in channel '" + channelToPrune.name + "'.", e.Channel);
                                    }
                                }
                            }
                        }
                        else
                        {
                            client.SendMessageToChannel("Prune what?", e.Channel);
                        }
                    }
                    else if (e.message.content.StartsWith("?quoththeraven"))
                    {
                        client.SendMessageToChannel("nevermore", e.Channel);
                    }
                    else if (e.message.content.StartsWith("?quote"))
                    {
                        client.SendMessageToChannel("Luigibot does what Reta don't.", e.Channel);
                    }
                    else if (e.message.content.StartsWith("?selfdestruct"))
                    {
                        if (e.author.user.username == "Axiom")
                        {
                            client.SendMessageToChannel("restaroni in pepparoni", e.Channel);
                        }
                        Environment.Exit(0);
                    }
                    else if (e.message.content.StartsWith("?changetopic"))
                    {
                        if (e.author.user.username == "Axiom")
                        {
                            string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                            if (split.Length > 0)
                            {
                                client.ChangeChannelTopic(split[1], e.Channel);
                            }
                        }
                    }
                    else if (e.message.content.StartsWith("?join"))
                    {
                        if (e.author.user.username == "Axiom")
                        {
                            string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                            if (split.Length > 0)
                            {
                                string substring = split[1].Substring(split[1].LastIndexOf('/') + 1);
                                //client.SendMessageToChannel(substring, e.Channel);
                                client.AcceptInvite(substring);
                            }
                        }
                    }
                };
                client.Connected += (sender, e) =>
                {
                    Console.WriteLine("Connected! User: "******"Closed ({0}): {1}", e.Code, e.Reason);
                };
                //ConnectStuff();
                //while (true) ;
                if (client.SendLoginRequest() != null)
                {
                    Console.WriteLine("Logged in!");

                    client.ConnectAndReadMessages();
                    Console.WriteLine($"Connected to {client.CurrentGatewayURL}");
                    client.UpdateCurrentGame(256);
                }
            });

            worker.Start();

            InputCheck();
            //System.Windows.Forms.Application.Run();

            /**
             * Since this is a test app and people actually do read my code...
             * I'd like to say one thing:
             * If you're not going to be doing any input accepting **INSIDE OF THE CONSOLE** you don't have to setup
             * a seperate thread for the client and accept input on main. This is why I've only commented out
             * the System.Windows.Forms.Application.Run(); part instead of removing it.
             *
             * If you're not accepting input, you can just run client on the main thread and run that
             * System.Windows.Forms.Application.Run(); snippet and this will keep the app alive, with no CPU
             * hit!
             */
            client.Dispose();

            Console.ReadLine();
        }
Beispiel #12
0
            static void Main(string[] args)
            {
                DiscordClient clientti = new DiscordClient("apikey", isbot);

                clientti.ClientPrivateInformation.Email    = "sposti";
                clientti.ClientPrivateInformation.Password = "******";


                clientti.Connected += (sender, e) =>
                {
                    Console.WriteLine("user connected " + e.User.Username);

                    clientti.UpdateCurrentGame("kek");
                };

                clientti.PrivateMessageReceived += (sender, e) =>
                {
                    var          fromAddress  = new MailAddress("botmail", "BOT");
                    var          toAddress    = new MailAddress("", "");
                    const string fromPassword = "******";
                    const string subject      = "uusi viesti discordista";
                    string       body         = "katso uusi viesti " + e.Author.Username;

                    var smtp = new SmtpClient
                    {
                        Host                  = "smtp.gmail.com",
                        Port                  = 587,
                        EnableSsl             = true,
                        DeliveryMethod        = SmtpDeliveryMethod.Network,
                        UseDefaultCredentials = false,
                        Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
                    };
                    using (var message = new MailMessage(fromAddress, toAddress)
                    {
                        Subject = subject,
                        Body = body
                    })
                    {
                        smtp.Send(message);
                    }
                };

                clientti.PrivateMessageReceived += (sender, e) =>
                {
                    string msg = e.Message.ToString();

                    if (e.Message == "!msg")
                    {
                        e.Author.SendMessage(msg);
                    }

                    if (msg.StartsWith("!"))
                    {
                        // var tag = msg.Substring(0, msg.IndexOf(' ') == -1 ?
                        var tag = msg.Substring(0, msg.IndexOf(' ') == -1 ? msg.Length : msg.IndexOf(' '));
                        tag = tag.Replace("!", "");
                        var cmd = msg.Substring(msg.IndexOf(' ') == -1 ? msg.Length : msg.IndexOf(' ') + 1);
                        if (tag == "test")
                        {
                            if (cmd == "")
                            {
                                e.Author.SendMessage("test");
                            }
                            else
                            {
                                e.Author.SendMessage("testi " + cmd);
                            }
                        }
                        if (tag == "kek")
                        {
                            if (cmd == "")
                            {
                                e.Author.SendMessage("kekkimusmaksimus");
                            }
                            else
                            {
                                e.Author.SendMessage("test " + cmd);
                            }
                        }
                    }

                    if (e.Message.Contains("join"))
                    {
                        if (!isbot)
                        {
                            string inviteID = e.Message.Substring(e.Message.LastIndexOf('/') + 1);
                            clientti.AcceptInvite(inviteID);
                            e.Author.SendMessage("joined your discord channel");
                            Console.WriteLine("got join request from " + inviteID);
                        }
                    }
                    ;
                };



                clientti.MessageReceived += (sender, e) =>

                {
                    var          fromAddress  = new MailAddress("bot mail", "BOT");
                    var          toAddress    = new MailAddress("", "");
                    const string fromPassword = "******";
                    const string subject      = "uusi viesti discordista";
                    string       body         = "katso uusi viesti" + e.Author.Username;

                    var smtp = new SmtpClient
                    {
                        Host                  = "smtp.gmail.com",
                        Port                  = 587,
                        EnableSsl             = true,
                        DeliveryMethod        = SmtpDeliveryMethod.Network,
                        UseDefaultCredentials = false,
                        Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
                    };
                    using (var message = new MailMessage(fromAddress, toAddress)
                    {
                        Subject = subject,
                        Body = body
                    })
                    {
                        smtp.Send(message);
                    }

                    if (e.MessageText == "!rules")
                    {
                        e.Channel.SendMessage("channel rules:");
                    }
                    //overwatch profile info with json file parsering
                    while (e.MessageText.StartsWith("!ow "))
                    {
                        string mytext  = e.MessageText;
                        string newline = mytext.Substring(mytext.IndexOf(' ') + 1);

                        string         url     = "https://api.lootbox.eu/pc/eu/" + newline.Replace("#", "-") + "/profile";
                        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);


                        HttpWebResponse response = (HttpWebResponse)request.GetResponse();


                        StreamReader sr = new StreamReader(response.GetResponseStream());

                        string res;
                        string html = sr.ReadToEnd();
                        sr.Close();
                        response.Close();
                        res = html;
                        dynamic dyn = JsonConvert.DeserializeObject(res);



                        string error = dyn.statusCode;
                        if (error == "404")
                        {
                            e.Channel.SendMessage("errori.");
                            goto Lopetus;
                        }
                        string name  = dyn.data.username;
                        string level = dyn.data.level;



                        string message = "```\n" + "nimi:" + name + " \nleveli: " + level + "\n``` ";
                        e.Channel.SendMessage(message);

                        break;
                    }
                    Lopetus : { }


                    //string msg = e.Message.ToString();
                    //if (msg.Contains(" "))
                    //{

                    //   var tag = msg.Substring(0, msg.IndexOf(' ') == -1 ? msg.Length : msg.IndexOf(' '));
                    //    tag = tag.Replace("!", "");
                    //    var cmd = msg.Substring(msg.IndexOf(' ') == -1 ? msg.Length : msg.IndexOf(' ') + 1);
                    //    if (tag == "test")
                    //    {
                    //        if (cmd == "")
                    //        {
                    //            e.Author.SendMessage("test");
                    //        }
                    //        else
                    //        {
                    //            e.Author.SendMessage("testi " + cmd);
                    //        }

                    //    }
                    //    if (tag == "kek")
                    //    {
                    //        if (cmd == "")
                    //        {
                    //            e.Author.SendMessage("kekkimusmaksimus");
                    //        }
                    //        else
                    //        {
                    //            e.Author.SendMessage("test " + cmd);
                    //        }
                    //    }

                    //}


                    //if (e.MessageText == "!admin")
                    //{
                    //    bool isadmin = false;
                    //    List<DiscordRole> roles = e.Author.Roles;
                    //    foreach (DiscordRole role in roles)
                    //    {
                    //        if (role.Permissions.HasPermission(DiscordSpecialPermissions.ManageServer))
                    //        {
                    //            isadmin = true;
                    //        }
                    //    }
                    //    if (isadmin)
                    //    {
                    //        e.Channel.SendMessage("Yes, you are! :D");
                    //        Console.WriteLine(isadmin);
                    //    }
                    //    else
                    //    {
                    //        e.Channel.SendMessage("No, you aren't :c");
                    //        Console.WriteLine(isadmin);
                    //    }


                    //}
                };

                try {
                    //login request
                    Console.WriteLine("sending login request");
                    clientti.SendLoginRequest();
                    Console.WriteLine("connection clien in separate thread");
                    Thread connect = new Thread(clientti.Connect);
                    connect.Start();
                    Console.WriteLine("client connected");
                } catch (Exception e)
                {
                    Console.WriteLine("something went wrong\n" + e.Message + "\nPress any key to close this window.");
                }
                Console.ReadKey();   //if user press the key bot will shut down
                Environment.Exit(0); //make sure all threads are closed
            }
Beispiel #13
0
        static void Main(string[] args)
        {
            //Checks to see if Bot_Settings.ini exists and if it doesnt it writes to console and ends the program.
            MakeIni.Create();
            // First of all, a DiscordClient will be created, and the email and password will be defined.
            Console.WriteLine("Defining variables");
            // Fill in token and change isbot to true if you use the API
            // Else, leave token alone and change isbot to false
            // But believe me, the API bots are nicer because of a sexy bot tag!
            //BotSettings.botToken gets the token from Bot_Settings.ini
            DiscordClient client = new DiscordClient(BotSettings.botToken, isbot);

            client.ClientPrivateInformation.Email    = "email";
            client.ClientPrivateInformation.Password = "******";

            // Then, we are going to set up our events before connecting to discord, to make sure nothing goes wrong.

            Console.WriteLine("Defining Events");
            // find that one you interested in

            client.Connected += (sender, e) => // Client is connected to Discord
            {
                Console.WriteLine("Connected! User: "******"https://github.com/NaamloosDT/DiscordSharp_Starter"); // This will display at "Playing: "
                                                                                                                             //Whoops! i messed up here. (original: Bot online!\nPress any key to close this window.)

                //if the bots username is not the same as the name set in the Bot_Settings.ini
                // this sets the bot name to be the updated name in the Bot_Settings.ini
                if (client.Me.Username != BotSettings.botName)
                {
                    DiscordUserInformation info = new DiscordUserInformation();
                    info.Username = BotSettings.botName;
                    client.ChangeClientInformation(info);
                }
                //checks to see if a avatar image exists and updates it.
                if (File.Exists("avatar.jpg"))
                {
                    client.ChangeClientAvatarFromFile("avatar.jpg");
                }
            };


            client.PrivateMessageReceived += (sender, e) => // Private message has been received
            {
                if (e.Message == pf + "help")
                {
                    e.Author.SendMessage("This is a private message!");
                    // Because this is a private message, the bot should send a private message back
                    // A private message does NOT have a channel
                }
                if (e.Message == pf + "update avatar")
                {
                    // Because this is a private message, the bot should send a private message back
                    // A private message does NOT have a channel
                }
                if (e.Message.StartsWith(pf + "join"))
                {
                    if (!isbot)
                    {
                        string inviteID = e.Message.Substring(e.Message.LastIndexOf('/') + 1);
                        // Thanks to LuigiFan (Developer of DiscordSharp) for this line of code!
                        client.AcceptInvite(inviteID);
                        e.Author.SendMessage("Joined your discord server!");
                        Console.WriteLine("Got join request from " + inviteID);
                    }
                    else
                    {
                        e.Author.SendMessage("Please use this url instead!" +
                                             "https://discordapp.com/oauth2/authorize?client_id=[CLIENT_ID]&scope=bot&permissions=0");
                    }
                }
            };


            client.MessageReceived += (sender, e) => // Channel message has been received
            {
                if (e.MessageText == pf + "admin")
                {
                    bool isadmin             = false;
                    List <DiscordRole> roles = e.Author.Roles;
                    foreach (DiscordRole role in roles)
                    {
                        if (role.Name.Contains("Administrator") || e.Author.HasPermission(DiscordSpecialPermissions.Administrator))
                        {
                            isadmin = true;
                            break;
                        }
                    }
                    if (isadmin)
                    {
                        e.Channel.SendMessage("Yes, you are! :D");
                    }
                    else
                    {
                        e.Channel.SendMessage("No, you aren't :c");
                    }
                }
                if (e.MessageText == pf + "help")
                {
                    e.Channel.SendMessage("This is a public message!");
                    // Because this is a public message,
                    // the bot should send a message to the channel the message was received.
                }
                if (e.MessageText == pf + "cat")
                {
                    e.Channel.SendMessage("Meow :cat: " + randomcat());
                }
            };

            //  Below: some things that might be nice?

            //  This sends a message to every new channel on the server
            client.ChannelCreated += (sender, e) =>
            {
                if (e.ChannelCreated.Type == ChannelType.Text)
                {
                    e.ChannelCreated.SendMessage("Nice! a new channel has been created!");
                }
            };

            //  When a user joins the server, send a message to them.
            client.UserAddedToServer += (sender, e) =>
            {
                e.AddedMember.SendMessage("Welcome " + e.Guild.Name + ", please read the rules.\nEnjoy you're time here!");
            };

            //  Don't want messages to be removed? this piece of code will
            //  Keep messages for you. Remove if unused :)

            /*client.MessageDeleted += (sender, e) =>
             *  {
             *      e.Channel.SendMessage("Removing messages has been disabled on this server!");
             *      e.Channel.SendMessage("<@" + e.DeletedMessage.Author.ID + "> sent: " +e.DeletedMessage.Content.ToString());
             *  };*/



            // Now, try to connect to Discord.
            try{
                // Make sure that IF something goes wrong, the user will be notified.
                // The SendLoginRequest should be called after the events are defined, to prevent issues.
                Console.WriteLine("Sending login request");
                client.SendLoginRequest();
                Console.WriteLine("Connecting client in separate thread");
                // Cannot convert from 'method group' to 'ThreadStart', so i removed threading
                // Pass argument 'true' to use .Net sockets.
                client.Connect();
                // Login request, and then connect using the discordclient i just made.
                Console.WriteLine("Client connected!");
            }catch (Exception e) {
                Console.WriteLine("Something went wrong!\n" + e.Message + "\nPress any key to close this window.");
            }

            // Done! your very own Discord bot is online!


            // Now to make sure the console doesnt close:
            Console.ReadKey();   // If the user presses a key, the bot will shut down.
            Environment.Exit(0); // Make sure all threads are closed.
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            // Connecter au Channel
            Console.WriteLine("Définir les variables");
            DiscordClient client = new DiscordClient();

            client.ClientPrivateInformation.Email    = "email compte discord";
            client.ClientPrivateInformation.Password = "******";

            // Set les events avant de se connecter au discord.
            Console.WriteLine("Définir les Events");
            // Trouver le chan

            client.Connected += (sender, e) => // Le Client est connecté à Discord
            {
                Console.WriteLine("Connecter! Utilisateur: " + e.User.Username);
                // Si le bot est bel et bien connecté, ce message va apparaître
                // Change le "Joue à:"
                client.UpdateCurrentGame("YANDERE SIMULATOR");
            };


            client.PrivateMessageReceived += (sender, e) => // Message privé reçu
            {
                if (e.Message == "!aide")
                {
                    e.Author.SendMessage("Salut! J'ai vu que tu demandais de l'aide. Voici la liste de mes commandes!");
                    e.Author.SendMessage("!aide: La liste de mes commandes.");
                    e.Author.SendMessage("Aïa, out!: Pour me mettre hors ligne.");
                    // Aïa devrait renvoyé le message en privé
                }
                if (e.Message.StartsWith("join ")) //Si quelqu'un d'autre invite Aïa sur un autre Channel (j'espère pas)
                {
                    string inviteID = e.Message.Substring(e.Message.LastIndexOf('/') + 1);
                    client.AcceptInvite(inviteID);
                    e.Author.SendMessage("J'ai join ton Channel");
                    Console.WriteLine("On m'a invité là: " + inviteID); //Me dire le channel dans la console
                }
            };


            client.MessageReceived += (sender, e) => // Message de channel reçu
            {
                if (e.MessageText == "Aïa, out!")
                {
                    bool ismj = false;                         //ismj est toujours faux à la base
                    List <DiscordRole> roles = e.Author.Roles; //Faire une liste des rôles sur le serveur
                    foreach (DiscordRole role in roles)        //Pour chaque rôle dans la liste
                    {
                        if (role.Name.Contains("MJ"))          //Si c'est MJ, mettre isMJ à vrai
                        {
                            ismj = true;
                        }
                    }
                    if (ismj) //Dire bye bye
                    {
                        e.Channel.SendMessage("Au revoir!");
                        Environment.Exit(1);
                    }
                    else //Sinon envoyer chier
                    {
                        e.Channel.SendMessage("Ne me dis pas quoi faire!");
                    }
                }
                // Réponses
                if (e.MessageText == "!aide")
                {
                    e.Channel.SendMessage("Envoie moi un message privé!");
                }
                if (e.MessageText == "DAMMIT BRIM")
                {
                    e.Channel.SendMessage("DAMMIT BRIM "); //L'espace après est important sinon elle se répète et crash :(
                }
                if (e.MessageText == "!loli")
                {
                    e.Channel.SendMessage("PEDO ALERT!");
                }
                if (e.MessageText == "!règles")
                {
                    e.Channel.SendMessage("Bienvenue sur le Discord! Il y a quelques règles...");
                    e.Channel.SendMessage("1. Soyez gentil");
                    e.Channel.SendMessage("2. Tout est de la faute de Brimstone");
                }
                if (e.MessageText == "!yaoi")
                {
                    e.Channel.SendMessage("Ooooh j'aime!");
                    e.Channel.SendMessage("https://www.youtube.com/watch?v=Gfl-CfEQcew");
                }
            };


            //¸Quand on nouveau membre join le chan
            client.UserAddedToServer += (sender, e) =>
            {
                e.AddedMember.SendMessage("Bienvenue sur le Discord! Il y a quelques règles...");
                e.AddedMember.SendMessage("1. Soyez gentil");
                e.AddedMember.SendMessage("2. Tout est de la faute de Brimstone");
            };

            // Si quelque chose ne va pas quand le bot essaie de se connecter
            try
            {
                Console.WriteLine("Envoie Requête de Connection");
                client.SendLoginRequest();
                Console.WriteLine("Connecter le clien dans une autre instance");
                Thread connect = new Thread(client.Connect);
                connect.Start();
                // Requête de connection et puis connecté le bot sur le client créé
                Console.WriteLine("Client connecté! Yay!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Y'a quelque chose qui n'a pas passé\n" + e.Message + "\nPèse sur n'importe quelle touche pour fermer.");
            }

            // Être certaine que la console ne ferme pas
            Console.ReadKey();   // Ferme quand on touche à une touche
            Environment.Exit(0); // Être certain que toutes les instances fonctionnent.
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            MakeIni.Create();


            Console.WriteLine("Defining variables");

            DiscordClient client = new DiscordClient(BotSettings.botToken, isbot);

            client.ClientPrivateInformation.Email    = "email";
            client.ClientPrivateInformation.Password = "******";


            Console.WriteLine("Defining Events");

            client.Connected += (sender, e) =>
            {
                Console.WriteLine("Connected! User: "******"https://github.com/Follew/Oscuro-Bot/");

                if (client.Me.Username != BotSettings.botName)
                {
                    DiscordUserInformation info = new DiscordUserInformation();
                    info.Username = BotSettings.botName;
                    client.ChangeClientInformation(info);
                }

                if (File.Exists("avatar.jpg"))
                {
                    client.ChangeClientAvatarFromFile("avatar.jpg");
                }
            };


            client.PrivateMessageReceived += (sender, e) =>
            {
                if (e.Message == pf + "help")
                {
                    e.Author.SendMessage("This is a private message!");
                }
                if (e.Message == pf + "update avatar")
                {
                }
                if (e.Message.StartsWith(pf + "join"))
                {
                    if (!isbot)
                    {
                        string inviteID = e.Message.Substring(e.Message.LastIndexOf('/') + 1);

                        client.AcceptInvite(inviteID);
                        e.Author.SendMessage("Joined your discord server!");
                        Console.WriteLine("Got join request from " + inviteID);
                    }
                    else
                    {
                        e.Author.SendMessage("Please use this url instead!" +
                                             "https://discordapp.com/oauth2/authorize?client_id=[CLIENT_ID]&scope=bot&permissions=0");
                    }
                }
            };


            client.MessageReceived += (sender, e) =>
            {
                if (e.MessageText == pf + "admin")
                {
                    bool isadmin             = false;
                    List <DiscordRole> roles = e.Author.Roles;

                    foreach (DiscordRole role in roles)
                    {
                        if (role.Name.Contains("Administrator") || e.Author.HasPermission(DiscordSpecialPermissions.Administrator))
                        {
                            isadmin = true;
                            break;
                        }
                    }
                    if (isadmin)
                    {
                        e.Channel.SendMessage("Yes, you are! :D");
                    }
                    else
                    {
                        e.Channel.SendMessage("No, you aren't :c");
                    }
                }
                if (e.MessageText == pf + "help")
                {
                    e.Channel.SendMessage("This is a public message!");
                }
                if (e.MessageText == pf + "cat")
                {
                    //e.Channel.SendMessage("Meow :cat: " + randomcat());
                }
            };


            client.ChannelCreated += (sender, e) =>
            {
                if (e.ChannelCreated.Type == ChannelType.Text)
                {
                    e.ChannelCreated.SendMessage("Nice! a new channel has been created!");
                }
            };

            client.UserAddedToServer += (sender, e) =>
            {
                e.AddedMember.SendMessage("Welcome " + e.Guild.Name + ", please read the rules.\nEnjoy you're time here!");
            };


            /*client.MessageDeleted += (sender, e) =>
             * {
             *  e.Channel.SendMessage("Removing messages has been disabled on this server!");
             *  e.Channel.SendMessage("<@" + e.DeletedMessage.Author.ID + "> sent: " +e.DeletedMessage.Content.ToString());
             * };*/

            try
            {
                Console.WriteLine("Sending login request");

                client.SendLoginRequest();

                Console.WriteLine("Connecting client in separate thread");

                client.Connect();

                Console.WriteLine("Client connected!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Something went wrong!\n" + e.Message + "\nPress any key to close this window.");
            }

            Console.ReadKey();   // If the user presses a key, the bot will shut down.
            Environment.Exit(0); // Make sure all threads are closed.
        }
        static void Main(string[] args)
        {
            // First of all, a DiscordClient will be created, and the email and password will be defined.
            Console.WriteLine("Defining variables");
            // Fill in token and change isbot to true if you use the API
            // Else, leave token alone and change isbot to false
            // But believe me, the API bots are nicer because of a sexy bot tag!
            DiscordClient client = new DiscordClient("bot token", isbot);

            client.ClientPrivateInformation.Email    = "email";
            client.ClientPrivateInformation.Password = "******";

            // Then, we are going to set up our events before connecting to discord, to make sure nothing goes wrong.

            Console.WriteLine("Defining Events");
            // find that one you interested in

            client.Connected += (sender, e) => // Client is connected to Discord
            {
                Console.WriteLine("Connected! User: "******"DS_starter!", true, "https://github.com/NaamloosDT/DiscordSharp_Starter"); // This will display at "Playing: "
                //Whoops! i messed up here. (original: Bot online!\nPress any key to close this window.)
            };


            client.PrivateMessageReceived += (sender, e) => // Private message has been received
            {
                if (e.Message == "!help")
                {
                    e.Author.SendMessage("This is a private message!");
                    // Because this is a private message, the bot should send a private message back
                    // A private message does NOT have a channel
                }
                if (e.Message.StartsWith("join"))
                {
                    if (!isbot)
                    {
                        string inviteID = e.Message.Substring(e.Message.LastIndexOf('/') + 1);
                        // Thanks to LuigiFan (Developer of DiscordSharp) for this line of code!
                        client.AcceptInvite(inviteID);
                        e.Author.SendMessage("Joined your discord server!");
                        Console.WriteLine("Got join request from " + inviteID);
                    }
                    else
                    {
                        e.Author.SendMessage("Please use this url instead!" +
                                             "https://discordapp.com/oauth2/authorize?client_id=[CLIENT_ID]&scope=bot&permissions=0");
                    }
                }
            };


            client.MessageReceived += (sender, e) => // Channel message has been received
            {
                if (e.MessageText == "!admin")
                {
                    bool isadmin             = false;
                    List <DiscordRole> roles = e.Author.Roles;
                    foreach (DiscordRole role in roles)
                    {
                        if (role.Name.Contains("Administrator"))
                        {
                            isadmin = true;
                        }
                    }
                    if (isadmin)
                    {
                        e.Channel.SendMessage("Yes, you are! :D");
                    }
                    else
                    {
                        e.Channel.SendMessage("No, you aren't :c");
                    }
                }
                if (e.MessageText == "!help")
                {
                    e.Channel.SendMessage("This is a public message!");
                    // Because this is a public message,
                    // the bot should send a message to the channel the message was received.
                }
                if (e.MessageText == "!cat")
                {
                    Thread t = new Thread(new ParameterizedThreadStart(randomcat));
                    t.Start(e.Channel);
                    string s;
                    using (WebClient webclient = new WebClient())
                    {
                        s = webclient.DownloadString("http://random.cat/meow");
                        int    pFrom = s.IndexOf("\\/i\\/") + "\\/i\\/".Length;
                        int    pTo   = s.LastIndexOf("\"}");
                        string cat   = s.Substring(pFrom, pTo - pFrom);
                        webclient.DownloadFile("http://random.cat/i/" + cat, "cat.png");
                        client.AttachFile(e.Channel, "meow!", "cat.png");
                    }
                }
            };

            //  Below: some things that might be nice?

            //  This sends a message to every new channel on the server
            client.ChannelCreated += (sender, e) =>
            {
                e.ChannelCreated.SendMessage("Nice! a new channel has been created!");
            };

            //  When a user joins the server, send a message to them.
            client.UserAddedToServer += (sender, e) =>
            {
                e.AddedMember.SendMessage("Welcome to my server! rules:");
                e.AddedMember.SendMessage("1. be nice!");
                e.AddedMember.SendMessage("- Your name!");
            };

            //  Don't want messages to be removed? this piece of code will
            //  Keep messages for you. Remove if unused :)
            client.MessageDeleted += (sender, e) =>
            {
                e.Channel.SendMessage("Removing messages has been disabled on this server!");
                e.Channel.SendMessage("<@" + e.DeletedMessage.Author.ID + "> sent: " + e.DeletedMessage.Content.ToString());
            };



            // Now, try to connect to Discord.
            try{
                // Make sure that IF something goes wrong, the user will be notified.
                // The SendLoginRequest should be called after the events are defined, to prevent issues.
                Console.WriteLine("Sending login request");
                client.SendLoginRequest();
                Console.WriteLine("Connecting client in separate thread");
                // Cannot convert from 'method group' to 'ThreadStart', so i removed threading
                // Pass argument 'true' to use .Net sockets.
                client.Connect();
                // Login request, and then connect using the discordclient i just made.
                Console.WriteLine("Client connected!");
            }catch (Exception e) {
                Console.WriteLine("Something went wrong!\n" + e.Message + "\nPress any key to close this window.");
            }

            // Done! your very own Discord bot is online!


            // Now to make sure the console doesnt close:
            Console.ReadKey();   // If the user presses a key, the bot will shut down.
            Environment.Exit(0); // Make sure all threads are closed.
        }
Beispiel #17
0
        private void SetupCommands()
        {
            #region Owner only
            CommandsManager.AddCommand(new CommandStub("selfdestruct", "Shuts the bot down.", "", PermissionType.Owner, cmdArgs =>
            {
                Exit();
            }));
            CommandsManager.AddCommand(new CommandStub("joinvoice", "Joins a specified voice channel", "Arg is case insensitive voice channel name to join.", PermissionType.Owner, 1, cmdArgs =>
            {
                DiscordChannel channelToJoin = cmdArgs.Channel.parent.channels.Find(x => x.Name.ToLower() == cmdArgs.Args[0].ToLower() && x.Type == ChannelType.Voice);
                if (channelToJoin != null)
                {
                    DiscordVoiceConfig config = new DiscordVoiceConfig
                    {
                        FrameLengthMs = 20,
                        Channels      = 1,
                        OpusMode      = Discord.Audio.Opus.OpusApplication.LowLatency,
                        SendOnly      = true
                    };

                    waveFormat = new WaveFormat(48000, 16, config.Channels);

                    if (!config.SendOnly)
                    {
                        waveCallbackInfo = WaveCallbackInfo.FunctionCallback();
                        outputDevice     = new WaveOut();
                    }

                    client.ConnectToVoiceChannel(channelToJoin, config);
                }
                else
                {
                    cmdArgs.Channel.SendMessage("Couldn't find the specified channel as a voice channel!");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("disconnect", "Disconnects from voice", "", PermissionType.Owner, 1, cmdArgs =>
            {
                client.DisconnectFromVoice();
            }));
            CommandsManager.AddCommand(new CommandStub("testvoice", "Broadcasts specified file over voice.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                if (File.Exists(cmdArgs.Args[0]))
                {
                    if (client.ConnectedToVoice())
                    {
                        SendVoice(cmdArgs.Args[0]);
                    }
                    else
                    {
                        cmdArgs.Channel.SendMessage("Not connected to voice!");
                    }
                }
                else
                {
                    cmdArgs.Channel.SendMessage("Couldn't broadcast specified file! It doesn't exist!");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("statusof", "`Status` test", "", PermissionType.Owner, 1, cmdArgs =>
            {
                string id = cmdArgs.Args[0].Trim(new char[] { '<', '@', '>' });
                if (!string.IsNullOrEmpty(id))
                {
                    DiscordMember member = cmdArgs.Channel.parent.members.Find(x => x.ID == id);
                    if (member != null)
                    {
                        string msg = $"Status of `{member.Username}`\n{member.Status}";
                        if (!string.IsNullOrEmpty(member.CurrentGame))
                        {
                            msg += $"\nPlaying: *{member.CurrentGame}*";
                        }
                        cmdArgs.Channel.SendMessage(msg);
                    }
                }
            }));
            CommandsManager.AddCommand(new CommandStub("changepic", "Changes the bot's guild pic test.", "Test", PermissionType.Owner, 1, cmdArgs =>
            {
                Regex linkParser = new Regex(@"\b(?:https?://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                string rawString = $"{cmdArgs.Args[0]}";
                if (linkParser.Matches(rawString).Count > 0)
                {
                    string url = linkParser.Matches(rawString)[0].ToString();
                    using (WebClient wc = new WebClient())
                    {
                        byte[] data = wc.DownloadData(url);
                        using (MemoryStream mem = new MemoryStream(data))
                        {
                            using (var image = System.Drawing.Image.FromStream(mem))
                            {
                                client.ChangeClientAvatar(new Bitmap(image));
                            }
                        }
                    }
                }
            }));
            CommandsManager.AddCommand(new CommandStub("sendchanneltest", "`Client.SendMessageToChannel` Test", "", PermissionType.Owner, cmdArgs =>
            {
                client.SendMessageToChannel("Works!", cmdArgs.Channel);
            }));
            CommandsManager.AddCommand(new CommandStub("setplaying", "Sets the current game the bot is playing.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                client.UpdateCurrentGame(cmdArgs.Args[0]);
            }));
            CommandsManager.AddCommand(new CommandStub("join", "Joins a specified server", "", PermissionType.Owner, 1, cmdArgs =>
            {
                string substring = cmdArgs.Args[0].Substring(cmdArgs.Args[0].LastIndexOf('/') + 1);
                client.AcceptInvite(substring);
            }));
            CommandsManager.AddCommand(new CommandStub("changeprefix", "Changes the command prefix to a specified character.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    char newPrefix       = cmdArgs.Args[0][0];
                    config.CommandPrefix = newPrefix;
                    cmdArgs.Channel.SendMessage($"Command prefix changed to **{config.CommandPrefix}** successfully!");
                }
                else
                {
                    cmdArgs.Channel.SendMessage("What prefix?");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("giveperm", "Gives the perm to the specified user (bot scope)", "", PermissionType.Owner, 2, e =>
            {
                //giveperm Admin <@2309208509852>
                if (e.Args.Count > 1)
                {
                    string permString   = e.Args[0];
                    PermissionType type = PermissionType.User;
                    switch (permString.ToLower())
                    {
                    case "admin":
                        type = PermissionType.Admin;
                        break;

                    case "mod":
                        type = PermissionType.Mod;
                        break;

                    case "none":
                        type = PermissionType.None;
                        break;

                    case "user":
                        type = PermissionType.User;
                        break;
                    }
                    string id = e.Args[1].Trim(new char[] { '<', '@', '>' });
                    CommandsManager.AddPermission(id, type);
                    e.Channel.SendMessage($"Given permission {type.ToString().Substring(type.ToString().IndexOf('.') + 1)} to <@{id}>!");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("prune", "Prune test", "", PermissionType.Owner, 1, cmdArgs =>
            {
                int messageCount = 0;
                if (int.TryParse(cmdArgs.Args[0], out messageCount))
                {
                    var messagesToPrune = client.GetMessageHistory(cmdArgs.Channel, messageCount);
                    foreach (var msg in messagesToPrune)
                    {
                        client.DeleteMessage(msg);
                        Thread.Sleep(100);
                    }
                    cmdArgs.Channel.SendMessage($"Attempted pruning of {messageCount} messages.");
                }
            }));
            #endregion
            #region Admin
            CommandsManager.AddCommand(new CommandStub("eval", "Evaluates real-time C# code. Be careful with this",
                                                       "Evaluates C# code that is dynamically compiled.\n\nThe following namespaces are available for use:\n * DiscordSharp\n * System.Threading\n * DiscordSharp.Objects\n\n\nMake sure your function returns a string value.\nYou can reference the DiscordSharp client by using `discordClient`.", PermissionType.Admin, 1, e =>
            {
                string whatToEval = e.Args[0];
                if (whatToEval.StartsWith("`") && whatToEval.EndsWith("`"))
                {
                    whatToEval = whatToEval.Trim('`');
                }
                try
                {
                    var eval   = EvalProvider.CreateEvalMethod <DiscordClient, string>(whatToEval, new string[] { "DiscordSharp", "System.Threading", "DiscordSharp.Objects" }, new string[] { "DiscordSharp.dll" });
                    string res = "";
                    Thread.Sleep(1000);
                    Thread executionThread = null;
                    Task evalTask          = new Task(() =>
                    {
                        executionThread = Thread.CurrentThread;
                        if (eval != null)
                        {
                            res = eval(client);
                        }
                        else
                        {
                            string errors = "Errors While Compiling: \n";
                            if (EvalProvider.errors != null)
                            {
                                if (EvalProvider.errors.Count > 0)
                                {
                                    foreach (var error in EvalProvider.errors)
                                    {
                                        errors += $"{error.ToString()}\n\n";
                                    }
                                }
                                e.Channel.SendMessage($"```\n{errors}\n```");
                            }
                            else
                            {
                                e.Channel.SendMessage("Errors!");
                            }
                        }
                    });
                    evalTask.Start();
                    evalTask.Wait(10 * 1000);
                    if (executionThread != null)
                    {
                        executionThread.Abort();
                    }
                    if (res == null || res == "")
                    {
                        e.Channel.SendMessage("Terminated after 10 second timeout.");
                    }
                    else
                    {
                        e.Channel.SendMessage($"**Result**\n```\n{res}\n```");
                    }
                }
                catch (Exception ex)
                {
                    string errors = "Errors While Compiling: \n";
                    if (EvalProvider.errors != null)
                    {
                        if (EvalProvider.errors.Count > 0)
                        {
                            foreach (var error in EvalProvider.errors)
                            {
                                errors += $"{error.ToString()}\n\n";
                            }
                        }
                        else
                        {
                            errors += ex.Message;
                        }
                        e.Channel.SendMessage($"```\n{errors}\n```");
                    }
                    else
                    {
                        e.Channel.SendMessage("Errors!");
                    }
                }
            }));
            #endregion
            #region Anyone, but limited to server mods
            CommandsManager.AddCommand(new CommandStub("gtfo", "Makes the bot leave the server", "", PermissionType.User, cmdArgs =>
            {
                bool canExecute = false;
                foreach (var roll in cmdArgs.Author.Roles)
                {
                    if (roll.permissions.HasPermission(DiscordSpecialPermissions.ManageServer))
                    {
                        canExecute = true;
                    }
                }
                if (canExecute)
                {
                    client.LeaveServer(cmdArgs.Channel.parent);
                }
                else
                {
                    cmdArgs.Channel.SendMessage("You don't have the proper permissions to do this! You need the ManagerServer permission.");
                }
            }));
            #endregion
            #region Literally anyone
            CommandsManager.AddCommand(new CommandStub("cmdinfo", "Displays help for a command.", "Help", PermissionType.User, 2, e =>
            {
                if (!String.IsNullOrEmpty(e.Args[0]))
                {
                    ICommand stub = CommandsManager.Commands.Find(x => x.CommandName == e.Args[0]);
                    if (stub != null)
                    {
                        string msg = "**Help for " + stub.CommandName + "**";
                        msg       += $"\n{stub.Description}";
                        if (!String.IsNullOrEmpty(stub.HelpTag))
                        {
                            msg += $"\n\n{stub.HelpTag}";
                        }
                        e.Channel.SendMessage(msg);
                    }
                    else
                    {
                        e.Channel.SendMessage("What command?");
                    }
                }
                else
                {
                    e.Channel.SendMessage("What command?");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("about", "Shows bot information", "", cmdArgs =>
            {
                string message = "**About Luigibot**\n";
                message       += "Owner: " + owner.Username + "\n";
                message       += $"Library: DiscordSharp {typeof(DiscordClient).Assembly.GetName().Version.ToString()}\n";
                var uptime     = (DateTime.Now - loginDate);
                message       += $"Uptime: {uptime.Days} days, {uptime.Hours} hours, {uptime.Minutes} minutes.\n";
                message       += "Runtime: ";

                if (runningOnMono)
                {
                    message += "Mono\n";
                }
                else
                {
                    message += ".Net\n";
                }

                message      += $"OS: {osString}\n";
                long memUsage = GetMemoryUsage();
                if (memUsage > 0)
                {
                    message += "Memory Usage: " + (memUsage / 1024) / 2 + "mb\n";
                }
                message += "Commands: " + CommandsManager.Commands.Count + "\n";
                message += "Command Prefix: " + config.CommandPrefix + "\n";
                message += "Total Servers: " + client.GetServersList().Count + "\n";
                cmdArgs.Channel.SendMessage(message);
            }));
            CommandsManager.AddCommand(new CommandStub("ygo", "Retrieves information for a Yu-Gi-Oh card from the YugiohPrices database.",
                                                       "Card names are (unfortunately) case sensitive.\n\n**Valid:** Dark Magician\n**Invalid: **dark magician", PermissionType.User, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    YugiohPricesSearcher searcher = new YugiohPricesSearcher();
                    try
                    {
                        var card = searcher.GetCardByName(cmdArgs.Args[0]).Result;
                        if (card.Name != "<NULL CARD>")
                        {
                            card.CardImage.Save("ygotemp.png");
                            string message = $"**{card.Name}**";
                            if (card.Type == CardType.Monster)
                            {
                                message += $" Level: {card.Level} Attribute: {card.Attribute}\n";
                            }
                            else
                            {
                                message += "\n";
                            }
                            message += $"**Description:** {card.Description}";
                            if (card.Type == CardType.Monster)
                            {
                                message += $"\n**Type:** {card.MonsterType}\n**ATK/DEF:** {card.Attack}/{card.Defense}";
                            }

                            client.AttachFile(cmdArgs.Channel, message, "ygotemp.png");
                        }
                        else
                        {
                            cmdArgs.Channel.SendMessage("Couldn't find that specified card!");
                        }
                    }
                    catch (HttpRequestException ex)
                    {
                        cmdArgs.Channel.SendMessage("Couldn't find that specified card! (" + ex.Message + ")");
                    }
                }
            }));
            CommandsManager.AddCommand(new CommandStub("khaled", "Anotha one.", "", cmdArgs =>
            {
                if (rng == null)
                {
                    Console.WriteLine("RNG null?!");
                    rng = new Random((int)DateTime.Now.Ticks);
                }
                cmdArgs.Channel.SendMessage($"***{KhaledQuotes[rng.Next(0, KhaledQuotes.Length - 1)]}***");
            }));
            #endregion
        }