Compare commits

...
Author SHA1 Message Date
7791fa5654
Improve error message when message.delete() fails
Some checks are pending
CI / CI (push) Waiting to run
2026-02-27 19:25:40 +01:00
9796e9245a
Don't send an unchanged link in x command 2026-02-27 19:24:01 +01:00
62b8ebb4cf
Use lookbehind to improve x command regex 2026-02-27 19:23:36 +01:00

View file

@ -9,9 +9,12 @@ module.exports = {
return; return;
} }
let replacedLink = ""; let replacedLink = "";
const regex = /(x|twitter)\.com/g const regex = /(?<=\/)(x|twitter)\.com/g
if(args[0].startsWith("https://") || args[0].startsWith("http://")){ if(args[0].startsWith("https://") || args[0].startsWith("http://")){
replacedLink = args[0].replace(regex, "fxtwitter.com"); replacedLink = args[0].replace(regex, "fxtwitter.com");
}else {
message.channel.send(noUrlErr);
return;
} }
if(replacedLink.length === 0){ if(replacedLink.length === 0){
message.channel.send(noUrlErr); message.channel.send(noUrlErr);
@ -21,7 +24,7 @@ module.exports = {
try{ try{
message.delete() message.delete()
}catch(err){ }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); console.error(err);
} }
} }