Skip to content

Snippets

The Snippets module allows you to create, manage, and use code snippets in your Discord server. Snippets are reusable pieces of text or code that can be quickly accessed by name, and you can create aliases to point to existing snippets.

Snippets are useful for storing frequently used code, text, or responses that you want to quickly access. You can create snippets with custom names, create aliases that point to existing snippets, and manage your snippet library.

Snippets are server-specific and can be locked by moderators to prevent unauthorized editing.

Commands

Command Aliases Description Documentation
$createsnippet cs Create a new snippet or alias Details
$snippet s View and use a snippet Details
$snippets ls List all available snippets Details
$snippetinfo si Get detailed information about a snippet Details
$editsnippet es Edit an existing snippet Details
$deletesnippet ds Delete a snippet Details
$togglesnippetlock tsl Lock or unlock a snippet Details

Common Use Cases

Creating Code Snippets

Store frequently used code blocks or canned responses for quick access.

Steps:

  1. Use the $createsnippet command with a unique name and the content.
  2. Access your snippet anytime using the $snippet command.

Example:

Text Only
$createsnippet python-example print('Hello, World!')
$snippet python-example

Creating Aliases

Create shortcuts to existing snippets to make them easier to remember or faster to type.

Steps:

  1. Use the $createsnippet command with a new name.
  2. Provide the name of an existing snippet as the content (this automatically creates an alias).

Example:

Text Only
$createsnippet short-name python-example

Managing Snippets

Organize, review, and protect your snippet library.

Steps:

  1. List all snippets with $snippets to browse the library.
  2. Check metadata (creator, date, lock status, usage count) with $snippetinfo.
  3. Edit snippets with $editsnippet when content needs updating.
  4. Protect important snippets using $togglesnippetlock to prevent unauthorized edits.

Example:

Text Only
$snippets
$snippetinfo python-example
$editsnippet python-example print('Hello, Updated World!')
$togglesnippetlock python-example

Permissions

Bot Permissions

Tux requires the following permissions for this module:

  • Send Messages - Required for command responses
  • Embed Links - Required for rich snippet displays
  • Manage Messages - Required for locking and managing snippet responses

User Permissions

Snippet commands are available to all users by default, but snippet creation and editing may be restricted to specific permission ranks based on server configuration.

Permission System

Tux uses a dynamic permission system. Configure command permissions via /config commands or see the Permission Configuration guide.