@takaro/modules 0.0.0-next.0da151e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/README.md +3 -0
  2. package/dist/BuiltinModule.d.ts +62 -0
  3. package/dist/BuiltinModule.d.ts.map +1 -0
  4. package/dist/BuiltinModule.js +245 -0
  5. package/dist/BuiltinModule.js.map +1 -0
  6. package/dist/community-modules.json +21 -0
  7. package/dist/dto/base.d.ts +7 -0
  8. package/dist/dto/base.d.ts.map +1 -0
  9. package/dist/dto/base.js +28 -0
  10. package/dist/dto/base.js.map +1 -0
  11. package/dist/dto/discordEvents.d.ts +32 -0
  12. package/dist/dto/discordEvents.d.ts.map +1 -0
  13. package/dist/dto/discordEvents.js +92 -0
  14. package/dist/dto/discordEvents.js.map +1 -0
  15. package/dist/dto/gameEvents.d.ts +83 -0
  16. package/dist/dto/gameEvents.d.ts.map +1 -0
  17. package/dist/dto/gameEvents.js +205 -0
  18. package/dist/dto/gameEvents.js.map +1 -0
  19. package/dist/dto/index.d.ts +54 -0
  20. package/dist/dto/index.d.ts.map +1 -0
  21. package/dist/dto/index.js +18 -0
  22. package/dist/dto/index.js.map +1 -0
  23. package/dist/dto/takaroEvents.d.ts +276 -0
  24. package/dist/dto/takaroEvents.d.ts.map +1 -0
  25. package/dist/dto/takaroEvents.js +794 -0
  26. package/dist/dto/takaroEvents.js.map +1 -0
  27. package/dist/main.d.ts +5 -0
  28. package/dist/main.d.ts.map +1 -0
  29. package/dist/main.js +35 -0
  30. package/dist/main.js.map +1 -0
  31. package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts +2 -0
  32. package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts.map +1 -0
  33. package/dist/modules/chatBridge/hooks/DiscordToGame.js +18 -0
  34. package/dist/modules/chatBridge/hooks/DiscordToGame.js.map +1 -0
  35. package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts +2 -0
  36. package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts.map +1 -0
  37. package/dist/modules/chatBridge/hooks/GameToDiscord.js +14 -0
  38. package/dist/modules/chatBridge/hooks/GameToDiscord.js.map +1 -0
  39. package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts +2 -0
  40. package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts.map +1 -0
  41. package/dist/modules/chatBridge/hooks/PlayerConnected.js +9 -0
  42. package/dist/modules/chatBridge/hooks/PlayerConnected.js.map +1 -0
  43. package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts +2 -0
  44. package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts.map +1 -0
  45. package/dist/modules/chatBridge/hooks/PlayerDisconnected.js +9 -0
  46. package/dist/modules/chatBridge/hooks/PlayerDisconnected.js.map +1 -0
  47. package/dist/modules/chatBridge/index.d.ts +5 -0
  48. package/dist/modules/chatBridge/index.d.ts.map +1 -0
  49. package/dist/modules/chatBridge/index.js +64 -0
  50. package/dist/modules/chatBridge/index.js.map +1 -0
  51. package/dist/modules/dailyRewards/commands/daily.d.ts +2 -0
  52. package/dist/modules/dailyRewards/commands/daily.d.ts.map +1 -0
  53. package/dist/modules/dailyRewards/commands/daily.js +103 -0
  54. package/dist/modules/dailyRewards/commands/daily.js.map +1 -0
  55. package/dist/modules/dailyRewards/commands/streak.d.ts +2 -0
  56. package/dist/modules/dailyRewards/commands/streak.d.ts.map +1 -0
  57. package/dist/modules/dailyRewards/commands/streak.js +34 -0
  58. package/dist/modules/dailyRewards/commands/streak.js.map +1 -0
  59. package/dist/modules/dailyRewards/commands/topstreak.d.ts +2 -0
  60. package/dist/modules/dailyRewards/commands/topstreak.d.ts.map +1 -0
  61. package/dist/modules/dailyRewards/commands/topstreak.js +44 -0
  62. package/dist/modules/dailyRewards/commands/topstreak.js.map +1 -0
  63. package/dist/modules/dailyRewards/functions/utils.d.ts +6 -0
  64. package/dist/modules/dailyRewards/functions/utils.d.ts.map +1 -0
  65. package/dist/modules/dailyRewards/functions/utils.js +32 -0
  66. package/dist/modules/dailyRewards/functions/utils.js.map +1 -0
  67. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.d.ts +2 -0
  68. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.d.ts.map +1 -0
  69. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.js +19 -0
  70. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.js.map +1 -0
  71. package/dist/modules/dailyRewards/index.d.ts +5 -0
  72. package/dist/modules/dailyRewards/index.d.ts.map +1 -0
  73. package/dist/modules/dailyRewards/index.js +127 -0
  74. package/dist/modules/dailyRewards/index.js.map +1 -0
  75. package/dist/modules/economyUtils/commands/balance.d.ts +2 -0
  76. package/dist/modules/economyUtils/commands/balance.d.ts.map +1 -0
  77. package/dist/modules/economyUtils/commands/balance.js +7 -0
  78. package/dist/modules/economyUtils/commands/balance.js.map +1 -0
  79. package/dist/modules/economyUtils/commands/claim.d.ts +2 -0
  80. package/dist/modules/economyUtils/commands/claim.d.ts.map +1 -0
  81. package/dist/modules/economyUtils/commands/claim.js +35 -0
  82. package/dist/modules/economyUtils/commands/claim.js.map +1 -0
  83. package/dist/modules/economyUtils/commands/confirmTransfer.d.ts +2 -0
  84. package/dist/modules/economyUtils/commands/confirmTransfer.d.ts.map +1 -0
  85. package/dist/modules/economyUtils/commands/confirmTransfer.js +38 -0
  86. package/dist/modules/economyUtils/commands/confirmTransfer.js.map +1 -0
  87. package/dist/modules/economyUtils/commands/grantCurrency.d.ts +2 -0
  88. package/dist/modules/economyUtils/commands/grantCurrency.d.ts.map +1 -0
  89. package/dist/modules/economyUtils/commands/grantCurrency.js +28 -0
  90. package/dist/modules/economyUtils/commands/grantCurrency.js.map +1 -0
  91. package/dist/modules/economyUtils/commands/revokeCurrency.d.ts +2 -0
  92. package/dist/modules/economyUtils/commands/revokeCurrency.d.ts.map +1 -0
  93. package/dist/modules/economyUtils/commands/revokeCurrency.js +28 -0
  94. package/dist/modules/economyUtils/commands/revokeCurrency.js.map +1 -0
  95. package/dist/modules/economyUtils/commands/shop.d.ts +2 -0
  96. package/dist/modules/economyUtils/commands/shop.d.ts.map +1 -0
  97. package/dist/modules/economyUtils/commands/shop.js +69 -0
  98. package/dist/modules/economyUtils/commands/shop.js.map +1 -0
  99. package/dist/modules/economyUtils/commands/topCurrency.d.ts +2 -0
  100. package/dist/modules/economyUtils/commands/topCurrency.d.ts.map +1 -0
  101. package/dist/modules/economyUtils/commands/topCurrency.js +22 -0
  102. package/dist/modules/economyUtils/commands/topCurrency.js.map +1 -0
  103. package/dist/modules/economyUtils/commands/transfer.d.ts +2 -0
  104. package/dist/modules/economyUtils/commands/transfer.d.ts.map +1 -0
  105. package/dist/modules/economyUtils/commands/transfer.js +55 -0
  106. package/dist/modules/economyUtils/commands/transfer.js.map +1 -0
  107. package/dist/modules/economyUtils/cronJobs/zombieKillReward.d.ts +2 -0
  108. package/dist/modules/economyUtils/cronJobs/zombieKillReward.d.ts.map +1 -0
  109. package/dist/modules/economyUtils/cronJobs/zombieKillReward.js +66 -0
  110. package/dist/modules/economyUtils/cronJobs/zombieKillReward.js.map +1 -0
  111. package/dist/modules/economyUtils/index.d.ts +5 -0
  112. package/dist/modules/economyUtils/index.d.ts.map +1 -0
  113. package/dist/modules/economyUtils/index.js +192 -0
  114. package/dist/modules/economyUtils/index.js.map +1 -0
  115. package/dist/modules/geoBlock/hooks/IPDetected.d.ts +2 -0
  116. package/dist/modules/geoBlock/hooks/IPDetected.d.ts.map +1 -0
  117. package/dist/modules/geoBlock/hooks/IPDetected.js +50 -0
  118. package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -0
  119. package/dist/modules/geoBlock/index.d.ts +9 -0
  120. package/dist/modules/geoBlock/index.d.ts.map +1 -0
  121. package/dist/modules/geoBlock/index.js +329 -0
  122. package/dist/modules/geoBlock/index.js.map +1 -0
  123. package/dist/modules/gimme/commands/gimme.d.ts +2 -0
  124. package/dist/modules/gimme/commands/gimme.d.ts.map +1 -0
  125. package/dist/modules/gimme/commands/gimme.js +25 -0
  126. package/dist/modules/gimme/commands/gimme.js.map +1 -0
  127. package/dist/modules/gimme/index.d.ts +5 -0
  128. package/dist/modules/gimme/index.d.ts.map +1 -0
  129. package/dist/modules/gimme/index.js +75 -0
  130. package/dist/modules/gimme/index.js.map +1 -0
  131. package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts +2 -0
  132. package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts.map +1 -0
  133. package/dist/modules/highPingKicker/cronJobs/Ping check.js +59 -0
  134. package/dist/modules/highPingKicker/cronJobs/Ping check.js.map +1 -0
  135. package/dist/modules/highPingKicker/index.d.ts +5 -0
  136. package/dist/modules/highPingKicker/index.d.ts.map +1 -0
  137. package/dist/modules/highPingKicker/index.js +44 -0
  138. package/dist/modules/highPingKicker/index.js.map +1 -0
  139. package/dist/modules/lottery/commands/buyTicket.d.ts +2 -0
  140. package/dist/modules/lottery/commands/buyTicket.d.ts.map +1 -0
  141. package/dist/modules/lottery/commands/buyTicket.js +51 -0
  142. package/dist/modules/lottery/commands/buyTicket.js.map +1 -0
  143. package/dist/modules/lottery/commands/nextDraw.d.ts +2 -0
  144. package/dist/modules/lottery/commands/nextDraw.d.ts.map +1 -0
  145. package/dist/modules/lottery/commands/nextDraw.js +34 -0
  146. package/dist/modules/lottery/commands/nextDraw.js.map +1 -0
  147. package/dist/modules/lottery/commands/viewTickets.d.ts +2 -0
  148. package/dist/modules/lottery/commands/viewTickets.d.ts.map +1 -0
  149. package/dist/modules/lottery/commands/viewTickets.js +20 -0
  150. package/dist/modules/lottery/commands/viewTickets.js.map +1 -0
  151. package/dist/modules/lottery/cronJobs/drawLottery.d.ts +2 -0
  152. package/dist/modules/lottery/cronJobs/drawLottery.d.ts.map +1 -0
  153. package/dist/modules/lottery/cronJobs/drawLottery.js +96 -0
  154. package/dist/modules/lottery/cronJobs/drawLottery.js.map +1 -0
  155. package/dist/modules/lottery/index.d.ts +5 -0
  156. package/dist/modules/lottery/index.d.ts.map +1 -0
  157. package/dist/modules/lottery/index.js +85 -0
  158. package/dist/modules/lottery/index.js.map +1 -0
  159. package/dist/modules/playerOnboarding/commands/starterkit.d.ts +2 -0
  160. package/dist/modules/playerOnboarding/commands/starterkit.d.ts.map +1 -0
  161. package/dist/modules/playerOnboarding/commands/starterkit.js +47 -0
  162. package/dist/modules/playerOnboarding/commands/starterkit.js.map +1 -0
  163. package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts +2 -0
  164. package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts.map +1 -0
  165. package/dist/modules/playerOnboarding/hooks/playerConnected.js +11 -0
  166. package/dist/modules/playerOnboarding/hooks/playerConnected.js.map +1 -0
  167. package/dist/modules/playerOnboarding/index.d.ts +5 -0
  168. package/dist/modules/playerOnboarding/index.d.ts.map +1 -0
  169. package/dist/modules/playerOnboarding/index.js +83 -0
  170. package/dist/modules/playerOnboarding/index.js.map +1 -0
  171. package/dist/modules/serverMessages/cronJobs/Automated message.d.ts +2 -0
  172. package/dist/modules/serverMessages/cronJobs/Automated message.d.ts.map +1 -0
  173. package/dist/modules/serverMessages/cronJobs/Automated message.js +41 -0
  174. package/dist/modules/serverMessages/cronJobs/Automated message.js.map +1 -0
  175. package/dist/modules/serverMessages/index.d.ts +5 -0
  176. package/dist/modules/serverMessages/index.d.ts.map +1 -0
  177. package/dist/modules/serverMessages/index.js +45 -0
  178. package/dist/modules/serverMessages/index.js.map +1 -0
  179. package/dist/modules/teleports/commands/deletetp.d.ts +2 -0
  180. package/dist/modules/teleports/commands/deletetp.d.ts.map +1 -0
  181. package/dist/modules/teleports/commands/deletetp.js +20 -0
  182. package/dist/modules/teleports/commands/deletetp.js.map +1 -0
  183. package/dist/modules/teleports/commands/deletewaypoint.d.ts +2 -0
  184. package/dist/modules/teleports/commands/deletewaypoint.d.ts.map +1 -0
  185. package/dist/modules/teleports/commands/deletewaypoint.js +20 -0
  186. package/dist/modules/teleports/commands/deletewaypoint.js.map +1 -0
  187. package/dist/modules/teleports/commands/listwaypoints.d.ts +2 -0
  188. package/dist/modules/teleports/commands/listwaypoints.d.ts.map +1 -0
  189. package/dist/modules/teleports/commands/listwaypoints.js +17 -0
  190. package/dist/modules/teleports/commands/listwaypoints.js.map +1 -0
  191. package/dist/modules/teleports/commands/setprivate.d.ts +2 -0
  192. package/dist/modules/teleports/commands/setprivate.d.ts.map +1 -0
  193. package/dist/modules/teleports/commands/setprivate.js +29 -0
  194. package/dist/modules/teleports/commands/setprivate.js.map +1 -0
  195. package/dist/modules/teleports/commands/setpublic.d.ts +2 -0
  196. package/dist/modules/teleports/commands/setpublic.d.ts.map +1 -0
  197. package/dist/modules/teleports/commands/setpublic.js +45 -0
  198. package/dist/modules/teleports/commands/setpublic.js.map +1 -0
  199. package/dist/modules/teleports/commands/settp.d.ts +2 -0
  200. package/dist/modules/teleports/commands/settp.d.ts.map +1 -0
  201. package/dist/modules/teleports/commands/settp.js +40 -0
  202. package/dist/modules/teleports/commands/settp.js.map +1 -0
  203. package/dist/modules/teleports/commands/setwaypoint.d.ts +2 -0
  204. package/dist/modules/teleports/commands/setwaypoint.d.ts.map +1 -0
  205. package/dist/modules/teleports/commands/setwaypoint.js +28 -0
  206. package/dist/modules/teleports/commands/setwaypoint.js.map +1 -0
  207. package/dist/modules/teleports/commands/teleport.d.ts +2 -0
  208. package/dist/modules/teleports/commands/teleport.d.ts.map +1 -0
  209. package/dist/modules/teleports/commands/teleport.js +68 -0
  210. package/dist/modules/teleports/commands/teleport.js.map +1 -0
  211. package/dist/modules/teleports/commands/teleportwaypoint.d.ts +2 -0
  212. package/dist/modules/teleports/commands/teleportwaypoint.d.ts.map +1 -0
  213. package/dist/modules/teleports/commands/teleportwaypoint.js +43 -0
  214. package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -0
  215. package/dist/modules/teleports/commands/tplist.d.ts +2 -0
  216. package/dist/modules/teleports/commands/tplist.d.ts.map +1 -0
  217. package/dist/modules/teleports/commands/tplist.js +46 -0
  218. package/dist/modules/teleports/commands/tplist.js.map +1 -0
  219. package/dist/modules/teleports/cronJobs/Waypoint reconciler.d.ts +2 -0
  220. package/dist/modules/teleports/cronJobs/Waypoint reconciler.d.ts.map +1 -0
  221. package/dist/modules/teleports/cronJobs/Waypoint reconciler.js +6 -0
  222. package/dist/modules/teleports/cronJobs/Waypoint reconciler.js.map +1 -0
  223. package/dist/modules/teleports/functions/utils.d.ts +14 -0
  224. package/dist/modules/teleports/functions/utils.d.ts.map +1 -0
  225. package/dist/modules/teleports/functions/utils.js +156 -0
  226. package/dist/modules/teleports/functions/utils.js.map +1 -0
  227. package/dist/modules/teleports/index.d.ts +5 -0
  228. package/dist/modules/teleports/index.d.ts.map +1 -0
  229. package/dist/modules/teleports/index.js +208 -0
  230. package/dist/modules/teleports/index.js.map +1 -0
  231. package/dist/modules/timedShutdown/cronJobs/Shutdown.d.ts +2 -0
  232. package/dist/modules/timedShutdown/cronJobs/Shutdown.d.ts.map +1 -0
  233. package/dist/modules/timedShutdown/cronJobs/Shutdown.js +7 -0
  234. package/dist/modules/timedShutdown/cronJobs/Shutdown.js.map +1 -0
  235. package/dist/modules/timedShutdown/cronJobs/warning.d.ts +2 -0
  236. package/dist/modules/timedShutdown/cronJobs/warning.d.ts.map +1 -0
  237. package/dist/modules/timedShutdown/cronJobs/warning.js +10 -0
  238. package/dist/modules/timedShutdown/cronJobs/warning.js.map +1 -0
  239. package/dist/modules/timedShutdown/index.d.ts +5 -0
  240. package/dist/modules/timedShutdown/index.d.ts.map +1 -0
  241. package/dist/modules/timedShutdown/index.js +43 -0
  242. package/dist/modules/timedShutdown/index.js.map +1 -0
  243. package/dist/modules/utils/commands/help.d.ts +2 -0
  244. package/dist/modules/utils/commands/help.d.ts.map +1 -0
  245. package/dist/modules/utils/commands/help.js +84 -0
  246. package/dist/modules/utils/commands/help.js.map +1 -0
  247. package/dist/modules/utils/commands/ping.d.ts +2 -0
  248. package/dist/modules/utils/commands/ping.d.ts.map +1 -0
  249. package/dist/modules/utils/commands/ping.js +6 -0
  250. package/dist/modules/utils/commands/ping.js.map +1 -0
  251. package/dist/modules/utils/index.d.ts +5 -0
  252. package/dist/modules/utils/index.d.ts.map +1 -0
  253. package/dist/modules/utils/index.js +52 -0
  254. package/dist/modules/utils/index.js.map +1 -0
  255. package/dist/modules.json +757 -0
  256. package/package.json +17 -0
  257. package/scripts/buildBuiltinJson.ts +81 -0
  258. package/src/BuiltinModule.ts +159 -0
  259. package/src/__tests__/aliases.integration.test.ts +90 -0
  260. package/src/__tests__/bugRepros.integration.test.ts +485 -0
  261. package/src/__tests__/builtinmodule.unit.test.ts +15 -0
  262. package/src/__tests__/commandArgs.integration.test.ts +291 -0
  263. package/src/__tests__/crossServerPlayer.integration.test.ts +176 -0
  264. package/src/__tests__/economy/claim.integration.test.ts +250 -0
  265. package/src/__tests__/economy/economyUtils.integration.test.ts +495 -0
  266. package/src/__tests__/economy/shop.integration.test.ts +177 -0
  267. package/src/__tests__/economy/zombieKillReward.integration.test.ts +293 -0
  268. package/src/__tests__/geoblock.integration.test.ts +322 -0
  269. package/src/__tests__/gimme.integration.test.ts +106 -0
  270. package/src/__tests__/help.integration.test.ts +314 -0
  271. package/src/__tests__/highPingKicker.integration.test.ts +618 -0
  272. package/src/__tests__/lottery.integration.test.ts +344 -0
  273. package/src/__tests__/modulePermission.integration.test.ts +387 -0
  274. package/src/__tests__/onboarding.integration.test.ts +122 -0
  275. package/src/__tests__/ping.integration.test.ts +36 -0
  276. package/src/__tests__/roleExpiry.integration.test.ts +78 -0
  277. package/src/__tests__/serverMessages.integration.test.ts +116 -0
  278. package/src/__tests__/systemConfigCooldown.integration.test.ts +84 -0
  279. package/src/__tests__/systemConfigCost.integration.test.ts +194 -0
  280. package/src/__tests__/teleports/listtp.integration.test.ts +189 -0
  281. package/src/__tests__/teleports/publicteleports.integration.test.ts +345 -0
  282. package/src/__tests__/teleports/teleport.integration.test.ts +153 -0
  283. package/src/__tests__/teleports/tpManagement.integration.test.ts +175 -0
  284. package/src/__tests__/teleports/waypoints.integration.test.ts +832 -0
  285. package/src/community-modules/README.md +5 -0
  286. package/src/community-modules/modules/vote.json +19 -0
  287. package/src/dto/base.ts +13 -0
  288. package/src/dto/discordEvents.ts +69 -0
  289. package/src/dto/gameEvents.ts +159 -0
  290. package/src/dto/index.ts +25 -0
  291. package/src/dto/takaroEvents.ts +525 -0
  292. package/src/main.ts +47 -0
  293. package/src/modules/.eslintrc +5 -0
  294. package/src/modules/chatBridge/hooks/DiscordToGame.js +18 -0
  295. package/src/modules/chatBridge/hooks/GameToDiscord.js +18 -0
  296. package/src/modules/chatBridge/hooks/PlayerConnected.js +11 -0
  297. package/src/modules/chatBridge/hooks/PlayerDisconnected.js +11 -0
  298. package/src/modules/chatBridge/index.ts +64 -0
  299. package/src/modules/dailyRewards/commands/daily.js +114 -0
  300. package/src/modules/dailyRewards/commands/streak.js +42 -0
  301. package/src/modules/dailyRewards/commands/topstreak.js +54 -0
  302. package/src/modules/dailyRewards/functions/utils.js +36 -0
  303. package/src/modules/dailyRewards/hooks/dailyLoginCheck.js +24 -0
  304. package/src/modules/dailyRewards/index.ts +138 -0
  305. package/src/modules/economyUtils/commands/balance.js +8 -0
  306. package/src/modules/economyUtils/commands/claim.js +42 -0
  307. package/src/modules/economyUtils/commands/confirmTransfer.js +55 -0
  308. package/src/modules/economyUtils/commands/grantCurrency.js +34 -0
  309. package/src/modules/economyUtils/commands/revokeCurrency.js +34 -0
  310. package/src/modules/economyUtils/commands/shop.js +87 -0
  311. package/src/modules/economyUtils/commands/topCurrency.js +29 -0
  312. package/src/modules/economyUtils/commands/transfer.js +73 -0
  313. package/src/modules/economyUtils/cronJobs/zombieKillReward.js +82 -0
  314. package/src/modules/economyUtils/index.ts +197 -0
  315. package/src/modules/geoBlock/hooks/IPDetected.js +53 -0
  316. package/src/modules/geoBlock/index.ts +333 -0
  317. package/src/modules/gimme/commands/gimme.js +30 -0
  318. package/src/modules/gimme/index.ts +76 -0
  319. package/src/modules/highPingKicker/cronJobs/Ping check.js +68 -0
  320. package/src/modules/highPingKicker/index.ts +44 -0
  321. package/src/modules/lottery/commands/buyTicket.js +64 -0
  322. package/src/modules/lottery/commands/nextDraw.js +47 -0
  323. package/src/modules/lottery/commands/viewTickets.js +28 -0
  324. package/src/modules/lottery/cronJobs/drawLottery.js +124 -0
  325. package/src/modules/lottery/index.ts +86 -0
  326. package/src/modules/playerOnboarding/commands/starterkit.js +61 -0
  327. package/src/modules/playerOnboarding/hooks/playerConnected.js +14 -0
  328. package/src/modules/playerOnboarding/index.ts +86 -0
  329. package/src/modules/serverMessages/cronJobs/Automated message.js +47 -0
  330. package/src/modules/serverMessages/index.ts +46 -0
  331. package/src/modules/teleports/commands/deletetp.js +25 -0
  332. package/src/modules/teleports/commands/deletewaypoint.js +24 -0
  333. package/src/modules/teleports/commands/listwaypoints.js +23 -0
  334. package/src/modules/teleports/commands/setprivate.js +39 -0
  335. package/src/modules/teleports/commands/setpublic.js +60 -0
  336. package/src/modules/teleports/commands/settp.js +50 -0
  337. package/src/modules/teleports/commands/setwaypoint.js +31 -0
  338. package/src/modules/teleports/commands/teleport.js +84 -0
  339. package/src/modules/teleports/commands/teleportwaypoint.js +57 -0
  340. package/src/modules/teleports/commands/tplist.js +62 -0
  341. package/src/modules/teleports/cronJobs/Waypoint reconciler.js +7 -0
  342. package/src/modules/teleports/functions/utils.js +189 -0
  343. package/src/modules/teleports/index.ts +217 -0
  344. package/src/modules/timedShutdown/cronJobs/Shutdown.js +8 -0
  345. package/src/modules/timedShutdown/cronJobs/warning.js +13 -0
  346. package/src/modules/timedShutdown/index.ts +45 -0
  347. package/src/modules/utils/commands/help.js +100 -0
  348. package/src/modules/utils/commands/ping.js +7 -0
  349. package/src/modules/utils/index.ts +53 -0
  350. package/tsconfig.build.json +10 -0
  351. package/tsconfig.json +9 -0
  352. package/typedoc.json +3 -0
@@ -0,0 +1,387 @@
1
+ import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
2
+ import { IHookEventTypeEnum } from '@takaro/apiclient';
3
+ import { describe } from 'node:test';
4
+ import { randomUUID } from 'crypto';
5
+ import { getMockServer } from '@takaro/mock-gameserver';
6
+
7
+ const group = 'Module permissions role assignments';
8
+
9
+ async function cleanRoleSetup(this: IntegrationTest<IModuleTestsSetupData>) {
10
+ const defaultSetup = await modulesTestSetup.bind(this)();
11
+
12
+ await this.client.module.moduleInstallationsControllerInstallModule({
13
+ gameServerId: defaultSetup.gameserver.id,
14
+ versionId: defaultSetup.teleportsModule.latestVersion.id,
15
+ });
16
+
17
+ const playersRes = await this.client.player.playerControllerSearch();
18
+
19
+ const permissions = await this.client.permissionCodesToInputs(['TELEPORTS_USE']);
20
+
21
+ await this.client.role.roleControllerUpdate(defaultSetup.role.id, {
22
+ name: defaultSetup.role.name,
23
+ permissions,
24
+ });
25
+
26
+ await this.client.module.moduleInstallationsControllerInstallModule({
27
+ gameServerId: defaultSetup.gameserver.id,
28
+ versionId: defaultSetup.teleportsModule.latestVersion.id,
29
+ });
30
+
31
+ await Promise.all(
32
+ playersRes.data.data.map(async (player) => {
33
+ await this.client.player.playerControllerRemoveRole(player.id, defaultSetup.role.id);
34
+ }),
35
+ );
36
+
37
+ return defaultSetup;
38
+ }
39
+
40
+ const tests = [
41
+ new IntegrationTest<IModuleTestsSetupData>({
42
+ group,
43
+ snapshot: false,
44
+ setup: cleanRoleSetup,
45
+ name: 'Player has global role -> works',
46
+ test: async function () {
47
+ const useTeleportsRole = await this.client.permissionCodesToInputs(['TELEPORTS_USE']);
48
+ await this.client.role.roleControllerUpdate(this.setupData.role.id, {
49
+ permissions: [
50
+ {
51
+ permissionId: useTeleportsRole[0].permissionId,
52
+ count: 3,
53
+ },
54
+ ],
55
+ });
56
+ await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, this.setupData.role.id);
57
+
58
+ const setEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(
59
+ IHookEventTypeEnum.ChatMessage,
60
+ 1,
61
+ );
62
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
63
+ msg: '/settp test',
64
+ playerId: this.setupData.players[0].id,
65
+ });
66
+
67
+ expect((await setEvents).length).to.be.eq(1);
68
+ expect((await setEvents)[0].data.meta.msg).to.be.eq('Teleport test set.');
69
+ },
70
+ }),
71
+ new IntegrationTest<IModuleTestsSetupData>({
72
+ group,
73
+ snapshot: false,
74
+ setup: cleanRoleSetup,
75
+ name: 'Player has role on other gameserver -> command denied',
76
+ test: async function () {
77
+ if (!this.domainRegistrationToken) throw new Error('Domain registration token not set');
78
+ const identityToken = randomUUID();
79
+ const mockserver = await getMockServer({
80
+ mockserver: { registrationToken: this.domainRegistrationToken, identityToken },
81
+ });
82
+ this.setupData.mockservers.push(mockserver);
83
+ const gameserverRes = await this.client.gameserver.gameServerControllerSearch({
84
+ filters: { identityToken: [identityToken] },
85
+ });
86
+ const newGameServer = gameserverRes.data.data[0];
87
+ if (!newGameServer) throw new Error('Game server not found');
88
+
89
+ await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, this.setupData.role.id, {
90
+ gameServerId: newGameServer.id,
91
+ });
92
+
93
+ const setEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(
94
+ IHookEventTypeEnum.ChatMessage,
95
+ 1,
96
+ );
97
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
98
+ msg: '/settp test',
99
+ playerId: this.setupData.players[0].id,
100
+ });
101
+
102
+ expect((await setEvents).length).to.be.eq(1);
103
+ expect((await setEvents)[0].data.meta.msg).to.be.eq(
104
+ "⚠️ You need the 'Teleports Use' permission to use this command. Please contact an admin if you need access.",
105
+ );
106
+ },
107
+ }),
108
+ new IntegrationTest<IModuleTestsSetupData>({
109
+ group,
110
+ snapshot: false,
111
+ setup: cleanRoleSetup,
112
+ name: 'Player has role on correct gameserver -> works',
113
+ test: async function () {
114
+ const useTeleportsRole = await this.client.permissionCodesToInputs(['TELEPORTS_USE']);
115
+ await this.client.role.roleControllerUpdate(this.setupData.role.id, {
116
+ permissions: [
117
+ {
118
+ permissionId: useTeleportsRole[0].permissionId,
119
+ count: 3,
120
+ },
121
+ ],
122
+ });
123
+
124
+ await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, this.setupData.role.id, {
125
+ gameServerId: this.setupData.gameserver.id,
126
+ });
127
+
128
+ const setEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(
129
+ IHookEventTypeEnum.ChatMessage,
130
+ 1,
131
+ );
132
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
133
+ msg: '/settp test',
134
+ playerId: this.setupData.players[0].id,
135
+ });
136
+
137
+ expect((await setEvents).length).to.be.eq(1);
138
+ expect((await setEvents)[0].data.meta.msg).to.be.eq('Teleport test set.');
139
+ },
140
+ }),
141
+ new IntegrationTest<IModuleTestsSetupData>({
142
+ group,
143
+ snapshot: false,
144
+ setup: modulesTestSetup,
145
+ name: 'Uses system roles',
146
+ test: async function () {
147
+ await this.client.module.moduleInstallationsControllerInstallModule({
148
+ gameServerId: this.setupData.gameserver.id,
149
+ versionId: this.setupData.teleportsModule.latestVersion.id,
150
+ userConfig: JSON.stringify({
151
+ timeout: 0,
152
+ }),
153
+ });
154
+
155
+ await Promise.all(
156
+ this.setupData.players.map(async (player) => {
157
+ await this.client.player.playerControllerRemoveRole(player.id, this.setupData.role.id);
158
+ }),
159
+ );
160
+
161
+ const playerRoleRes = await this.client.role.roleControllerSearch({ filters: { name: ['Player'] } });
162
+
163
+ const useTeleportsRole = await this.client.permissionCodesToInputs(['TELEPORTS_USE']);
164
+ await this.client.role.roleControllerUpdate(playerRoleRes.data.data[0].id, {
165
+ permissions: [
166
+ {
167
+ permissionId: useTeleportsRole[0].permissionId,
168
+ count: 3,
169
+ },
170
+ ],
171
+ });
172
+
173
+ const setTpEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(
174
+ IHookEventTypeEnum.ChatMessage,
175
+ 1,
176
+ );
177
+
178
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
179
+ msg: '/settp test',
180
+ playerId: this.setupData.players[0].id,
181
+ });
182
+
183
+ const setTpEventResult = await setTpEvent;
184
+
185
+ expect(setTpEventResult.length).to.be.eq(1);
186
+ expect(setTpEventResult[0].data.meta.msg).to.be.eq('Teleport test set.');
187
+
188
+ const tpEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(IHookEventTypeEnum.ChatMessage, 1);
189
+
190
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
191
+ msg: '/tp test',
192
+ playerId: this.setupData.players[0].id,
193
+ });
194
+
195
+ expect((await tpEvent)[0].data.meta.msg).to.be.eq('Teleported to test.');
196
+
197
+ await this.client.role.roleControllerUpdate(playerRoleRes.data.data[0].id, {
198
+ name: 'Player',
199
+ permissions: [],
200
+ });
201
+
202
+ const tpEventNoPerm = (await new EventsAwaiter().connect(this.client)).waitForEvents(
203
+ IHookEventTypeEnum.ChatMessage,
204
+ 1,
205
+ );
206
+
207
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
208
+ msg: '/tp test',
209
+ playerId: this.setupData.players[0].id,
210
+ });
211
+
212
+ expect((await tpEventNoPerm)[0].data.meta.msg).to.include("You need the 'Teleports Use' permission");
213
+ },
214
+ }),
215
+ new IntegrationTest<IModuleTestsSetupData>({
216
+ group,
217
+ snapshot: false,
218
+ setup: async function () {
219
+ const defaultSetup = await modulesTestSetup.bind(this)();
220
+
221
+ // Remove all permissions from the default role
222
+ await this.client.role.roleControllerUpdate(defaultSetup.role.id, {
223
+ name: defaultSetup.role.name,
224
+ permissions: [],
225
+ });
226
+
227
+ return defaultSetup;
228
+ },
229
+ name: 'Command execution denied when player lacks requiredPermissions',
230
+ test: async function () {
231
+ // Install economyUtils module which has commands with requiredPermissions
232
+ const installRes = await this.client.module.moduleInstallationsControllerInstallModule({
233
+ gameServerId: this.setupData.gameserver.id,
234
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
235
+ });
236
+
237
+ // Verify installation succeeded
238
+ expect(installRes.data.data).to.exist;
239
+
240
+ // Ensure we have at least 1 player
241
+ expect(this.setupData.players.length).to.be.at.least(1);
242
+ const executingPlayer = this.setupData.players[0];
243
+
244
+ // Remove any existing roles from the player to ensure they have no special permissions
245
+ await this.client.player.playerControllerRemoveRole(executingPlayer.id, this.setupData.role.id);
246
+
247
+ // Check player's roles after removal
248
+ const playerAfter = await this.client.player.playerControllerGetOne(executingPlayer.id);
249
+
250
+ // If player still has system roles, we need to handle the Player role specially
251
+ if (playerAfter.data.data.roleAssignments && playerAfter.data.data.roleAssignments.length > 0) {
252
+ // Find the Player role
253
+ const playerRole = playerAfter.data.data.roleAssignments.find((ra) => ra.role.name === 'Player');
254
+ if (!playerRole) throw new Error('Player role not found after removing roles');
255
+ // Update the Player role to have no permissions
256
+ await this.client.role.roleControllerUpdate(playerRole.role.id, {
257
+ name: 'Player',
258
+ permissions: [],
259
+ });
260
+ }
261
+
262
+ // Enable economy for this test
263
+ await this.client.settings.settingsControllerSet('economyEnabled', {
264
+ value: 'true',
265
+ gameServerId: this.setupData.gameserver.id,
266
+ });
267
+ await this.client.settings.settingsControllerSet('currencyName', {
268
+ gameServerId: this.setupData.gameserver.id,
269
+ value: 'test coin',
270
+ });
271
+
272
+ // Set up event listener - just listen for the chat message
273
+ const eventsAwaiter = await new EventsAwaiter().connect(this.client);
274
+ const chatEvents = eventsAwaiter.waitForEvents(IHookEventTypeEnum.ChatMessage, 1);
275
+
276
+ // Try to execute grantCurrency command without permission
277
+ const targetPlayer = this.setupData.players.length > 1 ? this.setupData.players[1] : executingPlayer;
278
+ const commandMsg = `/grantcurrency ${targetPlayer.name} 100`;
279
+
280
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
281
+ msg: commandMsg,
282
+ playerId: executingPlayer.id,
283
+ });
284
+
285
+ // Check if we got a permission denied message
286
+ const chatEventResults = await chatEvents;
287
+ expect(chatEventResults).to.have.length(1);
288
+ expect(chatEventResults[0].data.meta.msg).to.match(/do not have permission|need.*permission/i);
289
+ },
290
+ }),
291
+ new IntegrationTest<IModuleTestsSetupData>({
292
+ group,
293
+ snapshot: false,
294
+ setup: modulesTestSetup,
295
+ name: 'Command execution allowed when player has requiredPermissions',
296
+ test: async function () {
297
+ // Install economyUtils module
298
+ await this.client.module.moduleInstallationsControllerInstallModule({
299
+ gameServerId: this.setupData.gameserver.id,
300
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
301
+ });
302
+
303
+ // Create a role with ECONOMY_UTILS_MANAGE_CURRENCY permission
304
+ const permissions = await this.client.permissionCodesToInputs(['ECONOMY_UTILS_MANAGE_CURRENCY']);
305
+ const roleRes = await this.client.role.roleControllerCreate({
306
+ name: 'Currency Manager',
307
+ permissions,
308
+ });
309
+
310
+ // Assign the role to the player
311
+ await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, roleRes.data.data.id);
312
+
313
+ // Set up event listener for COMMAND_EXECUTED event
314
+ const eventsAwaiter = await new EventsAwaiter().connect(this.client);
315
+ const executedEvents = eventsAwaiter.waitForEvents(IHookEventTypeEnum.CommandExecuted, 1);
316
+
317
+ // Execute grantCurrency command with permission
318
+ const targetPlayer = this.setupData.players.length > 1 ? this.setupData.players[1] : this.setupData.players[0];
319
+
320
+ const commandMsg = `/grantcurrency ${targetPlayer.name} 100`;
321
+
322
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
323
+ msg: commandMsg,
324
+ playerId: this.setupData.players[0].id,
325
+ });
326
+
327
+ // Verify COMMAND_EXECUTED event was logged (not COMMAND_EXECUTION_DENIED)
328
+ const executedEventResults = await executedEvents;
329
+ expect(executedEventResults).to.have.length(1);
330
+ expect(executedEventResults[0].data.eventName).to.equal('command-executed');
331
+ // Command might fail during execution, but the important thing is that it was allowed to execute
332
+ // expect(executedEventResults[0].data.command.name).to.equal('grantcurrency');
333
+ // expect(executedEventResults[0].data.player.id).to.equal(this.setupData.players[0].id);
334
+ },
335
+ }),
336
+ new IntegrationTest<IModuleTestsSetupData>({
337
+ group,
338
+ snapshot: false,
339
+ setup: modulesTestSetup,
340
+ name: 'ROOT permission bypasses command permission checks',
341
+ test: async function () {
342
+ // Install economyUtils module
343
+ await this.client.module.moduleInstallationsControllerInstallModule({
344
+ gameServerId: this.setupData.gameserver.id,
345
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
346
+ });
347
+
348
+ // Create a role with ROOT permission
349
+ const permissions = await this.client.permissionCodesToInputs(['ROOT']);
350
+ const roleRes = await this.client.role.roleControllerCreate({
351
+ name: 'Root Admin Test',
352
+ permissions,
353
+ });
354
+
355
+ // Remove existing roles and assign ROOT role
356
+ await this.client.player.playerControllerRemoveRole(this.setupData.players[0].id, this.setupData.role.id);
357
+ await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, roleRes.data.data.id);
358
+
359
+ // Set up event listener for COMMAND_EXECUTED event
360
+ const eventsAwaiter = await new EventsAwaiter().connect(this.client);
361
+ const executedEvents = eventsAwaiter.waitForEvents(IHookEventTypeEnum.CommandExecuted, 1);
362
+
363
+ // Execute grantCurrency command with ROOT permission (should bypass permission check)
364
+ const targetPlayer = this.setupData.players.length > 1 ? this.setupData.players[1] : this.setupData.players[0];
365
+
366
+ const commandMsg = `/grantcurrency ${targetPlayer.name} 100`;
367
+
368
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
369
+ msg: commandMsg,
370
+ playerId: this.setupData.players[0].id,
371
+ });
372
+
373
+ // Verify command was executed successfully
374
+ const executedEventResults = await executedEvents;
375
+ expect(executedEventResults).to.have.length(1);
376
+ expect(executedEventResults[0].data.eventName).to.equal('command-executed');
377
+ // Command might fail during execution, but the important thing is that ROOT bypassed the permission check
378
+ // expect(executedEventResults[0].data.command.name).to.equal('grantcurrency');
379
+ },
380
+ }),
381
+ ];
382
+
383
+ describe(group, function () {
384
+ tests.forEach((test) => {
385
+ test.run();
386
+ });
387
+ });
@@ -0,0 +1,122 @@
1
+ import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
2
+ import { GameEvents } from '../dto/gameEvents.js';
3
+ import { HookEvents } from '../main.js';
4
+ import { faker } from '@faker-js/faker';
5
+ import { describe } from 'node:test';
6
+
7
+ const group = 'Onboarding';
8
+ const groupStarterkit = 'Onboarding - Starterkit';
9
+
10
+ const tests = [
11
+ new IntegrationTest<IModuleTestsSetupData>({
12
+ group,
13
+ snapshot: false,
14
+ setup: modulesTestSetup,
15
+ name: 'PlayerConnected hook sends a message when a player connects to the server',
16
+ test: async function () {
17
+ await this.client.module.moduleInstallationsControllerInstallModule({
18
+ gameServerId: this.setupData.gameserver.id,
19
+ versionId: this.setupData.onboardingModule.latestVersion.id,
20
+ });
21
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 5);
22
+ await this.client.gameserver.gameServerControllerExecuteCommand(this.setupData.gameserver.id, {
23
+ command: 'connectAll',
24
+ });
25
+
26
+ expect((await events).length).to.be.eq(5);
27
+ // Expect all messages to match
28
+ expect((await events).every((event) => event.data.meta.msg.match(/Welcome .+ to the server!/))).to.be.true;
29
+ },
30
+ }),
31
+ new IntegrationTest<IModuleTestsSetupData>({
32
+ group: groupStarterkit,
33
+ snapshot: false,
34
+ setup: modulesTestSetup,
35
+ name: 'Starterkit command gives the player items',
36
+ test: async function () {
37
+ const items = (await this.client.item.itemControllerSearch()).data.data;
38
+ await this.client.module.moduleInstallationsControllerInstallModule({
39
+ gameServerId: this.setupData.gameserver.id,
40
+ versionId: this.setupData.onboardingModule.latestVersion.id,
41
+ userConfig: JSON.stringify({
42
+ starterKitItems: items.map((item) => ({
43
+ item: item.id,
44
+ amount: faker.number.int({ min: 1, max: 6 }),
45
+ quality: faker.number.int({ min: 1, max: 6 }).toString(),
46
+ })),
47
+ }),
48
+ });
49
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.COMMAND_EXECUTED);
50
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
51
+ msg: '/starterkit',
52
+ playerId: this.setupData.players[0].id,
53
+ });
54
+
55
+ const resultLogs = (await events)[0].data.meta.result.logs;
56
+ expect(resultLogs.some((log: any) => log.msg.match(/giveItem 200 OK/))).to.be.true;
57
+ },
58
+ }),
59
+ new IntegrationTest<IModuleTestsSetupData>({
60
+ group: groupStarterkit,
61
+ snapshot: false,
62
+ setup: modulesTestSetup,
63
+ name: 'Starterkit command can only be used once',
64
+ test: async function () {
65
+ const items = (await this.client.item.itemControllerSearch()).data.data;
66
+ await this.client.module.moduleInstallationsControllerInstallModule({
67
+ gameServerId: this.setupData.gameserver.id,
68
+ versionId: this.setupData.onboardingModule.latestVersion.id,
69
+ userConfig: JSON.stringify({
70
+ starterKitItems: items.map((item) => ({
71
+ item: item.id,
72
+ amount: faker.number.int({ min: 1, max: 6 }),
73
+ quality: faker.number.int({ min: 1, max: 6 }).toString(),
74
+ })),
75
+ }),
76
+ });
77
+ const firstEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.COMMAND_EXECUTED);
78
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
79
+ msg: '/starterkit',
80
+ playerId: this.setupData.players[0].id,
81
+ });
82
+
83
+ const resultLogs = (await firstEvents)[0].data.meta.result.logs;
84
+ expect(resultLogs.some((log: any) => log.msg.match(/giveItem 200 OK/))).to.be.true;
85
+
86
+ const secondEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
87
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
88
+ msg: '/starterkit',
89
+ playerId: this.setupData.players[0].id,
90
+ });
91
+
92
+ expect((await secondEvents).length).to.be.eq(1);
93
+ expect((await secondEvents)[0].data.meta.msg).to.match(/ou already used starterkit on this server/);
94
+ },
95
+ }),
96
+ new IntegrationTest<IModuleTestsSetupData>({
97
+ group: groupStarterkit,
98
+ snapshot: false,
99
+ setup: modulesTestSetup,
100
+ name: 'Starterkit with nothing configured, shows an error message',
101
+ test: async function () {
102
+ await this.client.module.moduleInstallationsControllerInstallModule({
103
+ gameServerId: this.setupData.gameserver.id,
104
+ versionId: this.setupData.onboardingModule.latestVersion.id,
105
+ });
106
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
107
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
108
+ msg: '/starterkit',
109
+ playerId: this.setupData.players[0].id,
110
+ });
111
+
112
+ expect((await events).length).to.be.eq(1);
113
+ expect((await events)[0].data.meta.msg).to.match(/No starter kit items configured/);
114
+ },
115
+ }),
116
+ ];
117
+
118
+ describe(group, function () {
119
+ tests.forEach((test) => {
120
+ test.run();
121
+ });
122
+ });
@@ -0,0 +1,36 @@
1
+ import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
2
+ import { HookEvents } from '../dto/index.js';
3
+ import { describe } from 'node:test';
4
+
5
+ const group = 'Ping command';
6
+
7
+ const tests = [
8
+ new IntegrationTest<IModuleTestsSetupData>({
9
+ group,
10
+ snapshot: false,
11
+ setup: modulesTestSetup,
12
+ name: 'Ping command replies with pong',
13
+ test: async function () {
14
+ await this.client.module.moduleInstallationsControllerInstallModule({
15
+ gameServerId: this.setupData.gameserver.id,
16
+ versionId: this.setupData.utilsModule.latestVersion.id,
17
+ });
18
+
19
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE);
20
+
21
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
22
+ msg: '/ping',
23
+ playerId: this.setupData.players[0].id,
24
+ });
25
+
26
+ expect((await events).length).to.be.eq(1);
27
+ expect((await events)[0].data.meta.msg).to.be.eq('Pong!');
28
+ },
29
+ }),
30
+ ];
31
+
32
+ describe(group, function () {
33
+ tests.forEach((test) => {
34
+ test.run();
35
+ });
36
+ });
@@ -0,0 +1,78 @@
1
+ import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
2
+ import { GameEvents } from '../dto/index.js';
3
+ import { describe } from 'node:test';
4
+
5
+ const group = 'Role expiry';
6
+
7
+ const tests = [
8
+ new IntegrationTest<IModuleTestsSetupData>({
9
+ group,
10
+ snapshot: false,
11
+ setup: modulesTestSetup,
12
+ name: 'Assigning an expiring role, removed when executing command',
13
+ test: async function () {
14
+ // First, ensure all players have no roles
15
+ await Promise.all(
16
+ this.setupData.players.map((p) => this.client.player.playerControllerRemoveRole(p.id, this.setupData.role.id)),
17
+ );
18
+
19
+ await this.client.module.moduleInstallationsControllerInstallModule({
20
+ gameServerId: this.setupData.gameserver.id,
21
+ versionId: this.setupData.teleportsModule.latestVersion.id,
22
+ });
23
+
24
+ const eventsBeforeRole = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
25
+
26
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
27
+ msg: '/settp test',
28
+ playerId: this.setupData.players[0].id,
29
+ });
30
+
31
+ expect((await eventsBeforeRole).length).to.be.eq(1);
32
+ expect((await eventsBeforeRole)[0].data.meta.msg).to.match(
33
+ /⚠️ You need the 'Teleports Use' permission to use this command. Please contact an admin if you need access/,
34
+ );
35
+
36
+ // Assign the role with expiry 10 minutes from now
37
+ await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, this.setupData.role.id, {
38
+ expiresAt: new Date(Date.now() + 10 * 60 * 1000).toISOString(),
39
+ });
40
+
41
+ // Execute the command again. Now it should work, since the role is assigned
42
+ const eventsWithRole = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
43
+
44
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
45
+ msg: '/settp test2',
46
+ playerId: this.setupData.players[0].id,
47
+ });
48
+
49
+ expect((await eventsWithRole).length).to.be.eq(1);
50
+ expect((await eventsWithRole)[0].data.meta.msg).to.match(/Teleport test2 set/);
51
+
52
+ // Remove the role and reassign with expiry 1 ms from now
53
+ await this.client.player.playerControllerRemoveRole(this.setupData.players[0].id, this.setupData.role.id);
54
+ await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, this.setupData.role.id, {
55
+ expiresAt: new Date(Date.now() + 1).toISOString(),
56
+ });
57
+
58
+ // Execute the command again. Now it should not work, since the role is expired
59
+ const eventsAfterExpire = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
60
+
61
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
62
+ msg: '/settp test3',
63
+ playerId: this.setupData.players[0].id,
64
+ });
65
+
66
+ expect((await eventsAfterExpire).length).to.be.eq(1);
67
+ expect((await eventsAfterExpire)[0].data.meta.msg).to.match(
68
+ /⚠️ You need the 'Teleports Use' permission to use this command. Please contact an admin if you need access/,
69
+ );
70
+ },
71
+ }),
72
+ ];
73
+
74
+ describe(group, function () {
75
+ tests.forEach((test) => {
76
+ test.run();
77
+ });
78
+ });