public async Task CountToMessageReceived(SocketMessage msg)
        {
            if (!msg.Author.IsBot && msg.Channel is ITextChannel channel)
            {
                using var uow = _db.UnitOfWork;
                var gc = uow.GuildConfigs.For(channel.GuildId);

                if (gc.CountToNumberChannelId == channel.Id)
                {
                    var match = Regex.Match(msg.Content.Trim(), "\\A(\\d+)");

                    if (match.Success && ulong.TryParse(match.Groups[1].Value, out var currentNumber))
                    {
                        var lastMessages    = (await channel.GetMessagesAsync(10).FlattenAsync().ConfigureAwait(false)).ToList();
                        var messageIndex    = lastMessages.FindIndex(m => m.Id == msg.Id);
                        var previousMessage = lastMessages[messageIndex + 1];
                        var previousMatch   = Regex.Match(previousMessage.Content.Trim(), "\\A(\\d+)");

                        if (gc.CountToNumberDeleteWrongMessages && (previousMatch.Success && ulong.TryParse(previousMatch.Groups[1].Value, out var previousNumberParsingSuccess) && currentNumber - previousNumberParsingSuccess != 1 || previousMessage.Author.Id == msg.Author.Id))
                        {
                            await msg.DeleteAsync().ConfigureAwait(false);
                        }
                        else if (_random.NextDouble() < gc.CountToNumberMessageChance)
                        {
                            await channel.SendMessageAsync($"{currentNumber + 1}").ConfigureAwait(false);
                        }
                    }
                    else if (gc.CountToNumberDeleteWrongMessages)
                    {
                        await msg.DeleteAsync().ConfigureAwait(false);
                    }
                }
            }
        }
Exemple #2
0
        private void CensorMessage(SocketMessage msg)
        {
            if (msg.Author.Id == discord.client.CurrentUser.Id)
            {
                return;
            }
            if (DiscordHandler.UserIsAdmin(msg.Author))
            {
                return;
            }

            var guild = (msg.Channel as SocketGuildChannel).Guild;

            if (censoredUsersByGuild.TryGetValue(guild.Id, out List <ulong> bannedUsers))
            {
                if (bannedUsers.Contains(msg.Author.Id))
                {
                    msg.DeleteAsync();
                }
            }

            censoredWordsByGuild.TryGetValue(guild.Id, out List <string> bannedWords);

            foreach (string word in bannedWords)
            {
                if (msg.Content.ToLower().Contains(word))
                {
                    msg.DeleteAsync();
                    discord.SendMessageAsync(msg.Channel, $"Message removed due to censorship policy of `{guild.Name}`");
                    break;
                }
            }
        }
Exemple #3
0
        public static async Task <bool> DeleteStupidEmojis(SocketMessage message)
        {
            if (containsEmoji(message))
            {
                nlog.Info($"{message.Author} : {message.Content} ");
                IMessage lastmessage = await LastMessage(message.Channel, message.Author);

                DateTime?currentMessage  = message.CreatedAt.UtcDateTime;
                DateTime?previousMessage = lastmessage.CreatedAt.UtcDateTime;
                if (previousMessage == null)
                {
                    nlog.Info($"{message.Author} no previous messages. Deleting");

                    await message.DeleteAsync();

                    return(true);
                }
                if (!emojiFreeInterval(currentMessage, previousMessage, TimeSpan.FromSeconds(5)))
                {
                    nlog.Info($"{message.Author} posted with no message.");
                    await message.DeleteAsync();
                    await CreateReactions(lastmessage);

                    return(true);
                }
            }
            return(false);
        }
Exemple #4
0
        private async Task MessageReceivedAsync(SocketMessage arg)
        {
            foreach (var word in Words.FilteredWords)
            {
                if (arg.Content.ToLower().Contains(word))
                {
                    if (Utilities.HasRoles(arg.Author as SocketGuildUser, new List <string> {
                        "Admin", "Founder"
                    }))
                    {
                        break;
                    }
                    await arg.DeleteAsync();
                }
            }

            foreach (var attachment in arg.Attachments)
            {
                var url = new Uri($"http://api.rest7.com/v1/detect_nudity.php?url={attachment.Url}");
                using (var client = new WebClient())
                {
                    var data = JsonConvert.DeserializeObject <API>(client.DownloadString(url));
                    if (data.nudity)
                    {
                        await arg.DeleteAsync();

                        break;
                    }
                }
            }
        }
Exemple #5
0
        //Grant a user a role if they type the password in the verification channel
        public static async Task VerificationCheck(SocketMessage message)
        {
            var user  = (IGuildUser)message.Author;
            var guild = user.Guild;

            if (Setup.IsVerificationChannel((IGuildChannel)message.Channel))
            {
                if (message.Content.ToLower() == UserSettings.Verification.VerificationMessage(guild.Id).ToLower())
                {
                    await message.DeleteAsync();

                    ulong memberRoleId = UserSettings.Verification.MemberRoleID(guild.Id);
                    if (memberRoleId != 0)
                    {
                        var memberRole = user.Guild.GetRole(memberRoleId);
                        await user.AddRoleAsync(memberRole);

                        var embed  = Embeds.LogMemberAdd(user);
                        var user2  = (SocketGuildUser)user;
                        var botlog = (ITextChannel)user2.Guild.GetChannel(UserSettings.Channels.BotLogsId(user.Guild.Id));
                        await botlog.SendMessageAsync("", embed : embed).ConfigureAwait(false);
                    }
                    else
                    {
                        await message.Channel.SendMessageAsync("Attempted to give the new member a role, but it has to be configured first!");
                    }
                }
                else
                {
                    await message.DeleteAsync();
                }
            }
        }
Exemple #6
0
        public async Task OnText(SocketMessage message)
        {
            var txt     = message.Content.Trim().ToLower();
            var cleaned = "";

            foreach (var c in txt)
            {
                if (char.IsLower(c) && char.IsLetter(c))
                {
                    cleaned += c;
                }
            }

            if (cleaned != txt ||
                !stringSet.Contains(cleaned) ||
                string.IsNullOrEmpty(cleaned))
            {
                await message.DeleteAsync();

                return;
            }

            if (!previousString.EndsWith(cleaned[0]) && previousString != "")
            {
                await message.DeleteAsync();

                return;
            }

            previousString  = cleaned;
            previousMessage = message.Id;
            stringSet.Remove(cleaned);
        }
Exemple #7
0
        public async Task MessageReceivedAsync(SocketMessage rawMessage)
        {
            // Ignore system messages, or messages from other bots
            if (!(rawMessage is SocketUserMessage message))
            {
                return;
            }
            if (message.Source != MessageSource.User)
            {
                return;
            }
            var context = new SocketCommandContext(_discord, message);


            //Save Game Importing
            if (message.Attachments.Count == 1) //The message contains an attachment.
            {
                if (IsEventActive())
                {         //An event is active.
                    if (EventModule.IsParticipantRegistered(message.Author.Id))
                    {     //Check to see if the user is registered.
                        if (rawMessage.Attachments.FirstOrDefault <Attachment>().Filename.ToUpper().Contains("SA1"))
                        { //The message contains a save file. Download and process it.
                            string url            = rawMessage.Attachments.FirstOrDefault <Attachment>().Url;
                            string CacheDirectory = $"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Cache{Path.DirectorySeparatorChar}";
                            var    Client         = new WebClient();
                            Client.DownloadFile(new Uri(url), $"{CacheDirectory}{rawMessage.Author.Id}{rawMessage.Attachments.FirstOrDefault<Attachment>().Filename}");
                            Tools.BN6.SaveTool.ProcessSave($"{CacheDirectory}{rawMessage.Author.Id}{rawMessage.Attachments.FirstOrDefault<Attachment>().Filename}", rawMessage.Author.Id, EventModule.GetParticipant(rawMessage.Author).NetbattlerName);
                            EventModule.MarkAsSubmitted(rawMessage.Author);
                            await rawMessage.DeleteAsync();

                            await context.Channel.SendMessageAsync("Save file accepted.");
                        }
                        else if (rawMessage.Attachments.FirstOrDefault <Attachment>().Filename.ToUpper().Contains("SAV") || rawMessage.Attachments.FirstOrDefault <Attachment>().Filename.ToUpper().Contains(".SG"))
                        {
                            await rawMessage.DeleteAsync();

                            await context.Channel.SendMessageAsync("", false, EmbedTool.CommandError("I can only accept Save Files that are *.SA1 format. Please upload the correct save file."));
                        }
                    }
                }
            }


            // This value holds the offset where the prefix ends
            var argPos = 0;

            if (!(message.HasMentionPrefix(_discord.CurrentUser, ref argPos) || message.HasStringPrefix("!", ref argPos)))
            {
                return;
            }

            var result = await _commands.ExecuteAsync(context, argPos, _services);

            if (result.IsSuccess == false)
            {
                //The command failed?
            }
        }
Exemple #8
0
        public static async Task MemesChannel(SocketMessage msg)
        {
            if (msg.Channel is IPrivateChannel)
            {
                return;
            }

            var channel      = msg.Channel as IGuildChannel;
            var Guild        = channel.Guild as SocketGuild;
            var GuildAccount = GuildAccounts.GetAccount(Guild);

            ulong MemesChannelID = GuildAccount.MemesChannelID;

            if (msg.Channel.Id == MemesChannelID)
            {
                if (msg.Author.IsBot)
                {
                    return;
                }

                var MemesChannel = Guild.GetChannel(MemesChannelID) as IMessageChannel;

                if (!msg.Attachments.Any())
                {
                    await msg.DeleteAsync();

                    var InfoMsg = await MemesChannel.SendMessageAsync($"{Messages.wrong} Na tym kanale można wysyłać tylko obrazki.");

                    await Helpers.RemoveMessage(InfoMsg);
                }
                else
                {
                    var attachments = msg.Attachments;
                    foreach (var attachment in attachments)
                    {
                        if (attachment.Filename.EndsWith(".jpg") || attachment.Filename.EndsWith(".jpeg") || attachment.Filename.EndsWith(".png") || attachment.Filename.EndsWith(".gif") || attachment.Filename.EndsWith(".bmp"))
                        {
                            var like        = new Emoji("👍");
                            var dislike     = new Emoji("👎");
                            var MemeMessage = msg as IUserMessage;
                            await MemeMessage.AddReactionAsync(like);

                            await MemeMessage.AddReactionAsync(dislike);
                        }
                        else
                        {
                            await msg.DeleteAsync();

                            var InfoMsg = await MemesChannel.SendMessageAsync($"{Messages.wrong} Na tym kanale nie można wysyłać innych plików niż obrazki.");

                            await Helpers.RemoveMessage(InfoMsg);
                        }
                    }
                }
            }
        }
        public async Task MessageRecieved(SocketMessage rawMessage)
        {
            if (rawMessage == null)
            {
                throw new ArgumentNullException(nameof(rawMessage));
            }

            SaveAttachments(rawMessage);

            if (!(rawMessage.Channel is SocketGuildChannel channel))
            {
                return;
            }

            if (_db.Guilds.All(g => g.Id != channel.Guild.Id))
            {
                return;
            }
            var guildConfig = _db.Guilds.Single(g => g.Id == channel.Guild.Id);

            // Keep the welcome channel clean.
            if (rawMessage.Channel.Id == guildConfig.WelcomeChannel)
            {
                var guild  = channel.Guild;
                var prefix = guildConfig.Prefix == ' ' ? _db.Config.Prefix : guildConfig.Prefix;
                if (!guild.GetUser(rawMessage.Author.Id).GetPermissions(channel).ManageMessages)
                {
                    if (!rawMessage.Content.StartsWith($"{prefix}i") && !rawMessage.Content.ToLower().StartsWith("i") && !rawMessage.Content.StartsWith($"{prefix}agree") && !rawMessage.Content.StartsWith($"agree"))
                    {
                        try
                        {
                            await rawMessage.DeleteAsync();
                        }
                        catch (HttpException) { }
                    }
                    else
                    {
                        try
                        {
                            await Task.Delay(10000);

                            await rawMessage.DeleteAsync();
                        }
                        catch (HttpException) { }
                    }
                }
            }

            if (!rawMessage.Content.StartsWith("~report"))
            {
                await ProcessAttachments(rawMessage, channel);
            }
            await CheckTextBlacklist(rawMessage, guildConfig);
        }
Exemple #10
0
        private async Task MessageRecieved(SocketMessage message)
        {
            var channel = message.Channel;

            if (message.Content.Contains("gay") || message.Content.Contains("bitch") || message.Content.Contains("Bitch") || message.Content.Contains("F**k"))
            {
                await channel.SendMessageAsync($"Swearing is not allowed here, {message.Author.Mention}");

                await message.DeleteAsync();
            }
            if (message.Content.Contains("n***a") || message.Content.Contains("nigger"))
            {
                await channel.SendMessageAsync($"Racism is not allowed here, {message.Author.Mention}");

                await message.DeleteAsync();
            }
            if (message.Content.Contains("how are you all") || message.Content.Contains("How Are You All") || message.Content.Contains("How are you all") || message.Content.Contains("how are yall") || message.Content.Contains("How are yall") || message.Content.Contains("How Are Yall"))
            {
                await channel.SendMessageAsync($"We are fine, {message.Author.Mention}, thanks!");
            }
            if (message.Content == "hi" || message.Content == "hello" || message.Content == "yo" || message.Content.Contains("hi ") || message.Content.Contains("Hi") || message.Content.Contains("Hey") || message.Content.Contains("Yo") || message.Content.Contains("yo ") || message.Content.Contains("Hello") || message.Content.Contains("hello "))
            {
                if (!message.Author.IsBot)
                {
                    int rand = rnd.Next(5);
                    if (rand == 0)
                    {
                        await channel.SendMessageAsync($"Hi there, {message.Author.Mention}!");
                    }
                    if (rand == 1)
                    {
                        await channel.SendMessageAsync($"Yo, {message.Author.Mention}!");
                    }
                    if (rand == 2)
                    {
                        await channel.SendMessageAsync($"Hey, {message.Author.Mention}!");
                    }
                    if (rand == 3)
                    {
                        await channel.SendMessageAsync($"Hola, {message.Author.Mention}!");
                    }
                    if (rand == 4)
                    {
                        await channel.SendMessageAsync($"Hello, {message.Author.Mention}!");
                    }
                    if (rand == 5)
                    {
                        await channel.SendMessageAsync($"Hi, {message.Author.Mention}!");
                    }
                }
            }
        }
Exemple #11
0
        private async Task HandleCommandAsync(SocketMessage arg)
        {
            var message = arg as SocketUserMessage;

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

            if (message.Content == ".acro")
            {
                if (IsAcroRunning((message.Author as SocketGuildUser).Guild))
                {
                    await(arg.Channel as ISocketMessageChannel).SendMessageAsync("acro already running!!!");
                    return;
                }
                Logger.Info("Acro initiated (" + (message.Author as SocketGuildUser).Guild.Name + ")");


                Acro instance = new Acro((arg.Channel as SocketGuildChannel).Guild, (arg.Channel as SocketChannel));

                acroInstances.Add(instance);
                instance.StartSubmissionTimer();
                //instance.SubmissionTimerElapsed += Instance_SubmissionTimerElapsed;
                instance.VoteTimerElapsed += Instance_VoteTimerElapsed;
            }
            //controllo se il messaggio è una potenziale acro submission per questo server o un voto
            else if (acroInstances.Count > 0)
            {
                for (int i = 0; i < acroInstances.Count; i++)
                {
                    if (acroInstances[i].GetChannel().Id == message.Channel.Id)
                    {
                        if (!acroInstances[i].IsVoteTimerEnabled() && acroInstances[i].IsSubmissionTimerEnabled() && acroInstances[i].RegisterSubmission(arg.Content, arg.Author))
                        {
                            Logger.Info(arg.Author + " submitted");
                            await arg.DeleteAsync();
                        }
                        else if (!acroInstances[i].IsSubmissionTimerEnabled() && acroInstances[i].RegisterVote(arg.Content, arg.Author))
                        {
                            Logger.Info(arg.Author + " voted");
                            await arg.DeleteAsync();
                        }
                        else
                        {
                        }
                    }
                }
            }
        }
Exemple #12
0
        public static async Task CheckMessage(SocketMessage message)
        {
            var chnl  = message.Channel as SocketGuildChannel;
            var Guild = chnl.Guild;

            if (Guild != null && Directory.Exists("/home/bob_the_daniel/Data/" + Guild.OwnerId) && !Utilities.HasAdmin(message.Author as SocketGuildUser))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.NullValueHandling = NullValueHandling.Ignore;
                List <BadWord> badWords;

                using (StreamReader sr = new StreamReader(@"/home/bob_the_daniel/Data/" + Guild.OwnerId + "/badwords.json"))
                    using (JsonTextReader reader = new JsonTextReader(sr)) {
                        badWords = serializer.Deserialize <List <BadWord> >(reader);
                    }

                if (message.Content.Contains("discord.gg/"))
                {
                    if (!SettingFunctions.LoadModSettings(Guild).invitesAllowed)
                    {
                        ModerationFunctions.WarnUser(message.Author, 0.5f, "Posted Invite", Guild.OwnerId + "/Infractions/Discord/" + message.Author.Id);
                        await message.Channel.SendMessageAsync("warned " + message.Author.Mention + " for posting a discord invite");

                        Logging.LogDeleted("Bad word removed", message, Guild);
                        await message.DeleteAsync();

                        return;
                    }
                }

                //Guild.OwnerId
                if (File.Exists("/home/bob_the_daniel/Data/" + Guild.OwnerId + "/badwords.json"))
                {
                    foreach (BadWord badWord in badWords)
                    {
                        if (message.Content.Contains(badWord.word))
                        {
                            ModerationFunctions.WarnUser(message.Author, 0.5f, "Bad word", Guild.OwnerId + "/Infractions/Discord/" + message.Author.Id);
                            await message.Channel.SendMessageAsync("warned " + message.Author.Mention + " for bad word");

                            Logging.LogDeleted("Bad word removed", message, Guild);
                            await message.DeleteAsync();

                            return;
                        }
                    }
                }
            }
        }
