{ "commands": [ { "function": "\nimport { takaro, data, axios } from '@takaro/helpers';\nasync function main() {\n const { pog } = data;\n const playerRes = await takaro.player.playerControllerGetOne(data.player.id);\n const steamId = playerRes.data.data.steamId;\n const xboxLiveId = playerRes.data.data.xboxLiveId;\n const name = playerRes.data.data.name;\n const key = data.module.userConfig.votekey;\n\n let voteId = `username=${name}`;\n if (steamId.startsWith(\"7656\")) { voteId = `steamid=${steamId}`; }\n\n\n const res = await axios.get(`https://7daystodie-servers.com/api/?object=votes&element=claim&key=${key}&${voteId}`);\n if (res.data == 0) { data.player.pm(data.module.userConfig.didntvote); }\n if (res.data == 2) { data.player.pm(data.module.userConfig.alreadyvoted); }\n if (res.data == 1) {\n\n const claimresponse = await axios.post(`https://7daystodie-servers.com/api/?action=post&object=votes&element=claim&key=${key}&${voteId}`);\n if (claimresponse.data == 1) {\n if (data.module.userConfig.votednow.toLowerCase() !== 'none' && data.module.userConfig.votednow.toLowerCase() !== '\"none\"') { data.player.pm(data.module.userConfig.votednow); }\n if (data.module.userConfig.publicMessage.toLowerCase() !== 'none' && data.module.userConfig.publicMessage.toLowerCase() !== '\"none\"') {\n const originalMessage = data.module.userConfig.publicMessage;\n const modifiedMessage = originalMessage.replace(/\\{name\\}/g, name);\n await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: `say \"${modifiedMessage}\"` });\n }\n await takaro.playerOnGameserver.playerOnGameServerControllerAddCurrency(data.gameServerId, pog.playerId, { currency: data.module.userConfig.currency });\n for (const stuff of data.module.userConfig.giveStuff) {\n if (voteId.startsWith(`steamid`)) {\n await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: `giveplus Steam_${steamId} ${stuff}` });\n } else {\n await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: `giveplus ${xboxLiveId} ${stuff}` });\n }\n }\n }\n }\n}\n\n\n\nawait main();", "name": "vote", "trigger": "vote", "helpText": "Vote for the server and give players rewards.", "arguments": [] } ], "hooks": [], "cronJobs": [], "functions": [], "permissions": [], "name": "Vote", "description": "Takaro Vote Module", "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"required\":[\"votekey\",\"didntvote\",\"alreadyvoted\"],\"additionalProperties\":false,\"properties\":{\"votekey\":{\"title\":\"votekey\",\"description\":\"Votekey from website\",\"default\":\"\",\"type\":\"string\"},\"didntvote\":{\"title\":\"didntvote\",\"description\":\"Message to send to the player when voting site reports no vote was cast.\",\"default\":\"You haven't voted yet.\",\"type\":\"string\"},\"alreadyvoted\":{\"title\":\"alreadyvoted\",\"description\":\"Message to send to the player when voting site reports the vote was already claimed.\",\"default\":\"You have already claimed your last vote.\",\"type\":\"string\"},\"votednow\":{\"title\":\"votednow\",\"description\":\"Optional message to send to the player when vote is successful. \\nUse \\\"none\\\" as the message if you want nothing to be sent instead.\",\"default\":\"Thanks for voting.\",\"type\":\"string\"},\"publicMessage\":{\"title\":\"publicMessage\",\"description\":\"Optional message to broadcast to all players online when vote is successful. Use {name} in the message to refer to the player name.\\nUse \\\"none\\\" as the message if you want nothing to be sent instead.\",\"default\":\"[FF0000]{name}[-] voted at 7daystodie-servers.com and was rewarded Takaro Coins!\",\"type\":\"string\"},\"giveStuff\":{\"title\":\"giveStuff\",\"description\":\"Items to give to the player thru giveplus command. Must indicate quantities and, if applies, quality:\\n [ ]\\n\\nItem name has to be the exact name of an item as listed by \\\"listitems\\\".\\n\\nQuality is the quality of the dropped items for items that have a quality.\\n\\nusedTimes is the % that the item was used.\\n\\nThe default value is giving 2 waters and a tier 6 stone axe with no use. If you are going to copy/paste, include the arguments. \",\"default\":[\"drinkJarBoiledWater 2\",\"meleeToolRepairT0StoneAxe 1 6 0\"],\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"currency\":{\"title\":\"currency\",\"description\":\"How much currency to add to the player in Takaro\",\"default\":0,\"type\":\"number\"}}}", "uiSchema": "{}" }