@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.
- package/README.md +3 -0
- package/dist/BuiltinModule.d.ts +62 -0
- package/dist/BuiltinModule.d.ts.map +1 -0
- package/dist/BuiltinModule.js +245 -0
- package/dist/BuiltinModule.js.map +1 -0
- package/dist/community-modules.json +21 -0
- package/dist/dto/base.d.ts +7 -0
- package/dist/dto/base.d.ts.map +1 -0
- package/dist/dto/base.js +28 -0
- package/dist/dto/base.js.map +1 -0
- package/dist/dto/discordEvents.d.ts +32 -0
- package/dist/dto/discordEvents.d.ts.map +1 -0
- package/dist/dto/discordEvents.js +92 -0
- package/dist/dto/discordEvents.js.map +1 -0
- package/dist/dto/gameEvents.d.ts +83 -0
- package/dist/dto/gameEvents.d.ts.map +1 -0
- package/dist/dto/gameEvents.js +205 -0
- package/dist/dto/gameEvents.js.map +1 -0
- package/dist/dto/index.d.ts +54 -0
- package/dist/dto/index.d.ts.map +1 -0
- package/dist/dto/index.js +18 -0
- package/dist/dto/index.js.map +1 -0
- package/dist/dto/takaroEvents.d.ts +276 -0
- package/dist/dto/takaroEvents.d.ts.map +1 -0
- package/dist/dto/takaroEvents.js +794 -0
- package/dist/dto/takaroEvents.js.map +1 -0
- package/dist/main.d.ts +5 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +35 -0
- package/dist/main.js.map +1 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts +2 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts.map +1 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.js +18 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.js.map +1 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts +2 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts.map +1 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.js +14 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.js.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts +2 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.js +9 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.js.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts +2 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js +9 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js.map +1 -0
- package/dist/modules/chatBridge/index.d.ts +5 -0
- package/dist/modules/chatBridge/index.d.ts.map +1 -0
- package/dist/modules/chatBridge/index.js +64 -0
- package/dist/modules/chatBridge/index.js.map +1 -0
- package/dist/modules/dailyRewards/commands/daily.d.ts +2 -0
- package/dist/modules/dailyRewards/commands/daily.d.ts.map +1 -0
- package/dist/modules/dailyRewards/commands/daily.js +103 -0
- package/dist/modules/dailyRewards/commands/daily.js.map +1 -0
- package/dist/modules/dailyRewards/commands/streak.d.ts +2 -0
- package/dist/modules/dailyRewards/commands/streak.d.ts.map +1 -0
- package/dist/modules/dailyRewards/commands/streak.js +34 -0
- package/dist/modules/dailyRewards/commands/streak.js.map +1 -0
- package/dist/modules/dailyRewards/commands/topstreak.d.ts +2 -0
- package/dist/modules/dailyRewards/commands/topstreak.d.ts.map +1 -0
- package/dist/modules/dailyRewards/commands/topstreak.js +44 -0
- package/dist/modules/dailyRewards/commands/topstreak.js.map +1 -0
- package/dist/modules/dailyRewards/functions/utils.d.ts +6 -0
- package/dist/modules/dailyRewards/functions/utils.d.ts.map +1 -0
- package/dist/modules/dailyRewards/functions/utils.js +32 -0
- package/dist/modules/dailyRewards/functions/utils.js.map +1 -0
- package/dist/modules/dailyRewards/hooks/dailyLoginCheck.d.ts +2 -0
- package/dist/modules/dailyRewards/hooks/dailyLoginCheck.d.ts.map +1 -0
- package/dist/modules/dailyRewards/hooks/dailyLoginCheck.js +19 -0
- package/dist/modules/dailyRewards/hooks/dailyLoginCheck.js.map +1 -0
- package/dist/modules/dailyRewards/index.d.ts +5 -0
- package/dist/modules/dailyRewards/index.d.ts.map +1 -0
- package/dist/modules/dailyRewards/index.js +127 -0
- package/dist/modules/dailyRewards/index.js.map +1 -0
- package/dist/modules/economyUtils/commands/balance.d.ts +2 -0
- package/dist/modules/economyUtils/commands/balance.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/balance.js +7 -0
- package/dist/modules/economyUtils/commands/balance.js.map +1 -0
- package/dist/modules/economyUtils/commands/claim.d.ts +2 -0
- package/dist/modules/economyUtils/commands/claim.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/claim.js +35 -0
- package/dist/modules/economyUtils/commands/claim.js.map +1 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.d.ts +2 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.js +38 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.js.map +1 -0
- package/dist/modules/economyUtils/commands/grantCurrency.d.ts +2 -0
- package/dist/modules/economyUtils/commands/grantCurrency.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/grantCurrency.js +28 -0
- package/dist/modules/economyUtils/commands/grantCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.d.ts +2 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.js +28 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/shop.d.ts +2 -0
- package/dist/modules/economyUtils/commands/shop.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/shop.js +69 -0
- package/dist/modules/economyUtils/commands/shop.js.map +1 -0
- package/dist/modules/economyUtils/commands/topCurrency.d.ts +2 -0
- package/dist/modules/economyUtils/commands/topCurrency.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/topCurrency.js +22 -0
- package/dist/modules/economyUtils/commands/topCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/transfer.d.ts +2 -0
- package/dist/modules/economyUtils/commands/transfer.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/transfer.js +55 -0
- package/dist/modules/economyUtils/commands/transfer.js.map +1 -0
- package/dist/modules/economyUtils/cronJobs/zombieKillReward.d.ts +2 -0
- package/dist/modules/economyUtils/cronJobs/zombieKillReward.d.ts.map +1 -0
- package/dist/modules/economyUtils/cronJobs/zombieKillReward.js +66 -0
- package/dist/modules/economyUtils/cronJobs/zombieKillReward.js.map +1 -0
- package/dist/modules/economyUtils/index.d.ts +5 -0
- package/dist/modules/economyUtils/index.d.ts.map +1 -0
- package/dist/modules/economyUtils/index.js +192 -0
- package/dist/modules/economyUtils/index.js.map +1 -0
- package/dist/modules/geoBlock/hooks/IPDetected.d.ts +2 -0
- package/dist/modules/geoBlock/hooks/IPDetected.d.ts.map +1 -0
- package/dist/modules/geoBlock/hooks/IPDetected.js +50 -0
- package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -0
- package/dist/modules/geoBlock/index.d.ts +9 -0
- package/dist/modules/geoBlock/index.d.ts.map +1 -0
- package/dist/modules/geoBlock/index.js +329 -0
- package/dist/modules/geoBlock/index.js.map +1 -0
- package/dist/modules/gimme/commands/gimme.d.ts +2 -0
- package/dist/modules/gimme/commands/gimme.d.ts.map +1 -0
- package/dist/modules/gimme/commands/gimme.js +25 -0
- package/dist/modules/gimme/commands/gimme.js.map +1 -0
- package/dist/modules/gimme/index.d.ts +5 -0
- package/dist/modules/gimme/index.d.ts.map +1 -0
- package/dist/modules/gimme/index.js +75 -0
- package/dist/modules/gimme/index.js.map +1 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts +2 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts.map +1 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.js +59 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.js.map +1 -0
- package/dist/modules/highPingKicker/index.d.ts +5 -0
- package/dist/modules/highPingKicker/index.d.ts.map +1 -0
- package/dist/modules/highPingKicker/index.js +44 -0
- package/dist/modules/highPingKicker/index.js.map +1 -0
- package/dist/modules/lottery/commands/buyTicket.d.ts +2 -0
- package/dist/modules/lottery/commands/buyTicket.d.ts.map +1 -0
- package/dist/modules/lottery/commands/buyTicket.js +51 -0
- package/dist/modules/lottery/commands/buyTicket.js.map +1 -0
- package/dist/modules/lottery/commands/nextDraw.d.ts +2 -0
- package/dist/modules/lottery/commands/nextDraw.d.ts.map +1 -0
- package/dist/modules/lottery/commands/nextDraw.js +34 -0
- package/dist/modules/lottery/commands/nextDraw.js.map +1 -0
- package/dist/modules/lottery/commands/viewTickets.d.ts +2 -0
- package/dist/modules/lottery/commands/viewTickets.d.ts.map +1 -0
- package/dist/modules/lottery/commands/viewTickets.js +20 -0
- package/dist/modules/lottery/commands/viewTickets.js.map +1 -0
- package/dist/modules/lottery/cronJobs/drawLottery.d.ts +2 -0
- package/dist/modules/lottery/cronJobs/drawLottery.d.ts.map +1 -0
- package/dist/modules/lottery/cronJobs/drawLottery.js +96 -0
- package/dist/modules/lottery/cronJobs/drawLottery.js.map +1 -0
- package/dist/modules/lottery/index.d.ts +5 -0
- package/dist/modules/lottery/index.d.ts.map +1 -0
- package/dist/modules/lottery/index.js +85 -0
- package/dist/modules/lottery/index.js.map +1 -0
- package/dist/modules/playerOnboarding/commands/starterkit.d.ts +2 -0
- package/dist/modules/playerOnboarding/commands/starterkit.d.ts.map +1 -0
- package/dist/modules/playerOnboarding/commands/starterkit.js +47 -0
- package/dist/modules/playerOnboarding/commands/starterkit.js.map +1 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts +2 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts.map +1 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.js +11 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.js.map +1 -0
- package/dist/modules/playerOnboarding/index.d.ts +5 -0
- package/dist/modules/playerOnboarding/index.d.ts.map +1 -0
- package/dist/modules/playerOnboarding/index.js +83 -0
- package/dist/modules/playerOnboarding/index.js.map +1 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.d.ts +2 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.d.ts.map +1 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.js +41 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.js.map +1 -0
- package/dist/modules/serverMessages/index.d.ts +5 -0
- package/dist/modules/serverMessages/index.d.ts.map +1 -0
- package/dist/modules/serverMessages/index.js +45 -0
- package/dist/modules/serverMessages/index.js.map +1 -0
- package/dist/modules/teleports/commands/deletetp.d.ts +2 -0
- package/dist/modules/teleports/commands/deletetp.d.ts.map +1 -0
- package/dist/modules/teleports/commands/deletetp.js +20 -0
- package/dist/modules/teleports/commands/deletetp.js.map +1 -0
- package/dist/modules/teleports/commands/deletewaypoint.d.ts +2 -0
- package/dist/modules/teleports/commands/deletewaypoint.d.ts.map +1 -0
- package/dist/modules/teleports/commands/deletewaypoint.js +20 -0
- package/dist/modules/teleports/commands/deletewaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/listwaypoints.d.ts +2 -0
- package/dist/modules/teleports/commands/listwaypoints.d.ts.map +1 -0
- package/dist/modules/teleports/commands/listwaypoints.js +17 -0
- package/dist/modules/teleports/commands/listwaypoints.js.map +1 -0
- package/dist/modules/teleports/commands/setprivate.d.ts +2 -0
- package/dist/modules/teleports/commands/setprivate.d.ts.map +1 -0
- package/dist/modules/teleports/commands/setprivate.js +29 -0
- package/dist/modules/teleports/commands/setprivate.js.map +1 -0
- package/dist/modules/teleports/commands/setpublic.d.ts +2 -0
- package/dist/modules/teleports/commands/setpublic.d.ts.map +1 -0
- package/dist/modules/teleports/commands/setpublic.js +45 -0
- package/dist/modules/teleports/commands/setpublic.js.map +1 -0
- package/dist/modules/teleports/commands/settp.d.ts +2 -0
- package/dist/modules/teleports/commands/settp.d.ts.map +1 -0
- package/dist/modules/teleports/commands/settp.js +40 -0
- package/dist/modules/teleports/commands/settp.js.map +1 -0
- package/dist/modules/teleports/commands/setwaypoint.d.ts +2 -0
- package/dist/modules/teleports/commands/setwaypoint.d.ts.map +1 -0
- package/dist/modules/teleports/commands/setwaypoint.js +28 -0
- package/dist/modules/teleports/commands/setwaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/teleport.d.ts +2 -0
- package/dist/modules/teleports/commands/teleport.d.ts.map +1 -0
- package/dist/modules/teleports/commands/teleport.js +68 -0
- package/dist/modules/teleports/commands/teleport.js.map +1 -0
- package/dist/modules/teleports/commands/teleportwaypoint.d.ts +2 -0
- package/dist/modules/teleports/commands/teleportwaypoint.d.ts.map +1 -0
- package/dist/modules/teleports/commands/teleportwaypoint.js +43 -0
- package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/tplist.d.ts +2 -0
- package/dist/modules/teleports/commands/tplist.d.ts.map +1 -0
- package/dist/modules/teleports/commands/tplist.js +46 -0
- package/dist/modules/teleports/commands/tplist.js.map +1 -0
- package/dist/modules/teleports/cronJobs/Waypoint reconciler.d.ts +2 -0
- package/dist/modules/teleports/cronJobs/Waypoint reconciler.d.ts.map +1 -0
- package/dist/modules/teleports/cronJobs/Waypoint reconciler.js +6 -0
- package/dist/modules/teleports/cronJobs/Waypoint reconciler.js.map +1 -0
- package/dist/modules/teleports/functions/utils.d.ts +14 -0
- package/dist/modules/teleports/functions/utils.d.ts.map +1 -0
- package/dist/modules/teleports/functions/utils.js +156 -0
- package/dist/modules/teleports/functions/utils.js.map +1 -0
- package/dist/modules/teleports/index.d.ts +5 -0
- package/dist/modules/teleports/index.d.ts.map +1 -0
- package/dist/modules/teleports/index.js +208 -0
- package/dist/modules/teleports/index.js.map +1 -0
- package/dist/modules/timedShutdown/cronJobs/Shutdown.d.ts +2 -0
- package/dist/modules/timedShutdown/cronJobs/Shutdown.d.ts.map +1 -0
- package/dist/modules/timedShutdown/cronJobs/Shutdown.js +7 -0
- package/dist/modules/timedShutdown/cronJobs/Shutdown.js.map +1 -0
- package/dist/modules/timedShutdown/cronJobs/warning.d.ts +2 -0
- package/dist/modules/timedShutdown/cronJobs/warning.d.ts.map +1 -0
- package/dist/modules/timedShutdown/cronJobs/warning.js +10 -0
- package/dist/modules/timedShutdown/cronJobs/warning.js.map +1 -0
- package/dist/modules/timedShutdown/index.d.ts +5 -0
- package/dist/modules/timedShutdown/index.d.ts.map +1 -0
- package/dist/modules/timedShutdown/index.js +43 -0
- package/dist/modules/timedShutdown/index.js.map +1 -0
- package/dist/modules/utils/commands/help.d.ts +2 -0
- package/dist/modules/utils/commands/help.d.ts.map +1 -0
- package/dist/modules/utils/commands/help.js +84 -0
- package/dist/modules/utils/commands/help.js.map +1 -0
- package/dist/modules/utils/commands/ping.d.ts +2 -0
- package/dist/modules/utils/commands/ping.d.ts.map +1 -0
- package/dist/modules/utils/commands/ping.js +6 -0
- package/dist/modules/utils/commands/ping.js.map +1 -0
- package/dist/modules/utils/index.d.ts +5 -0
- package/dist/modules/utils/index.d.ts.map +1 -0
- package/dist/modules/utils/index.js +52 -0
- package/dist/modules/utils/index.js.map +1 -0
- package/dist/modules.json +757 -0
- package/package.json +17 -0
- package/scripts/buildBuiltinJson.ts +81 -0
- package/src/BuiltinModule.ts +159 -0
- package/src/__tests__/aliases.integration.test.ts +90 -0
- package/src/__tests__/bugRepros.integration.test.ts +485 -0
- package/src/__tests__/builtinmodule.unit.test.ts +15 -0
- package/src/__tests__/commandArgs.integration.test.ts +291 -0
- package/src/__tests__/crossServerPlayer.integration.test.ts +176 -0
- package/src/__tests__/economy/claim.integration.test.ts +250 -0
- package/src/__tests__/economy/economyUtils.integration.test.ts +495 -0
- package/src/__tests__/economy/shop.integration.test.ts +177 -0
- package/src/__tests__/economy/zombieKillReward.integration.test.ts +293 -0
- package/src/__tests__/geoblock.integration.test.ts +322 -0
- package/src/__tests__/gimme.integration.test.ts +106 -0
- package/src/__tests__/help.integration.test.ts +314 -0
- package/src/__tests__/highPingKicker.integration.test.ts +618 -0
- package/src/__tests__/lottery.integration.test.ts +344 -0
- package/src/__tests__/modulePermission.integration.test.ts +387 -0
- package/src/__tests__/onboarding.integration.test.ts +122 -0
- package/src/__tests__/ping.integration.test.ts +36 -0
- package/src/__tests__/roleExpiry.integration.test.ts +78 -0
- package/src/__tests__/serverMessages.integration.test.ts +116 -0
- package/src/__tests__/systemConfigCooldown.integration.test.ts +84 -0
- package/src/__tests__/systemConfigCost.integration.test.ts +194 -0
- package/src/__tests__/teleports/listtp.integration.test.ts +189 -0
- package/src/__tests__/teleports/publicteleports.integration.test.ts +345 -0
- package/src/__tests__/teleports/teleport.integration.test.ts +153 -0
- package/src/__tests__/teleports/tpManagement.integration.test.ts +175 -0
- package/src/__tests__/teleports/waypoints.integration.test.ts +832 -0
- package/src/community-modules/README.md +5 -0
- package/src/community-modules/modules/vote.json +19 -0
- package/src/dto/base.ts +13 -0
- package/src/dto/discordEvents.ts +69 -0
- package/src/dto/gameEvents.ts +159 -0
- package/src/dto/index.ts +25 -0
- package/src/dto/takaroEvents.ts +525 -0
- package/src/main.ts +47 -0
- package/src/modules/.eslintrc +5 -0
- package/src/modules/chatBridge/hooks/DiscordToGame.js +18 -0
- package/src/modules/chatBridge/hooks/GameToDiscord.js +18 -0
- package/src/modules/chatBridge/hooks/PlayerConnected.js +11 -0
- package/src/modules/chatBridge/hooks/PlayerDisconnected.js +11 -0
- package/src/modules/chatBridge/index.ts +64 -0
- package/src/modules/dailyRewards/commands/daily.js +114 -0
- package/src/modules/dailyRewards/commands/streak.js +42 -0
- package/src/modules/dailyRewards/commands/topstreak.js +54 -0
- package/src/modules/dailyRewards/functions/utils.js +36 -0
- package/src/modules/dailyRewards/hooks/dailyLoginCheck.js +24 -0
- package/src/modules/dailyRewards/index.ts +138 -0
- package/src/modules/economyUtils/commands/balance.js +8 -0
- package/src/modules/economyUtils/commands/claim.js +42 -0
- package/src/modules/economyUtils/commands/confirmTransfer.js +55 -0
- package/src/modules/economyUtils/commands/grantCurrency.js +34 -0
- package/src/modules/economyUtils/commands/revokeCurrency.js +34 -0
- package/src/modules/economyUtils/commands/shop.js +87 -0
- package/src/modules/economyUtils/commands/topCurrency.js +29 -0
- package/src/modules/economyUtils/commands/transfer.js +73 -0
- package/src/modules/economyUtils/cronJobs/zombieKillReward.js +82 -0
- package/src/modules/economyUtils/index.ts +197 -0
- package/src/modules/geoBlock/hooks/IPDetected.js +53 -0
- package/src/modules/geoBlock/index.ts +333 -0
- package/src/modules/gimme/commands/gimme.js +30 -0
- package/src/modules/gimme/index.ts +76 -0
- package/src/modules/highPingKicker/cronJobs/Ping check.js +68 -0
- package/src/modules/highPingKicker/index.ts +44 -0
- package/src/modules/lottery/commands/buyTicket.js +64 -0
- package/src/modules/lottery/commands/nextDraw.js +47 -0
- package/src/modules/lottery/commands/viewTickets.js +28 -0
- package/src/modules/lottery/cronJobs/drawLottery.js +124 -0
- package/src/modules/lottery/index.ts +86 -0
- package/src/modules/playerOnboarding/commands/starterkit.js +61 -0
- package/src/modules/playerOnboarding/hooks/playerConnected.js +14 -0
- package/src/modules/playerOnboarding/index.ts +86 -0
- package/src/modules/serverMessages/cronJobs/Automated message.js +47 -0
- package/src/modules/serverMessages/index.ts +46 -0
- package/src/modules/teleports/commands/deletetp.js +25 -0
- package/src/modules/teleports/commands/deletewaypoint.js +24 -0
- package/src/modules/teleports/commands/listwaypoints.js +23 -0
- package/src/modules/teleports/commands/setprivate.js +39 -0
- package/src/modules/teleports/commands/setpublic.js +60 -0
- package/src/modules/teleports/commands/settp.js +50 -0
- package/src/modules/teleports/commands/setwaypoint.js +31 -0
- package/src/modules/teleports/commands/teleport.js +84 -0
- package/src/modules/teleports/commands/teleportwaypoint.js +57 -0
- package/src/modules/teleports/commands/tplist.js +62 -0
- package/src/modules/teleports/cronJobs/Waypoint reconciler.js +7 -0
- package/src/modules/teleports/functions/utils.js +189 -0
- package/src/modules/teleports/index.ts +217 -0
- package/src/modules/timedShutdown/cronJobs/Shutdown.js +8 -0
- package/src/modules/timedShutdown/cronJobs/warning.js +13 -0
- package/src/modules/timedShutdown/index.ts +45 -0
- package/src/modules/utils/commands/help.js +100 -0
- package/src/modules/utils/commands/ping.js +7 -0
- package/src/modules/utils/index.ts +53 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +9 -0
- package/typedoc.json +3 -0
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
2
|
+
import { GameEvents, HookEvents } from '../dto/index.js';
|
|
3
|
+
import { EventChatMessageChannelEnum } from '@takaro/apiclient';
|
|
4
|
+
import { randomUUID } from 'crypto';
|
|
5
|
+
import { describe } from 'node:test';
|
|
6
|
+
|
|
7
|
+
const group = 'Bug repros';
|
|
8
|
+
|
|
9
|
+
const tests = [
|
|
10
|
+
new IntegrationTest<IModuleTestsSetupData>({
|
|
11
|
+
group,
|
|
12
|
+
snapshot: false,
|
|
13
|
+
name: 'Bug repro: can trigger 2 hooks for the same event inside a single module',
|
|
14
|
+
setup: modulesTestSetup,
|
|
15
|
+
test: async function () {
|
|
16
|
+
const genFn = (param: string) => {
|
|
17
|
+
return `import { data, takaro } from '@takaro/helpers';
|
|
18
|
+
async function main() {
|
|
19
|
+
const { player } = data;
|
|
20
|
+
await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {
|
|
21
|
+
message: '${param} hook',
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
await main();`;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const mod = (
|
|
28
|
+
await this.client.module.moduleControllerCreate({
|
|
29
|
+
name: 'Test module',
|
|
30
|
+
})
|
|
31
|
+
).data.data;
|
|
32
|
+
// Add the buggy hooks
|
|
33
|
+
await this.client.hook.hookControllerCreate({
|
|
34
|
+
name: 'Test hook 1',
|
|
35
|
+
versionId: mod.latestVersion.id,
|
|
36
|
+
regex: 'test msg',
|
|
37
|
+
eventType: 'chat-message',
|
|
38
|
+
function: genFn('First'),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
await this.client.hook.hookControllerCreate({
|
|
42
|
+
name: 'Test hook 2',
|
|
43
|
+
versionId: mod.latestVersion.id,
|
|
44
|
+
regex: 'test msg',
|
|
45
|
+
eventType: 'chat-message',
|
|
46
|
+
function: genFn('Second'),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
await this.client.module.moduleInstallationsControllerInstallModule({
|
|
50
|
+
gameServerId: this.setupData.gameserver.id,
|
|
51
|
+
versionId: mod.latestVersion.id,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
55
|
+
|
|
56
|
+
await this.client.hook.hookControllerTrigger({
|
|
57
|
+
eventType: 'chat-message',
|
|
58
|
+
gameServerId: this.setupData.gameserver.id,
|
|
59
|
+
moduleId: mod.id,
|
|
60
|
+
playerId: this.setupData.players[0].id,
|
|
61
|
+
eventMeta: {
|
|
62
|
+
msg: 'test msg',
|
|
63
|
+
channel: EventChatMessageChannelEnum.Global,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect((await events).length).to.be.eq(2);
|
|
68
|
+
expect((await events).map((e) => e.data.meta.msg)).to.include.members(['First hook', 'Second hook']);
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
// Before, the event "hook-executed" would not have the correct result logs saved
|
|
72
|
+
// The TakaroDTO validation was rejecting it because "not a string"
|
|
73
|
+
// `An instance of TakaroEventHookExecuted has failed the validation:\n - property result.logs[1].msg has failed the following constraints: isString \n - property result.logs[2].msg has failed the following constraints: isString \n"`
|
|
74
|
+
new IntegrationTest<IModuleTestsSetupData>({
|
|
75
|
+
group,
|
|
76
|
+
snapshot: false,
|
|
77
|
+
name: 'Bug repro: console.log in a function works with objects',
|
|
78
|
+
setup: modulesTestSetup,
|
|
79
|
+
test: async function () {
|
|
80
|
+
const mod = (
|
|
81
|
+
await this.client.module.moduleControllerCreate({
|
|
82
|
+
name: 'Test module',
|
|
83
|
+
})
|
|
84
|
+
).data.data;
|
|
85
|
+
await this.client.hook.hookControllerCreate({
|
|
86
|
+
name: 'Test hook 1',
|
|
87
|
+
versionId: mod.latestVersion.id,
|
|
88
|
+
regex: 'test msg',
|
|
89
|
+
eventType: 'chat-message',
|
|
90
|
+
function: `import { data, takaro } from '@takaro/helpers';
|
|
91
|
+
async function main() {
|
|
92
|
+
console.log("foo");
|
|
93
|
+
console.log({ foo: "bar" });
|
|
94
|
+
console.log(["baz", 1]);
|
|
95
|
+
}
|
|
96
|
+
await main();`,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
await this.client.module.moduleInstallationsControllerInstallModule({
|
|
100
|
+
gameServerId: this.setupData.gameserver.id,
|
|
101
|
+
versionId: mod.latestVersion.id,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const listener = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.HOOK_EXECUTED, 1);
|
|
105
|
+
|
|
106
|
+
await this.client.hook.hookControllerTrigger({
|
|
107
|
+
eventType: 'chat-message',
|
|
108
|
+
gameServerId: this.setupData.gameserver.id,
|
|
109
|
+
moduleId: mod.id,
|
|
110
|
+
playerId: this.setupData.players[0].id,
|
|
111
|
+
eventMeta: {
|
|
112
|
+
msg: 'test msg',
|
|
113
|
+
channel: EventChatMessageChannelEnum.Global,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const result = (await listener)[0].data.meta.result;
|
|
118
|
+
expect(result.success).to.be.true;
|
|
119
|
+
const logs = result.logs;
|
|
120
|
+
const msgs = logs.map((l: any) => l.msg);
|
|
121
|
+
expect(msgs).to.include.members(['foo', JSON.stringify({ foo: 'bar' }), JSON.stringify(['baz', 1])]);
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
/**
|
|
125
|
+
* Repro for `console.log`ging `undefined`
|
|
126
|
+
*/
|
|
127
|
+
new IntegrationTest<IModuleTestsSetupData>({
|
|
128
|
+
group,
|
|
129
|
+
snapshot: false,
|
|
130
|
+
name: 'Bug repro: console.log in a function works with undefined and null objects',
|
|
131
|
+
setup: modulesTestSetup,
|
|
132
|
+
test: async function () {
|
|
133
|
+
const mod = (
|
|
134
|
+
await this.client.module.moduleControllerCreate({
|
|
135
|
+
name: 'Test module',
|
|
136
|
+
})
|
|
137
|
+
).data.data;
|
|
138
|
+
await this.client.hook.hookControllerCreate({
|
|
139
|
+
name: 'Test hook 1',
|
|
140
|
+
versionId: mod.latestVersion.id,
|
|
141
|
+
regex: 'test msg',
|
|
142
|
+
eventType: 'chat-message',
|
|
143
|
+
function: `import { data, takaro } from '@takaro/helpers';
|
|
144
|
+
async function main() {
|
|
145
|
+
console.log(undefined);
|
|
146
|
+
console.log(null);
|
|
147
|
+
}
|
|
148
|
+
await main();`,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
await this.client.module.moduleInstallationsControllerInstallModule({
|
|
152
|
+
gameServerId: this.setupData.gameserver.id,
|
|
153
|
+
versionId: mod.latestVersion.id,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const listener = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.HOOK_EXECUTED, 1);
|
|
157
|
+
|
|
158
|
+
await this.client.hook.hookControllerTrigger({
|
|
159
|
+
eventType: 'chat-message',
|
|
160
|
+
gameServerId: this.setupData.gameserver.id,
|
|
161
|
+
moduleId: mod.id,
|
|
162
|
+
playerId: this.setupData.players[0].id,
|
|
163
|
+
eventMeta: {
|
|
164
|
+
msg: 'test msg',
|
|
165
|
+
channel: EventChatMessageChannelEnum.Global,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const result = (await listener)[0].data.meta.result;
|
|
170
|
+
expect(result.success).to.be.true;
|
|
171
|
+
const logs = result.logs;
|
|
172
|
+
const msgs = logs.map((l: any) => l.msg);
|
|
173
|
+
expect(msgs[0]).to.be.eq('undefined');
|
|
174
|
+
expect(msgs[1]).to.be.eq('null');
|
|
175
|
+
},
|
|
176
|
+
}),
|
|
177
|
+
/**
|
|
178
|
+
* Repro for https://github.com/gettakaro/takaro/issues/1047
|
|
179
|
+
* System config uses the names of functions to create structure
|
|
180
|
+
* If a module is installed, and you then rename the function, the system config will be broken
|
|
181
|
+
*/
|
|
182
|
+
new IntegrationTest<IModuleTestsSetupData>({
|
|
183
|
+
group,
|
|
184
|
+
snapshot: false,
|
|
185
|
+
name: 'Bug repro: renaming functions breaks system config #1047',
|
|
186
|
+
setup: modulesTestSetup,
|
|
187
|
+
test: async function () {
|
|
188
|
+
const mod = (
|
|
189
|
+
await this.client.module.moduleControllerCreate({
|
|
190
|
+
name: 'Test module',
|
|
191
|
+
})
|
|
192
|
+
).data.data;
|
|
193
|
+
const createdCommand = await this.client.command.commandControllerCreate({
|
|
194
|
+
name: 'testcmd',
|
|
195
|
+
versionId: mod.latestVersion.id,
|
|
196
|
+
trigger: 'testpong',
|
|
197
|
+
function: `import { data, takaro } from '@takaro/helpers';
|
|
198
|
+
async function main() {
|
|
199
|
+
const { player } = data;
|
|
200
|
+
await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {
|
|
201
|
+
message: 'pong',
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
await main();`,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
await this.client.module.moduleInstallationsControllerInstallModule({
|
|
208
|
+
gameServerId: this.setupData.gameserver.id,
|
|
209
|
+
versionId: mod.latestVersion.id,
|
|
210
|
+
userConfig: JSON.stringify({}),
|
|
211
|
+
systemConfig: JSON.stringify({ commands: { testcmd: { aliases: ['foobar'] } } }),
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
215
|
+
|
|
216
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
217
|
+
msg: '/foobar',
|
|
218
|
+
playerId: this.setupData.players[0].id,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
expect((await events).length).to.be.eq(1);
|
|
222
|
+
expect((await events)[0].data.meta.msg).to.be.eq('pong');
|
|
223
|
+
|
|
224
|
+
// Rename the function
|
|
225
|
+
await this.client.command.commandControllerUpdate(createdCommand.data.data.id, { name: 'testcmd2' });
|
|
226
|
+
|
|
227
|
+
const eventsAfter = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
228
|
+
|
|
229
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
230
|
+
msg: '/foobar',
|
|
231
|
+
playerId: this.setupData.players[0].id,
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
expect((await eventsAfter).length).to.be.eq(1);
|
|
235
|
+
expect((await eventsAfter)[0].data.meta.msg).to.be.eq('pong');
|
|
236
|
+
},
|
|
237
|
+
}),
|
|
238
|
+
/**
|
|
239
|
+
* Repro for https://github.com/gettakaro/takaro/issues/1405
|
|
240
|
+
* When providing invalid code, Takaro trips over itself and throws a nasty error
|
|
241
|
+
* Instead, it should catch it properly and return an actionable message for the user
|
|
242
|
+
*/
|
|
243
|
+
new IntegrationTest<IModuleTestsSetupData>({
|
|
244
|
+
group,
|
|
245
|
+
snapshot: false,
|
|
246
|
+
name: 'Bug repro: invalid module code throws bad error #1405',
|
|
247
|
+
setup: modulesTestSetup,
|
|
248
|
+
test: async function () {
|
|
249
|
+
const mod = (
|
|
250
|
+
await this.client.module.moduleControllerCreate({
|
|
251
|
+
name: 'Test module',
|
|
252
|
+
})
|
|
253
|
+
).data.data;
|
|
254
|
+
await this.client.command.commandControllerCreate({
|
|
255
|
+
name: 'testcmd',
|
|
256
|
+
versionId: mod.latestVersion.id,
|
|
257
|
+
trigger: 'test',
|
|
258
|
+
// Yes, very bad code! This is what a user might accidentally do
|
|
259
|
+
function: `import { data, takaro } from '@takaro/helpers';
|
|
260
|
+
|
|
261
|
+
const messed = (await takaro.variable.variableControllerSearch({ search: { key: [\`object Object\`] } })).data.data
|
|
262
|
+
for (const thisVar of messed) {
|
|
263
|
+
let originalString = thisVar.key;
|
|
264
|
+
let newString = originalString.replace("[object Object]", "2024-09-20");
|
|
265
|
+
|
|
266
|
+
await takaro.variable.variableControllerUpdate(thisVar.id, { key: newString, value: thisVar.value });
|
|
267
|
+
|
|
268
|
+
}
|
|
269
|
+
data.player.pm(\`done\`).
|
|
270
|
+
`,
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
await this.client.module.moduleInstallationsControllerInstallModule({
|
|
274
|
+
gameServerId: this.setupData.gameserver.id,
|
|
275
|
+
versionId: mod.latestVersion.id,
|
|
276
|
+
userConfig: JSON.stringify({}),
|
|
277
|
+
systemConfig: JSON.stringify({}),
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.COMMAND_EXECUTED, 1);
|
|
281
|
+
|
|
282
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
283
|
+
msg: '/test',
|
|
284
|
+
playerId: this.setupData.players[0].id,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const result = (await events)[0].data.meta.result;
|
|
288
|
+
expect(result.success).to.be.false;
|
|
289
|
+
expect(result.reason).to.include('SyntaxError: Unexpected end of input.');
|
|
290
|
+
},
|
|
291
|
+
}),
|
|
292
|
+
/**
|
|
293
|
+
* Create a module with a version and command that returns a 'hello world' message and tag it
|
|
294
|
+
* Install the module and trigger the command
|
|
295
|
+
* Then, edit the command so it returns a 'goodbye world' message and tag the module again
|
|
296
|
+
* Trigger the command again and check if the message is 'goodbye world' *
|
|
297
|
+
*/
|
|
298
|
+
new IntegrationTest<IModuleTestsSetupData>({
|
|
299
|
+
group,
|
|
300
|
+
snapshot: false,
|
|
301
|
+
name: 'Bug repro: command code not updated after tag change',
|
|
302
|
+
setup: modulesTestSetup,
|
|
303
|
+
test: async function () {
|
|
304
|
+
const mod = (
|
|
305
|
+
await this.client.module.moduleControllerCreate({
|
|
306
|
+
name: 'Test module',
|
|
307
|
+
})
|
|
308
|
+
).data.data;
|
|
309
|
+
const createdCommand = await this.client.command.commandControllerCreate({
|
|
310
|
+
name: 'testcmd',
|
|
311
|
+
versionId: mod.latestVersion.id,
|
|
312
|
+
trigger: 'test',
|
|
313
|
+
function: `import { data, takaro } from '@takaro/helpers';
|
|
314
|
+
async function main() {
|
|
315
|
+
const { player } = data;
|
|
316
|
+
await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {
|
|
317
|
+
message: 'hello world',
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
await main();`,
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
const tagRes1 = await this.client.module.moduleVersionControllerTagVersion({
|
|
324
|
+
moduleId: mod.id,
|
|
325
|
+
tag: '0.0.1',
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
await this.client.module.moduleInstallationsControllerInstallModule({
|
|
329
|
+
gameServerId: this.setupData.gameserver.id,
|
|
330
|
+
versionId: tagRes1.data.data.id,
|
|
331
|
+
userConfig: JSON.stringify({}),
|
|
332
|
+
systemConfig: JSON.stringify({}),
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
336
|
+
|
|
337
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
338
|
+
msg: '/test',
|
|
339
|
+
playerId: this.setupData.players[0].id,
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
expect((await events).length).to.be.eq(1);
|
|
343
|
+
expect((await events)[0].data.meta.msg).to.be.eq('hello world');
|
|
344
|
+
|
|
345
|
+
// Update the command
|
|
346
|
+
await this.client.command.commandControllerUpdate(createdCommand.data.data.id, {
|
|
347
|
+
function: `import { data, takaro } from '@takaro/helpers';
|
|
348
|
+
async function main() {
|
|
349
|
+
const { player } = data;
|
|
350
|
+
await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {
|
|
351
|
+
message: 'goodbye world',
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
await main();`,
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
const tagRes2 = await this.client.module.moduleVersionControllerTagVersion({
|
|
358
|
+
moduleId: mod.id,
|
|
359
|
+
tag: '0.0.2',
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
await this.client.module.moduleInstallationsControllerInstallModule({
|
|
363
|
+
gameServerId: this.setupData.gameserver.id,
|
|
364
|
+
versionId: tagRes2.data.data.id,
|
|
365
|
+
userConfig: JSON.stringify({}),
|
|
366
|
+
systemConfig: JSON.stringify({}),
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
const eventsAfter = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
370
|
+
|
|
371
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
372
|
+
msg: '/test',
|
|
373
|
+
playerId: this.setupData.players[0].id,
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
expect((await eventsAfter).length).to.be.eq(1);
|
|
377
|
+
expect((await eventsAfter)[0].data.meta.msg).to.be.eq('goodbye world');
|
|
378
|
+
},
|
|
379
|
+
}),
|
|
380
|
+
new IntegrationTest<IModuleTestsSetupData>({
|
|
381
|
+
group,
|
|
382
|
+
snapshot: false,
|
|
383
|
+
name: 'Bug repro: permissions from old module versions cleanly transfer when upgrading',
|
|
384
|
+
setup: modulesTestSetup,
|
|
385
|
+
/**
|
|
386
|
+
* Scenario:
|
|
387
|
+
* Module with PermA, v0.0.1 is installed
|
|
388
|
+
* User then tags v0.0.2 and installs this
|
|
389
|
+
* Players with permA can still use the module function that requires that permission
|
|
390
|
+
*/
|
|
391
|
+
test: async function () {
|
|
392
|
+
const permission = 'USE_TEST_PERMISSION';
|
|
393
|
+
const module = (
|
|
394
|
+
await this.client.module.moduleControllerCreate({
|
|
395
|
+
name: randomUUID(),
|
|
396
|
+
latestVersion: {
|
|
397
|
+
permissions: [{ permission, canHaveCount: false, friendlyName: 'test', description: 'blabla test' }],
|
|
398
|
+
},
|
|
399
|
+
})
|
|
400
|
+
).data.data;
|
|
401
|
+
|
|
402
|
+
await this.client.command.commandControllerCreate({
|
|
403
|
+
name: 'test',
|
|
404
|
+
versionId: module.latestVersion.id,
|
|
405
|
+
trigger: 'test',
|
|
406
|
+
function: `import { data, takaro, checkPermission } from '@takaro/helpers';
|
|
407
|
+
async function main() {
|
|
408
|
+
const { player, pog } = data;
|
|
409
|
+
|
|
410
|
+
if (!checkPermission(pog, '${permission}')) {
|
|
411
|
+
await takaro.gameserver.gameServerControllerSendMessage('${this.setupData.gameserver.id}', {
|
|
412
|
+
message: 'no permission',
|
|
413
|
+
});
|
|
414
|
+
} else {
|
|
415
|
+
await takaro.gameserver.gameServerControllerSendMessage('${this.setupData.gameserver.id}', {
|
|
416
|
+
message: 'yes permission',
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
}
|
|
421
|
+
await main();`,
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// Create version 0.0.1
|
|
425
|
+
const v1 = (
|
|
426
|
+
await this.client.module.moduleVersionControllerTagVersion({
|
|
427
|
+
moduleId: module.id,
|
|
428
|
+
tag: '0.0.1',
|
|
429
|
+
})
|
|
430
|
+
).data.data;
|
|
431
|
+
|
|
432
|
+
// Install this version
|
|
433
|
+
await this.client.module.moduleInstallationsControllerInstallModule({
|
|
434
|
+
gameServerId: this.setupData.gameserver.id,
|
|
435
|
+
versionId: v1.id,
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
// Create a role with the permission
|
|
439
|
+
const permissionCode = await this.client.permissionCodesToInputs([permission]);
|
|
440
|
+
const role = (await this.client.role.roleControllerCreate({ name: 'testing role', permissions: permissionCode }))
|
|
441
|
+
.data.data;
|
|
442
|
+
|
|
443
|
+
// Assign the role to a player
|
|
444
|
+
await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, role.id);
|
|
445
|
+
|
|
446
|
+
// Firing the command should return 'yes permission'
|
|
447
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
448
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
449
|
+
msg: '/test',
|
|
450
|
+
playerId: this.setupData.players[0].id,
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
expect((await events)[0].data.meta.msg).to.be.eq('yes permission');
|
|
454
|
+
|
|
455
|
+
// Tag a new version
|
|
456
|
+
const v2 = (
|
|
457
|
+
await this.client.module.moduleVersionControllerTagVersion({
|
|
458
|
+
moduleId: module.id,
|
|
459
|
+
tag: '0.0.2',
|
|
460
|
+
})
|
|
461
|
+
).data.data;
|
|
462
|
+
|
|
463
|
+
// Install this version
|
|
464
|
+
await this.client.module.moduleInstallationsControllerInstallModule({
|
|
465
|
+
gameServerId: this.setupData.gameserver.id,
|
|
466
|
+
versionId: v2.id,
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
// Firing the command should return 'yes permission'
|
|
470
|
+
const eventsAfter = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
471
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
472
|
+
msg: '/test',
|
|
473
|
+
playerId: this.setupData.players[0].id,
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
expect((await eventsAfter)[0].data.meta.msg).to.be.eq('yes permission');
|
|
477
|
+
},
|
|
478
|
+
}),
|
|
479
|
+
];
|
|
480
|
+
|
|
481
|
+
describe(group, function () {
|
|
482
|
+
tests.forEach((test) => {
|
|
483
|
+
test.run();
|
|
484
|
+
});
|
|
485
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { expect } from '@takaro/test';
|
|
2
|
+
import { getModules } from '../main.js';
|
|
3
|
+
import { describe, it } from 'node:test';
|
|
4
|
+
|
|
5
|
+
describe('BuiltInModule', () => {
|
|
6
|
+
it('Can load module items', async () => {
|
|
7
|
+
const mods = await getModules();
|
|
8
|
+
|
|
9
|
+
const utilsModule = mods.find((mod) => mod.name === 'utils');
|
|
10
|
+
|
|
11
|
+
expect(utilsModule).to.not.be.undefined;
|
|
12
|
+
expect(utilsModule?.versions).to.have.length(1);
|
|
13
|
+
expect(utilsModule?.versions[0].commands).to.have.length(2);
|
|
14
|
+
});
|
|
15
|
+
});
|