public async Task Info() { Discord.IUser U = 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(U, embed : EmbedBuilder); await Context.Message.DeleteAsync(); }
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; } } } }
public static string Prepare(this string Trivia, Dictionary <string, string> Changes, ITextChannel Channel = null, Discord.IGuild Guild = null, Discord.IUser User = null) { var changes = new Dictionary <string, string>(Changes) { { "%OWNER%", Global.Settings.OwnerName } }; GuildSetting Settings = null; if (Channel != null && Settings == null) { Settings = Channel.GetSettings(); } else if (Guild != null && Settings == null) { Settings = Guild.GetSettings(); } else if (User != null && Settings == null) { Settings = Global.GuildSettings.GetSettings(User.Id); } if (User != null) { changes.Add("%MENTION%", User.Mention); } if (Settings != null) { changes.Add("%P%", Settings.Prefix); changes.Add("%PREFIX%", Settings.Prefix); } var Text = Trivia; if (Text.Contains("%LANGUAGES%") || Text.Contains("%LANGS%")) { var LangNames = string.Join(", ", Global.LanguageHandler.Languages.Select(langPair => langPair.Key + " - " + langPair.Value.Name)); Text = Text.Replace("%LANGUAGES%", LangNames); Text = Text.Replace("%LANGS%", LangNames); } foreach (var Pair in changes) { string Key = Pair.Key; if (!Key.EndsWith("%")) { Key += "%"; } if (!Key.StartsWith("%")) { Key = "%" + Key; } Text = Text.Replace(Key.ToUpper(), Pair.Value); } return(Text); }