This Node.js module returns information about the in-game time and weather in GTA Online lobbies for any given time. It's intended to be used in Discord bots, but could be used in any Node.js environment.
Special thanks to Pardonias
Example use in a Discord.js bot with gtaweather.js
placed next to the main .js file:
const Discord = require("discord.js");
const GTAWeather = require("./gtaweather");
const client = new Discord.Client();
client.on('message', msg => {
if (msg.content.toLowerCase() == "!gtaweather") {
// Getting current weather
var weather = null;
try {
weather = GTAWeather.GetForecast();
} catch (err) {
msg.channel.send("An error has occured: " + err.message);
}
// Constructing response
msg.channel.send(
weather.description + "\n" +
"In-game time: " + weather.gameTimeStr + "\n" +
"Current weather: " + weather.currentWeatherDescription + " " + weather.currentWeatherEmoji + "\n" +
(weather.isRaining ? "Rain is expected to stop in " : "Rain is expected in ") + weather.rainEtaStr
);
}
});
client.login('token');
function GetForecast(targetDate?: Date): GTAWeatherState
Returns the current in-game time and weather in GTA Online. Can throw an
Error
object on error.
targetDate
is the time the forecast will be given for (if omitted, the current time is used)See the structure of the returned object below.
description
(string) - Describes the time/date the forecast is forthumbnailURL
(string) - URL to a thumbnail picture showing the weathergameTimeHrs
(number) - In-game time as the number of hours [0.0, 24.0)gameTimeStr
(string) - In-game time, formatted as HH:MM (24-hour)currentWeatherEmoji
(string) - Emoji showing the weathercurrentWeatherDescription
(string) - Name of the weather conditionrainEtaSec
(number) - Time until it starts/stops raining, in seconds (seeisRaining
)rainEtaStr
(string) - Time until it starts/stops raining, as a human-readable string (seeisRaining
)isRaining
(boolean) - Shows if it's raining.- If
true
, thenrainEtaSec
andrainEtaStr
show when the rain stops, otherwise they show when it starts
- If
The description
field of GTAWeatherState
has Discord-specific formatting such as: Forecast for **24 April 2019 15:18:18 UTC** (now)
. You can just remove *
characters from the string if you don't need that.
- v1.0
- Initial release
- v1.1
- Fixed incorrect emojis
- v1.2
- Changed sunrise time from 5AM to 6AM
- Minor code changes and fixes
Licensed under WTFPL v2 (see the file COPYING).