Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #annonymous sender
- #pong list
- #expiration
- #votestats
- #how long left on vote
- #unvote somehow?
- rachela_create_vote:
- type: task
- script:
- - definemap options:
- 1:
- type: string
- name: topic
- description: Thing to vote for
- required: true
- 2:
- type: string
- name: title
- description: (Optional) Title of vote
- required: false
- 3:
- type: boolean
- name: threaded
- description: (Optional) Creates the vote in a new thread
- required: false
- 4:
- type: mentionable
- name: ping
- description: (Optional) Input users and roles to ping
- required: false
- - ~discordcommand id:rachela create name:vote "description:Creates a topic for upvoting or downvoting" group:626078288556851230 options:<[options]>
- rachela_vote_handle:
- type: world
- events:
- on discord slash command name:vote:
- - ~discordinteraction defer interaction:<context.interaction>
- - define embed <discord_embed[color=#1abc9c]>
- - define user <context.interaction.user>
- - define embed <[embed].with[author_name].as[<[user].nickname[<context.interaction.channel.group>].if_null[<[user].name>]>]>
- # todo:fallback for if they don't have an avatar?
- # - if <[user].avatar_url.exists>:
- - define embed <[embed].with[author_icon_url].as[<[user].avatar_url>]>
- - define embed <[embed].with[description].as[<context.options.get[topic]>]>
- - if <context.options.contains[title]>:
- #check if too long
- - define embed <[embed].with[title].as[<context.options.get[title]>]>
- - if <context.options.contains[threaded]> && <context.options.get[threaded]>:
- - ~discordcreatethread id:rachela name:<context.options.get[title].if_null[Vote!]> parent:<context.interaction.channel> save:thread
- - define message "Your vote was made here<&co> <<>#<entry[thread].created_thread.id><>>"
- - ~discordinteraction reply interaction:<context.interaction> <[message]> ephemeral:true
- - define channel <entry[thread].created_thread>
- #- ~discordmessage id:rachela channel:<[channel]> <[embed]> save:message
- - else:
- - define channel <context.interaction.channel>
- #- ~discordmessage id:rachela channel:<[channel]> <[embed]> save:message
- - ~discordinteraction delete interaction:<context.interaction> ephemeral:true
- - if <context.options.contains[ping]>:
- - ~discordmessage id:rachela channel:<[channel]> <context.options.get[ping].mention> save:message
- - else:
- - ~discordmessage id:rachela channel:<[channel]> <[embed]> save:message
- - definemap buttons:
- 1:
- id: vote_yes_<entry[message].message.id>
- label: 0
- style: secondary
- emoji: <<>:upvote_green:740606478880211065<>>
- 2:
- id: vote_no_<entry[message].message.id>
- label: 0
- style: secondary
- emoji: <<>:downvote_red:740606479035400215<>>
- - ~discordmessage id:rachela edit:<entry[message].message> channel:<[channel]> <[embed]> rows:<[buttons]>
- - flag server discord.open_votes.<entry[message].message.id>.message:<entry[message].message>
- - flag server discord.open_votes.<entry[message].message.id>.author:<[user]>
- - flag server discord.open_votes.<entry[message].message.id>.active expire:15m
- discord_vote_buttons:
- type: world
- check_if_expired:
- - define message_id <context.button.map.get[id].after_last[_]>
- - if !<server.has_flag[discord.open_votes.<[message_id]>.active]>:
- - define embed "<discord_embed[color=<color[100,0,0]>;description=This vote has expired.]>"
- - ~discordinteraction reply interaction:<context.interaction> <[embed]> ephemeral:true
- - stop
- - define player_flag_name discord.votes.<[message_id]>
- - define user <context.interaction.user>
- refresh_votes:
- - definemap buttons:
- 1:
- id: vote_yes_<[message_id]>
- label: <server.flag[discord.open_votes.<[message_id]>.upvotes].if_null[0]>
- style: secondary
- emoji: <<>:upvote_green:740606478880211065<>>
- 2:
- id: vote_no_<[message_id]>
- label: <server.flag[discord.open_votes.<[message_id]>.downvotes].if_null[0]>
- style: secondary
- emoji: <<>:downvote_red:740606479035400215<>>
- - define message <server.flag[discord.open_votes.<[message_id]>.message]>
- # change the button integers
- - ~discordmessage id:rachela edit:<[message]> <[message].embed.first.if_null[<[message].text>]> rows:<[buttons]>
- #/vote topic:thing to vote for
- events:
- on discord button clicked id:vote_yes_*:
- - inject discord_vote_buttons.check_if_expired
- # check if voted
- - if <[user].has_flag[<[player_flag_name]>]>:
- # check if upvoted
- - if <[user].flag[<[player_flag_name]>]> == upvote:
- # already upvoted
- - define embed "<discord_embed[color=<color[100,0,0]>;description=You've already voted.]>"
- - else:
- # changed upvote to downvote
- - define embed "<discord_embed[color=#1abc9c;description=Your vote was accepted and changed.]>"
- - flag server discord.open_votes.<[message_id]>.upvotes:++
- - flag server discord.open_votes.<[message_id]>.downvotes:--
- - else:
- # upvoted
- - define embed "<discord_embed[color=#1abc9c;description=Your vote was accepted.]>"
- - flag server discord.open_votes.<[message_id]>.upvotes:++
- - flag <[user]> <[player_flag_name]>:upvote
- - ~discordinteraction reply interaction:<context.interaction> <[embed]> ephemeral:true
- - inject discord_vote_buttons.refresh_votes
- on discord button clicked id:vote_no_*:
- - inject discord_vote_buttons.check_if_expired
- # check if voted
- - if <[user].has_flag[<[player_flag_name]>]>:
- # check if downvoted
- - if <[user].flag[<[player_flag_name]>]> == downvote:
- # already downvoted
- - define embed "<discord_embed[color=<color[100,0,0]>;description=You've already voted.]>"
- - else:
- # changed downvote to upvote
- - define embed "<discord_embed[color=#1abc9c;description=Your vote was accepted and changed.]>"
- - flag server discord.open_votes.<[message_id]>.upvotes:--
- - flag server discord.open_votes.<[message_id]>.downvotes:++
- - else:
- # downvoted
- - define embed "<discord_embed[color=#1abc9c;description=Your vote was accepted.]>"
- - flag server discord.open_votes.<[message_id]>.downvotes:++
- - flag <[user]> <[player_flag_name]>:downvote
- - ~discordinteraction reply interaction:<context.interaction> <[embed]> ephemeral:true
- - inject discord_vote_buttons.refresh_votes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement