Advertisement
b86003795

Dichill isnt gay LOL

Dec 10th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.89 KB | None | 0 0
  1. [Command("Obfuscate")]
  2.         public async Task Obfuscate(string Strength)
  3.         {
  4.             Strength = Strength.ToLower();
  5.             int StrengthNum = 0;
  6.             if (Strength == "veryweak" || Strength == "vw") StrengthNum = 1;
  7.             else if (Strength == "weak" || Strength == "w") StrengthNum = 2;
  8.             else if (Strength == "medium" || Strength == "m") StrengthNum = 3;
  9.             else if (Strength == "hard" || Strength == "h") StrengthNum = 4;
  10.             else if (Strength == "veryhard" || Strength == "vh") StrengthNum = 5;
  11.             if (StrengthNum == 0)
  12.             {
  13.                 EmbedBuilder EmbedBuilder = new EmbedBuilder();
  14.  
  15.                 EmbedBuilder.WithTitle("Error While Obfuscation")
  16.                     .WithDescription("Please Select A Protection Strength!")
  17.                     .WithColor(Color.Red);
  18.  
  19.                 await ReplyAsync("", false, EmbedBuilder.Build());
  20.                 return;
  21.             }
  22.             try
  23.             {
  24.                 EmbedBuilder EmbedBuilder = new EmbedBuilder();
  25.                 var Attachments = Context.Message.Attachments;
  26.                 WebClient WebClient = new WebClient();
  27.  
  28.                 string FileName = Attachments.ElementAt(0).Filename;
  29.                 string FileExtension = FileName.Split('.').Last();
  30.                 if (FileExtension != "lua")
  31.                 {
  32.                     EmbedBuilder.WithTitle("Error While Obfuscation")
  33.                         .WithDescription("File's Extension is not .lua!")
  34.                         .WithColor(Color.Red);
  35.  
  36.                     await ReplyAsync("", false, EmbedBuilder.Build());
  37.                     return;
  38.                 }
  39.  
  40.                 string FileUrl = Attachments.ElementAt(0).Url;
  41.  
  42.                 byte[] FileBuffer = WebClient.DownloadData(FileUrl);
  43.  
  44.                 string Script = Encoding.UTF8.GetString(FileBuffer);
  45.  
  46.                 EmbedBuilder.WithTitle("Obfuscating Script...")
  47.                     .WithDescription("Script is Currently Obfucating!")
  48.                     .WithColor(Color.Blue);
  49.  
  50.                 var ObfuscatingMessage = await ReplyAsync("", false, EmbedBuilder.Build());
  51.  
  52.                 string ObfuscatedScript = Obfuscator.ObfuscateScript(Script, StrengthNum);
  53.                 if (ObfuscatedScript == null)
  54.                 {
  55.                     EmbedBuilder.WithTitle("Error While Obfuscation")
  56.                         .WithDescription("Null Returned After Obfuscation!")
  57.                         .WithColor(Color.Red);
  58.  
  59.                     await ReplyAsync("", false, EmbedBuilder.Build());
  60.                     return;
  61.                 }
  62.                 string FilePath = Directory.GetCurrentDirectory() + "\\" + FileName.Split('.')[0] + "-obf.lua";
  63.                 File.WriteAllText(FilePath, ObfuscatedScript);
  64.                 EmbedBuilder.WithTitle("Script Obfuscated!")
  65.                     .WithDescription("Script Obfuscated!\nTimestamp: " + DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss"))
  66.                     .WithColor(Color.Blue);
  67.  
  68.                 await Context.User.SendFileAsync(FilePath, "", false, EmbedBuilder.Build());
  69.  
  70.                 EmbedBuilder.WithTitle("Script Obfuscated!")
  71.                     .WithDescription("Script Obfuscated, Sent To DM!\nTimestamp: " + DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss"))
  72.                     .WithColor(Color.Blue);
  73.  
  74.                 await ObfuscatingMessage.ModifyAsync(MessageProperties => { MessageProperties.Embed = EmbedBuilder.Build(); });
  75.             }
  76.             catch (Exception Exception)
  77.             {
  78.                 EmbedBuilder EmbedBuilder = new EmbedBuilder();
  79.  
  80.                 EmbedBuilder.WithTitle("Error While Obfuscation")
  81.                 .WithDescription(Exception.Message.ToString())
  82.                 .WithColor(Color.Red);
  83.  
  84.                 await ReplyAsync("", false, EmbedBuilder.Build());
  85.                 return;
  86.             }
  87.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement