thecatcore / Fabric---Discord-Link

MIT License
75 stars 31 forks source link

Uptime is not calculated correctly when using webhooks #135

Closed kwvanderlinde closed 3 years ago

kwvanderlinde commented 3 years ago

Describe the bug When using webhooks, the server uptime is a large negative value. E.g., "-18 day(s), 0 hour(s), -13 minute(s) and -24 second(s)"

Reproduction steps

  1. Set a webhook URL in fdlink.json.
  2. Make sure the botActivities in messages.json to ["Uptime: %uptime_D day(s), %uptime_H hour(s), %uptime_M minute(s) and %uptime_S second(s)"].
  3. Start the server.
  4. Check the bot activity for uptime.

Expected behaviour The correct, positive uptime should be displayed. E.g., shortly after starting the server, it could look like "0 day(s), 0 hour(s), 0 minute(s) and 40 second(s)"

Additional context

fdlink.json

{
  "chatChannels": [
    "<<channel ID>>"
  ],
  "logChannels": [
    "<<channel ID>>"
  ],
  "webhookURL": "<<webhook URL>>",
  "ignoreBots": true,
  "activityUpdateInterval": 120,
  "minecraftToDiscord": {
    "general": {
      "enableDebugLogs": false
    },
    "chatChannels": {
      "commandPrefix": "-",
      "allowDiscordCommands": false,
      "serverStartingMessage": false,
      "serverStartMessage": true,
      "serverStopMessage": false,
      "serverStoppingMessage": true,
      "customChannelDescription": true,
      "minecraftToDiscordTag": true,
      "minecraftToDiscordDiscriminator": false,
      "playerMessages": true,
      "teamPlayerMessages": true,
      "joinAndLeaveMessages": true,
      "advancementMessages": true,
      "challengeMessages": true,
      "goalMessages": true,
      "deathMessages": true,
      "sendMeCommand": true,
      "sendSayCommand": true,
      "adminMessages": false,
      "atATellRaw": true,
      "achievementMessages": true
    },
    "logChannels": {
      "serverStartingMessage": true,
      "serverStartMessage": true,
      "serverStopMessage": true,
      "serverStoppingMessage": true,
      "customChannelDescription": true,
      "minecraftToDiscordTag": true,
      "minecraftToDiscordDiscriminator": false,
      "playerMessages": true,
      "teamPlayerMessages": false,
      "joinAndLeaveMessages": true,
      "advancementMessages": true,
      "challengeMessages": true,
      "goalMessages": true,
      "deathMessages": true,
      "sendMeCommand": true,
      "sendSayCommand": true,
      "adminMessages": true,
      "atATellRaw": true,
      "achievementMessages": true
    }
  },
  "discordToMinecraft": {
    "pingLongVersion": false
  },
  "emojiMap": [
    {
      "name": "example_name",
      "id": ":example_id:22222222"
    },
    {
      "name": "example_name2",
      "id": ":example_id2:22222222"
    }
  ],
  "version": 8,
  "token": "<<bot token>>"
}