SendLoginRequest() public method

Sends a login request.
public SendLoginRequest ( ) : string
return string
Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            if (!App.ClientConfiguration.Settings.UseWindows10Notifications)
            {
                notificationIcon = new NotifyIcon();
                notificationIcon.Text = "Dissonance";
                notificationIcon.Visible = true;
                notificationIcon.Icon = CustomDiscordClient.Properties.Resources.taskbar;
                notificationIcon.BalloonTipIcon = ToolTipIcon.None;
            }

            Icon = new BitmapImage(MagicalDiscordIcon);
            //channelsList.Visibility = Visibility.Hidden;

            MainClient = new DiscordClient();
            MainClient.RequestAllUsersOnStartup = true;

            SetupEvents();

            Title = "Dissonance - Connecting..";
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

            if(MainClient.SendLoginRequest() != null)
                discordTask = Task.Run(() => MainClient.Connect());

            openServerViews = new List<ServerView>();

            SettingsGearClicked += MainWindow_SettingsGearClicked;

            SetupTheme();
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello world!");
            Console.ReadLine();

            Console.WriteLine("Running Discord bot test...");
            test = new DiscordClient();
            test.LoginInformation = new DiscordLoginInformation();
            test.LoginInformation.email[0] = "*****@*****.**";
            test.LoginInformation.password[0] = "papabear12";
            Console.WriteLine("Attempting login..");
            //Console.WriteLine("out: {0}", test.SendLoginRequest());
            try
            {
                Thread t = new Thread(InputThread);
                t.Start();
                test.MessageReceived += (sender, e) =>
                {
                    Console.WriteLine("[- Message from {0} in {1} on {2}: {3}", e.username, e.ChannelName, e.ServerName, e.message);
                    if (e.message.StartsWith("?status"))
                        test.SendMessageToChannel("I work ;)", e.ChannelName, e.ServerName);
                };
                test.SendLoginRequest();
                Thread tt = new Thread(test.ConnectAndReadMessages);
                tt.Start();
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadLine();
        }
        public MainWindow()
        {
            InitializeComponent();

            #if WIN10NOTIF
            #else
            notificationIcon = new NotifyIcon();
            notificationIcon.Text = "WPF Discord";
            notificationIcon.Visible = true;
            notificationIcon.Icon = CustomDiscordClient.Properties.Resources.taskbar;
            notificationIcon.BalloonTipIcon = ToolTipIcon.None;
            #endif

            Icon = new BitmapImage(MagicalDiscordIcon);
            //channelsList.Visibility = Visibility.Hidden;

            MainClient = new DiscordClient();
            MainClient.RequestAllUsersOnStartup = true;

            SetupEvents();

            Title = "Connecting..";
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

            if(MainClient.SendLoginRequest() != null)
                discordTask = Task.Run(() => MainClient.Connect());

            openServerViews = new List<ServerView>();

            SetupTheme();
        }
Ejemplo n.º 4
0
	static void Main(string[] args){
		DiscordClient client = new DiscordClient();
		client.ClientPrivateInformation.Email= "*****@*****.**";
		client.ClientPrivateInformation.Password="******";
		client.MessageReceived += (s,e) => {
			if(e.MessageText == "!test"){
				e.Channel.SendMessage("Ayy");
			}};
		client.SendLoginRequest();
		Thread connect = new Thread(client.Connect);
		connect.Start();
}
Ejemplo n.º 5
0
        private async Task<bool> doLoginStuff(string user, string pass)
        {
            bool returnval = false;

            await Task.Run(() =>
            {
                DiscordClient tempClient = new DiscordClient();
                tempClient.ClientPrivateInformation = new DiscordUserInformation { email = user, password = pass };
                if (tempClient.SendLoginRequest() != null)
                {
                    returnval = true;
                }
                else
                    returnval = false;
            });

            return returnval;
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            client = new DiscordClient();
            if(File.Exists("credentials.txt"))
            {
                using (StreamReader sr = new StreamReader("credentials.txt"))
                {
                    client.ClientPrivateInformation.email = sr.ReadLine();
                    client.ClientPrivateInformation.password = sr.ReadLine();
                    sr.Close();
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("Error");
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write(" Please create credentials.txt with email and password for bot.");

                Console.ReadLine();
            }

            if (client.SendLoginRequest() != null)
                ClientTask(client);

            Console.ReadLine();
        }
Ejemplo n.º 7
0
        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");
            DiscordClient client = new DiscordClient();
            client.ClientPrivateInformation.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");
            client.Connected += (sender, e) => // Client is connected to Discord
            {
                Console.WriteLine("Connected! User: "******"Bot online!"); // 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 "))
                {
                    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);
                }
            };


            client.MessageReceived += (sender, e) => // Channel message has been received
            {
                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.
                }
            };

            //  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");
                Thread connect = new Thread(client.Connect);
                connect.Start();
                 // 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.
        }