Exemple #13
0
        private async Task HandleTimeoutUser(SocketMessage message)
        {
            await message.DeleteAsync();

            int timeRemaining = Timewatch.GetRemainingTime(_timedOutUsers[message.Author]);
            await message.Author.SendMessageAsync(string.Format("You're on a timeout for {0} more seconds.", timeRemaining));
        }
Exemple #14
0
        private async Task HandleAdminCommand(SocketMessage messageParam)
        {
            if (!(messageParam is SocketUserMessage message))
            {
                return;
            }
            int argPos = 0;

            if (!message.HasCharPrefix('&', ref argPos))
            {
                return;
            }
            var context = new CommandContext(Client, message);
            var result  = await AdminCommands.ExecuteAsync(context, argPos, Services);

            if (!result.IsSuccess)
            {
                await messageParam.DeleteAsync();

                var reply = await context.Channel.SendMessageAsync("Error: " + result.ErrorReason);

                await Task.Delay(Commands.UserCommands.Delay);

                await reply.DeleteAsync();
            }
        }
Exemple #15
0
        private async Task ClearMessageAsync(SocketMessage socketMessage)
        {
            var message = socketMessage as SocketUserMessage;

            if (message == null)
            {
                return;
            }

            if (message.Content.StartsWith("!"))
            {
                await message.DeleteAsync();
            }

            if (message.Author.Username == "Rythm")
            {
                await _client.GetGuild(152690567720075264).GetTextChannel(404659774043717632).SendMessageAsync($"{message.Content}");

                await message.DeleteAsync();

                await socketMessage.DeleteAsync();
            }

            await Task.CompletedTask;
        }
Exemple #16
0
        private async Task MessageReceivedAsync(SocketMessage message)
        {
            if (message.Author.Id == _client.CurrentUser.Id)
            {
                return;
            }

            switch (message.Content.ToLower())
            {
            case "!vanguard":
                AssignRole(message, "Vanguard");
                break;

            case "!operations":
                AssignRole(message, "Operations");
                break;

            case "!exile":
                AssignRole(message, "Exile");
                break;

            case "!antistasi":
                AssignRole(message, "Antistasi");
                break;

            default:
                if (message.Channel.Name == "tags")
                {
                    await message.DeleteAsync();
                }

                break;
            }
        }
Exemple #17
0
        private static async void AssignRole(SocketMessage message, string roleName)
        {
            var guildUser = message.Author as SocketGuildUser;
            var guildRole = guildUser?.Guild.Roles.First(role => role.Name == roleName);

            if (guildRole == null)
            {
                return;
            }

            //Remove role
            if (guildUser.Roles.Any(role => role.Name == guildRole.Name))
            {
                await guildUser.RemoveRoleAsync(guildRole);

                guildUser.SendMessageAsync($"Role {guildRole.Name} removed!");
            }
            //Add role
            else
            {
                await guildUser.AddRoleAsync(guildRole);

                guildUser.SendMessageAsync($"Role {guildRole.Name} added!");
            }

            message.DeleteAsync();
        }
        private static async Task OnMessageReceived(SocketMessage message)
        {
            if (Regex.IsMatch(message.Content, @"discord(?:\.gg|app\.com\/invite)\/([\w\-]+)") && message.Channel.Id != Global.Channels["referralcodes"] && !message.Content.Contains("discord.gg/oneplus"))
            {
                await message.DeleteAsync();
            }

            var channelId = message.Channel.Id;

            if (channelId == Global.Channels["setups"])
            {
                await ValidateSetupsMessage(message);
            }
            else if (channelId == Global.Channels["info"])
            {
                if (message.Embeds.Count == 1)
                {
                    var userMessage = (IUserMessage)message;
                    await RoleReact(userMessage);
                }
            }
            else if (channelId == Global.Channels["referralcodes"])
            {
                if (message.Author.IsBot)
                {
                    return;
                }

                await HandleReferralMessage(message);
            }
        }
