Add X command that replaces X/Twitter links with fxtwitter
Some checks failed
CI / CI (push) Has been cancelled
Some checks failed
CI / CI (push) Has been cancelled
This commit is contained in:
parent
94d1b0f297
commit
1f48a896a5
1 changed files with 27 additions and 0 deletions
27
commands/misc/x.js
Normal file
27
commands/misc/x.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
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");
|
||||
return;
|
||||
}
|
||||
let replacedLink = "";
|
||||
const regex = /(x|twitter)\.com/g
|
||||
if(args[0].startsWith("https://") || args[0].startsWith("http://")){
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
message.channel.send(replacedLink);
|
||||
try{
|
||||
message.delete()
|
||||
}catch(err){
|
||||
console.error(`${this.name}: An error happened while trying to delete the original message.`)
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Reference in a new issue