Skip to main content

X Word Story Game

This command manages an X word story game.

Trigger

Type: Regex
Trigger: \A

Restrictions

Set this command to only run in your x-word-story channel in the channel restrictions.

Usage

  • Just type the correct amount of words and write a story together :)

Configuration

  • $words
    Number of words to be used in the x-word-story channel.

  • 📌 $ignored_roles
    Roles to ignore when checking whether a message posted in the channel is valid.

  • $twice
    Response when users attempt to write twice in a row.

Code

{{/*
X-word-story game.
See <https://yagpdb-cc.github.io/fun/x-word-story> for more information.

Author: SpecialEliteSNP <https://github.com/SpecialEliteSNP>
*/}}

{{/* Configurable values */}}
{{ $words := 3 }}
{{ $ignored_roles := cslice 763447831829938176 764103587223044116 778952687986802698 764054381535821825 775003755842109440 }}

{{ $twice := "you can't write a story on your own 😉" }}
{{/* End of configurable values */}}

{{/* CODE - Don't edit this part */}}
{{ $r := true }}{{ range .Member.Roles }}{{ if in $ignored_roles . }}{{ $r = false }}{{ end }}{{ end }}
{{ if $r }}
{{ $s := sdict }}{{ with (dbGet 20 "story-channel").Value }}{{ $s = sdict . }}{{ end }}
{{ if not $s }}
{{ dbSet 20 "story-channel" (sdict "l" 0) }}
{{ addReactions "☑" }}
{{ print .User.Mention ", <#" .Channel.ID "> is all set up as your " $words "-word-channel!" }}
{{ else if eq $s.l .User.ID }}
{{ addReactions "👎" }}
{{ deleteTrigger 1 }}
{{ print .User.Mention ", " $twice }}
{{ deleteResponse 5 }}
{{ else if not (reFind (print `\A\s*(?:[[:alpha:]]+\s+){` (sub $words 1) `}[[:alpha:]]+\s*\z`) .Message.Content) }}
{{ addReactions "❌" }}
{{ deleteTrigger 1 }}
{{ print .User.Mention ", please use exactly **" $words "** words in this channel 😉" }}
{{ deleteResponse 5 }}
{{ else }}
{{ $s.Set "l" .User.ID }}
{{ $s.Set (str .User.ID) (add ($s.Get (str .User.ID)) 1) }}
{{ dbSet 20 "story-channel" $s }}
{{ end }}
{{ end }}

Author

This custom command was written by @SpecialEliteSNP.