Exemplo n.º 1
0
        public async Task Info()
        {
            var   _client = Context.Client;
            ulong ID      = 672009794147581953;
            var   channel = _client.GetChannel(ID) as IMessageChannel;

            Discord.IUser U             = Context.Message.Author;
            IEmote[]      emotes1       = new IEmote[] { Emote.Parse("<:Unreal:672062790499827721>"), Emote.Parse("<:Unity:672063190535766026>"), Emote.Parse("<:3DSMax:672063870776508418>"), Emote.Parse("<:Blender:672063714572107786>") };
            var           roleEmbedAuth = new EmbedAuthorBuilder

            {
                Name = U.ToString(),
            };

            var rolebuilder = new EmbedBuilder()
                              .WithTitle("React to gain a role.")
                              .WithDescription($"Select a reaction to gain a role.\n\n{Emote.Parse("<:Unreal:672062790499827721>")} - Unreal Development\n\n <:Unity:672063190535766026> - Unity Development\n\n <:3DSMax:672063870776508418> - 3DSMax Modelling\n\n <:Blender:672063714572107786> - Blender Moddeling")
                              .WithUrl("https://discordapp.com")
                              .WithAuthor(author => {
                author
                .WithName("Role Giver")
                .WithUrl("https://discordapp.com");
            });
            var roleembed   = rolebuilder.Build();
            var rolemessage = await channel.SendMessageAsync(embed : roleembed);

            await rolemessage.AddReactionsAsync(emotes1);

            var emoji           = new Emoji("\uD83C\uDFAB");
            var ticketEmbedAuth = new EmbedAuthorBuilder

            {
                Name = U.ToString(),
            };

            var ticketbuilder = new EmbedBuilder()
                                .WithTitle("React to open a support ticket.")
                                .WithDescription($"React with {emoji} to open a support ticket")
                                .WithUrl("https://discordapp.com")
                                .WithAuthor(author => {
                author
                .WithName("Support Ticket Creator")
                .WithUrl("https://discordapp.com");
            });
            var ticketembed   = ticketbuilder.Build();
            var ticketmessage = await channel.SendMessageAsync(embed : ticketembed);

            await ticketmessage.AddReactionAsync(emoji);

            await Context.Message.DeleteAsync();
        }
Exemplo n.º 2
0
        public async Task Info(Discord.IUser user)
        {
            Discord.IUser U             = user;
            Discord.IUser E             = Context.Message.Author;
            string        imgurl        = U.AvatarId;
            string        userurl       = U.Id.ToString();
            string        AvatartoEmbed = $"https://cdn.discordapp.com/avatars/{userurl}/{imgurl}.webp?size=1024";
            Random        rnd           = new Random();
            int           red           = rnd.Next(0, 255);
            int           green         = rnd.Next(0, 255);
            int           blue          = rnd.Next(0, 255);
            var           EmbedAuth     = new EmbedAuthorBuilder
            {
                Name = U.ToString(),
            };

            var EmbedFoot = new EmbedFooterBuilder
            {
                IconUrl = "https://cdn.discordapp.com/embed/avatars/0.png",
                Text    = $"Generated - {DateTime.UtcNow.ToLongDateString()}",
            };

            var EmbedBuilder = new EmbedBuilder
            {
                Title    = "Profile Picture",
                Author   = EmbedAuth,
                ImageUrl = AvatartoEmbed,
                Footer   = EmbedFoot,
                Url      = AvatartoEmbed,
                Color    = new Discord.Color(red, green, blue),
            }.Build();

            await Discord.UserExtensions.SendMessageAsync(E, embed : EmbedBuilder);


            await Context.Message.DeleteAsync();
        }
Exemplo n.º 3
0
        private async Task MessageReceived(SocketMessage rawMessage)
        {
            // Ignore system messages and messages from bots
            if (!(rawMessage is SocketUserMessage message))
            {
                return;
            }
            if (message.Source != MessageSource.User)
            {
                return;
            }

            int argPos = 0;

            if (message.HasCharPrefix('!', ref argPos))
            {
                var context = new SocketCommandContext(_discord, message);
                var result  = await _commands.ExecuteAsync(context, argPos, _provider);

                if (result.Error.HasValue && result.Error.Value != CommandError.UnknownCommand)
                {
                    await context.Channel.SendMessageAsync(result.ToString());
                }
                else if (result.IsSuccess)
                {
                    Discord.IUser U = context.Message.Author;
                    Console.WriteLine($"[General/Command] {DateTime.Now.ToLongTimeString()} Command     {U} has used command {message.ToString()}");
                }
            }
            else

            {
                var    con = new SqlConnection("Data Source=regigigas.database.windows.net;Initial Catalog=BadWords;Integrated Security=false;User ID=RetroGamerSP;Password=Herobrine4009");
                string sql = @"SELECT word
               FROM  dbo.BarredWords";
                using (var command = new SqlCommand(sql, con))
                {
                    con.Open();
                    using (var reader = command.ExecuteReader())
                    {
                        var list = new List <string>();
                        while (reader.Read())
                        {
                            list.Add(reader.GetString(0));
                        }
                        blockedwords = list.ToArray();
                    }
                }
                string stringtocheck = message.ToString();
                foreach (string x in blockedwords)
                {
                    string hopattern  = @"\bho-oh\b";
                    string hopattern2 = @"\bho oh\b";
                    string pattern    = @"\b" + x + @"\b";
                    if (Regex.IsMatch(stringtocheck, pattern, RegexOptions.IgnoreCase) && !Regex.IsMatch(stringtocheck, hopattern, RegexOptions.IgnoreCase) && !Regex.IsMatch(stringtocheck, hopattern2, RegexOptions.IgnoreCase))
                    {
                        await message.DeleteAsync();

                        await message.Author.SendMessageAsync("You used a prohibited word || " + x);

                        Discord.IUser E              = message.Author;
                        var           _guild         = message.Channel as SocketGuildChannel;
                        var           _client        = _guild.Guild;
                        string        imgurl         = E.AvatarId;
                        string        userurl        = E.Id.ToString();
                        string        AvatartoEmbed  = $"https://cdn.discordapp.com/avatars/{userurl}/{imgurl}.webp?size=1024";
                        string        PunishmentType = "Deleted Message";
                        ulong         ID             = 677610610090835978;
                        var           channel        = _client.GetChannel(ID) as IMessageChannel;
                        var           EmbedAuth      = new EmbedAuthorBuilder
                        {
                            Name = E.ToString(),
                        };

                        var builder = new EmbedBuilder()
                                      .WithTitle($"Punishment Type: {PunishmentType}")
                                      .WithDescription($"Punished User: {E.Username.ToString()}")
                                      .WithUrl("https://discordapp.com")
                                      .WithTimestamp(DateTimeOffset.FromUnixTimeMilliseconds(1580207925966))
                                      .WithFooter(footer =>
                        {
                            footer
                            .WithText("Punished On");
                        })
                                      .WithImageUrl(AvatartoEmbed)
                                      .WithAuthor(author =>
                        {
                            author
                            .WithName("Punishment Log")
                            .WithUrl("https://discordapp.com")
                            .WithIconUrl("https://cdn.discordapp.com/embed/avatars/0.png");
                        })
                                      .AddField("Reason:", "Use of Prohibited Word || " + x)
                                      .AddField("Channel:", message.Channel)
                                      .AddField("Message", stringtocheck)
                                      .AddField("Punished By", "Automated Filter")
                                      .WithColor(new Color(255, 0, 0));
                        var embed = builder.Build();
                        await channel.SendMessageAsync(embed : embed);

                        break;
                    }
                }
            }
        }