discord-anti-spam icon indicating copy to clipboard operation
discord-anti-spam copied to clipboard

Can you make it so I can add embeds?

Open FxckingAngel opened this issue 3 years ago • 17 comments

const antiSpam = new AntiSpam({ warnThreshold: 3, muteThreshold: 4, maxInterval: 2000, warnMessage: "{@user}, Please stop spamming", muteMessage: [em], //That's the embed maxDuplicatesWarning: 6, maxDuplicatesMute: 8, ignoredPermissions: ["ADMINISTRATOR"], ignoreBots: true, verbose: true, ignoredMembers: [], unMuteTime: 10, removeMessages: true, modLogsEnabled: false, modLogsChannelName: "mod-logs", modLogsMode: "embed", });

FxckingAngel avatar Feb 13 '22 05:02 FxckingAngel

Have you tried putting it out of a array?

Scraayp avatar Feb 13 '22 07:02 Scraayp

No I will try

FxckingAngel avatar Feb 16 '22 06:02 FxckingAngel

I does not work with or without the array.

FxckingAngel avatar Feb 16 '22 06:02 FxckingAngel

Can you send the embed code also

Scraayp avatar Feb 16 '22 06:02 Scraayp

var em = new Discord.MessageEmbed() .setTitle(Muted!) .setDescription(Admin has muted you!) .setColor(800080) .setImage("https://i.pinimg.com/originals/93/4a/c2/934ac2e1254bfe067aff258f92260310.gif")

FxckingAngel avatar Feb 16 '22 06:02 FxckingAngel

I'll look into this later today.

Scraayp avatar Feb 16 '22 06:02 Scraayp

also here error sorry for not giving all info before asking

if (typeof data !== 'string') throw new error(errorMessage);
                                    ^

RangeError [EMBED_DESCRIPTION]: MessageEmbed description must be a string.

FxckingAngel avatar Feb 16 '22 06:02 FxckingAngel

Oh. Ye that explains alot

Scraayp avatar Feb 16 '22 06:02 Scraayp

This may work! message.channel.send({ embeds: this.format(this.options.muteMessage, message}))

FxckingAngel avatar Feb 16 '22 16:02 FxckingAngel

for a catch

FxckingAngel avatar Feb 16 '22 16:02 FxckingAngel

You can simply rely on the packages events... like warnAdd on that event:

antiSpam.onEvent("warnAdd", (member) => {
   //create your embed in here and send it to the log channel, or whichever channel you want.
   //in my case here is my code:
    const logChannel = member.guild.channels.cache.find(c => c.name.includes("mod-logs"));
    if (logChannel) {
        const embed = new MessageEmbed()
            .setColor("#ff0000")
            .setTitle("Member Warned")
            .setThumbnail(member.guild.me.user.displayAvatarURL())
            .setFooter({ text: member.guild.me.displayName, iconURL: member.guild.me.user.displayAvatarURL() })
            .setTimestamp()
            .setDescription(stripIndents`
            **Warned member:** ${member} (${member.id})
            **Warned By:** ${member.guild.me}
            **Reason:** Spam`)
        logChannel.send({text: '', embeds: embed});
    }
});

comicallybad avatar Feb 21 '22 03:02 comicallybad

@FxckingAngel Have you tried to using an actual string?

var em = new Discord.MessageEmbed()
       .setTitle("Muted!")
       .setDescription("Admin has muted you!")
   	.setColor(800080)
       .setImage("https://i.pinimg.com/originals/93/4a/c2/934ac2e1254bfe067aff258f92260310.gif")
     

Scraayp avatar Feb 21 '22 07:02 Scraayp

sorry for late reply they both work but for the first one need to fix this

antiSpam.on("warnAdd", (member) => {
    const logChannel = member.guild.channels.cache.find(c => c.name.includes("mellie-logs"));
    if (logChannel) {
        const embed = new MessageEmbed()
            .setColor("#800080")
            .setTitle("Member Warned")
        .setThumbnail(member.guild.me.user.displayAvatarURL())
            .setFooter({ text: member.guild.me.displayName, iconURL: member.guild.me.user.displayAvatarURL() })
            .setTimestamp()
            .setDescription(`
            **Warned member:** ${member} (${member.id})
            **Warned By:** ${member.guild.me}
            **Reason:** Spam`)
        logChannel.send({embeds: [embed]});
    }
});

yes but It won't send @Scraayp

FxckingAngel avatar Feb 24 '22 04:02 FxckingAngel

You can simply rely on the packages events... like warnAdd on that event:

antiSpam.onEvent("warnAdd", (member) => {
   //create your embed in here and send it to the log channel, or whichever channel you want.
   //in my case here is my code:
    const logChannel = member.guild.channels.cache.find(c => c.name.includes("mod-logs"));
    if (logChannel) {
        const embed = new MessageEmbed()
            .setColor("#ff0000")
            .setTitle("Member Warned")
            .setThumbnail(member.guild.me.user.displayAvatarURL())
            .setFooter({ text: member.guild.me.displayName, iconURL: member.guild.me.user.displayAvatarURL() })
            .setTimestamp()
            .setDescription(stripIndents`
            **Warned member:** ${member} (${member.id})
            **Warned By:** ${member.guild.me}
            **Reason:** Spam`)
        logChannel.send({text: '', embeds: embed});
    }
});

This works just fix it like mine above https://github.com/Michael-J-Scofield/discord-anti-spam/issues/160#issuecomment-1049491176

FxckingAngel avatar Feb 24 '22 05:02 FxckingAngel

That doesn't fix the issue why the warnMessage option already doesn't give the option to add the embeds.

Scraayp avatar Feb 24 '22 07:02 Scraayp

Hello, i have read the code of the module and i have find this lines that make the crash when you using embeds messages (you need to a .content a the end of the this.format())

222 if (embed.description) embed.setDescription(embed.description) 223 if (embed.title) embed.setTitle(embed.title) 224 if (embed.footer && embed.footer.text) embed.footer.text = this.format(embed.footer.text, message) 225 if (embed.author && embed.author.name) embed.author.name = this.format(embed.author.name, message)

ddemile avatar May 17 '22 05:05 ddemile

Hello, i have read the code of the module and i have find this lines that make the crash when you using embeds messages (you need to a .content a the end of the this.format())

222 if (embed.description) embed.setDescription(embed.description) 223 if (embed.title) embed.setTitle(embed.title) 224 if (embed.footer && embed.footer.text) embed.footer.text = this.format(embed.footer.text, message) 225 if (embed.author && embed.author.name) embed.author.name = this.format(embed.author.name, message)

I already found out :). It's in my work in progress branch.

But thank you for letting know!

Scraayp avatar May 17 '22 06:05 Scraayp

A option to add embeds was added in v2.8.0. Please see https://discord-anti-spam.js.org for more information!

Scraayp avatar Sep 12 '22 13:09 Scraayp