mirror of
https://github.com/cloudmaker97/FS25-Discord-Bot.git
synced 2025-12-06 00:18:34 +00:00
Added current game month in discord embed #2
This commit is contained in:
parent
ef8deb53b5
commit
c8c0e1018a
7 changed files with 85 additions and 2 deletions
|
|
@ -16,10 +16,26 @@
|
|||
"descriptionOffline": "Server is offline",
|
||||
"descriptionUnknown": "Server status fetching",
|
||||
"titleServerName": "Server name",
|
||||
"titleServerMap": "Server map",
|
||||
"titleServerMods": "Server mods",
|
||||
"titleServerPassword": "Server password",
|
||||
"titleServerTime": "Server time",
|
||||
"titlePlayerCount": "Players online",
|
||||
"noPlayersOnline": "No players online"
|
||||
},
|
||||
"common": {
|
||||
"monthJanuary": "January",
|
||||
"monthFebruary": "February",
|
||||
"monthMarch": "March",
|
||||
"monthApril": "April",
|
||||
"monthMay": "May",
|
||||
"monthJune": "June",
|
||||
"monthJuly": "July",
|
||||
"monthAugust": "August",
|
||||
"monthSeptember": "September",
|
||||
"monthOctober": "October",
|
||||
"monthNovember": "November",
|
||||
"monthDecember": "December"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
import ITranslationDiscordEmbed from "./ITranslationDiscordEmbed";
|
||||
import ITranslationCommon from "./ITranslationCommon";
|
||||
|
||||
export default interface ITranslation {
|
||||
discordEmbed: ITranslationDiscordEmbed;
|
||||
common: ITranslationCommon;
|
||||
}
|
||||
14
source/Interfaces/Configuration/ITranslationCommon.ts
Normal file
14
source/Interfaces/Configuration/ITranslationCommon.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export default interface ITranslationCommon {
|
||||
monthJanuary: string;
|
||||
monthFebruary: string;
|
||||
monthMarch: string;
|
||||
monthApril: string;
|
||||
monthMay: string;
|
||||
monthJune: string;
|
||||
monthJuly: string;
|
||||
monthAugust: string;
|
||||
monthSeptember: string;
|
||||
monthOctober: string;
|
||||
monthNovember: string;
|
||||
monthDecember: string;
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ export default interface ITranslationDiscordEmbed {
|
|||
descriptionOffline: string;
|
||||
descriptionUnknown: string;
|
||||
titleServerName: string;
|
||||
titleServerMap: string;
|
||||
titleServerMods: string;
|
||||
titleServerPassword: string;
|
||||
titleServerTime: string;
|
||||
titlePlayerCount: string;
|
||||
|
|
|
|||
|
|
@ -76,8 +76,22 @@ export default class Configuration implements IConfiguration{
|
|||
|| this.isValueEmptyOrUndefined(this?.translation?.discordEmbed?.titleServerName)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.discordEmbed?.titleServerPassword)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.discordEmbed?.titleServerTime)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.discordEmbed?.titleServerMap)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.discordEmbed?.titleServerMods)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.discordEmbed?.titlePlayerCount)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.discordEmbed?.noPlayersOnline)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthJanuary)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthFebruary)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthMarch)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthApril)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthMay)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthJune)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthJuly)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthAugust)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthSeptember)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthOctober)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthNovember)
|
||||
|| this.isValueEmptyOrUndefined(this?.translation?.common?.monthDecember)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ export default class DiscordEmbed {
|
|||
let embed = new EmbedBuilder();
|
||||
let config = this.appConfiguration;
|
||||
|
||||
serverStats.getServerMonth();
|
||||
|
||||
embed.setTitle(config.translation.discordEmbed.title);
|
||||
if (!serverStats.isOnline()) {
|
||||
embed.setColor(0xCA0000);
|
||||
|
|
@ -127,6 +129,7 @@ export default class DiscordEmbed {
|
|||
{name: config.translation.discordEmbed.titleServerName, value: serverStats.getServerName()},
|
||||
{name: config.translation.discordEmbed.titleServerPassword, value: serverPassword},
|
||||
{name: config.translation.discordEmbed.titleServerTime, value: serverStats.getServerTime()},
|
||||
{name: config.translation.discordEmbed.titleServerMap, value: serverStats.getServerMap()},
|
||||
{
|
||||
name: `${config.translation.discordEmbed.titlePlayerCount} (${serverStats.getPlayerCount()}/${serverStats.getMaxPlayerCount()}):`,
|
||||
value: playerListString
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import Configuration from "./Configuration";
|
|||
import {XMLParser} from "fast-xml-parser";
|
||||
import Logging from "./Logging";
|
||||
import IPlayer from "../Interfaces/Feed/IPlayer";
|
||||
import IConfiguration from "../Interfaces/Configuration/IConfiguration";
|
||||
|
||||
export const CONNECTION_REFUSED = 'ECONNREFUSED';
|
||||
export const NOT_FOUND = 'ENOTFOUND';
|
||||
|
|
@ -102,7 +103,7 @@ export default class ServerStatusFeed {
|
|||
* @returns {string} The server map name
|
||||
*/
|
||||
public getServerMap(): string {
|
||||
return <string>this.getServerStats()?.Server.map;
|
||||
return <string>this.getServerStats()?.Server.mapName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -117,6 +118,37 @@ export default class ServerStatusFeed {
|
|||
return dayTime / (60 * 60 * 1000) + 0.0001;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server month as a string
|
||||
* @returns {string} The server month as a string
|
||||
*/
|
||||
public getServerMonth(): string {
|
||||
let config: IConfiguration = Configuration.getConfiguration();
|
||||
let dayTime = this.getServerStats()?.Server.dayTime;
|
||||
if (dayTime === undefined) {
|
||||
return "Error";
|
||||
}
|
||||
let month = dayTime / (60 * 60 * 1000 * 24);
|
||||
month = month % 1;
|
||||
month = month * 12;
|
||||
month = Math.floor(month);
|
||||
let months = [
|
||||
config.translation.common.monthJanuary,
|
||||
config.translation.common.monthFebruary,
|
||||
config.translation.common.monthMarch,
|
||||
config.translation.common.monthApril,
|
||||
config.translation.common.monthMay,
|
||||
config.translation.common.monthJune,
|
||||
config.translation.common.monthJuly,
|
||||
config.translation.common.monthAugust,
|
||||
config.translation.common.monthSeptember,
|
||||
config.translation.common.monthOctober,
|
||||
config.translation.common.monthNovember,
|
||||
config.translation.common.monthDecember
|
||||
]
|
||||
return months[month-1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server time in the format HH:MM
|
||||
* @returns {string} The server time in the format HH:MM
|
||||
|
|
@ -136,7 +168,7 @@ export default class ServerStatusFeed {
|
|||
if(minutesString.length === 1) {
|
||||
minutesString = `0${minutesString}`;
|
||||
}
|
||||
return `${hoursString}:${minutesString}`;
|
||||
return `${hoursString}:${minutesString} (${this.getServerMonth()})`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue