Git Product home page Git Product logo

Comments (10)

scottricity avatar scottricity commented on June 18, 2024 1

your using it the wrong way too LOL, You have the settings in a other function, Keep the settings outside both and tada, READ THE EXAMPLES KID

you're*
If you're going to be unprofessional, do it properly.

from discord-anti-spam.

ari-party avatar ari-party commented on June 18, 2024

your using it the wrong way too LOL, You have the settings in a other function, Keep the settings outside both and tada, READ THE EXAMPLES KID

from discord-anti-spam.

ari-party avatar ari-party commented on June 18, 2024

just read the examples on the npmjs.org site

from discord-anti-spam.

Jaxenormus avatar Jaxenormus commented on June 18, 2024

I can’t have the settings on the outside because I require the guild ID

from discord-anti-spam.

Androz2091 avatar Androz2091 commented on June 18, 2024

@CalebDelbridge you can use something like that:

const AntiSpam = require('discord-anti-spam');
let AntiSpamClients = {};

client.on("message", async message => {
    let antiSpam = AntiSpamClients[message.guild.id];
    if(!antiSpam){
        let warnThresholdSetting = client.guildSpamSettings.get(message.guild.id, "warnThreshold")
        let kickThresholdSetting = client.guildSpamSettings.get(message.guild.id, "kickThreshold")
        let banThresholdSetting = client.guildSpamSettings.get(message.guild.id, "banThreshold")
        let maxIntervalSetting = client.guildSpamSettings.get(message.guild.id, "maxInterval")
        let maxDuplicatesWarningSetting = client.guildSpamSettings.get(message.guild.id, "maxDuplicatesWarning")
        let maxDuplicatesKickSetting = client.guildSpamSettings.get(message.guild.id, "maxDuplicatesKic")
        let maxDuplicatesBanSetting = client.guildSpamSettings.get(message.guild.id, "maxDuplicatesBan")
        antiSpam = new AntiSpam({
             warnThreshold: warnThresholdSetting, // Amount of messages sent in a row that will cause a warning.
             kickThreshold: kickThresholdSetting, // Amount of messages sent in a row that will cause a ban.
             banThreshold: banThresholdSetting, // Amount of messages sent in a row that will cause a ban.
             maxInterval: maxIntervalSetting, // Amount of time (in milliseconds) in which messages are considered spam.
             warnMessage: '{@user}, Please stop spamming.', // Message that will be sent in chat upon warning a user.
             kickMessage: '**{user_tag}** has been kicked for spamming.', // Message that will be sent in chat upon kicking a user.
             banMessage: '**{user_tag}** has been banned for spamming.', // Message that will be sent in chat upon banning a user.
             maxDuplicatesWarning: maxDuplicatesWarningSetting, // Amount of duplicate messages that trigger a warning.
             maxDuplicatesKick: maxDuplicatesKickSetting, // Amount of duplicate messages that trigger a warning.
             maxDuplicatesBan: maxDuplicatesBanSetting, // Amount of duplicate messages that trigger a warning.
             ignoreBots: false, // Ignore bot messages.
             verbose: false, // Extended Logs from module.	warnEnabled: true,
             warnEnabled: true,
             kickEnabled: true,
             banEnabled: true
        });
        AntiSpamClients[message.guild.id] = antiSpam;
    }
    antiSpam.message(message); // it works!!
});

from discord-anti-spam.

Jaxenormus avatar Jaxenormus commented on June 18, 2024

@Androz2091 for some reason it wont work with the variable names but when I input numbers directly it does work I have no idea whats going on here

from discord-anti-spam.

Androz2091 avatar Androz2091 commented on June 18, 2024

And it worked with your old code?

from discord-anti-spam.

Jaxenormus avatar Jaxenormus commented on June 18, 2024

No what I meant is that when I remove the client.guildSettings variables and just input numbers it works fine but when I use the variable names it does not

from discord-anti-spam.

Androz2091 avatar Androz2091 commented on June 18, 2024

Can you print the result of those calls in the console? like that:

let warnThresholdSetting = client.guildSpamSettings.get(message.guild.id, "warnThreshold")
console.log(warnThresholdSetting);

for each setting

from discord-anti-spam.

Jaxenormus avatar Jaxenormus commented on June 18, 2024

Here you go:

    let warnThresholdSetting = await client.guildSpamSettings.get(message.guild.id, "warnThreshold")
    let kickThresholdSetting = await client.guildSpamSettings.get(message.guild.id, "kickThreshold")
    let banThresholdSetting = await client.guildSpamSettings.get(message.guild.id, "banThreshold")
    let maxIntervalSetting = await client.guildSpamSettings.get(message.guild.id, "maxInterval")
    let maxDuplicatesWarningSetting = await client.guildSpamSettings.get(message.guild.id, "maxDuplicatesWarning")
    let maxDuplicatesKickSetting = await client.guildSpamSettings.get(message.guild.id, "maxDuplicatesKick")
    let maxDuplicatesBanSetting = await client.guildSpamSettings.get(message.guild.id, "maxDuplicatesBan")
    console.log(warnThresholdSetting)
    console.log(kickThresholdSetting)
    console.log(banThresholdSetting)
    console.log(maxIntervalSetting)
    console.log(maxDuplicatesBanSetting)
    console.log(maxDuplicatesKickSetting)
    console.log(maxDuplicatesWarningSetting)

3
7
7
2000
12
10
7

from discord-anti-spam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.