aboutsummaryrefslogtreecommitdiff
path: root/util/updater.js
blob: ea8fa2c5371fd7c858eb215584c489b0f461b3d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import axios from "../../axios"
import constants from "./constants"

const PREFIX = constants.PREFIX,
 VERSION = constants.VERSION

register("worldLoad", () => {
    axios.get(`https://chattriggers.com/api/modules/1367`)
    .then(res => {
        let ctVersionArray = (res.data.releases[0].releaseVersion).split('.'),
         currentVersionArray = VERSION.split('.'),
         newVersion = false

        for(let i = ctVersionArray.length; i >= 0; i--)
        {
            if (ctVersionArray[i] > currentVersionArray[i])
                newVersion = true
            else if (currentVersionArray[i] > ctVersionArray[i])
                newVersion = false
        }

        if(newVersion)
        {
            ChatLib.chat(`${PREFIX}&eYou are using an unsupported version of Coleweight!`)
            new TextComponent(`${PREFIX}&eClick &3here&e to update!`)
            .setClickAction("run_command")
            .setClickValue(`/ct load`)
            .chat()
            ChatLib.chat("")
        }
    })
    
})

export default ""