Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Latest commit

 

History

History
21 lines (20 loc) · 772 Bytes

mentionListener.cc.md

File metadata and controls

21 lines (20 loc) · 772 Bytes

Recommend Trigger: Regex - Trigger Text: <@!?\d+>
Description: Send AFK message of user get mentioned
Usage: Mention user
Code: below

{{ $id := reFind `\d+` .Cmd | toInt64 }}
{{ if and (ne $id .User.ID) }}
{{ with (dbGet $id "afk") }}
	{{ $user := userArg .UserID }}
	{{ $eta := "" }}
	{{ if gt .ExpiresAt.Unix 0 }} {{ $eta = humanizeDurationSeconds (.ExpiresAt.Sub currentTime) | printf "*%s will be back in around %s.*" $user.Username }} {{ end }}
	{{ sendMessage nil (cembed
		"author" (sdict "name" (printf "%s is AFK" $user.String) "icon_url" ($user.AvatarURL "256"))
		"description" (joinStr "\n\n" $eta .Value)
		"color" (randInt 0 16777216)
		"footer" (sdict "text" "Away since")
		"timestamp" .UpdatedAt
	) }}
{{ end }}{{ end }}