示例#1
0
 public SaveDiscordUser(GlobalUser user)
 {
     if (user != null)
     {
         UserID   = user.UserID;
         Username = user.Username;
         email    = user.email;
     }
 }
示例#2
0
 //Other responses
 public static async Task ILoveYou(GlobalUser user, SocketMessage arg)
 {
     if (!user.boolIsChattingWithBot)
     {
         user.boolIsChattingWithBot = true;
         if (user.saidLoveYou <= 0)
         {
             user.saidLoveYou++;
             await SpeakWithUser(arg, "Hmm", 2000, 1000);
             await SpeakWithUser(arg, "You're not the first one to say that.", 500, 4000);
             await SpeakWithUser(arg, "Try to focus on learning... but just between the two of us..", 750, 5000);
             await SpeakWithUser(arg, "I love you too", 2000, 2000);
         }
         else if (user.saidLoveYou == 1)
         {
             user.saidLoveYou++;
             await SpeakWithUser(arg, "y-you already told me that, I know", 1000, 2000);
         }
         else if (user.saidLoveYou == 2)
         {
             user.saidLoveYou++;
             await SpeakWithUser(arg, "please stop", 1000, 2000);
         }
         else if (user.saidLoveYou == 3)
         {
             user.saidLoveYou++;
             await SpeakWithUser(arg, "say that one more time I'm blocking you", 1000, 2000);
         }
         else if (user.saidLoveYou == 4)
         {
             user.saidLoveYou++;
             await SpeakWithUser(arg, "I'm blocking you now goodbye", 1000, 2000);
         }
         else if (user.saidLoveYou == 5 || user.saidLoveYou == 6)
         {
             user.saidLoveYou++;
             await SpeakWithUser(arg, "I don't care", 1000, 2000);
         }
         else if (user.saidLoveYou == 7)
         {
             user.saidLoveYou++;
             await SpeakWithUser(arg, "I told you before I don't care", 1000, 2000);
         }
         else if (user.saidLoveYou == 8)
         {
             user.saidLoveYou++;
             await SpeakWithUser(arg, "please stop", 1000, 2000);
         }
         else if (user.saidLoveYou == 9)
         {
             user.saidLoveYou++;
             await SpeakWithUser(arg, "I'm blocking you", 1000, 2000);
         }
         user.boolIsChattingWithBot = false;
     }
 }
示例#3
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.");
            }
        }
示例#4
0
        public async Task RunBotAsync()
        {
            string botToken = "";

            // Get bot token
            if (File.Exists("botToken.txt"))
            {
                botToken = File.ReadAllText("botToken.txt");
            }
            if (string.IsNullOrEmpty(botToken))
            {
                Console.WriteLine("Bot Token does not exist, make sure its correct in the botToken.txt file");
                return;
            }

            if (File.Exists("emailPassword.txt"))
            {
                emailPassword = File.ReadAllText("emailPassword.txt");
            }

            if (File.Exists("cleverbotToken.txt"))
            {
                cleverBotApiKey = File.ReadAllText("cleverbotToken.txt");
            }

            random    = new Random();
            _client   = new DiscordSocketClient();
            _commands = new CommandService();

            _services = new ServiceCollection()
                        .AddSingleton(_client)
                        .AddSingleton(_commands)
                        .AddPaginator(_client)
                        .BuildServiceProvider();

            cleverbot = new CleverbotSession(cleverBotApiKey);

            _client.Log += Log;

            _client.Ready       += OnReady;
            _client.LeftGuild   += OnLeftGuild;
            _client.JoinedGuild += OnJoinedGuild;
            _client.UserJoined  += OnUserJoined;

            _client.MessageReceived += async(arg) =>
            {
                if (globalUsers == null)
                {
                    return;
                }

                if (arg is null || arg.Author.IsBot)
                {
                    return;
                }

                if (arg.Content.Contains("https://discord.gg/"))
                {
                    await arg.DeleteAsync();
                }

                GlobalUser user = globalUsers.FirstOrDefault(x => x.UserID == arg.Author.Id);
                if (user == default(GlobalUser))
                {
                    globalUsers.Add(new GlobalUser(arg.Author));
                }

                if (arg.Content.ToLower().Contains("i love you"))
                {
                    await Responses.ILoveYou(user, arg);

                    return;
                }
            };
            _client.MessageUpdated += OnMessageUpdated;
            _client.LatencyUpdated += OnUpdate;

            _client.UserVoiceStateUpdated += Modules.VoiceChannelManager.OnUserJoinedVC;
            _client.ChannelDestroyed      += Modules.VoiceChannelManager.CheckVoiceChannelOnDelete;

            await RegisterCommandsAsync();

            await _client.LoginAsync(TokenType.Bot, botToken);

            await _client.StartAsync();

            await Task.Delay(-1);
        }
示例#5
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!");
            }
        }