Skip to content

Commit 08887da

Browse files
committed
refactor: minor tweaks
1 parent 46092a0 commit 08887da

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

src/Logger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function warnMessage(message) {
116116
}
117117

118118
function errorMessage(error) {
119-
const errorString = `${error.toString()}${error.stack?.replace(error.toString(), "")}`;
119+
const errorString = `${error.toString()}${error.stack?.replace(error.toString(), "") ?? ""}`;
120120
if (config.other.logToFiles) {
121121
errorLogger.log("error", errorString);
122122
}

src/contracts/helperFunctions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ function splitMessage(message, amount) {
239239

240240
/**
241241
* Formats an error message
242-
* @param {Error} error
242+
* @param {Error | unknown} error
243243
* @returns {string}
244244
*/
245245
function formatError(error) {

src/discord/DiscordManager.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class DiscordManager extends CommunicationBridge {
100100

101101
const channel = await this.stateHandler.getChannel(chat || "Guild");
102102
if (channel === undefined) {
103-
console.error(`Channel ${chat} not found!`);
103+
console.error(`Channel ${chat.replace(/§[0-9a-fk-or]/g, "").trim()} not found!`);
104104
return;
105105
}
106106

@@ -179,7 +179,7 @@ class DiscordManager extends CommunicationBridge {
179179

180180
channel = await this.stateHandler.getChannel(channel);
181181
if (channel === undefined) {
182-
console.log(`Channel ${channel} not found!`);
182+
console.log(`Channel ${channel.replace(/§[0-9a-fk-or]/g, "").trim()} not found!`);
183183
}
184184

185185
channel.send({
@@ -197,7 +197,7 @@ class DiscordManager extends CommunicationBridge {
197197

198198
channel = await this.stateHandler.getChannel(channel);
199199
if (channel === undefined) {
200-
console.log(`Channel ${channel} not found!`);
200+
console.log(`Channel ${channel.replace(/§[0-9a-fk-or]/g, "").trim()} not found!`);
201201
return;
202202
}
203203

@@ -220,7 +220,7 @@ class DiscordManager extends CommunicationBridge {
220220

221221
channel = await this.stateHandler.getChannel(channel);
222222
if (channel === undefined) {
223-
console.log(`Channel ${channel} not found!`);
223+
console.log(`Channel ${channel.replace(/§[0-9a-fk-or]/g, "").trim()} not found!`);
224224
return;
225225
}
226226

src/minecraft/CommandHandler.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,23 @@ class CommandHandler {
4646
return;
4747
}
4848

49-
bot.chat(`/${officer ? "oc" : "gc"} [SOOPY V2] ${message}`);
49+
const chat = officer ? "oc" : "gc";
5050

51-
console.minecraft(`${player} - [${command}] ${message}`);
51+
bot.chat(`/${chat} [SOOPY V2] ${message}`);
5252

53+
console.minecraft(`${player} - [${command}] ${message}`);
5354
(async () => {
5455
try {
5556
const URI = encodeURI(`https://soopy.dev/api/guildBot/runCommand?user=${player}&cmd=${message.slice(1)}`);
5657
const response = await axios.get(URI);
5758

5859
if (response?.data?.msg === undefined) {
59-
return bot.chat(`/${officer ? "oc" : "gc"} [SOOPY V2] An error occured while running the command`);
60+
return bot.chat(`/${chat} [SOOPY V2] An error occured while running the command`);
6061
}
6162

62-
bot.chat(`/${officer ? "oc" : "gc"} [SOOPY V2] ${response.data.msg}`);
63+
bot.chat(`/${chat} [SOOPY V2] ${response.data.msg}`);
6364
} catch (e) {
64-
bot.chat(`/${officer ? "oc" : "gc"} [SOOPY V2] ${e.cause ?? e.message ?? "Unknown error"}`);
65+
bot.chat(`/${chat} [SOOPY V2] ${e.cause ?? e.message ?? "Unknown error"}`);
6566
}
6667
})();
6768
}

0 commit comments

Comments
 (0)