简体   繁体   English

反链接不删除消息 discord.js V13

[英]Anti-link doesn't delete messages discord.js V13

I wrote this code for detecting links in messages, but it doesn't delete the message or send the embed logs!我编写了这段代码来检测消息中的链接,但它不会删除消息或发送嵌入日志! And also there is no error shown in terminal.并且终端中也没有显示错误。 I've tried console.log() the message in the if statement and it seems detected!我已经在if语句中尝试了console.log()消息,它似乎被检测到了!

This is my code这是我的代码

Any help is appreciated!任何帮助表示赞赏!

This is accomplished easier using regex checker使用正则表达式检查器更容易完成

const {
    guild,
    channel,
    content
} = message;
const linklog = guild.channels.cache.get("995975097909248031");


const embed = new MessageEmbed()
    .setTitle(`${message.member} try to send a link in ${channel} with message: \n  `);


if(/http:|https:|discord.gg|www./gi.test(message.content)){
    let split = content.split("");
    if (split.length >= 2000){
        embed.setDescription(`${split.toString} ...`);
    } else {
        embed.setDescription(`${content}`);
    }
   
    await linklog.send({
        content: `<@${message.author.id}> tried to send links in <#${message.channel.id}>`,
        embeds: [embed]
    });
    await message.delete();
    await channel.send(`<@${message.author.id}> No links here`);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM