Commit e482ed5 1 parent 8b5f443 commit e482ed5 Copy full SHA for e482ed5
File tree 4 files changed +87
-0
lines changed
4 files changed +87
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : discord publish to store.nanos.world
2
+
3
+ on :
4
+ release :
5
+ types : [published]
6
+
7
+ jobs :
8
+ build :
9
+ runs-on : ubuntu-latest
10
+ name : Publish package
11
+ steps :
12
+ - uses : actions/checkout@v2
13
+ - name : Nanos Store Action
14
+ uses : nanos-world/nanos-store-action@v1.0
15
+ with :
16
+ # folder which contains the asset/package - if it's on root, leave it blank
17
+ folder : ' '
18
+ # name of the asset/package
19
+ name : ' discord'
20
+ # changelog of the release - can be edited on the store before it gets published
21
+ changelog : ' built through actions'
22
+ # API token - generate at https://store.nanos.world/settings/tokens/ and set under Settings -> Secrets -> Actions with name STORE_SECRET
23
+ token : ${{ secrets.STORE_SECRET }}
Original file line number Diff line number Diff line change
1
+ # package configurations
2
+ [package ]
3
+ # package name
4
+ name = " discord"
5
+ # contributors
6
+ author = " SyedMuhammad"
7
+ # version
8
+ version = " 0.0.1"
9
+ # image URL
10
+ image = " "
11
+ # package type: 'script' (normal package), 'game-mode' (unique package - can only load one at a time) or 'loading-screen' (special package loaded in loading screen)
12
+ type = " script"
13
+ # whether to force the custom map Script to do not load
14
+ force_no_map_script = false
15
+ # auto destroy all entities spawned by this package when it unloads
16
+ auto_cleanup = true
17
+ # packages requirements
18
+ packages_requirements = [
19
+
20
+ ]
21
+ # asset packs requirements
22
+ assets_requirements = [
23
+
24
+ ]
Original file line number Diff line number Diff line change
1
+ DISCORD_WEBOOK_TOKEN = " "
2
+ DISCORD_WEBOOK_ID = " "
Original file line number Diff line number Diff line change
1
+ PERSISTENT_DATA = Package .GetPersistentData ()
2
+
3
+ -- Parses Configuration
4
+ DISCORD_WEBOOK_ID = PERSISTENT_DATA .DISCORD_WEBOOK_ID
5
+ DISCORD_WEBOOK_TOKEN = PERSISTENT_DATA .DISCORD_WEBOOK_TOKEN
6
+
7
+ -- Verify Configuration
8
+ if (not DISCORD_WEBOOK_ID or not DISCORD_WEBOOK_TOKEN or DISCORD_WEBOOK_ID == " " or DISCORD_WEBOOK_TOKEN == " " ) then
9
+ Package .Error (" Failed loading Discord Webhook ID or Token" )
10
+ return
11
+ end
12
+
13
+ -- Send Message method
14
+ function SendDiscordMessage (message )
15
+ HTTP .Request (
16
+ " https://discord.com" ,
17
+ " /api/webhooks/" .. DISCORD_WEBOOK_ID .. " /" .. DISCORD_WEBOOK_TOKEN ,
18
+ " POST" ,
19
+ ' {"content": "' .. message .. ' "}'
20
+ )
21
+ end
22
+
23
+ -- Events intercept to print on Discord
24
+ Server .Subscribe (" Chat" , function (text , player )
25
+ SendDiscordMessage (" **" .. player :GetName () .. " **: " .. text )
26
+ end )
27
+
28
+ Player .Subscribe (" Spawn" , function (player )
29
+ SendDiscordMessage (player :GetName () .. " has joined the server" )
30
+ end )
31
+
32
+ Player .Subscribe (" Destroy" , function (player )
33
+ SendDiscordMessage (player :GetName () .. " has left the server" )
34
+ end )
35
+
36
+ -- Output Success
37
+ Package .Log (" Loaded Discord Configuration successfuly." )
38
+ SendDiscordMessage (" Server started!" )
You can’t perform that action at this time.
0 commit comments