Exemplo n.º 1
0
        public static async Task SendReward(GlobalUser user, LootItem item, SocketTextChannel channel)
        {
            if (string.IsNullOrEmpty(user.email))
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp-mail.outlook.com");

                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(user.email);
                mail.Subject = "Winning Item: " + item.Name;
                mail.Body    = "You have won the item from the lottery \\o/, and the item is: " + item.Name + "! " + item.Description + "\nThe link for getting the reward is here: " + item.url;

                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", Program.emailPassword);
                SmtpServer.EnableSsl   = true;

                SmtpServer.Send(mail);
            }
            else
            {
                await channel.SendMessageAsync(user.Username + " dont have an email address registered. Just PM me your email.");
            }
        }
Exemplo n.º 2
0
        public async Task StartSlotting(float betPoints)
        {
            DiscordServer server = DiscordServer.GetServerFromID(Context.Guild.Id);

            if (server == null)
            {
                return;
            }

            ServerUser user = server.Users.Find(x => x.userID == Context.User.Id);

            if (user == null)
            {
                return;
            }

            if (user.Points < betPoints)
            {
                await ReplyAsync("You dont have enough points to bet: " + betPoints + "! (" + user.Points + ")");

                return;
            }
            user.Points -= betPoints;

            int[]         one          = int3();
            int[]         two          = int3();
            int[]         three        = int3();
            List <string> selectedRoll = new List <string>()
            {
                rolls[one[0]],
                rolls[two[0]],
                rolls[three[0]],

                rolls[one[1]],
                rolls[two[1]],
                rolls[three[1]],

                rolls[one[2]],
                rolls[two[2]],
                rolls[three[2]]
            };
            bool won = false;

            if (selectedRoll[0] == selectedRoll[1] && selectedRoll[0] == selectedRoll[2])
            {
                won = true;
            }
            else if (selectedRoll[3] == selectedRoll[4] && selectedRoll[3] == selectedRoll[5])
            {
                won = true;
            }
            else if (selectedRoll[6] == selectedRoll[7] && selectedRoll[6] == selectedRoll[8])
            {
                won = true;
            }

            LootItem wonItem = null;

            if (server.lootItems.Count > 0)
            {
                wonItem = server.lootItems[Program.random.Next(0, server.lootItems.Count)];
            }

            Embed newEmbed = new EmbedBuilder()
                             .WithTitle("Slot Machine")
                             .WithColor(Program.embedColor)
                             .WithTimestamp(DateTimeOffset.Now)
                             .WithFooter(footer => {
                footer
                .WithText("Slot Machine");
            })
                             .AddField("D-did you win?",
                                       selectedRoll[0] + " | " + selectedRoll[1] + " | " + selectedRoll[2] + "\n"
                                       + selectedRoll[3] + "  | " + selectedRoll[4] + "  | " + selectedRoll[5] + "\n"
                                       + selectedRoll[6] + "  | " + selectedRoll[7] + "  | " + selectedRoll[8] + "")
                             .AddField("Results:", "Betting: " + betPoints + " Points.\n" +
                                       (won ? "Won: " + (server.lootItems != null || server.lootItems.Count > 0 ? wonItem.Name : "Nothing") : "Lost: " + betPoints + " Points.")).Build();

            await ReplyAsync("", false, newEmbed);

            GlobalUser gUser = Program.globalUsers.Find(x => x.UserID == Context.User.Id);

            if (won && server.lootItems.Count > 0)
            {
                if (gUser != null)
                {
                    await Rewards.SendReward(gUser, wonItem, (SocketTextChannel)Context.Channel);
                }
            }

            if (string.IsNullOrEmpty(gUser?.email) && won)
            {
                await ReplyAsync("We reccomend you to register your email so we can send you the rewards. PM " + Program._client.CurrentUser.Mention + " your email!");
            }
        }