Skip to main content

Ghost-Ping Detector v1

caution

If you are adding this command for the first time, consider looking at version two of the ghost-ping detector instead.

This command detects ghost pings.

Ghost pings

A ghost ping is when you mention a user and then delete the message, leaving a ping that cannot be found: hence the term "ghost ping".

note

This command only works if the ghost ping was deleted within 5 seconds of being sent (or 10 seconds if $CHECK is enabled).

Trigger

Type: Regex
Trigger: <@!?\d{17,19}> or \A.

Configuration

  • $CHECK
    Whether to schedule two execCC checks. The way this command works is that it checks after 5 seconds whether the message was deleted. This does mean that if you delete the message more than 5 seconds after message creation, this CC won't catch it by default.

    By enabling this option, the command will check twice instead of once, meaning that messages deleted between 5 and 10 seconds of being sent will be caught as well.

Code

{{/*
Ghost-ping detector v1.
See <https://yagpdb-cc.github.io/utilities/ghost-ping-v1> for more information.

Author: Devonte <https://github.com/devnote-dev>
*/}}

{{/* Configurable values */}}
{{ $CHECK := false }}
{{/* End of configurable values */}}

{{ if .ExecData }}
{{ $mentions := "" }}{{ $ping := false }}

{{ if ($m := getMessage nil .ExecData.message) }}
{{ if not $m.Mentions }}
{{ $ping = true }}
{{ end }}
{{ else }}
{{ $ping = true }}
{{ end }}

{{ if $ping }}
{{ if gt (len .ExecData.mentions) 1 }}
{{ range .ExecData.mentions }}
{{- $mentions = joinStr ">, <@" $mentions . -}}
{{ end }}
{{ else }}
{{ $mentions = index .ExecData.mentions 0 }}
{{ end }}

{{/* Message to send when a ping is detected: */}}
{{ sendMessage nil (print "Ghost ping detected by <@" .ExecData.author "> - <@" $mentions ">") }}
{{ else }}
{{ if and $CHECK (not .ExecData.break) }}
{{ $ids := cslice }}
{{ range .Message.Mentions }}
{{- $ids = $ids.Append (str .ID) -}}
{{ end }}

{{ execCC .CCID nil 5 (sdict "message" .Message.ID "author" .Message.Author.ID "mentions" $ids "content" .Message.Content "break" true) }}
{{ end }}
{{ end }}
{{ else }}
{{ if .Message.Mentions }}
{{ $ids := cslice }}
{{ range .Message.Mentions }}
{{ $ids = $ids.Append (str .ID) }}
{{ end }}

{{ execCC .CCID nil 5 (sdict "message" .Message.ID "author" .Message.Author.ID "mentions" $ids "break" false) }}
{{ end }}
{{ end }}

Author

This custom command was written by @devnote-dev.