Example #1
0
        private async Task BannedWordsDrop(SocketMessage msg)
        {
            SocketUserMessage message = msg as SocketUserMessage;
            string            msgsent = message.ToString().ToLower();
            SocketGuildUser   author  = message.Author as SocketGuildUser;
            SocketUser        user    = author as SocketUser;

            //string[] badWords = File.ReadAllLines(@"BannedWords.txt");
            if (badWords.Any(msgsent.Contains))
            {
                Console.WriteLine("Banned Phrase Detected!");
                Console.WriteLine($"User: {msg.Author.Username}");
                Console.WriteLine($"Phrase: {msg.Content}");

                //ban time constant represents 2 min, not 2 milliseconds. Make sure that the timer creation compensates
                UserAccounts.AddAccountBanCount(user);
                ulong banTimeC = 300000 + UserAccounts.GetAccountBanCount(user) * 60000;
                var   role     = author.Guild.Roles.FirstOrDefault(x => x.Name.ToString() == "Being Dropped Out of a Helicopter");
                Console.WriteLine("Dropping user...");
                await author.AddRoleAsync(role);

                await msg.Channel.SendMessageAsync("", false, Misc.CreateHeliDropEmbed(user.Username, "Helibot Automatic Detection Service", true, msg.ToString(), "Banned Word Detected", banTimeC));

                Console.WriteLine("User Dropped!");
                Console.WriteLine("Initializing AutoLanding Service");
                DropTimer Countdown = new DropTimer();
                Countdown.SetComponents(author, message, banTimeC);
                Countdown.InitTimer();
                Countdown.TimerElapsed += CountDownElapsed;
                //Countdown.ClockElapsed += CountDownClockElapsed;
                Console.WriteLine("AutoLanding Service initialized.");
            }
        }
Example #2
0
		private async Task BannedWordsDrop(SocketMessage msg)
		{
			var message = msg as SocketUserMessage;
			var author = msg.Author as SocketGuildUser;
			var user = author as SocketUser;
			string[] badWords = File.ReadAllLines(@"BannedWords.txt");
			if (badWords.Any(msg.Content.Contains))
			{
				//ban time constant represents 2 min, not 2 milliseconds. Make sure that the timer creation compensates
				ulong banTime = UserAccounts.GetAccountBanCount(user) * 2;
				var role = author.Guild.Roles.FirstOrDefault(x => x.Name.ToString() == "Being Dropped Out of a Helicopter");
				Bans.CreateUserBan(author.Id, banTime);
				Console.WriteLine("Banned word detected");
				await msg.Channel.SendMessageAsync("Dropped from the heli, f****t.");
			}
		}