Overview
Therule command is a base command that provides subcommands for managing server rules. It allows administrators to add, remove, edit, list, retrieve, and post server rules.
Most operations require elevated permissions, but viewing rules (
list and get) is available to all users.Subcommands
Therule command has the following subcommands:
/rule add- Add a new rule/rule remove- Remove an existing rule/rule edit- Edit an existing rule/rule list- List all rules/rule get- Get a specific rule/rule post- Post rules embed to a channel
Subcommand: add
Add a new rule to the server’s rule database.Signature
Parameters
The text content of the new rule
Permissions Required
Usage Example
src/commands/administration.rs:244-290
Subcommand: remove
Remove an existing rule by its number.Signature
Parameters
The rule number to remove
Permissions Required
Usage Example
src/commands/administration.rs:292-326
Subcommand: edit
Edit the text of an existing rule.Signature
Parameters
The rule number to edit
The new text for the rule
Permissions Required
Usage Example
src/commands/administration.rs:402-438
Subcommand: list
Display all server rules. This command is available to all users.Signature
Parameters
This command takes no parameters.Permissions Required
None - available to all server members.Usage Example
src/commands/administration.rs:328-363
Subcommand: get
Retrieve and display a specific rule by its number. Available to all users.Signature
Parameters
The rule number to retrieve
Permissions Required
None - available to all server members.Usage Example
src/commands/administration.rs:365-400
Subcommand: post
Post a formatted rules embed to a specified channel (or the default rules channel).Signature
Parameters
Optional text channel to post the rules in. If not specified, uses the configured rules channel.
Permissions Required
Usage Examples
Post to default rules channel:src/commands/administration.rs:440-487
Implementation Details
Rule Numbering
When adding a new rule, the system:- Queries the database for the highest existing rule number
- Assigns the new rule a number that is one higher
- If no rules exist, starts at rule number 1
Database Structure
Rules are stored in therules table with the following structure:
rule_number- Integer, the rule’s numberrule_text- Text, the content of the rule
Permission Check Function
Most rule subcommands use theexecutor_is_dev_or_admin permission check (src/commands/administration.rs:4-24) which verifies:
- User has semester moderator role
- OR user has staff role
- OR user has Discord administrator permission
Use Cases
- Creating and maintaining server rules
- Updating outdated rules
- Removing rules that are no longer relevant
- Posting rules in onboarding or information channels
- Allowing users to reference specific rules during moderation