Skip to content

Commit

Permalink
fix issue with default values being invalid and dashboard showing exc…
Browse files Browse the repository at this point in the history
…essive pop-ups (#1745)

Co-authored-by: Ashish <[email protected]>
  • Loading branch information
ashishjh-bst and ashishjh-bst authored Oct 24, 2024
1 parent c058c51 commit 4e8d1ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions automod_legacy/assets/automod_legacy.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ <h3>Basic automod</h3>

<div class="form-group">
<label for="NumMessages">Number of messages:</label>
<input type="number" min="0" class="form-control" name="Spam.NumMessages"
<input type="number" min="1" class="form-control" name="Spam.NumMessages"
value="{{.AutomodConfig.Spam.NumMessages}}"></input>
<p class="help-block">Number of messages sent within the time frame below for it to be triggered:</p>
</div>
<div class="form-group">
<label for="Within">Within (seconds):</label>
<input type="number" min="0" class="form-control" name="Spam.Within" value="{{.AutomodConfig.Spam.Within}}"></input>
<input type="number" min="1" class="form-control" name="Spam.Within" value="{{.AutomodConfig.Spam.Within}}"></input>
<p class="help-block">The timeframe to check messages from.</p>
</div>
<p>Something decent to just protect from raw spam could be five messages within two seconds. Normal users won't come
Expand All @@ -139,7 +139,7 @@ <h3>Basic automod</h3>

<div class="form-group">
<label for="Treshold">Mention Threshold</label>
<input type="number" min="0" class="form-control" name="Mention.Treshold"
<input type="number" min="1" class="form-control" name="Mention.Treshold"
value="{{.AutomodConfig.Mention.Treshold}}"></input>
<p class="help-block">The number of mentions in a message for it to trigger.<br>
If it's set to 5, then someone mentioning five people or more would trigger this.</p>
Expand Down
11 changes: 6 additions & 5 deletions automod_legacy/automod.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ func (c Config) Name() string {
return "Automoderator"
}

func NewConfig() *Config {
func DefaultConfig() *Config {
return &Config{
Spam: &SpamRule{},
Mention: &MentionRule{},
Spam: &SpamRule{NumMessages: 1, Within: 5},
Mention: &MentionRule{Treshold: 1},
Invite: &InviteRule{},
Links: &LinksRule{},
Sites: &SitesRule{},
Expand All @@ -64,9 +64,10 @@ func NewConfig() *Config {
}

func GetConfig(guildID int64) (config *Config, err error) {

config = NewConfig()
err = common.GetRedisJson(KeyConfig(guildID), &config)
if config == nil {
config = DefaultConfig()
}
return
}

Expand Down

0 comments on commit 4e8d1ac

Please sign in to comment.