From 62fbb445e2867cc2cb1e1799879ce01ecadfb6fa Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Thu, 26 Feb 2026 18:30:02 +0100 Subject: [PATCH 1/6] Send a message if no X/Twitter links are provided --- commands/misc/x.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/commands/misc/x.js b/commands/misc/x.js index 802cf75..1d35bd4 100644 --- a/commands/misc/x.js +++ b/commands/misc/x.js @@ -3,8 +3,9 @@ module.exports = { name: 'x', description: 'Replaces X/Twitter links with fxtwitter and deletes the original message', execute({message, args}) { - if(args.length < 0) { - message.channel.send("TODO: NO_X_LINK_ERR"); + const noUrlErr = "You need to provide an X or twitter link to use this command." + if(args.length < 1) { + message.channel.send(noUrlErr); return; } let replacedLink = ""; @@ -13,7 +14,7 @@ module.exports = { replacedLink = args[0].replace(regex, "fxtwitter.com"); } if(replacedLink.length === 0){ - message.channel.send("You need to provide an X or twitter link to use this command."); + message.channel.send(noUrlErr); return; } message.channel.send(replacedLink); From 62b8ebb4cf1f104bbebe9934bce5f8826fd69277 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Fri, 27 Feb 2026 19:23:36 +0100 Subject: [PATCH 2/6] Use lookbehind to improve x command regex --- commands/misc/x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/misc/x.js b/commands/misc/x.js index 1d35bd4..bf8e1c7 100644 --- a/commands/misc/x.js +++ b/commands/misc/x.js @@ -9,7 +9,7 @@ module.exports = { return; } let replacedLink = ""; - const regex = /(x|twitter)\.com/g + const regex = /(?<=\/)(x|twitter)\.com/g if(args[0].startsWith("https://") || args[0].startsWith("http://")){ replacedLink = args[0].replace(regex, "fxtwitter.com"); } From 9796e9245ae75b40e71d1f5003696c5ce5b9612a Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Fri, 27 Feb 2026 19:24:01 +0100 Subject: [PATCH 3/6] Don't send an unchanged link in x command --- commands/misc/x.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/commands/misc/x.js b/commands/misc/x.js index bf8e1c7..2e7283b 100644 --- a/commands/misc/x.js +++ b/commands/misc/x.js @@ -12,6 +12,9 @@ module.exports = { const regex = /(?<=\/)(x|twitter)\.com/g if(args[0].startsWith("https://") || args[0].startsWith("http://")){ replacedLink = args[0].replace(regex, "fxtwitter.com"); + }else { + message.channel.send(noUrlErr); + return; } if(replacedLink.length === 0){ message.channel.send(noUrlErr); From 7791fa5654d3c1705d5a5f5e86f70d5b28465ca4 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Fri, 27 Feb 2026 19:25:40 +0100 Subject: [PATCH 4/6] Improve error message when message.delete() fails --- commands/misc/x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/misc/x.js b/commands/misc/x.js index 2e7283b..2a9b515 100644 --- a/commands/misc/x.js +++ b/commands/misc/x.js @@ -24,7 +24,7 @@ module.exports = { try{ message.delete() }catch(err){ - console.error(`${this.name}: An error happened while trying to delete the original message.`) + console.error(`${this.name}: An error occurred while trying to delete the original message.`) console.error(err); } } From d7b8e706b867abc50a1edbe1ce454860965fb8b9 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Fri, 27 Feb 2026 19:28:54 +0100 Subject: [PATCH 5/6] Add ig link replacing command --- commands/misc/ig.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 commands/misc/ig.js diff --git a/commands/misc/ig.js b/commands/misc/ig.js new file mode 100644 index 0000000..af45466 --- /dev/null +++ b/commands/misc/ig.js @@ -0,0 +1,31 @@ + +module.exports = { + name: 'ig', + description: 'Replaces Instagram links with kkinstagram and deletes the original message', + execute({message, args}) { + const noUrlErr = "You need to provide an Instagram link to use this command." + if(args.length < 1) { + message.channel.send(noUrlErr); + return; + } + let replacedLink = ""; + const regex = /(?<=\/)(instagram)\.com/g + if(args[0].startsWith("https://") || args[0].startsWith("http://")){ + replacedLink = args[0].replace(regex, "kkinstagram.com"); + }else { + message.channel.send(noUrlErr); + return; + } + if(replacedLink.length === 0){ + message.channel.send(noUrlErr); + return; + } + message.channel.send(replacedLink); + try{ + message.delete() + }catch(err){ + console.error(`${this.name}: An error occurred while trying to delete the original message.`) + console.error(err); + } + } +}; \ No newline at end of file From bc497c7dea5aa12042f0250899c77310b62ffb3d Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Fri, 27 Feb 2026 19:55:37 +0100 Subject: [PATCH 6/6] Fix sending links if they didn't get changed --- commands/misc/ig.js | 5 +---- commands/misc/x.js | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/commands/misc/ig.js b/commands/misc/ig.js index af45466..21268b7 100644 --- a/commands/misc/ig.js +++ b/commands/misc/ig.js @@ -12,11 +12,8 @@ module.exports = { const regex = /(?<=\/)(instagram)\.com/g if(args[0].startsWith("https://") || args[0].startsWith("http://")){ replacedLink = args[0].replace(regex, "kkinstagram.com"); - }else { - message.channel.send(noUrlErr); - return; } - if(replacedLink.length === 0){ + if(replacedLink.length === 0 || args[0] === replacedLink){ message.channel.send(noUrlErr); return; } diff --git a/commands/misc/x.js b/commands/misc/x.js index 2a9b515..87b6a26 100644 --- a/commands/misc/x.js +++ b/commands/misc/x.js @@ -12,11 +12,8 @@ module.exports = { const regex = /(?<=\/)(x|twitter)\.com/g if(args[0].startsWith("https://") || args[0].startsWith("http://")){ replacedLink = args[0].replace(regex, "fxtwitter.com"); - }else { - message.channel.send(noUrlErr); - return; } - if(replacedLink.length === 0){ + if(replacedLink.length === 0 || args[0] === replacedLink){ message.channel.send(noUrlErr); return; }