Javascript 获取discord消息中的URL链接,并在链接上添加一些字符
我想使机器人上的不和谐,这个机器人有一个特点,就是可以取代链接的消息,而无需预览链接。我想问,当链接被替换时,如何添加字符,以便预览链接不会出现。例如: 当有人键入:bla-bla-bla-bla-bla-bla-bla-bla-bla时,我希望消息发送链接为:bla-bla-bla-bla(无预览链接) 以下是代码:Javascript 获取discord消息中的URL链接,并在链接上添加一些字符,javascript,replace,hyperlink,bots,discord,Javascript,Replace,Hyperlink,Bots,Discord,我想使机器人上的不和谐,这个机器人有一个特点,就是可以取代链接的消息,而无需预览链接。我想问,当链接被替换时,如何添加
if (!msg.startsWith(prefix + '!intro')){
//wrap this in an async since awaits only work in them
async function purge(){
message.delete(); //delete the commands message, so it doesnt interfere with the message we are going to delete
const fetched = await message.channel.fetchMessages({limit: args[0]}); //grabs the last number(args) of messages in the channel
console.log(fetched.size + 'message found, deleting....'); //lets post into console how many message we are deleting
}
purge();
}
if (msg.includes('HTTPS')){
message.replaceWith( '<' + msg + '>' );
}
if(!msg.startsWith(前缀+'!intro')){
//将其包装为异步,因为它们只等待工作
异步函数清除(){
message.delete();//删除命令消息,这样它就不会干扰我们要删除的消息
const fetched=wait message.channel.fetchMessages({limit:args[0]});//获取通道中最后一个数量(args)的消息
console.log(fetched.size+'message found,deleting…');//让我们将删除的消息数量发布到控制台
}
清除();
}
如果(消息包括('HTTPS')){
消息。替换为(“”);
}
在此之前,我使用bot来删除垃圾信息,因此如果他们不使用命令发送,则该信息将被删除
多谢各位