Skip to content

Commit

Permalink
Merge pull request #289 from Kathund/fix-blacklist
Browse files Browse the repository at this point in the history
Fix blacklist
  • Loading branch information
Killermaschine88 authored Dec 25, 2024
2 parents 095f002 + 640a4eb commit ec88d00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/discord/commands/blacklistCommand.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const HypixelDiscordChatBridgeError = require("../../contracts/errorHandler.js");
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const { SuccessEmbed } = require("../../contracts/embedHandler.js");

module.exports = {
Expand Down Expand Up @@ -35,13 +36,17 @@ module.exports = {
const name = interaction.options.getString("username");
const arg = interaction.options.getString("arg").toLowerCase();

bot.chat("/lobby megawalls");
await delay(250);
if (arg == "add") {
bot.chat(`/ignore add ${name}`);
} else if (arg == "remove") {
bot.chat(`/ignore remove ${name}`);
} else {
throw new HypixelDiscordChatBridgeError("Invalid Usage: `/ignore [add/remove] [name]`.");
}
await delay(250);
bot.chat("/limbo");

const embed = new SuccessEmbed(
`Successfully ${arg == "add" ? "added" : "removed"} \`${name}\` ${arg == "add" ? "to" : "from"} the blacklist.`,
Expand Down
9 changes: 5 additions & 4 deletions src/minecraft/handlers/ChatHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -848,16 +848,17 @@ class StateHandler extends eventHandler {

isAlreadyBlacklistedMessage(message) {
return (
message.includes(`You've already ignored that player! /ignore remove Player to unignore them!`) &&
message.includes(`You've already blocked that player! /block remove <player> to unblock them!`) &&
!message.includes(":")
);
}

isBlacklistRemovedMessage(message) {
return message.startsWith("Removed") && message.includes("from your ignore list.") && !message.includes(":");
return message.startsWith("Unblocked") && message.endsWith(".") && !message.includes(":");
}

isBlacklistMessage(message) {
return message.startsWith("Added") && message.includes("to your ignore list.") && !message.includes(":");
return message.startsWith("Blocked") && message.endsWith(".") && !message.includes(":");
}

isGuildMessage(message) {
Expand Down Expand Up @@ -1082,7 +1083,7 @@ class StateHandler extends eventHandler {
return;
}

const linkedUser = Object.values(linked).find((u) => player)
const linkedUser = Object.values(linked).find((u) => player);
if (linkedUser === undefined) {
return;
}
Expand Down

0 comments on commit ec88d00

Please sign in to comment.