Security: tune the Join Gate, raid mode, anti-nuke and heat with commands
- /security settings, joingate check|account-age, words add|remove|list, raid, antinuke set|limit, heat, alert-dms - Same rule as the rest of the configuration: owner or trusted, validated in the engine - schema.sql was missing security_settings.alert_dm, so the bot couldn't read security settings on a database built from it. Fixed, with an ALTER for existing installs - A test checks every command against Discord's limits Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
5657d0789a
commit
d95ebf473e
10 files changed
+1020
-4
No files matched your search
@@ -43,7 +43,7 @@ var Security = &discordgo.ApplicationCommand{
|
||||
Description: "Anti-raid and anti-nuke protection",
|
||||
DefaultMemberPermissions: &manageGuild,
|
||||
Contexts: guildOnly,
|
||||
Options: []*discordgo.ApplicationCommandOption{
|
||||
Options: append([]*discordgo.ApplicationCommandOption{
|
||||
{Type: discordgo.ApplicationCommandOptionSubCommand, Name: "status", Description: "Show what's on and who is trusted"},
|
||||
{
|
||||
Type: discordgo.ApplicationCommandOptionSubCommand, Name: "toggle", Description: "Turn a protection on or off",
|
||||
@@ -94,7 +94,7 @@ var Security = &discordgo.ApplicationCommand{
|
||||
{Type: discordgo.ApplicationCommandOptionSubCommand, Name: "end-raid", Description: "End raid mode now (owner or trusted)"},
|
||||
{Type: discordgo.ApplicationCommandOptionSubCommand, Name: "snapshot", Description: "Save a snapshot of roles and channels to restore from"},
|
||||
{Type: discordgo.ApplicationCommandOptionSubCommand, Name: "restore", Description: "Recreate deleted roles and channels from the latest snapshot (owner or trusted)"},
|
||||
},
|
||||
}, tuneOptions()...),
|
||||
}
|
||||
|
||||
func lockOptions(unlock bool) []*discordgo.ApplicationCommandOption {
|
||||
@@ -211,6 +211,10 @@ func SecurityHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), opTimeout)
|
||||
defer cancel()
|
||||
|
||||
if handleTune(ctx, s, i, e, sub) {
|
||||
return
|
||||
}
|
||||
|
||||
switch sub.Name {
|
||||
case "status":
|
||||
if !allowedOrTrusted(ctx, e, i, discordgo.PermissionManageGuild) {
|
||||
@@ -434,7 +438,7 @@ func status(ctx context.Context, e *security.Engine, guildID string) string {
|
||||
fmt.Fprintf(&b, ", <@%d>", t.TargetID)
|
||||
}
|
||||
}
|
||||
b.WriteString("\nFine-tune filters, limits and actions on the dashboard.")
|
||||
b.WriteString("\nSee every setting with `/security settings`, and change them with `/security joingate`, `words`, `raid`, `antinuke` and `heat`.")
|
||||
return b.String()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user