Ejemplo n.º 1
0
        private bool HaveRole(SocketGuildUser user, ServerUserControl usercontrol)
        {
            if (usercontrol.Getcombobox() == "@everyone" || string.IsNullOrWhiteSpace(usercontrol.Getcombobox()))
            {
                return(true);
            }
            else
            {
                bool ok = false;
                foreach (SocketRole role in user.Roles)
                {
                    if (usercontrol.Getcombobox() == role.Name)
                    {
                        ok = true;
                    }
                }

                return(ok);
            }
        }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            List <ulong> discorduser = new List <ulong>();

            discorduser.Add(447041400995840000);
            foreach (UserControl us in flowLayoutPanel1.Controls)
            {
                ServerUserControl server = (ServerUserControl)us;
                if (server.Checkbox())
                {
                    SocketGuild socket = server.GetGuild();
                    IReadOnlyCollection <SocketGuildUser> users = socket.Users;
                    int    i     = 0;
                    int    count = users.Count;
                    Random rnd   = new Random();

                    if (server.Getcombobox() == "HALF-MEMBERS")
                    {
                        SocketGuildUser user = users.ElementAt(rnd.Next(0, count));

                        if (i < count / 2)
                        {
                            if (!discorduser.Contains(user.Id))
                            {
                                discorduser.Add(user.Id);
                                user.SendMessageAsync(textBox1.Text);
                                i++;
                            }
                        }
                    }
                    else
                    {
                        foreach (SocketGuildUser user in users)
                        {
                            if (server.Getcombobox() == "New-Members")
                            {
                                DateTimeOffset usertime       = (DateTimeOffset)user.JoinedAt;
                                DateTimeOffset currentime     = DateTime.Now;
                                double         differencedays = (currentime.DateTime - usertime.DateTime).TotalDays;
                                double         timeselected   = Convert.ToDouble(server.GetCombobox2());


                                if (!discorduser.Contains(user.Id))
                                {
                                    if (differencedays < timeselected)
                                    {
                                        discorduser.Add(user.Id);
                                        user.SendMessageAsync(textBox1.Text);
                                    }
                                }
                            }
                            else
                            {
                                if (!discorduser.Contains(user.Id) && HaveRole(user, server))
                                {
                                    Console.WriteLine(user.Id + " " + user.JoinedAt);
                                    discorduser.Add(user.Id);
                                    user.SendMessageAsync(textBox1.Text);
                                }
                            }
                        }
                    }
                }
                textBox1.Text = "";
            }
        }