Advertisement
merovigiam

Untitled

Jun 6th, 2020
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. this.Client.MessageReactionAdded += async e =>
  2. {
  3. try
  4. {
  5. if (!e.User.Id.ToString().Equals("123") && (e.Channel.Name == "lfg-bot" || e.Channel.Name == "looking-for-games" || e.Channel.Name == "bots" || e.Channel.Name == "scheduled-games" || e.Channel.Name == "bot-testing" || e.Channel.Name == "looking-for-non-tts-games"))
  6. {
  7. string wholeStringEmbed = "";
  8. int posFrom = 0;
  9. int posTo = 0;
  10. string cutUrl = "";
  11. string[] urlSplit = null;
  12. ulong theMessageOtherId = 0;
  13.  
  14. bool thisIsLFGsoSyncOtherChannel = false;
  15. DiscordMessage theOtherMessageDesired = null;
  16.  
  17. var originalMensage = e.Message;
  18. string theOriginalTextMessage = "";
  19. if (originalMensage != null)
  20. {
  21. theOriginalTextMessage = originalMensage.Content;
  22. }
  23.  
  24. var isXStillPresentForAValidMessage = true;
  25. DiscordMessage theMessagedd = originalMensage;
  26. if (theMessagedd == null || theMessagedd.Content == null)
  27. {
  28. theMessagedd = await e.Channel.GetMessageAsync(e.Message.Id);
  29. if (theMessagedd.Content != null)
  30. {
  31. theOriginalTextMessage = theMessagedd.Content;
  32. }
  33. }
  34.  
  35. if (theOriginalTextMessage == null)
  36. {
  37. int indexer = 0;
  38. do
  39. {
  40. theMessagedd = await e.Channel.GetMessageAsync(e.Message.Id);
  41. theOriginalTextMessage = theMessagedd.Content ?? null;
  42. indexer++;
  43. } while (indexer < 15 && theOriginalTextMessage == null);
  44. }
  45.  
  46.  
  47. var messageReactions = theMessagedd.Reactions;
  48. foreach (var reaction in messageReactions)
  49. {
  50. if (reaction.Emoji.Name == "🚷" && reaction.IsMe)
  51. {
  52. isXStillPresentForAValidMessage = false;
  53. }
  54. }
  55.  
  56. if (theMessagedd.Channel.Name == "looking-for-games" || theMessagedd.Channel.Name == "lfg-bot")
  57. {
  58. thisIsLFGsoSyncOtherChannel = true;
  59. }
  60.  
  61.  
  62.  
  63.  
  64.  
  65. if (theMessagedd.Embeds.Count > 0 && theMessagedd.Author != null && theMessagedd.Author.Id.Equals(123) && isXStillPresentForAValidMessage)
  66. {
  67. //detect which emoji reacted and act accordingly
  68.  
  69. var theFooter = new DiscordEmbedBuilder.EmbedFooter();
  70. DiscordEmbed oldBed = theMessagedd.Embeds.First();
  71. theFooter.Text = oldBed.Footer.Text;//.Text(oldBed.Footer.Text, oldBed.Footer.IconUrl)
  72. theFooter.IconUrl = oldBed.Footer.IconUrl.ToString();//.Text(oldBed.Footer.Text, oldBed.Footer.IconUrl)
  73. string newDescription = oldBed.Description;
  74. if (!newDescription.Contains(e.User.Mention))
  75. {
  76. newDescription += ", " + e.User.Mention;
  77. }
  78.  
  79. if (thisIsLFGsoSyncOtherChannel)
  80. {
  81. wholeStringEmbed = oldBed.Description;
  82. posFrom = wholeStringEmbed.IndexOf('(');
  83. posTo = wholeStringEmbed.IndexOf(')');
  84. cutUrl = wholeStringEmbed.Substring(posFrom, posTo - posFrom);
  85. urlSplit = cutUrl.Split('/');
  86. theMessageOtherId = ulong.Parse(urlSplit.Last());
  87. theOtherMessageDesired = await e.Channel.GetMessageAsync(theMessageOtherId);
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement