Untitled

 avatar
unknown
plain_text
a year ago
16 kB
2
Indexable
$nomention

$c[ Below you can set the default limit of options a person can add in their polls, it must be atleast 2 and maximum 9, default is 9 ]
$var[poll_options_limit;9]

$if[$checkContains[$customID || $message;poll_vote;poll_send-$authorID;poll_mng]==true]

$c[ Below you can change the formatting of the poll embed, using several placeholders available. ]
$var[poll_format;```{poll_description}```
> :bar_chart: There are **{options_amount}** options available in this poll.
{options_list}]

$c[ Below you can change the formatting of the options list, using {option-name} and {option-votes} placeholders, this formatting will only apply if the poll has a minimum of 1 vote, if it has no votes yet it will show a raw list instead till someone votes. ]
$var[list_format;``• {option-name} - {option-votes} votes``]

$c[ Below you can pick the embed color, must be a valid color hexcode value. ]
$var[poll_color;#5865f2]

$endif



$if[$checkContains[$customID;poll_settings-$authorID]==true]

$textSplit[$customID;-]
$if[$serverChannelExists[$splitText[3]]==true]
$var[def_channel;$splitText[3]]
$endif

$newModal[poll_modal;Poll settings]
$addTextInput[title;short;Poll Title;3;40;no;;Title will be shown in the poll embed title.]
$addTextInput[description;short;Poll Description;2;180;no;;Description will be shown in the poll embed description.]
$addTextInput[options;paragraph;Options (One per line, max $var[poll_options_limit]);2;200;yes;Option 1
Option 2
Option 3
Option 4...;List each option on a new line.]
$addTextInput[channel;short;Channel ID or Name;3;40;no;$var[def_channel];Channel ID/name where the poll will start, or leave empty.]
$endif

$if[$customID==poll_modal]
$removeButtons
$defer

$textSplit[$url[encode;$input[options]];%0A]

$if[$or[$getTextSplitLength<2;$getTextSplitLength==;$input[options]==]==true]
$var[minimum;false]
$else
$var[minimum;true]
$endif

$if[$splitText[1]==]
$var[minimum;false]
$else
$var[minimum;true]
$endif
$if[$splitText[2]==]
$var[minimum;false]
$endif

$if[$var[minimum]==false]
$title[Minimum 2 options.]
$description[Hey <@$authorID>, you must add atleast 2 options in order to start a poll, please list each option on a new line, one under other, you can add up to **$var[poll_options_limit]** poll options.]
$color[#ea003a]
$ephemeral
$stop
$endif

$if[$getTextSplitLength>$var[poll_options_limit]]
$title[Options limit exceeded.]
$description[Sorry <@$authorID>, but there's a limit of how many options you can add in a poll, the maximal amount of options you can add is of **$var[poll_options_limit]**, in your poll you included **$getTextSplitLength** options, you must remove atleast **$sub[$getTextSplitLength;$var[poll_options_limit]]** options to continue. ]
$color[#ea003a]
$ephemeral
$stop
$endif

$var[channel;$findChannel[$input[channel]]]
$if[$serverChannelExists[$var[channel]]==false]
$var[channel;$channelID]
$endif

$if[$input[title]==]
$var[title;Title not given.]
$else
$var[title;$input[title]]
$endif
$if[$input[description]==]
$var[description;Description not given.]
$else
$var[description;$input[description]]
$endif

$var[options;$input[options]]

$setUserVar[poll_system;$input[options]ʃ$var[channel]ʃ$url[encode;$input[title]]ʃ$url[encode;$input[description]];$authorID]

$title[Settings successfully saved!]
$description[> You can change these settings by pressing the **settings** button back, if you don't want to change anything else you can press the **Send Poll** button.]
$addField[Title;```$var[title]```;yes]
$addField[Description;```$var[description]```;yes]
$addField[Channel;<#$var[channel]>;yes]
$addField[Options;```$var[options]```;yes]
$color[#08b278]

$ephemeral
$endif

$if[$checkContains[$customID || $message;poll_mng]==true]
$defer
$removeButtons
$removeComponent[pollmenu_vote]

$if[$checkContains[$customID || $message;$authorID]==true]
$var[poll_owner;true]
$else
$var[poll_owner;false]
$endif

$textSplit[$customID $message;-]
$var[poll_id;$splitText[2]]
$var[poll_author;$splitText[3]]

$if[$checkContains[$getUserVar[poll_system;$authorID];$messageID]==true]
$textSplit[$getUserVar[poll_system;$authorID];$messageID]
$var[data_1;$splitText[2]]

$textSplit[$var[data_1];,]
$var[voted_option;$splitText[1]]
$var[voted_unix;$splitText[2]]
$var[voted;Yes]
$var[bool;1]

$else

$var[voted;No]
$var[bool;0]
$endif

$if[$checkContains[$getUserVar[poll_system;$botID];$messageID]==true]
$var[poll_state;Closed]
$else
$var[poll_state;Open]
$endif

$if[$var[poll_owner]==true]
$var[by;**you**]

$if[$checkContains[$getUserVar[poll_system;$botID];$messageID]==true]
$addButton[no;poll_switch-$messageID;Reopen Poll;success;no;;]
$else
$addButton[no;poll_switch-$messageID;Close Poll;danger;no;;]
$endif

$else
$var[by;<@$var[poll_author]>]
$endif

$title[Poll Information]
$description[> :bar_chart: This poll was initiated on ``$creationDate[$messageID;January 2, 2006 3:04 PM]`` by $var[by]!]
$addField[Started by;<@$var[poll_author]> ``( $username[$var[poll_author]]#$discriminator[$var[poll_author]] )``;yes]
$addField[Channel;<#$channelID>;yes]
$addField[Poll State;```$var[poll_state]```;yes]
$addField[Creation date;```$creationDate[$messageID;January 2, 2006 3:04 PM]```;no]
$addField[You voted?;```$var[voted]```;yes]
$if[$var[bool]==1]
$addField[You voted for...;```Option $var[voted_option]```;yes]
$addField[Voted Timestamp;<t:$var[voted_unix]:F> (<t:$var[voted_unix]:R>);yes]
$else
$addButton[no;https://discord.com/channels/$guildID/$channelID/$messageID;Vote!;link;no;;]
$endif
$color[$var[poll_color]]
$ephemeral
$endif

$if[$checkContains[$customID;poll_switch-]==true]
$defer
$removeButtons
$textSplit[$customID;-]
$var[msg_id;$splitText[2]]
$try
$var[poll_title;$getEmbedData[$channelID;$var[msg_id];1;title]]
$endtry

$title[Success!]
$color[#08b278]
$if[$checkContains[$getUserVar[poll_system;$botID];$var[msg_id]]==false]
$description[
Poll ``$var[poll_title]`` has been **closed**! Members are not able to vote anymore, you can open it again using the **Reopen again** button below.
]
$addButton[no;poll_switch-$var[msg_id];Reopen again;success;no;;]
$try
$setUserVar[poll_system;$getUserVar[poll_system;$botID] $var[msg_id];$botID]
$catch
$setUserVar[poll_system;$var[msg_id];$botID]
$endtry
$else
$description[Poll ``$var[poll_title]`` has been **reopened**! Members are able to vote again, you can close it back using the **Close again** button below.]
$setUserVar[poll_system;$replaceText[$getUserVar[poll_system;$botID];$var[msg_id];;-1];$botID]
$addButton[no;poll_switch-$var[msg_id];Close again;danger;no;;]
$endif

$endif

$if[$customID==poll_send-$authorID]
$removeButtons

$if[$charCount[$getUserVar[poll_system]]<5]
$title[Not ready yet!]
$description[Hey, it seems you didn't modify the settings for this poll yet, please hit the **Settings** button and add atleast 2 options for your poll before sending it.]
$color[#ea003a]
$ephemeral
$stop
$endif

$textSplit[$getUserVar[poll_system];ʃ]
$var[channel;$replaceText[$splitText[2]; ;;-1]]
$var[poll_title;$url[decode;$splitText[3]]]
$var[poll_description;$url[decode;$splitText[4]]]
$var[poll_options;$url[encode;$splitText[1]]]

$if[$serverChannelExists[$var[channel]]==true]
$useChannel[$var[channel]]
$endif

$if[$charCount[$var[poll_title]]<3]
$var[poll_title;$username[$authorID]#$discriminator[$authorID]'s Poll]
$endif
$if[$charCount[$var[poll_description]]<3]
$var[poll_description;This poll doesn't have a description set.]
$endif

$c[ ... ]

$var[display_list;true]
$var[default_data;0]
$var[menu_appears_on;3]

$textSplit[$replaceText[$var[poll_options];%0D;%0A;-1];%0A]
$var[options;$getTextSplitLength]
$var[real_options_amount;0]
$var[n;1]
$var[n2;1]
$var[correct_2;1]

$eval[$repeatMessage[2;$repeatMessage[5;%{DOL}%optOff[
%{DOL}%if[%{DOL}%splitText[%{DOL}%var[n\]\]!=\]
%{DOL}%var[real_options_amount\;%{DOL}%sum[%{DOL}%var[real_options_amount\]\;1\]\]
%{DOL}%try

%{DOL}%var[labels\;%{DOL}%var[labels\]%0A %{DOL}%url[decode\;%{DOL}%splitText[%{DOL}%var[n\]\]\]\]
%{DOL}%var[chart_labels\;%{DOL}%var[chart_labels\],"%{DOL}%splitText[%{DOL}%var[n\]\] - "\]
%{DOL}%var[dataset\;%{DOL}%var[dataset\],%{DOL}%var[default_data\]\]

%{DOL}%endtry
%{DOL}%endif
%{DOL}%var[n\;%{DOL}%sum[%{DOL}%var[n\]\;1\]\]
\]]]]

$c[ ... ] 

$var[list;$var[labels]]

$if[$var[display_list]==true]
$var[d_list;$url[decode;$var[list]]]
$endif


$var[dataset;$replaceText[  $var[dataset];  ,;;-1]]

$var[chart_labels;$replaceText[  $var[chart_labels];  ,;;-1]]
$var[labels_output;$replaceText[$replaceText[$var[chart_labels];%0A;;-1];%0D;;-1]]
$var[labels_output;$url[decode;$var[chart_labels]]]

$c[ CHART JSON ]
$var[chart_url;$url[encode;{
 "type": "outlabeledPie",
 "data": {
 "labels": [ $var[labels_output] \],
 "datasets": [{
 "backgroundColor": ["#FF3784", "#36A2EB", "#4BC0C0", "#F77825", "#9966FF", "#08B278", "#BBC103", "#6674FF", "#007EDA", "#DC0752"\],
 "data": [$var[dataset]\]
 }\]
 },
 "options": {
 "plugins": {
 "legend": false,
 "outlabels": {
 "text": "%l %p",
 "color": "white",
 "stretch": 35,
 "font": {
 "resizable": true,
 "minSize": 12,
 "maxSize": 18
 }
 }
 }
 }
}]]

$try
$var[msg_id;$sendEmbedMessage[$var[channel];;$var[poll_title];
;$replaceText[$replaceText[$replaceText[$var[poll_format];{poll_description};$var[poll_description];-1];{options_amount};$var[real_options_amount];-1];{options_list};$var[d_list];-1]
;$var[poll_color]
;New Poll!
;$c[author icon]
;Poll started by $username[$authorID]#$discriminator[$authorID]$c[footer]
;$c[footer icon]
;$c[thumbnail]
;https://quickchart.io/chart?bkg=rgba(255%2C%20255%2C%20255%2C%200)&c=$var[chart_url]&poll_params=&sep=&poll_title=$url[encode;$var[poll_title]]&sep=&poll_desc=$url[encode;$var[poll_description]]&sep=&poll_author=$authorID&sep=&poll_amount=$var[real_options_amount]&sep=&poll_options=$url[encode;$var[d_list]]&sep=
;no
;yes]]
$catch
$title[Unexpected error!]
$description[Hey <@$authorID>, there has been an unexpected error. Please ensure that you have set everything up correctly. Remember, polls must have a minimum of two and a maximum of ten valid options, listed one underneath the other. If the error persists, please notify a developer.]
$color[#ea003a]
$ephemeral
$stop
$endtry
$setUserVar[poll_system;;$authorID]

$if[$var[real_options_amount]<$var[menu_appears_on]]
$else
$newSelectMenu[pollmenu_vote;1;1;Click here to vote!;$var[msg_id]]
$addSelectMenuOption[pollmenu_vote;Manage;poll_mng-$var[msg_id]-$authorID;Pick this option to manage this poll!;;;$var[msg_id]]
$endif

$eval[$repeatMessage[2;$repeatMessage[5;%{DOL}%optOff[
%{DOL}%if[%{DOL}%splitText[%{DOL}%var[n2\]\]!=\]
%{DOL}%try

%{DOL}%if[%{DOL}%var[real_options_amount\]<%{DOL}%var[menu_appears_on\]\]
%{DOL}%addButton[no\;poll_vote-%{DOL}%var[correct_2\]\;%{DOL}%cropText[%{DOL}%url[decode\;%{DOL}%splitText[%{DOL}%var[n2\]\]\]\;58\;...\]\;primary\;no\;\;%{DOL}%var[msg_id\]\]
%{DOL}%var[type\;buttons\]
%{DOL}%else
%{DOL}%addSelectMenuOption[pollmenu_vote\;%{DOL}%cropText[%{DOL}%url[decode\;%{DOL}%splitText[%{DOL}%var[n2\]\]\]\;58\;...\]\;poll_vote-%{DOL}%var[correct_2\]\;Vote for option number %{DOL}%var[correct_2\]\;\;\;%{DOL}%var[msg_id\]\]
%{DOL}%var[type\;menu\]
%{DOL}%endif
%{DOL}%var[correct_2\;%{DOL}%sum[%{DOL}%var[correct_2\]\;1\]\]

%{DOL}%endtry
%{DOL}%endif
%{DOL}%var[n2\;%{DOL}%sum[%{DOL}%var[n2\]\;1\]\]
\]]]]

$if[$var[real_options_amount]<$var[menu_appears_on]]
$addButton[no;poll_mng-$var[msg_id]-$authorID;Manage;success;no;;$var[msg_id]]
$endif

$title[Successfully sent!]
$description[Hey <@$authorID>, your poll has been successfully sent to <#$var[channel]>]
$color[#08b278]
$endif

$if[$checkContains[$customID || $message;poll_vote]==true]
$defer

$if[$checkContains[$getUserVar[poll_system;$botID];$messageID]==true]
$removeButtons
$removeComponent[pollmenu_vote]
$title[This poll is closed!]
$description[Sorry **$username**, but you can't vote in this poll since it has been flagged as **closed** by its author, you can ask the author to reopen it at anytime.]
$color[#ea003a]
$ephemeral
$stop
$endif

$try
  $cooldown[1m;]
$catch
$removeButtons
$removeComponent[pollmenu_vote]
$description[Hey **$username**, you will be able to change your vote <t:$sum[$getTimestamp;$getCooldown[normal]]:R>!]
$color[#ea003a]
$ephemeral
$stop
$endtry

$textSplit[$customID $message;-]
$var[voted_option;$splitText[2]]
$var[msg_id;$messageID]

$if[$checkContains[$getUserVar[poll_system];$messageID]==true]
$textSplit[$getUserVar[poll_system];$messageID]
$var[data_1;$splitText[2]]
$textSplit[$var[data_1];,]
$var[last_voted;$splitText[1]]
$var[voted_before;true]
$setUserVar[poll_system;$replaceText[$getUserVar[poll_system];$messageID;;-1]]
$else
$var[voted_before;false]
$endif

$if[$var[last_voted]==$var[voted_option]]
$setUserVar[poll_system;$replaceText[$getUserVar[poll_system];$messageID;;-1]]
$endif

$try
$setUserVar[poll_system;$getUserVar[poll_system]-$messageID$var[voted_option],$getTimestamp$messageID;$authorID]
$catch
$setUserVar[poll_system;$messageID$var[voted_option],$getTimestamp$messageID;$authorID]
$endtry

$try
$var[title;$getEmbedData[$channelID;$var[msg_id];1;title]]
$endtry
$try
$var[footer;$getEmbedData[$channelID;$messageID;1;footer]]
$endtry
$var[description;$getEmbedData[$channelID;$var[msg_id];1;description]]
$var[img_url;$getEmbedData[$channelID;$var[msg_id];1;image]]
$textSplit[$var[img_url];&poll_params=]
$var[poll_params;&poll_params=$splitText[2]]
$var[image;$replaceText[$replaceText[$var[img_url];$var[poll_params];;1];https://quickchart.io/chart?bkg=rgba(255%2C%20255%2C%20255%2C%200)&c=;;1]]

$var[json;$url[decode;$replaceText[$var[image];\];\\];-1]]]

$textSplit[$var[json];"data": ]
$var[2;$splitText[3]]
$textSplit[$var[2];\]]
$var[raw;$splitText[1]\]]
$var[output;$replaceText[$splitText[1];[;;-1]]

$textSplit[$var[output];,]
$var[current;$splitText[$var[voted_option]]]
$if[$var[voted_before]==true]
$var[past;$splitText[$var[last_voted]]]
$endif

$textSplit[$var[output];,]
$editSplitText[$var[voted_option];$sum[$var[current];1]]
$if[$var[voted_before]==true]
$editSplitText[$var[last_voted];$sub[$var[past];1]]
$endif
$var[changed_output;$joinSplitText[,]]
$var[final_json;$replaceText[$var[json]; "data": $var[raw]; "data": [$var[changed_output]\];1]]

$textSplit[$var[poll_params];&poll_params=]
$var[raw_params;$splitText[2]]
$textSplit[$var[raw_params];&sep=]

$var[desc;$replaceText[$url[decode;$splitText[3]];&poll_desc=;;-1]]
$var[options_amount;$replaceText[$splitText[5];&poll_amount=;;-1]]
$var[list_raw;$replaceText[$splitText[6];&poll_options=;;-1]]

$textSplit[$var[changed_output];,]
$var[ops;0]

$eval[$repeatMessage[2;$repeatMessage[5;%{DOL}%optOff[
%{DOL}%try
%{DOL}%if[%{DOL}%splitText[%{DOL}%var[ops\]\]!=\]
%{DOL}%var[op%{DOL}%sum[%{DOL}%var[ops\]\;1\]\;%{DOL}%splitText[%{DOL}%var[ops\]\]\]
%{DOL}%endif
%{DOL}%endtry
%{DOL}%var[ops\;%{DOL}%sum[%{DOL}%var[ops\]\;1\]\]
\]]]]

$textSplit[$var[list_raw];%0A]
$var[explored;0]

$var[final_image;https://quickchart.io/chart?bkg=rgba(255%2C%20255%2C%20255%2C%200)&c=$url[encode;$var[final_json]]&poll_params=$var[raw_params]]

$eval[$repeatMessage[2;$repeatMessage[6;%{DOL}%optOff[
%{DOL}%try
%{DOL}%if[%{DOL}%splitText[%{DOL}%var[explored\]\]!=\]
%{DOL}%var[list_looped\;%{DOL}%var[list_looped\]
%{DOL}%replaceText[%{DOL}%replaceText[%{DOL}%var[list_format\]\;{option-name}\;%{DOL}%splitText[%{DOL}%var[explored\]\]\;-1\]\;{option-votes}\;%{DOL}%numberSeparator[%{DOL}%var[op%{DOL}%var[explored\]\]\]\;-1\]\]
%{DOL}%endif
%{DOL}%endtry
%{DOL}%var[explored\;%{DOL}%sum[%{DOL}%var[explored\]\;1\]\]
\]]]]

$title[$var[title]]
$description[$replaceText[$replaceText[$replaceText[$var[poll_format];{poll_description};$var[desc];-1];{options_amount};$var[options_amount];-1];{options_list};$url[decode;$var[list_looped]];-1]]
$if[$var[footer]!=]
$footer[$var[footer]]
$endif
$image[$var[final_image]]
$color[$var[poll_color]]

$if[$var[voted_before]==true]
$if[$var[last_voted]==$var[voted_option]]
$var[dm_msg;You successfully **removed** your vote from the ``$var[title]`` poll in the server ``$serverName[$guildID]``!]
$else
$var[dm_msg;You successfully **changed** your vote from option **$var[last_voted]** to option **$var[voted_option]** for the ``$var[title]`` poll in the server ``$serverName[$guildID]``!]
$endif
$else
$var[dm_msg;You successfully **voted** for the option number **$var[voted_option]** in the "``$var[title]``" poll in the server ``$serverName[$guildID]``!]
$endif

$try
$sendEmbedMessage[$dmChannelID[$authorID];;Success!;;$var[dm_msg];#08b278;;;;;;;yes;no]
$endtry

$endif