diff --git a/docs/commands.md b/docs/commands.md
index 6c0387587..65c6e5d4f 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -250,6 +250,7 @@ In-Game Command | Description
[**connection/connections**](commands.md#connectionconnections) | Get recent connection events.
[**death/deaths**](commands.md#deathdeaths) | Get recent death events.
[**decay**](commands.md#decay) | Get time before structure decay.
+[**events**](commands.md#events) | Get recent events.
[**heli**](commands.md#heli) | Get information about Patrol Helicopter (Location, time since last downed, time since last on map).
[**large**](commands.md#large) | Get information about Large Oil Rig (Time till crate unlocks, time since last trigger).
[**leader**](commands.md#leader-1) | Give/Take the Team Leadership.
@@ -339,6 +340,17 @@ In-Game Command | Description
![In-Game Command decay Image](images/ingame_commands/decay_ingame.png)
+## **events**
+
+> **Get recent In-Game events.** Available events are cargo, heli, small, large, chinook
+
Command: `!events` - Get last 5 events
+
Command: `!events 3` - Get last 3 events
+
Command: `!events cargo` - Get last 5 events from cargo
+
Command: `!events cargo 2` - Get last 2 events from cargo
+
+![In-Game Command events Image](images/ingame_commands/events_ingame.png)
+
+
## **heli**
> **Get information about Patrol Helicopter (Location, time since last downed, time since last on map).**
diff --git a/docs/full_list_features.md b/docs/full_list_features.md
index 0cc951649..014df3641 100644
--- a/docs/full_list_features.md
+++ b/docs/full_list_features.md
@@ -25,6 +25,7 @@
- **connection/connections** - Display latest team connections.
- **death/deaths** - Display latest deaths.
- **decay** - Get decay time of different wall-types.
+- **events** - Get recent events.
- **heli** - Get information regarding Patrol Helicopter.
- **large** - Get information regarding Large Oil Rig.
- **leader** - Transfer leadership.
diff --git a/docs/images/ingame_commands/events_ingame.png b/docs/images/ingame_commands/events_ingame.png
new file mode 100644
index 000000000..2c7dbaeea
Binary files /dev/null and b/docs/images/ingame_commands/events_ingame.png differ
diff --git a/src/handlers/discordCommandHandler.js b/src/handlers/discordCommandHandler.js
index 5a10e480e..25c9b6cea 100644
--- a/src/handlers/discordCommandHandler.js
+++ b/src/handlers/discordCommandHandler.js
@@ -62,6 +62,10 @@ module.exports = {
commandLowerCase.startsWith(`${prefix}${client.intlGet(guildId, 'commandSyntaxDecay')}`)) {
response = rustplus.getCommandDecay(command);
}
+ else if (commandLowerCase.startsWith(`${prefix}${client.intlGet('en', 'commandSyntaxEvents')}`) ||
+ commandLowerCase.startsWith(`${prefix}${client.intlGet(guildId, 'commandSyntaxEvents')}`)) {
+ response = rustplus.getCommandEvents(command);
+ }
else if (commandLowerCase === `${prefix}${client.intlGet('en', 'commandSyntaxHeli')}` ||
commandLowerCase === `${prefix}${client.intlGet(guildId, 'commandSyntaxHeli')}`) {
response = rustplus.getCommandHeli();
diff --git a/src/handlers/inGameCommandHandler.js b/src/handlers/inGameCommandHandler.js
index 719ad33be..6f1956223 100644
--- a/src/handlers/inGameCommandHandler.js
+++ b/src/handlers/inGameCommandHandler.js
@@ -70,6 +70,10 @@ module.exports = {
commandLowerCase.startsWith(`${prefix}${client.intlGet(guildId, 'commandSyntaxDecay')}`)) {
rustplus.printCommandOutput(rustplus.getCommandDecay(command));
}
+ else if (commandLowerCase.startsWith(`${prefix}${client.intlGet('en', 'commandSyntaxEvents')}`) ||
+ commandLowerCase.startsWith(`${prefix}${client.intlGet(guildId, 'commandSyntaxEvents')}`)) {
+ rustplus.printCommandOutput(rustplus.getCommandEvents(command));
+ }
else if (commandLowerCase === `${prefix}${client.intlGet('en', 'commandSyntaxHeli')}` ||
commandLowerCase === `${prefix}${client.intlGet(guildId, 'commandSyntaxHeli')}`) {
rustplus.printCommandOutput(rustplus.getCommandHeli());
diff --git a/src/languages/en.json b/src/languages/en.json
index e56dcfc7b..1b0b396a9 100644
--- a/src/languages/en.json
+++ b/src/languages/en.json
@@ -99,6 +99,7 @@
"commandSyntaxDeath": "death",
"commandSyntaxDeaths": "deaths",
"commandSyntaxDecay": "decay",
+ "commandSyntaxEvents": "events",
"commandSyntaxHeli": "heli",
"commandSyntaxLanguage": "language",
"commandSyntaxLarge": "large",
@@ -446,6 +447,7 @@
"noRegisteredConnectionEventsUser": "No registered connection events for {user}.",
"noRegisteredDeathEvents": "No registered death events yet.",
"noRegisteredDeathEventsUser": "No registered death events for {user}.",
+ "noRegisteredEvents": "No registered events yet.",
"noRegisteredMarkers": "No registered markers.",
"noSavedNotes": "There are no saved notes.",
"noToolCupboardWereFound": "No Tool Cupboard monitors were found.",
diff --git a/src/structures/MapMarkers.js b/src/structures/MapMarkers.js
index 2222d1879..3a66ed64f 100644
--- a/src/structures/MapMarkers.js
+++ b/src/structures/MapMarkers.js
@@ -302,6 +302,7 @@ class MapMarkers {
this.rustplus.sendEvent(
this.rustplus.notificationSettings.vendingMachineDetectedSetting,
this.client.intlGet(this.rustplus.guildId, 'newVendingMachine', { location: pos.string }),
+ null,
Constants.COLOR_NEW_VENDING_MACHINE);
}
}
@@ -361,6 +362,7 @@ class MapMarkers {
this.rustplus.notificationSettings.heavyScientistCalledSetting,
this.client.intlGet(this.rustplus.guildId, 'heavyScientistsCalledSmall',
{ location: oilRigLocation.location }),
+ 'small',
Constants.COLOR_HEAVY_SCIENTISTS_CALLED_SMALL,
this.rustplus.isFirstPoll,
'small_oil_rig_logo.png');
@@ -395,6 +397,7 @@ class MapMarkers {
this.rustplus.notificationSettings.heavyScientistCalledSetting,
this.client.intlGet(this.rustplus.guildId, 'heavyScientistsCalledLarge',
{ location: oilRigLocation.location }),
+ 'large',
Constants.COLOR_HEAVY_SCIENTISTS_CALLED_LARGE,
this.rustplus.isFirstPoll,
'large_oil_rig_logo.png');
@@ -426,12 +429,14 @@ class MapMarkers {
this.rustplus.sendEvent(
this.rustplus.notificationSettings.chinook47DetectedSetting,
this.client.intlGet(this.rustplus.guildId, 'chinook47EntersMap', { location: pos.string }),
+ 'chinook',
Constants.COLOR_CHINOOK47_ENTERS_MAP);
}
else {
this.rustplus.sendEvent(
this.rustplus.notificationSettings.chinook47DetectedSetting,
this.client.intlGet(this.rustplus.guildId, 'chinook47Located', { location: pos.string }),
+ 'chinook',
Constants.COLOR_CHINOOK47_LOCATED);
}
marker.ch47Type = 'crate';
@@ -486,6 +491,7 @@ class MapMarkers {
this.rustplus.sendEvent(
this.rustplus.notificationSettings.cargoShipDetectedSetting,
this.client.intlGet(this.rustplus.guildId, 'cargoShipEntersMap', { location: pos.string }),
+ 'cargo',
Constants.COLOR_CARGO_SHIP_ENTERS_MAP);
let instance = this.client.getInstance(this.rustplus.guildId);
@@ -499,6 +505,7 @@ class MapMarkers {
this.rustplus.sendEvent(
this.rustplus.notificationSettings.cargoShipDetectedSetting,
this.client.intlGet(this.rustplus.guildId, 'cargoShipLocated', { location: pos.string }),
+ 'cargo',
Constants.COLOR_CARGO_SHIP_LOCATED);
}
@@ -510,6 +517,7 @@ class MapMarkers {
this.rustplus.sendEvent(
this.rustplus.notificationSettings.cargoShipLeftSetting,
this.client.intlGet(this.rustplus.guildId, 'cargoShipLeftMap', { location: marker.location.string }),
+ 'cargo',
Constants.COLOR_CARGO_SHIP_LEFT_MAP);
if (this.cargoShipEgressTimers[marker.id]) {
@@ -585,6 +593,7 @@ class MapMarkers {
this.client.intlGet(this.rustplus.guildId, 'patrolHelicopterEntersMap', {
location: pos.string
}),
+ 'heli',
Constants.COLOR_PATROL_HELICOPTER_ENTERS_MAP);
}
else {
@@ -593,6 +602,7 @@ class MapMarkers {
this.client.intlGet(this.rustplus.guildId, 'patrolHelicopterLocatedAt', {
location: pos.string
}),
+ 'heli',
Constants.COLOR_PATROL_HELICOPTER_LOCATED_AT);
}
@@ -609,6 +619,7 @@ class MapMarkers {
this.client.intlGet(this.rustplus.guildId, 'patrolHelicopterLeftMap', {
location: marker.location.string
}),
+ 'heli',
Constants.COLOR_PATROL_HELICOPTER_LEFT_MAP);
this.timeSincePatrolHelicopterWasOnMap = new Date();
@@ -619,6 +630,7 @@ class MapMarkers {
this.client.intlGet(this.rustplus.guildId, 'patrolHelicopterTakenDown', {
location: marker.location.string
}),
+ 'heli',
Constants.COLOR_PATROL_HELICOPTER_TAKEN_DOWN);
this.timeSincePatrolHelicopterWasDestroyed = new Date();
@@ -656,6 +668,7 @@ class MapMarkers {
this.client.intlGet(this.rustplus.guildId, 'cargoShipEntersEgressStage', {
location: marker.location.string
}),
+ 'cargo',
Constants.COLOR_CARGO_SHIP_ENTERS_EGRESS_STAGE);
if (this.cargoShipEgressTimers[id]) {
@@ -674,6 +687,7 @@ class MapMarkers {
this.client.intlGet(this.rustplus.guildId, 'lockedCrateSmallOilRigUnlocked', {
location: oilRigLocation
}),
+ 'small',
Constants.COLOR_LOCKED_CRATE_SMALL_OILRIG_UNLOCKED,
this.rustplus.isFirstPoll,
'locked_crate_small_oil_rig_logo.png');
@@ -691,6 +705,7 @@ class MapMarkers {
this.client.intlGet(this.rustplus.guildId, 'lockedCrateLargeOilRigUnlocked', {
location: oilRigLocation
}),
+ 'large',
Constants.COLOR_LOCKED_CRATE_LARGE_OILRIG_UNLOCKED,
this.rustplus.isFirstPoll,
'locked_crate_large_oil_rig_logo.png');
diff --git a/src/structures/RustPlus.js b/src/structures/RustPlus.js
index 3af7ad2ce..2bdb240a5 100644
--- a/src/structures/RustPlus.js
+++ b/src/structures/RustPlus.js
@@ -85,6 +85,14 @@ class RustPlus extends RustPlusLib {
this.playerConnections = new Object();
this.allDeaths = [];
this.playerDeaths = new Object();
+ this.events = {
+ all: [],
+ cargo: [],
+ heli: [],
+ small: [],
+ large: [],
+ chinook: []
+ };
this.patrolHelicopterTracers = new Object();
this.cargoShipTracers = new Object();
@@ -222,6 +230,27 @@ class RustPlus extends RustPlusLib {
this.playerDeaths[steamId].unshift(data);
}
+ updateEvents(event, message) {
+ const commandCargoEn = `${Client.client.intlGet('en', 'commandSyntaxCargo')}`;
+ const commandHeliEn = `${Client.client.intlGet('en', 'commandSyntaxHeli')}`;
+ const commandSmallEn = `${Client.client.intlGet('en', 'commandSyntaxSmall')}`;
+ const commandLargeEn = `${Client.client.intlGet('en', 'commandSyntaxLarge')}`;
+ const commandChinookEn = `${Client.client.intlGet('en', 'commandSyntaxChinook')}`;
+ if (![commandCargoEn, commandHeliEn, commandSmallEn, commandLargeEn, commandChinookEn].includes(event)) return;
+
+ const str = `${Timer.getCurrentDateTime()} - ${message}`;
+
+ if (this.events['all'].length === 10) {
+ this.events['all'].pop();
+ }
+ this.events['all'].unshift(str);
+
+ if (this.events[event].length === 10) {
+ this.events[event].pop();
+ }
+ this.events[event].unshift(str);
+ }
+
deleteThisRustplusInstance() {
this.isDeleted = true;
this.disconnect();
@@ -286,9 +315,11 @@ class RustPlus extends RustPlusLib {
}
}
- async sendEvent(setting, text, embed_color, firstPoll = false, image = null) {
+ async sendEvent(setting, text, event, embed_color, firstPoll = false, image = null) {
const img = (image !== null) ? image : setting.image;
+ this.updateEvents(event, text);
+
if (!firstPoll && setting.discord) {
await DiscordMessages.sendDiscordEventMessage(this.guildId, this.serverId, text, img, embed_color);
}
@@ -1108,6 +1139,107 @@ class RustPlus extends RustPlusLib {
}
}
+ getCommandEvents(command) {
+ const prefix = this.generalSettings.prefix;
+ const commandEvents = `${prefix}${Client.client.intlGet(this.guildId, 'commandSyntaxEvents')}`;
+ const commandEventsEn = `${prefix}${Client.client.intlGet('en', 'commandSyntaxEvents')}`;
+ const commandCargo = `${Client.client.intlGet(this.guildId, 'commandSyntaxCargo')}`;
+ const commandCargoEn = `${Client.client.intlGet('en', 'commandSyntaxCargo')}`;
+ const commandHeli = `${Client.client.intlGet(this.guildId, 'commandSyntaxHeli')}`;
+ const commandHeliEn = `${Client.client.intlGet('en', 'commandSyntaxHeli')}`;
+ const commandSmall = `${Client.client.intlGet(this.guildId, 'commandSyntaxSmall')}`;
+ const commandSmallEn = `${Client.client.intlGet('en', 'commandSyntaxSmall')}`;
+ const commandLarge = `${Client.client.intlGet(this.guildId, 'commandSyntaxLarge')}`;
+ const commandLargeEn = `${Client.client.intlGet('en', 'commandSyntaxLarge')}`;
+ const commandChinook = `${Client.client.intlGet(this.guildId, 'commandSyntaxChinook')}`;
+ const commandChinookEn = `${Client.client.intlGet('en', 'commandSyntaxChinook')}`;
+
+ const EVENTS = [commandCargo, commandCargoEn, commandHeli, commandHeliEn, commandSmall,
+ commandSmallEn, commandLarge, commandLargeEn, commandChinook, commandChinookEn];
+
+ if (command.toLowerCase().startsWith(`${commandEvents}`)) {
+ command = command.slice(`${commandEvents}`.length).trim();
+ }
+ else {
+ command = command.slice(`${commandEventsEn}`.length).trim();
+ }
+
+ let event = command.replace(/ .*/, '').toLowerCase();
+ let number = command.slice(event.length + 1);
+
+ if (event === '') {
+ event = 'all';
+ number = 5;
+ }
+ else if (event !== '' && EVENTS.includes(event)) {
+ if (number === '') {
+ number = 5;
+ }
+ else {
+ number = parseInt(number);
+ if (isNaN(number)) {
+ number = 5;
+ }
+ }
+ }
+ else if (event !== '' && !EVENTS.includes(event)) {
+ number = parseInt(event);
+ event = 'all';
+ if (isNaN(number)) {
+ number = 5;
+ }
+ }
+ else {
+ event = 'all';
+ number = 5;
+ }
+
+ switch (event) {
+ case commandCargoEn:
+ case commandCargo: {
+ event = 'cargo';
+ } break;
+
+ case commandHeliEn:
+ case commandHeli: {
+ event = 'heli';
+ } break;
+
+ case commandSmallEn:
+ case commandSmall: {
+ event = 'small';
+ } break;
+
+ case commandLargeEn:
+ case commandLarge: {
+ event = 'large';
+ } break;
+
+ case commandChinookEn:
+ case commandChinook: {
+ event = 'chinook';
+ } break;
+
+ default: {
+ event = 'all';
+ } break;
+ }
+
+ const strings = [];
+ let counter = 0;
+ for (const e of this.events[event]) {
+ if (counter === 5 || counter === number) break;
+ strings.push(e);
+ counter += 1;
+ }
+
+ if (strings.length === 0) {
+ return Client.client.intlGet(this.guildId, 'noRegisteredEvents');
+ }
+
+ return strings;
+ }
+
getCommandHeli(isInfoChannel = false) {
const strings = [];
for (const patrolHelicopter of this.mapMarkers.patrolHelicopters) {
diff --git a/src/structures/RustPlusLite.js b/src/structures/RustPlusLite.js
index dddb8dae1..187c66fd1 100644
--- a/src/structures/RustPlusLite.js
+++ b/src/structures/RustPlusLite.js
@@ -148,7 +148,7 @@ async function rustPlusLiteDisconnectedEvent(rustplusLite) {
}
async function rustPlusLiteErrorEvent(rustplusLite, error) {
- rustplusLite.log(Client.client.intlGet(null, 'errorCap'), err, 'error');
+ rustplusLite.log(Client.client.intlGet(null, 'errorCap'), error, 'error');
}
module.exports = RustPlusLite;
diff --git a/src/util/keywords.js b/src/util/keywords.js
index c585cf33a..4715fa8b8 100644
--- a/src/util/keywords.js
+++ b/src/util/keywords.js
@@ -30,6 +30,7 @@ module.exports = {
client.intlGet(guildId, 'commandSyntaxDeath'),
client.intlGet(guildId, 'commandSyntaxDeaths'),
client.intlGet(guildId, 'commandSyntaxDecay'),
+ client.intlGet(guildId, 'commandSyntaxEvents'),
client.intlGet(guildId, 'commandSyntaxHeli'),
client.intlGet(guildId, 'commandSyntaxLarge'),
client.intlGet(guildId, 'commandSyntaxLeader'),
@@ -68,6 +69,7 @@ module.exports = {
client.intlGet('en', 'commandSyntaxDeath'),
client.intlGet('en', 'commandSyntaxDeaths'),
client.intlGet('en', 'commandSyntaxDecay'),
+ client.intlGet('en', 'commandSyntaxEvents'),
client.intlGet('en', 'commandSyntaxHeli'),
client.intlGet('en', 'commandSyntaxLarge'),
client.intlGet('en', 'commandSyntaxLeader'),