SHARE
TWEET

Untitled

a guest Apr 19th, 2019 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ```py
  2. !servalias insult embed
  3. {{ G = get_gvar("68c31679-634d-46de-999b-4e20b1f8b172") }}
  4. {{ L = [x.split(",") for x in G.split("\n\n")] }}
  5. {{ I = [x.pop(roll(f'1d{len(x)}-1')).title() for x in L] }}
  6. {{ aL = L[0] + L[1] }}
  7. {{ add = [aL.pop(roll(f'1d{len(aL)-1}')).title() for x in range(int("&1&".strip("&")))]}}
  8. {{ I = [I[0], I[1]] + add + [I[2]] }}
  9. -title "You {{" ".join(I)}}!"
  10. -thumb <image> -color <color>
  11. ```
  12.  
  13. Line by Line
  14.  
  15. `!servalias insult embed`
  16. This creates a `servalias` named `insult`, calling the command `embed`
  17.  
  18. `{{ G = get_gvar("68c31679-634d-46de-999b-4e20b1f8b172") }}`
  19. This sets a local variable, `G` to the contents of the gvar with the ID `68c31679-634d-46de-999b-4e20b1f8b172`. The `get_gvar()` function grabs the content of the Gvar as plain text.
  20.  
  21. `{{ L = [x.split(",") for x in G.split("\n\n")] }}`
  22. This sets a local variable, `L` to a list comprehension. What that is doing is breaking down the variable G into a list of lists.
  23.  
  24. `G.split("\n\n")` So, this is splitting text everytime there is two line breaks. In this case, it ends up being in three parts.
  25. `x.split(",") for x in ` This part is saying for each part of the split we did above, call that part `x`, then split THAT part on every comma.
  26. So L ends up being something like `[["Words","Stuff"],["Other","Words","More!"],["More","Words"]]`
  27.  
  28. `{{ I = [x.pop(roll(f'1d{len(x)}-1')).title() for x in L] }}`
  29. This sets another local variable, `I`, to another list comprehension, this time iterating on the variable `L`.
  30.  
  31. `x.pop(roll(f'1d{len(x)}-1')).title()` Okay, a little more complicated. We're going to start in the middle.
  32. `f'1d{len(x)}-1' So, this is an f-string, or formatted strings. It allows us to run code in the middle of string, in this case `{len(x)}`, which will be the length of `x` (which is the current part of `L` that we're looking at.). So in our example, say we're looking at the first part of L, which is `["words","stuff"]`. The length of this is 2, so it will return the string, `1d2-1`. The -1 is important because lists are index-0, that is, the first item in the list has an index of 0 (as opposed to 1).
  33. `roll()` This rolls the returned string, which as we determined above, is `1d2-1`. Lets say it returns `1`.
  34. `x.pop()` What this does is *pop* the item at the given index out of the list. This removes the item from the list, and returns it. This removes the chance of that particular item being chosen again. With our result of `1`, this will return the second item (because its index-0), which is `"stuff"`. This will make `x` be `["words"]` now.
  35. `.title()` This just capitalizes the first character of each word in the string. Now it will return `"Words"`
  36. Now, iterating over this list could make `I` `["Words","More!","Words"]`, and those would be removed from `L`, so `L` is now `[["stuff"],["Other","Words"],["More"]]`
  37.  
  38. `{{ aL = L[0] + L[1] }}`
  39. This sets the variable `aL` to the combination of the first results of `L`, so `["stuff"]` and `["Other","Words"]`, making `aL` `["stuff","Other","Words"]`, as they were added together. This doesn't remove those two lists from `L`
  40.  
  41. `{{ add = [aL.pop(roll(f'1d{len(aL)-1}')).title() for x in range(int("&1&".strip("&")))]}}`
  42.  
  43. Another fun one. This sets the variable `add` to another list comprehension, this time on a varible list.
  44.  
  45. `range(int("&1&".strip("&")))`
  46. `&1&` is a placeholder that gets replaced by the first argument given to the alias. so with `!insult 3`, `&1&` would return `3`. However, with no args given, it doesn't get replaced, and stays as `&1&`.
  47. `.strip('&')` So, this strips the '&' character from either side of the string. This lets us have a default of `"1"` when no arguments given (because `"&1&"` with the "&"'s removed is `"1"`)
  48. `int()` this converts the string to a integer. This will error if the first arg is anything other than a number (like if anyone were to `!insult silverbass`)
  49. `range()` this creates a list of numbers. In this case, because only one argument is given to it, it creates a list of numbers from `0` to the number given, not including that number. So with an argument of `1`, it will make a list `[0]`, but with an argument of `3`, it will return `[0,1,2]`
  50.  
  51. `aL.pop(roll(f'1d{len(aL)-1}')).title()` More fun, but its basically the exact same as the last time. A formatted string, this time calling the length of the `aL` list as opposed to the current iteration. A roll of that string, and then a *pop* out of `aL`, returning and removing the given index, then capitalizing it.
  52.  
  53. For this example, lets say the user did `!insult 2`. So the range will return `[0,1]`, making it do the function twice. The length of `aL` the first time is 3, so it will roll `1d3-1`, lets say it returns `0`. This will get popped out of `aL` as `"Stuff"`
  54. The second time it runs, the length is 2 (because we just removed one result), so it will roll `1d2-1`. This time lets say we got 1, so the second time it will return `"Words"`.
  55.  
  56. So `add` is now `["Stuff", "Words"]`
  57.  
  58. `{{ I = [I[0], I[1]] + add + [I[2]] }}`
  59. This overwrites the variable `I` with a new list.
  60.  
  61. `[I[0], I[1]]` So this will be the first two items in `I`, `"Words"` and `"More!"`, making it `["Words","More!"]`.
  62. `add` is just the entire `add` variable, `["Stuff", "Words"]`
  63. and finally `[I[2]]` is the third (and final) item in `I`, `"Words"`
  64.  
  65. Combining them all together, the variable `I` is now, `["Words","More!","Stuff", "Words","Words"]`
  66.  
  67. `-title "You {{" ".join(I)}}!"`
  68. So, this adds a `-title` to the `embed` the command starts with. The contents of this title is `"You {{" ".join(I)}}!"`
  69.  
  70. `{{" ".join(I)}}` This joins the contents of the variable `I`, putting space (`" "`) between each item. So in this case, it would return `"Words More! Stuff Words Words"`
  71.  
  72. Putting that together with the text outside the code, the title will be `"You Words More! Stuff Words Words!"`
  73.  
  74. `-thumb <image> -color <color>`
  75. This just sets the thumbnail and color of the embed to those that are set on your character.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top