Exemple #19
0
        private async Task CensorMessages(SocketMessage msg)
        {
            if (_config.BadWordChannelWhitelist.Contains(msg.Channel.Id))
            {
                return;
            }

            var user = msg.Author as SocketGuildUser;

            if (user == null)
            {
                return;
            }

            if (user.IsWebhook || user.IsBot || _config.IsExempt(user))
            {
                return;
            }

            if (!msg.Embeds.Any() && StringContainsWord(msg.Content))
            {
                try { await msg.DeleteAsync(); }
                // TODO: This error is thrown when a message contains multiple banned words
                catch (HttpException) { }
            }
        }
Exemple #20
0
        private async Task <Task> BadWordsWarn(SocketMessage msg)
        {
            ulong id = 696018470197788715;
            var   IMessageChannel = _client.GetChannel(id) as IMessageChannel;

            string[] badWords = File.ReadAllLines(@"bad-words.txt");
            foreach (string badWord in badWords)
            {
                if (msg.Content.Replace(" ", "").ToLower().Contains(badWord.Replace(" ", "")))
                {
                    var builder = new EmbedBuilder()
                    {
                        Color       = new Color(0, 255, 0),
                        Description = $"```This message was removed due to foul language: '{msg}' because of the word: '{badWord}'```",
                        Title       = $"Message Deleted from {msg.Author}",
                    };

                    await msg.DeleteAsync();

                    await IMessageChannel.SendMessageAsync("", false, builder.Build());

                    return(Task.CompletedTask);
                }
            }
            return(Task.CompletedTask);
        }
Exemple #21
0
        public static async Task CountingChannel(SocketMessage msg)
        {
            if (msg.Channel is IPrivateChannel)
            {
                return;
            }

            var channel      = msg.Channel as IGuildChannel;
            var Guild        = channel.Guild as SocketGuild;
            var GuildAccount = GuildAccounts.GetAccount(Guild);

            ulong CountingChannelID = GuildAccount.CountingChannelID;

            if (msg.Channel.Id == CountingChannelID)
            {
                if (msg.Author.IsBot)
                {
                    return;
                }

                var CountingChannel = Guild.GetChannel(CountingChannelID) as IMessageChannel;

                if (!msg.Content.Any(Char.IsDigit))
                {
                    await msg.DeleteAsync();

                    var InfoMsg = await CountingChannel.SendMessageAsync("Na tym kanale można wysyłać tylko liczby.");

                    await Helpers.RemoveMessage(InfoMsg);
                }
            }
        }
Exemple #22
0
		/// <summary>
		/// No.
		/// </summary>
		/// <param name="message"></param>
		/// <returns></returns>
		private Task VB(SocketMessage message)
		{
			_dataServices.ChannelLog($"{message.Author} posted about Velocity Brawl #{message.Channel}. You should go kill them.");
			message.DeleteAsync(); //Delete their message about shit game
			var authBuilder = new EmbedAuthorBuilder()
			{
				Name = $"Hey there {message.Author.Username}!",
				IconUrl = message.Author.GetAvatarUrl(),
			};

			var builder = new EmbedBuilder()
			{
				Author = authBuilder,

				Title = $"Please no...",
				//ThumbnailUrl = "https://www.tophattwaffle.com/wp-content/uploads/2017/11/1024_png-300x300.png",
				Color = new Color(243, 128, 72),

				Description = $"I saw you posted about Velocity Brawl. How about we do not do that."
			};

			message.Channel.SendMessageAsync("", false, builder);

			return Task.CompletedTask;
		}
Exemple #23
0
        public async Task CheckForSuggestionChannel(SocketMessage msg)
        {
            if (msg.Author.IsBot || msg.Channel.GetType() == typeof(SocketDMChannel) || Global.DevUIDs.Contains(msg.Author.Id))
            {
                return;
            }

            SocketGuildUser user = (SocketGuildUser)msg.Author;

            if (user.GuildPermissions.ManageMessages)
            {
                return;
            }

            SocketGuildChannel channel = (SocketGuildChannel)msg.Channel;
            ulong        _id           = channel.Guild.Id;
            BsonDocument item          = await collection.Find(Builders <BsonDocument> .Filter.Eq("_id", _id)).FirstOrDefaultAsync();

            string itemVal = item?.GetValue("suggestionschannel").ToString();

            if (itemVal != null)
            {
                if (itemVal == msg.Channel.Id.ToString())
                {
                    await msg.DeleteAsync();

                    RestUserMessage message = await msg.Channel.SendMessageAsync("", false, Global.EmbedMessage("Error", $" {msg.Author.Mention} You can't send messages here unless you're " +
                                                                                                                $"executing the {await Global.DeterminePrefix(new ShardedCommandContext(_client, msg as SocketUserMessage))}suggest command.", false, Discord.Color.Red).Build());

                    await Task.Delay(5000);

                    await message.DeleteAsync();
                }
            }
        }
Exemple #24
0
        private async Task _client_MessageReceived_Slowmode(SocketMessage m)
        {
            if (m.Author.Id == _client.CurrentUser.Id)
            {
                return;                                        // Ignore messages from the bot itself
            }
            if (!(m.Author is SocketGuildUser author))
            {
                return;                                        // Ignore messages that do not come from a guild
            }
            if (author.Roles.Select(r => r.Id).Any(x => _config.BypassIds.Contains(x)))
            {
                return;                                                                         // Ignore messages from privileged users
            }
            var channel = m.Channel as SocketTextChannel;

            if (!Intervals.ContainsKey(channel))
            {
                return;                                  // Ignore channels for which slowmode is not enabled
            }
            var interval = Intervals[channel];

            if (!_lastMessage.ContainsKey(author.Id))
            {
                var dictionary = new Dictionary <SocketTextChannel, DateTime>();
                dictionary.Add(channel, DateTime.UtcNow);
                _lastMessage.Add(author.Id, dictionary);
            }
            else
            {
                if (DateTime.UtcNow.Subtract(_lastMessage[author.Id][channel]).TotalSeconds >= Intervals[channel]) // If the user's message was sent after the interval was up
                {
                    _lastMessage[author.Id][channel] = DateTime.UtcNow;
                }
                else
                {
                    // Delete message and mute user
                    await m.DeleteAsync();

                    var muteRole = author.Guild.GetRole(_config.MuteRoleId);
                    await author.AddRoleAsync(muteRole);

                    // author.Guild.Id, author.Id, 0, DateTime.UtcNow, DateTime.UtcNow.Add(MuteTime), "N/A (SLOWMODE AUTO-MUTE)"
                    var mute = await _records.AddMuteAsync(new Mute
                    {
                        GuildId     = author.Guild.Id,
                        SubjectId   = author.Id,
                        ModeratorId = 0,
                        Timestamp   = DateTime.UtcNow,
                        UnmuteAt    = DateTime.UtcNow.Add(MuteTime),
                        Reason      = "N/A (SLOWMODE AUTO-MUTE)",
                        Active      = true
                    });

                    _unpunish.Mutes.Add(mute);
                    _records.DisposeContext();
                    await _log.LogModMessageAsync($"Automatically muted {author.Nickname ?? author.Username}#{author.Discriminator} ({author.Id})'s message in {channel.Mention} for {MuteTime.Humanize(5)} for violating slowmode: `{m.Content}`");
                }
            }
        }
Exemple #25
0
 public async Task OnUserMessageAsync(SocketMessage message, bool privateChannel)
 {
     try
     {
         var result = Garden.TreeCodeMatcher.Match(message.Content);
         if (privateChannel)
         {
             if (!result.Success || string.IsNullOrEmpty(result.Value))
             {
                 message.Author.SendMessageAsync("**Please double check your Tree Code!**").Forget();
             }
             else
             {
                 await RegisterUser(message.Author, result.Value);
             }
         }
         else
         {
             if (result.Success && !string.IsNullOrEmpty(result.Value))
             {
                 await message.DeleteAsync();
                 await RegisterUser(message.Author, result.Value);
             }
         }
     }
     catch
     {
     }
 }
