What a rule is
A rule watches your server. When it sees what you told it to look for, it does something.
rule: no-invites
on: message.sent
when: message.invites > 0
then:
- deleterule:the rule's name: small letters, numbers and-.on:when it wakes up. Here: every time someone sends a message.when:what has to be true. Here: the message has an invite link.then:what it does. Here: it deletes the message.
That's a whole rule. Everything else is extra. about: adds one line that shows on the rule's card.
Adding a rule: run antiraid customrules add and paste it, or upload a .yaml file. You can also start from a ready-made one: antiraid customrules templates.
New rules start in test mode. They only write down what they would do, so you can check them first. Testing shows how.
One file, many parts: put --- on its own line between them.
When it runs
on: picks the moment your rule wakes up. Give one, or a list: on: [message.sent, message.edited].
Each one lets the rule check different things: a message has text, a member has roles. The full list comes next; Fields says what each one holds.
message.sentA member sends a message. · has category, channel, member, messagemessage.editedA message's text changes;before.*is the text before. · has before, category, channel, member, messagemessage.deletedA message the bot still remembers is deleted. · has category, channel, member, messagereaction.addedA reaction is added, on any message however old. · has category, channel, member, reactionreaction.removedA reaction is taken off. · has category, channel, member, reactionmember.joinedSomeone joins. · has membermember.leftSomeone leaves, is kicked or banned. · has membermember.roles_changedA member's roles change;roles.added/roles.removedsay which. · has member, rolesmember.renamedA nickname or username changes;before_member.*is the old one. · has before_member, membermember.boostedA member starts boosting. · has membermember.timed_outA member is timed out, by anyone. · has membervoice.joinedA member joins a voice channel. · has category, channel, member, voicevoice.leftA member leaves voice. · has category, channel, member, voicevoice.movedA member moves between voice channels;voice.beforeis where from. · has category, channel, member, voicethread.createdA member starts a thread. · has category, channel, memberchannel.createdA channel is created. · has category, channelinvite.createdAn invite is created. · has category, channel, invite, memberautomod.hitDiscord's AutoMod acts on a member. · has automod, category, channel, memberraid.startedAntiRaid catches a raid (any of its events trips);memberis who set it off. · has member, raidraid.ended15 minutes after a raid's last trip, or when staff unlock (raid.reason). · has raidscheduleOn a timer:every: 6h, or a time likeevery: mon 09:00withtimezone:.manualOnly when run withantiraid customrules run. · has member
Where and who
where:
channels: ["#general", "#memes"]
skip: [mods, "@Trusted"]
limit: 1 per member per 10mwhere:only these channels or categories:channels,categories. Or leave some out withignore_channels,ignore_categories. Nowhere:means everywhere.skip:who the rule leaves alone: roles, members,mods,admins,owner, or a saved list likelist("vip"). Bots are always left alone.limit:how often it may act.1 per member per 10mmeans once every 10 minutes for each person. You can also sayper channel,per categoryorper server, for up to 30 days.
Names like "#general" and "@Trusted" are saved as IDs. If you rename the channel, the rule keeps working; the next time you save it, you're asked to use the new name.
Checks
when: is what has to be true. One check:when: member.joined < 3d → "joined less than 3 days ago"
More than one check: one per line, in a group.
when:
all:
- message.invites > 0
- member.joined < 3dall:every line must be true.any:at least one line must be true.not:none of the lines may be true.
A group can hold another group:
when:
all:
- message.invites > 0
- any:
- member.joined < 3d
- member.created < 1wComparing:
==is,!=isn't>more than,<less than,>=at least,<=at mostcontainshas this text anywhere;has wordhas it as a whole wordstartswith,endswith: how the text begins or endsin: is one of these:channel.name in ["general", "memes"]has any [...]/has all [...]:member.roles has any list("vip")matches '...': a pattern (regex), for when nothing else fits- Add
anyto check several at once:message.text contains any ["free nitro", "steam gift"] - On a list of texts, they ask about each item:
message.files endswith any [".exe", ".scr"]
Time: member.created < 1w → "the account is less than a week old". 30s seconds, 10m minutes, 2h hours, 3d days, 2w weeks.
Big and small letters don't matter: message.text == "hi" also matches "Hi". Only matches cares: message.text matches '^Hi$'.
Shortcut: and, or, not and brackets put checks on one line: message.invites > 0 and member.joined < 3d.
Fields
Fields are what a check can look at, like member.joined or message.text. Which ones you get depends on on:: a rule on: member.joined has no message, so no message.*.
The word in brackets is what it holds: a number, some text, yes/no, a time, or IDs. The full list comes next.
- message
message.text(text),message.length(number),message.lines(number),message.caps(number),message.letters(number),message.words(texts),message.mentions(number),message.role_mentions(number),message.everyone(yes/no),message.links(number),message.domains(texts),message.invites(number),message.emojis(number),message.attachments(number),message.files(texts),message.stickers(number),message.id(ID),message.link(text),message.created(time),message.reply(yes/no),message.forwarded(yes/no),message.edited(yes/no),message.command(yes/no),message.foreign_invites(number) - before
before.text(text),before.length(number),before.lines(number),before.caps(number),before.letters(number),before.words(texts),before.mentions(number),before.role_mentions(number),before.everyone(yes/no),before.links(number),before.domains(texts),before.invites(number),before.emojis(number),before.attachments(number),before.files(texts),before.stickers(number) - member
member.id(ID),member.name(text),member.display(text),member.nick(text),member.mention(text),member.avatar(text),member.roles(IDs),member.perms(texts),member.joined(time),member.created(time),member.avatar_default(yes/no),member.bot(yes/no),member.pending(yes/no),member.boosting(yes/no),member.timed_out(yes/no) - channel
channel.id(ID),channel.name(text),channel.mention(text),channel.nsfw(yes/no),channel.slowmode(duration),channel.thread(yes/no),channel.parent(ID),channel.type(text) - category
category.id(ID),category.name(text) - server
server.id(ID),server.name(text),server.members(number),server.icon(text) - roles
roles.added(IDs),roles.removed(IDs) - rule
rule.name(text) - before_member
before_member.name(text),before_member.display(text),before_member.nick(text) - reaction
reaction.emoji(text),reaction.name(text),reaction.custom(yes/no),reaction.emoji_id(ID),reaction.message(ID),reaction.author(ID),reaction.link(text),reaction.super(yes/no) - voice
voice.before(ID),voice.before_name(text),voice.members(number),voice.muted(yes/no),voice.deafened(yes/no),voice.streaming(yes/no),voice.video(yes/no) - invite
invite.code(text),invite.max_uses(number),invite.max_age(duration),invite.temporary(yes/no) - automod
automod.rule(ID),automod.action(text),automod.keyword(text),automod.matched(text),automod.content(text) - raid
raid.id(number),raid.event(text),raid.label(text),raid.started(time),raid.duration(duration),raid.trips(number),raid.offenders(number),raid.channel(ID),raid.reason(text) - var
var.name: a value alet:step saved earlier in the rule message.invitescounts every invite link;message.foreign_invitesonly invites to other servers (the bot needs Manage Server to know yours).
What it does
then: is a list of steps, done from top to bottom.
then:
- delete
- timeout: 1h
reason: Invite from a new account
- send:
to: "#mod-log"
content: "{member.mention} posted an invite."A step with options gets a colon after its name, with the options under it: - delete: then required: true on the next line.
Options any step can have:
required: true: if this step fails, the rest of the rule stops.after: 10m: do this step later, up to 1 day.
Every step is listed next.
replyAnswers the message:reply: "Please don't spam."delete_after: 30sremoves it later;ping: truepings them.sendPosts a message in a channel:send: { to: "#staff", content: "…" }, or a saved one by name:send: invite-alert.dmSends them a private message:dm: "Welcome!". Closed DMs don't count as the rule failing.reactAdds a reaction to the message:react: "👀"pinPins the message.remove_reactionTakes the reaction back off (onreaction.added).deleteDeletes the message.create_threadStarts a thread on the message:create_thread: "Questions".duration: 1dcloses it after a quiet day.timeoutMutes them for a while:timeout: 1h.reason:says why.untimeoutEnds their timeout.warnWarns them:warn: "Spamming". It's saved as a ModUtils case.kickRemoves them from the server; they can join again.reason:says why.banBans them.delete_days: 1also deletes their messages from the last day.softbanBans and unbans them straight away, so they're removed and their recent messages are deleted.add_roleGives a role:add_role: "@Muted".for: 1htakes it off again after an hour.remove_roleTakes a role away:remove_role: "@Verified".for: 1hgives it back after an hour.clear_roleTakes a role off everyone who has it:clear_role: "@Pman". It goes slowly, about one person every 2 seconds.nicknameChanges their nickname:nickname: "{member.name}"voice_moveMoves them to another voice channel:voice_move: "#AFK"voice_disconnectTakes them out of voice.slowmodeSets slowmode:slowmode: 30s.in: "#general"picks the channel.lockStops everyone talking in a channel.in: ["#general"]picks channels;for: 10munlocks after 10 minutes.unlockLets everyone talk again;in:picks channels.lockdownAntiRaid's lockdown:lockdown: publiclocks every channel everyone can see,lockdown: guildevery channel.for: 30mends it.unlockdownEnds AntiRaid's lockdown.countAdds 1 to a count:count: strikes. See Counting.reset_countPuts a count back to 0:reset_count: strikesletSaves a value for the steps after it:let: { greeting: pick('Hi', 'Hey') }, used as{var.greeting}.stopStops any other rule from running for the same thing.run_commandRuns a bot command:run_command: warnings {member.id}. Only commands the bot owner allowed, run as whoever last saved the rule.quiet: trueputs its replies in the rule log instead.
Counting
A rule can count things, like how many messages someone sent, and then act on the number.
then:
- count: messages
- if: count('messages', 5s) >= 6
then:
- timeout: 10m
- reset_count: messagescount: messagesadds 1 to this person'smessagescount.count('messages', 5s)is how many they had in the last 5 seconds.if:asks a question. Itsthen:steps run when the answer is yes; addelse:for steps when it's no.reset_count: messagesstarts the count from 0 again.
Counting per channel: counts are per person unless you say otherwise. Add by: channel (or category, server) under count:, and read it with count('messages', 5s, channel).
**stop:** a step that stops any other rule from running for the same thing.
Messages and placeholders
Anything in { } is filled in when the rule runs:
"Welcome {member.mention}!"→ "Welcome @Ava!""{count('invites', 1h)} invites this hour"→ "3 invites this hour"
Braces that aren't ours stay as they are, so text from other bots is safe to paste.
Quotes: text with # in it goes in quotes: "Ask in #help". Without them, YAML thinks #help is a note to itself and drops it. A note of your own is # and a space: # like this.
Pings: a message only pings who your rule names itself, like {member.mention} or a role you wrote. Pings copied from someone's message don't ping.
Remembering something: let: saves a value for the steps after it, read as {var.name}.
then:
- let:
hello: pick('Welcome', 'Hey', 'Glad you made it')
- send:
to: "#general"
content: "{var.hello}, {member.mention}!"Functions
Functions are small helpers for checks and { }. You give them something in brackets and they give back an answer: len(message.words) is how many words a message has.
The full list comes next.
count('strikes', 1d)How manycount: strikessteps this person had in the last day. A third part counts forchannel,categoryorserverinstead.list('staff')The items in a saved list.normalize(message.text)The text with tricks undone, in small letters:FR33 N1TRO→free nitro. Look-alike letters and zalgo too.lower(member.name)The text in small letters.upper(member.name)The text in capitals.len(message.words)How many: words, items or letters.chance(10%)Yes one time in ten, at random.mentions(list('staff'))A list turned into pings.pick('Hi', 'Hey', 'Hello')One of them, at random.pick(list('replies'))picks from a list.
Lists, messages and keep rules
Besides rules, you can save three other things. Put --- between them in one file.
**list:** items to use in many rules:
list: staff
items: ["@Moderators", "@Admins"]Use it as skip: [list("staff")] or member.roles has any list("staff"). A list holds roles, channels and members, or words. One plain word makes it all words, so "@everyone" stays text: match it with contains any.
**message:** a message to send from many rules:
message: invite-alert
to: "#mod-log"
content: "{member.mention} posted an invite."Use it as - send: invite-alert.
**keep:** something that should always be true for every member:
keep: booster-divider
role: "@Boosters"
while: member.roles has any list("booster-roles")The member gets the role while while: is true, and loses it when it isn't. A keep rule can set a nickname: instead of a role. It's checked whenever a member changes, and once for everyone when you save it.
Testing and going live
Every rule has a mode:
test: it runs, but only writes down what it would do. New rules start here.live: it really acts.off: it does nothing.
Change it with the Mode menu on the rule's card, or antiraid customrules mode <name> live.
Before going live:
antiraid customrules try <name> <message link or text>shows each check as ✅ or ❌ and each step it would do. Nothing happens.antiraid customrules logshows what your rules did, or would have done in test mode.
Your rules: antiraid customrules view lists them; pick one to see its card. The dashboard's Rules page has the same, with a form to build a rule by clicking.
Limits
- 150 rules, 25 keep rules and 25 schedules per server; 50 rules on one trigger.
- 25 steps per rule; a document is at most 20 KB.
count()looks back up to 30 days;after:anddelete_after:wait up to 1 day;for:up to 28 days.- 5,000 saved steps waiting per server. An
after:step over an hour late (the bot was offline) is skipped, but roles and locks always end. - A schedule runs at most every 10 minutes.
- Each minute, a server's rules share 60 actions (deleting, timeouts, messages, roles and the rest), 120 reactions, and 30 changes for big jobs (
clear_role, a keep rule's first check). Past one of those, the step is skipped and logged. - Reactions wait their turn in each channel, so the steps after them don't wait. One still waiting after a minute is dropped and logged.
- While AntiRaid sees a raid, rules get half the reactions and big jobs pause, so the bot can act on the raid first.
- A rule that fails 10 times in a row is switched off, and AntiRaid's log channel is told.
- A
lockdownstep runs at most once every 10 minutes per server. - A
matchespattern gets 5 ms per message; a slower one counts as no match and is logged.
Ready-made rules
49 rules to start from, from one-liners to whole setups. Install one in Discord with [p]antiraid customrules templates: it asks for your channels and roles, and starts in test mode. Or copy one and add it with [p]antiraid customrules add, after changing names like #mod-log to your own.
Safety
Rules that keep spam, scams and raiders out.
anti-invitemedium Deletes invites to other servers; a third within an hour gets a timeout.
Shows message.foreign_invites, count, if / else
See the YAML
rule: anti-invite
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Deletes invites to other servers; a third within an hour gets a timeout.
on: [message.sent, message.edited] # new and edited messages
skip: [mods]
when: message.foreign_invites > 0 # an invite to another server (yours are fine)
then:
- delete
- count: invites
- if: count('invites', 1h) >= 3 # their third in an hour?
then:
- timeout: 1h
reason: Posting invite links
- reset_count: invites
else: # first or second: a warning
- send:
content: "{member.mention}, invite links aren't allowed here."
delete_after: 10s # the warning goes after 10 secondsanti-spammedium Times out a member who sends 6 messages within 5 seconds.
Shows count over a few seconds, reset_count
See the YAML
rule: anti-spam
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Times out a member who sends 6 messages within 5 seconds.
on: message.sent # runs on every message
skip: [mods] # mods are left alone
then:
- count: messages # add 1 to this member's count
- if: count('messages', 5s) >= 6 # 6 or more in 5 seconds?
then:
- delete
- timeout: 10m
reason: Sending messages too fast
- reset_count: messages # count from 0 againdehoistmedium A display name starting with a symbol, to sit at the top of the member list, is reset to the username.
Shows a keep rule with nickname:, an any: group
See the YAML
keep: dehoist
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: A display name starting with a symbol is reset to the username.
nickname: "{member.name}" # the nickname to give: their username
while: # the name starts with any of these
any:
- member.display startswith "!"
- member.display startswith "?"
- member.display startswith "."
- member.display startswith ","
- member.display startswith "-"
- member.display startswith "_"
- member.display startswith "*"
- member.display startswith "+"
- member.display startswith "#"
- member.display startswith "("
- member.display startswith ")"
- member.display startswith "["
- member.display startswith "~"
- member.display startswith "'"
- member.display startswith "="
- member.display startswith "<"
- member.display startswith ">"
- member.display startswith "/"
- member.display startswith ":"
- member.display startswith ";"
- member.display startswith "^"
- member.display startswith "&"
- member.display startswith "%"
- member.display startswith "$"
- member.display startswith "@"The same checks on one line, using the shortcut:
while: member.display startswith any ["!", "?", ".", ",", "-", "_", "*", "+", "#", "(", ")", "[", "~", "'", "=", "<", ">", "/", ":", ";", "^", "&", "%", "$", "@"]no-exesmall Deletes .exe, .scr and .bat files, with a short notice.
Shows message.files endswith any, delete_after:
See the YAML
rule: no-exe
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Deletes .exe, .scr and .bat files, with a short notice.
on: message.sent
when: message.files endswith any [".exe", ".scr", ".bat"] # any file ending like this
then:
- delete
- send:
content: "{member.mention}, programs can't be shared here."
delete_after: 10s # the notice goes after 10 secondsscam-linksmedium Deletes links to scam sites. Bans if they joined today, otherwise a timeout.
Shows a list:, contains any, if / else, ban with delete_days:
See the YAML
list: scam-sites
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
items: ["discord-gift.com", "dlscord.gg", "steamcommunity.ru", "free-nitro.xyz"] # add more as you see them
---
rule: scam-links
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Deletes links to scam sites. Bans if they joined today, otherwise a timeout.
on: [message.sent, message.edited]
skip: [mods]
when:
any: # either of these is enough
- message.domains has any list("scam-sites")
- normalize(message.text) contains any ["free nitro", "steam gift"]
then:
- delete
- if: member.joined < 1d # joined today: most likely a scam account
then:
- ban:
reason: Scam link
delete_days: 1 # also clears their messages from the last day
else:
- timeout: 1h
reason: Scam linkmass-mentionssmall 5 or more pings in one message: deleted, and a 10-minute timeout.
Shows comparing numbers, reason:
See the YAML
rule: mass-mentions
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: 5 or more pings in one message are deleted, with a 10-minute timeout.
on: message.sent
skip: [mods]
when: message.mentions >= 5 # 5 or more people pinged
then:
- delete
- timeout: 10m
reason: Pinging lots of people at oncesneaky-editsmall Deletes a message that was edited to add a link.
Shows message.edited, before.*
See the YAML
rule: sneaky-edit
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Deletes a message that was edited to add a link.
on: message.edited
skip: [mods]
when: message.links > before.links # more links now than before the edit
then:
- deletelink-floodsmall A message linking 3 or more different sites is deleted.
Shows len()
See the YAML
rule: link-flood
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: A message linking 3 or more different sites is deleted.
on: message.sent
skip: [mods]
when: len(message.domains) >= 3 # how many different sites it links
then:
- delete
- send:
content: "{member.mention}, that's a lot of links at once."
delete_after: 10sghost-pingmedium Someone pings and deletes it within a minute: the bot says so.
Shows message.deleted, time checks, or
See the YAML
rule: ghost-ping
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Someone pings and deletes it within a minute, so the bot says so.
on: message.deleted
when:
all:
- message.mentions > 0 or message.role_mentions > 0 # it pinged someone
- message.created < 1m # and was gone within a minute
then:
- send:
content: "👻 {member.mention} pinged and deleted it: {message.text}"clean-namesmedium Renames anyone who joins or changes to a name with a banned word.
Shows member.renamed, normalize(), nickname
See the YAML
list: name-words
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
items: ["badword", "anotherbadword"] # change these to your own
---
rule: clean-names
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Renames anyone who joins or changes to a name with a banned word.
on: [member.joined, member.renamed]
skip: [mods]
when: normalize(member.display) has word any list("name-words") # tricks like b4dw0rd count too
then:
- nickname: "Renamed member"
reason: Name with a banned wordautomod-escalatemedium A third Discord AutoMod hit in a day becomes a 1-hour timeout.
Shows automod.hit, count over a day
See the YAML
rule: automod-escalate
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: A third Discord AutoMod hit in a day becomes a 1-hour timeout.
on: automod.hit # Discord's own AutoMod caught them
then:
- count: automod
- if: count('automod', 1d) >= 3
then:
- timeout: 1h
reason: Discord AutoMod caught them 3 times today
- reset_count: automodrude-reactionssmall Takes 🖕 and other rude reactions off any message.
Shows reaction.added, in [...], remove_reaction
See the YAML
rule: rude-reactions
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Takes rude reactions off any message.
on: reaction.added
when: reaction.emoji in ["🖕", "🍆", "💩"] # is one of these
then:
- remove_reactionfresh-bot-cleanupmedium Softbans brand-new accounts with no avatar and a name like abc1234. Watch it in test mode for a few days first.
Shows matches, an all: group, softban
See the YAML
rule: fresh-bot-cleanup
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Softbans brand-new accounts with no avatar and a name like abc1234. Test it for a few days first.
on: member.joined
when:
all: # every one of these
- member.created < 1d # account made today
- member.avatar_default # never set an avatar
- member.name matches '^[a-z]+[0-9]{4,}$' # letters then 4 or more numbers
then:
- softban:
reason: Looks like a throwaway accounttoo-newmedium Accounts under 1 hour old are told why in a DM, then kicked. Watch it in test mode for a few days first.
Shows member.created, dm, kick
See the YAML
rule: too-new
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Accounts under 1 hour old are told why in a DM, then kicked. Test it for a few days first.
on: member.joined
when: member.created < 1h
then:
- dm: "Hi! {server.name} doesn't let in accounts made less than an hour ago. Please come back a little later."
- kick:
reason: Account less than an hour oldModeration helpers
Rules that take some of the work off your mods.
strikesmedium Bad words: strikes 1 and 2 get a warning, strike 3 a 1-day timeout.
Shows count, reset_count, a count in a message
See the YAML
list: strike-words
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
items: ["badword", "anotherbadword"] # change these to your own
---
rule: strikes
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Bad words get a warning for strikes 1 and 2, and a 1-day timeout on strike 3.
on: [message.sent, message.edited]
skip: [mods]
when: normalize(message.text) has word any list("strike-words")
then:
- delete
- count: strikes
- if: count('strikes', 7d) >= 3 # their third this week
then:
- timeout: 1d
reason: Third strike
- reset_count: strikes
else:
- send:
content: "{member.mention}, that's strike {count('strikes', 7d)} of 3."
delete_after: 30sword-laddermedium Two rules: severe words get a timeout and stop there; mild ones a delete and a reminder.
Shows order:, stop, two lists
See the YAML
list: severe-words
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
items: ["severeword"] # words that get a timeout
---
list: mild-words
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
items: ["darn", "heck"] # words that only get deleted
---
rule: word-ladder-severe
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Severe words are deleted, with a 1-day timeout.
order: 1 # runs before word-ladder-mild
on: message.sent
skip: [mods]
when: normalize(message.text) has word any list("severe-words")
then:
- delete
- timeout: 1d
reason: Severe language
- stop # so word-ladder-mild doesn't run too
---
rule: word-ladder-mild
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Mild words are deleted, with a friendly reminder.
order: 2
on: message.sent
skip: [mods]
when: normalize(message.text) has word any list("mild-words")
then:
- delete
- send:
content: "{member.mention}, please keep it friendly."
delete_after: 15scaps-locksmall Asks people to ease off the caps, at most once per person every 5 minutes, not in your memes channel.
Shows maths in checks, lower(), limit:, ignore_channels
Install asks: Where are capitals fine?
See the YAML
rule: caps-lock
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Asks people to ease off the caps, at most once per person every 5 minutes.
on: message.sent
where:
ignore_channels: ["#memes"] # caps are fine here
skip: [mods]
when: message.letters >= 20 and message.caps * 2 > message.letters # over half of it in capitals
limit: 1 per member per 5m # at most once every 5 minutes each
then:
- reply: "Easy on the caps! Like this: {lower(message.text)}"
delete_after: 30slink-warnsmall Links from anyone without @Trusted are deleted with a ModUtils warning; GIFs are fine.
Shows not, warn, skip: a role
Install asks: Which role may post links?
See the YAML
rule: link-warn
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Links from anyone without the trusted role are deleted with a warning. GIFs are fine.
on: message.sent
skip: [mods, "@Trusted"] # these can post links
when: message.links > 0 and not message.text contains "tenor.com" # a link, but not a GIF
then:
- delete
- warn: Posted a link without the trusted role # saved as a ModUtils casebusy-slowmodemedium 30 messages in a minute turns on a 10-second slowmode, which goes back off after 10 minutes.
Shows by: channel, slowmode, after:
Install asks: Which channel gets busy?
See the YAML
rule: busy-slowmode
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: 30 messages in a minute turns on a 10-second slowmode for 10 minutes.
on: message.sent
where:
channels: ["#general"]
then:
- count: busy
by: channel # one count for the whole channel
- if: count('busy', 1m, channel) >= 30
then:
- slowmode: 10s
- reset_count: busy
by: channel
- slowmode: 0s
after: 10m # later: back to normaltimeout-logsmall Posts in your mod log whenever someone is timed out.
Shows member.timed_out, send with to:
Install asks: Where should alerts go?
See the YAML
rule: timeout-log
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Posts in your mod log whenever someone is timed out.
on: member.timed_out
then:
- send:
to: "#mod-log"
content: "🔇 {member.mention} was timed out."pardon-rolesmall Giving someone @Pardoned ends their timeout and takes the role back off.
Shows member.roles_changed, roles.added, untimeout, remove_role
Install asks: Which role ends a timeout?
See the YAML
list: pardon-roles
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
items: ["@Pardoned"]
---
rule: pardon-role
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Giving someone the pardon role ends their timeout and takes the role back off.
on: member.roles_changed
when: roles.added has any list("pardon-roles") # the role was just given
then:
- untimeout
- remove_role: "@Pardoned"join-userinfosmall Posts ModUtils' userinfo card for each new member in your mod log. The bot owner allows it first with antiraid customrules allowcommand add userinfo.
Shows run_command, in:
Install asks: Where should alerts go?
See the YAML
rule: join-userinfo
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Posts the userinfo card for each new member in your mod log.
on: member.joined
then:
- run_command: userinfo {member.id} # the bot owner has to allow userinfo first
in: "#mod-log"new-account-alertmedium Accounts under a week old get an alert that pings your staff.
Shows a saved message: with an embed, mentions()
Install asks: Where should alerts go? · Which role are your staff?
See the YAML
list: alert-staff
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
items: ["@Mods"]
---
message: new-account-card
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
to: "#mod-log"
content: "{mentions(list('alert-staff'))}" # pings everyone in the list
embed:
title: New account joined
description: "{member.mention} joined. Their account is less than a week old."
---
rule: new-account-alert
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Accounts under a week old get an alert that pings your staff.
on: member.joined
when: member.created < 1w
then:
- send: new-account-card # the saved message aboveUtility
Handy jobs: welcomes, threads, roles and logs.
welcomesmall Says hello to everyone who joins.
Shows member.joined, send, { } placeholders
Install asks: Where should welcomes go?
See the YAML
rule: welcome
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Says hello to everyone who joins.
on: member.joined
then:
- send:
to: "#welcome"
content: "Welcome to {server.name}, {member.mention}! 👋"goodbyesmall Says goodbye when someone leaves.
Shows member.left
Install asks: Where should goodbyes go?
See the YAML
rule: goodbye
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Says goodbye when someone leaves.
on: member.left
then:
- send:
to: "#welcome"
content: "{member.name} left. See you around! 👋"bug-threadssmall Every post in your bug reports channel gets its own thread.
Shows create_thread, duration:, where: channels
Install asks: Where are bugs reported?
See the YAML
rule: bug-threads
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Every post in your bug reports channel gets its own thread.
on: message.sent
where:
channels: ["#bug-reports"]
then:
- create_thread: "Bug from {member.display}"
duration: 1d # closes after a quiet dayhelp-threadssmall New threads in your help category get a note that help is on the way.
Shows thread.created, where: categories
Install asks: Which category is for help?
See the YAML
rule: help-threads
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: New threads in your help category get a note that help is on the way.
on: thread.created
where:
categories: ["Help"]
then:
- send:
content: "Thanks {member.mention}! Someone will be with you soon." # posted in the new threadin-voice-rolesmall @In Voice while someone is in voice, taken off when they leave.
Shows voice.joined, voice.left, add_role
Install asks: Which role means in voice?
See the YAML
rule: in-voice-role
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Gives the in-voice role to anyone who joins voice.
on: voice.joined
then:
- add_role: "@In Voice"
---
rule: in-voice-role-off
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Takes the in-voice role away when they leave voice.
on: voice.left
then:
- remove_role: "@In Voice"deafened-to-afksmall Joining or moving in voice while deafened sends you to the AFK channel.
Shows voice.moved, voice_move
Install asks: Which voice channel is AFK?
See the YAML
rule: deafened-to-afk
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Joining or moving in voice while deafened sends you to the AFK channel.
on: [voice.joined, voice.moved]
where:
ignore_channels: ["#AFK"] # already there
when: voice.deafened
then:
- voice_move: "#AFK"afk-disconnectsmall Anyone who ends up in the AFK channel is taken out of voice.
Shows voice_disconnect
Install asks: Which voice channel is AFK?
See the YAML
rule: afk-disconnect
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Anyone who ends up in the AFK channel is taken out of voice.
on: [voice.joined, voice.moved]
where:
channels: ["#AFK"]
then:
- voice_disconnectdivider-rolesmedium Keeps a divider role on anyone who has one of the roles under it.
Shows a keep rule with role:, a list:
Install asks: Which role is the divider? · Which roles sit under it?
See the YAML
list: divider-holds
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
items: ["@Roles under it"] # the roles that sit under the divider
---
keep: divider-roles
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Keeps a divider role on anyone who has one of the roles under it.
role: "@Divider"
while: member.roles has any list("divider-holds")booster-glowsmall New boosters get @New Booster for a week.
Shows member.boosted, for:
Install asks: Which role do new boosters get?
See the YAML
rule: booster-glow
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: New boosters get the new booster role for a week.
on: member.boosted
then:
- add_role: "@New Booster"
for: 7d # taken off again after a weekmod-pinsmall A mod's message starting with 📌 gets pinned, and the bot says so.
Shows member.perms, pin, required:
See the YAML
rule: mod-pin
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: A mod's message starting with a pin emoji gets pinned.
on: message.sent
when: message.text startswith "📌" and member.perms has "manage_messages"
then:
- pin:
required: true # if pinning fails, don't say it worked
- send:
content: "📌 Pinned for {member.display}."
delete_after: 1mping-panelsmall Staff typing !pingpanel post a 7-day RoleUtils reaction panel for your ping role, with no ✅ reply left behind. The bot owner allows it first with antiraid customrules allowcommand add reactrole create.
Shows run_command with quiet:
Install asks: Which role does the panel give?
See the YAML
list: panel-roles
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
items: ["@Pings"]
---
rule: ping-panel
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Staff typing !pingpanel post a reaction panel for the ping role.
on: message.sent
when: message.text == "!pingpanel" and member.perms has "manage_roles"
then:
- run_command: reactrole create reaction "Pings" 🔔 {mentions(list('panel-roles'))}
quiet: true # the ✅ reply goes to the rule log; the panel still postsnew-channel-slowmodesmall Every new text channel starts with a 5-second slowmode.
Shows channel.created, channel.type
See the YAML
rule: new-channel-slowmode
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Every new channel starts with a 5-second slowmode.
on: channel.created
when: channel.type == "text" # not voice channels or categories
then:
- slowmode: 5s # in the new channelinvite-logsmall Logs who made each invite, how many uses it has and how long it lasts.
Shows invite.created, invite fields
Install asks: Where should alerts go?
See the YAML
rule: invite-log
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Logs who made each invite, how many uses it has and how long it lasts.
on: invite.created
then:
- send:
to: "#mod-log"
content: "🔗 {member.mention} made invite `{invite.code}` for {channel.mention}. Uses: {invite.max_uses} (0 is no limit), lasts: {invite.max_age}."event-signupsmall ✅ on a message in your events channel gives @Event; taking it off takes @Event away. For full reaction-role menus, use RoleUtils.
Shows reaction.removed
Install asks: Where are events posted? · Which role do sign-ups get?
See the YAML
rule: event-signup
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: A check mark on a message in your events channel gives the event role.
on: reaction.added
where:
channels: ["#events"]
when: reaction.emoji == "✅"
then:
- add_role: "@Event"
---
rule: event-signup-off
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Taking the check mark off takes the event role away.
on: reaction.removed
where:
channels: ["#events"]
when: reaction.emoji == "✅"
then:
- remove_role: "@Event"weekly-winner-resetsmall Every Monday, takes @Weekly Winner off everyone.
Shows schedule, clear_role
Install asks: Which role is reset each week? · Your timezone, like Europe/London
See the YAML
rule: weekly-winner-reset
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Every Monday, takes the weekly winner role off everyone.
on: schedule
every: mon 00:00 # Mondays at midnight
timezone: "UTC"
then:
- clear_role: "@Weekly Winner"Fun
Small surprises for your members, each with a cooldown so it never gets spammy.
good-morningsmall "gm" or "good morning" gets a ☀️, once per person every 12 hours.
Shows startswith any, limit:
See the YAML
rule: good-morning
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: A good morning gets a sun, once per person every 12 hours.
on: message.sent
when: message.text startswith any ["good morning", "goodmorning", "gm"]
limit: 1 per member per 12h
then:
- react: "☀️"lucky-cloversmall A 1 in 100 chance of a 🍀 on any message, at most once per channel every 10 minutes, not in your staff category.
Shows chance(), ignore_categories
Install asks: Which category should it skip?
See the YAML
rule: lucky-clover
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: A 1 in 100 chance of a clover on any message.
on: message.sent
where:
ignore_categories: ["Staff"]
when: chance(1%) # one message in a hundred, at random
limit: 1 per channel per 10m
then:
- react: "🍀"hello-duskymedium "hi dusky" gets a random greeting by name.
Shows contains any, let, pick(), {var.…}
See the YAML
rule: hello-dusky
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Saying hi to Dusky gets a random greeting back.
on: message.sent
when: message.text contains any ["hi dusky", "hello dusky", "hey dusky"]
limit: 1 per member per 1m
then:
- let:
hello: pick('Hi', 'Hey there', 'Hello', 'Yo') # one of these, at random
- reply: "{var.hello}, {member.display}! 👋"hypesmall !hype replies with a loud LET'S GOOO.
Shows upper(), reply with ping:
See the YAML
rule: hype
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Typing !hype gets a loud reply.
on: message.sent
when: message.text == "!hype"
limit: 1 per channel per 1m
then:
- reply: "LET'S GOOO {upper(member.display)}! 🎉"
ping: true # pings them in the replyart-starssmall Posts with images in your art channel get a ⭐.
Shows message.attachments, react
Install asks: Which channel is for art?
See the YAML
rule: art-stars
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Posts with images in your art channel get a star.
on: message.sent
where:
channels: ["#art"]
when: message.attachments > 0 # it has a file or picture
then:
- react: "⭐"random-greetingmedium Welcomes new members with one of four greetings, at most once a minute.
Shows pick() in a message
Install asks: Where should greetings go?
See the YAML
rule: random-greeting
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Welcomes new members with a random greeting.
on: member.joined
limit: 1 per server per 1m # a wave of joins gets one greeting
then:
- send:
to: "#general"
content: "{pick('Welcome', 'Look who just arrived', 'A wild member appeared', 'Glad you made it')}, {member.mention}!"question-of-the-daymedium Posts a random question every day at noon.
Shows every: with timezone:, pick() from a list
Install asks: Where should questions go? · Your timezone, like Europe/London
See the YAML
list: qotd-questions
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
items: ["What's the best snack?", "Cats or dogs?", "What are you playing right now?", "Which superpower would you pick?", "What song is stuck in your head?"]
---
rule: question-of-the-day
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Posts a random question every day at noon.
on: schedule
every: "12:00" # every day at noon
timezone: "UTC"
then:
- send:
to: "#general"
content: "❓ **Question of the day:** {pick(list('qotd-questions'))}"friday-remindersmall "Movie night at 8!" every Friday at 18:00.
Shows every: fri 18:00
Install asks: Where should it be posted? · Your timezone, like Europe/London
See the YAML
rule: friday-reminder
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: A movie night reminder every Friday evening.
on: schedule
every: fri 18:00 # Fridays at 6 in the evening
timezone: "UTC"
then:
- send:
to: "#general"
content: "🍿 Movie night at 8! Grab a snack."Raid
What happens when AntiRaid catches a raid, or when you need to lock things fast.
raid-responsefull When AntiRaid catches a raid: lock every public channel and alert staff. When it ends: unlock and post a summary.
Shows raid.started / raid.ended, lockdown / unlockdown, raid fields
Install asks: Where should alerts go? · Which role are your staff?
See the YAML
list: raid-staff
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
items: ["@Mods"]
---
rule: raid-response
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: When AntiRaid catches a raid, locks every public channel and alerts staff.
on: raid.started
then:
- lockdown: public # every channel everyone can see
- send:
to: "#mod-log"
content: "{mentions(list('raid-staff'))}"
embed:
title: "🚨 Raid: {raid.label}"
description: "Every public channel is locked until the raid is over."
---
rule: raid-over
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: When the raid ends, unlocks and posts a summary.
on: raid.ended
then:
- unlockdown
- send:
to: "#mod-log"
embed:
title: "✅ Raid over"
description: "It lasted {raid.duration}: {raid.trips} trips by {raid.offenders} members. Ended because: {raid.reason}."raid-slowmodemedium When a raid starts: a 30-second slowmode in your main chat, lifted after 30 minutes.
Shows after: on a raid, in:
Install asks: Which channel is your main chat?
See the YAML
rule: raid-slowmode
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: When a raid starts, a 30-second slowmode in your main chat for 30 minutes.
on: raid.started
then:
- slowmode: 30s
in: "#general"
- slowmode: 0s
in: "#general"
after: 30m # back to normal laterpanic-locksmall Rules your staff run themselves: one locks your main chat for 15 minutes, one unlocks it straight away.
Shows manual, lock with for:, unlock
Install asks: Which channel should it lock?
See the YAML
rule: panic-lock
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Locks your main chat for 15 minutes. Run it with antiraid customrules run panic-lock.
on: manual # only runs when staff run it
then:
- lock:
in: ["#general"]
for: 15m # unlocks by itself after 15 minutes
- send:
to: "#general"
content: "🔒 This channel is locked for 15 minutes."
---
rule: panic-unlock
# Dusky template by Cool aid · duskybot.xyz/docs/antiraid/customrules
about: Unlocks your main chat now. Run it with antiraid customrules run panic-unlock.
on: manual
then:
- unlock:
in: ["#general"]Templates by Cool aid. Free to use and change on your own server.
Written from AntiRaid 2.25.0, the same text as explain.