Skip to main content

Slowmode

Custom slowmode system that deletes messages that violate the slowmode time configured. Allows configuring permissions that bypass slowmode.

note

As stated above, this system does not actually prevent the user from sending messages: it simply deletes messages that violate the slowmode constraints.

Trigger

Type: Regex
Trigger: \A or .*
Additional options: Errors as custom command output disabled

Usage

  • -slowmode on <time> - Turns on the slowmode, using time in seconds as the slowmode time.
  • -slowmode off - Disables slowmode.

Configuration

  • $bypassperms
    Permissions required to bypass slowmode.

    Available permissions:
    • Administrator
    • ManageServer
    • ReadMessages
    • SendMessages
    • SendTTSMessages
    • ManageMessages
    • EmbedLinks
    • AttachFiles
    • ReadMessageHistory
    • MentionEveryone
    • VoiceConnect
    • VoiceSpeak
    • VoiceMuteMembers
    • VoiceDeafenMembers
    • VoiceMoveMembers
    • VoiceUseVAD
    • ManageNicknames
    • ManageRoles
    • ManageWebhooks
    • ManageEmojis
    • CreateInstantInvite
    • KickMembers
    • BanMembers
    • ManageChannels
    • AddReactions
    • ViewAuditLogs
  • $usageperms
    Permissions required to run slowmode commands.

    Available permissions:
    • Administrator
    • ManageServer
    • ReadMessages
    • SendMessages
    • SendTTSMessages
    • ManageMessages
    • EmbedLinks
    • AttachFiles
    • ReadMessageHistory
    • MentionEveryone
    • VoiceConnect
    • VoiceSpeak
    • VoiceMuteMembers
    • VoiceDeafenMembers
    • VoiceMoveMembers
    • VoiceUseVAD
    • ManageNicknames
    • ManageRoles
    • ManageWebhooks
    • ManageEmojis
    • CreateInstantInvite
    • KickMembers
    • BanMembers
    • ManageChannels
    • AddReactions
    • ViewAuditLogs

Code

{{/*
Custom slowmode system that deletes messages that violate the slowmode time configured. Allows configuring permissions that bypass slowmode.
See <https://yagpdb-cc.github.io/moderation/slowmode> for more information.

Author: sponge <https://github.com/Spongerooski>
*/}}

{{/* Configurable values */}}
{{ $bypassperms := .Permissions.ManageMessages }}
{{ $usageperms := .Permissions.ManageMessages }}
{{/* End of configurable values */}}

{{/* ACTUAL CODE */}}
{{ if hasPermissions $usageperms }}
{{ if $matches := reFindAllSubmatches `\A-slowmode on (\d+)` .Message.Content }}
{{ $slowmodeduration := (index $matches 0 1) }}
{{ with (dbGet 660 "channels").Value }}
{{ $value := sdict . }}
{{ $value.Set (str $.Channel.ID) (str $slowmodeduration) }}
{{ dbSet 660 "channels" $value }}
{{ else }}
{{ dbSet 660 "channels" (sdict (str $.Channel.ID) (str $slowmodeduration)) }}
{{ end }}
done! slowmode has been set to `{{ $slowmodeduration }}s`
{{ else if reFind `\A-slowmode off` .Message.Content }}
{{ if $db := (dbGet 660 "channels").Value }}
{{ $value := sdict $db }}
{{ $value.Del (str $.Channel.ID) }}
{{ dbSet 660 "channels" $value }}
{{ end }}
the slowmode has been removed from this channel
{{ end }}
{{ end }}

{{ if not (hasPermissions $bypassperms) }}
{{ if $db := (dbGet 660 "channels").Value }}
{{ $value := sdict $db }}
{{ $get := $value.Get (str .Channel.ID) }}
{{ if $get }}
{{ if $slowmode := dbGet .User.ID (str .Channel.ID) }}
{{ deleteTrigger 0 }}
{{ else }}
{{ dbSetExpire .User.ID (str .Channel.ID) "epic" (toInt $get) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}

Author

This custom command was written by @Spongerooski.