mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-23 17:47:27 +00:00
revamp #2
This commit is contained in:
parent
6a7b68afc3
commit
cb87a9495b
1 changed files with 35 additions and 19 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
exports.custom = [
|
||||
"lbrylink" //change this to your function name
|
||||
]
|
||||
|
@ -9,18 +8,35 @@ exports.lbrylink = function(bot,msg,suffix) {
|
|||
if (link != -1) {
|
||||
var text = msg.content.replace("lbry://", "https://open.lbry.io/");
|
||||
var message = GetWordByPos(text, link)
|
||||
var name = message.replace("https://open.lbry.io/", "");
|
||||
if (text.search("<") != -1) {
|
||||
var name = "@" + msg.mentions.members.first().user.username
|
||||
var trim = message.split("/").pop()
|
||||
var trim2 = trim.substr(2)
|
||||
var id = trim2.substr(0, trim2.length - 1)
|
||||
if (msg.mentions.members.first().id != id) {
|
||||
var message = "https://open.lbry.io/@" + msg.mentions.members.first().user.username + "/" + message.split("/").pop()
|
||||
var newname = name + "/" + message.split("/").pop()
|
||||
} else {
|
||||
var message = "https://open.lbry.io/@" + msg.mentions.members.first().user.username
|
||||
var newname = name
|
||||
}
|
||||
} else {
|
||||
var newname = message.replace("https://open.lbry.io/", "");
|
||||
}
|
||||
const embed = {
|
||||
"description": msg.author+", I see you tried to post a LBRY URL, here's a friendly hyperlink to share and for others to access your content with a single click: \n"+"[lbry://"+name+"]("+message+")",
|
||||
"description": msg.author + ", I see you tried to post a LBRY URL, here's a friendly hyperlink to share and for others to access your content with a single click: \n" + "[lbry://" + newname + "](" + message + ")",
|
||||
"color": 7976557,
|
||||
"author": {
|
||||
"name": "LBRY Linker",
|
||||
"icon_url": "https://i.imgur.com/yWf5USu.png"
|
||||
}
|
||||
};
|
||||
msg.channel.send({embed})
|
||||
msg.channel.send({
|
||||
embed
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
function GetWordByPos(str, pos) {
|
||||
var left = str.substr(0, pos);
|
||||
var right = str.substr(pos);
|
||||
|
|
Loading…
Add table
Reference in a new issue