Skip to content

Commit

Permalink
Merge branch 'alexemanuelol:master' into voice_extras
Browse files Browse the repository at this point in the history
  • Loading branch information
FaiThiX authored May 5, 2024
2 parents 98ea10b + a9d885a commit a0d5b20
Show file tree
Hide file tree
Showing 28 changed files with 39,755 additions and 36,843 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A NodeJS Discord Bot that uses the [rustplus.js](https://github.com/liamcottle/r

## **How-to Setup Video**

[![Image of setup video](https://www.youtube.com/s/desktop/4a88d8c6/img/favicon_144x144.png)](https://www.youtube.com/watch?v=xqcqXcWypEo)
[![Image of setup video](https://www.youtube.com/s/desktop/4a88d8c6/img/favicon_144x144.png)](https://youtu.be/GX03brJiMZg)

## **Features**

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rustplusplus",
"version": "1.15.0",
"version": "1.16.0",
"description": "A NodeJS Discord Bot that uses the rustplus.js library to utilize the power of the Rust+ Companion App with additional Quality-of-Life features.",
"main": "index.ts",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/players.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ async function displaySeveralUsers(client, interaction, battlemetricsId, playerI
for (const field of fields) {
embed.addFields({
name: fieldCounter === 0 ? client.intlGet(interaction.guildId, 'players') : '\u200B',
value: field,
value: field === '' ? '\u200B' : field,
inline: true
});
fieldCounter += 1;
Expand Down
5 changes: 4 additions & 1 deletion src/commands/voice.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ module.exports = {
await DiscordMessages.sendVoiceMessage(interaction,
client.intlGet(interaction.guildId, 'commandsVoiceBotJoinedVoice'));
client.log(client.intlGet(null, 'infoCap'), client.intlGet(interaction.guildId, 'commandsVoiceJoin',
{ name: voiceChannel.name, id: voiceChannel.id, guild: voiceChannel.guild.name }));
{ name: voiceChannel && voiceChannel.name ? voiceChannel.name : client.intlGet(interaction.guildId, 'unknown'),
id: voiceChannel && voiceChannel.id ? voiceChannel.id : client.intlGet(interaction.guildId, 'unknown'),
guild: voiceChannel && voiceChannel.guild.name ? voiceChannel.guild.name : client.intlGet(interaction.guildId, 'unknown')}
));
}
else {
await DiscordMessages.sendVoiceMessage(interaction,
Expand Down
2 changes: 1 addition & 1 deletion src/discordTools/discordEmbeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ module.exports = {
for (const field of fields) {
embed.addFields({
name: fieldCounter === 0 ? Client.client.intlGet(guildId, 'players') : '\u200B',
value: field,
value: field === '' ? '\u200B' : field,
inline: true
});
fieldCounter += 1;
Expand Down
12 changes: 10 additions & 2 deletions src/discordTools/discordMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ module.exports = {
await module.exports.sendMessage(guildId, content, null, instance.channelId.events);
},

sendActivityNotificationMessage: async function (guildId, serverId, color, text, steamId, title = null) {
sendActivityNotificationMessage: async function (guildId, serverId, color, text, steamId, title = null, everyone = false) {
const instance = Client.client.getInstance(guildId);

let png = null;
Expand All @@ -355,6 +355,10 @@ module.exports = {
embeds: [DiscordEmbeds.getActivityNotificationEmbed(guildId, serverId, color, text, steamId, png, title)]
}

if (everyone) {
content.content = '@everyone';
}

await module.exports.sendMessage(guildId, content, null, instance.channelId.activity);
},

Expand Down Expand Up @@ -574,13 +578,17 @@ module.exports = {
await Client.client.interactionEditReply(interaction, content);
},

sendBattlemetricsEventMessage: async function (guildId, battlemetricsId, title, description, fields = null) {
sendBattlemetricsEventMessage: async function (guildId, battlemetricsId, title, description, fields = null, everyone = false) {
const instance = Client.client.getInstance(guildId);

const content = {
embeds: [DiscordEmbeds.getBattlemetricsEventEmbed(guildId, battlemetricsId, title, description, fields)]
}

if (everyone) {
content.content = '@everyone';
}

await module.exports.sendMessage(guildId, content, null, instance.channelId.activity);
},

Expand Down
4 changes: 2 additions & 2 deletions src/external/process_rustlabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ function processItemDurability(rustlabsName, shortname, name, data, type = 'item
if (toolMatches.length !== 0) {
for (const toolMatch of toolMatches) {
if (toolMatch.length !== 3) exit();
toolShortname = toolMatch[1];
toolName = toolMatch[2];
toolShortname = Utils.decodeHtml(toolMatch[1]).replace('%20', ' ');
toolName = Utils.decodeHtml(toolMatch[2]).replace('%20', ' ');
break;
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/handlers/battlemetricsHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ module.exports = {
tracker: content.name
});
await DiscordMessages.sendActivityNotificationMessage(
guildId, content.serverId, Constants.COLOR_ACTIVE, str, null, content.title);
guildId, content.serverId, Constants.COLOR_ACTIVE, str, null, content.title,
content.everyone);
if (rustplus && (rustplus.serverId === content.serverId) && content.inGame) {
rustplus.sendInGameMessage(str);
}
Expand All @@ -139,7 +140,8 @@ module.exports = {
tracker: content.name
});
await DiscordMessages.sendActivityNotificationMessage(
guildId, content.serverId, Constants.COLOR_ACTIVE, str, null, content.title);
guildId, content.serverId, Constants.COLOR_ACTIVE, str, null, content.title,
content.everyone);
if (rustplus && (rustplus.serverId === content.serverId) && content.inGame) {
rustplus.sendInGameMessage(str);
}
Expand All @@ -157,7 +159,8 @@ module.exports = {
});

await DiscordMessages.sendActivityNotificationMessage(
guildId, content.serverId, Constants.COLOR_INACTIVE, str, null, content.title);
guildId, content.serverId, Constants.COLOR_INACTIVE, str, null, content.title,
content.everyone);
if (rustplus && (rustplus.serverId === content.serverId) && content.inGame) {
rustplus.sendInGameMessage(str);
}
Expand Down Expand Up @@ -356,7 +359,7 @@ module.exports = {
for (const field of fields) {
outPutFields.push({
name: '\u200B',
value: field,
value: field === '' ? '\u200B' : field,
inline: true
});
fieldCounter += 1;
Expand Down Expand Up @@ -410,7 +413,7 @@ module.exports = {
for (const field of fields) {
outPutFields.push({
name: '\u200B',
value: field,
value: field === '' ? '\u200B' : field,
inline: true
});
fieldCounter += 1;
Expand All @@ -431,6 +434,7 @@ module.exports = {
`__**${client.intlGet(guildId, 'old')}:**__ ${oldName}\n` +
`__**${client.intlGet(guildId, 'new')}:**__ ${newName}`;

await DiscordMessages.sendBattlemetricsEventMessage(guildId, battlemetricsId, title, description);
await DiscordMessages.sendBattlemetricsEventMessage(guildId, battlemetricsId, title, description, null,
instance.trackers[trackerId].everyone);
},
}
10 changes: 10 additions & 0 deletions src/handlers/smartSwitchHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ module.exports = {
active = true;
}
else {
const str = client.intlGet(guildId, 'deviceIsAlreadyOnOff', {
device: switches[entityId].name,
status: onCap
});
rustplus.sendInGameMessage(str);
return true;
}
}
Expand All @@ -401,6 +406,11 @@ module.exports = {
active = false;
}
else {
const str = client.intlGet(guildId, 'deviceIsAlreadyOnOff', {
device: switches[entityId].name,
status: offCap
});
rustplus.sendInGameMessage(str);
return true;
}
}
Expand Down
Loading

0 comments on commit a0d5b20

Please sign in to comment.