Exemple #26
0
        public async Task MessageReceived(SocketMessage message)
        {
            if (!message.Author.IsBot)
            {
                var hasDoggo = false;

                foreach (var attachment in message.Attachments)
                {
                    hasDoggo = await HasDoggo(attachment.Url);
                }

                foreach (var embed in message.Embeds)
                {
                    hasDoggo = await HasDoggo(embed.Url);
                }

                if (message.Attachments.Any() || message.Embeds.Any())
                {
                    if (hasDoggo)
                    {
                        await message.Channel.SendMessageAsync("Doggo Image Removed!");

                        await message.DeleteAsync(new RequestOptions { AuditLogReason = "Doggo Image" });
                    }
                }
            }
        }
Exemple #27
0
        private async Task HandleMessageAsync(SocketMessage messageParam)
        {
            if (!(messageParam is SocketUserMessage))
            {
                m_logger.LogWarning("Received a message that wasn't a SocketUserMessage");
            }
            if ((messageParam.Author as SocketGuildUser)?.GuildPermissions.Administrator ?? false)
            {
                m_logger.LogInfo($"The message was sent by an administrator, ignoring.");
                return;
            }
            var message = messageParam as SocketUserMessage;

            string letterOnlyMessage = new string(message.Content.Where(c => char.IsLetter(c) || char.IsWhiteSpace(c)).ToArray());

            if (m_config.Configuration.BlacklistedWord.Any(s => letterOnlyMessage.Contains(s, StringComparison.OrdinalIgnoreCase)))
            {
                m_logger.LogInfo($"Deleting bad message");
                await messageParam.DeleteAsync();

                await messageParam.Channel.SendMessageAsync($"{messageParam.Author.Mention}, I have deleted your message because it contained a bad word");

                m_logger.LogInfo($"Deleted {messageParam.Author} message");
            }
        }
Exemple #28
0
        /// <summary>
        /// No.
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        private async Task VB(SocketMessage message)
        {
            await message.DeleteAsync(); //Delete their message about shit game

            var authBuilder = new EmbedAuthorBuilder()
            {
                Name    = $"Hey there {message.Author.Username}!",
                IconUrl = message.Author.GetAvatarUrl(),
            };

            var builder = new EmbedBuilder()
            {
                Author = authBuilder,

                Title = $"Please no...",
                //ThumbnailUrl = "https://www.tophattwaffle.com/wp-content/uploads/2017/11/1024_png-300x300.png",
                Color = new Color(243, 128, 72),

                Description = $"I saw you posted about Velocity Brawl. How about we do not do that."
            };

            await message.Channel.SendMessageAsync("", false, builder);

            await DataBaseUtil.AddShitpostAsync("VB", message);
        }
Exemple #29
0
 public async Task SnippetHandler(SocketMessage arg)
 {
     if (!CurrentTickets.Any(x => x.TicketChannel == arg.Channel.Id))
         return;
     var ticket = CurrentTickets.Find(x => x.TicketChannel == arg.Channel.Id);
     if (!arg.Content.StartsWith('!') && !arg.Content.Contains(' '))
         return;
     if (arg.Content == "!snippets")
         return;
     
     string snipname = arg.Content;
    
     if (Snippets.ContainsKey(snipname))
     {
         var dmchan = await client.GetUser(ticket.UserID).GetOrCreateDMChannelAsync();
         string snipval = Snippets[snipname];
         await arg.DeleteAsync();
         ticket.Transcript.AddMessage(snipval, arg.Author, arg.Id, arg.Timestamp);
         await dmchan.SendMessageAsync($"**[Staff] {arg.Author.ToString()}** - {snipval}");
         await arg.Channel.SendMessageAsync($"**[Staff] {arg.Author.ToString()}** - {snipval}");
     }
     else
     {
         //await arg.Channel.SendMessageAsync("", false, new EmbedBuilder()
         //{
         //    Title = "Invalid snippet!",
         //    Description = $"Looks like the snippet \"{arg.Content}\" Doesn't exist! For a list of snippets, do `!snippets`",
         //    Color = Color.Red
         //}.Build());
     }
 }
Exemple #30
0
        private async Task HandleCommandAsync(SocketMessage arg)
        {
            var message = arg as SocketUserMessage;

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

            int argPos = 0;

            if (message.HasStringPrefix("&", ref argPos) || message.HasMentionPrefix(_client.CurrentUser, ref argPos))
            {
                var context = new SocketCommandContext(_client, message);

                var result = await _commands.ExecuteAsync(context, argPos, _services);

                if (!result.IsSuccess)
                {
                    Console.WriteLine(result.ErrorReason);
                }

                await Task.Delay(1500);

                await arg.DeleteAsync();
            }
        }