Discord Scripting Language (DSCB)
A fast, lightweight, and modern programming language built from the ground up to create, deploy, and maintain custom Discord bots effortlessly on Arch Linux.
yay -S dscb
1. Introduction
DSCB (Discord Scripting Language) bridges clean, human-readable bot scripting directly with native discord.py runtime internals. Built with a custom Pratt Parser, Lexical Environment Frames, and a Safe Async Messaging Engine, DSCB eliminates boilerplate code while giving you access to 100% of Discord's API.
A standard 600-line Python bot with moderation, embeds, AutoMod, database storage, and slash commands can be written in under 60 lines of clean DSCB syntax with zero async boilerplate.
2. Arch Linux / AUR Installation
The DSCB language engine is distributed through the Arch User Repository (AUR) under the official package name dscb.
Install with an AUR Helper (yay / paru)
# Install using yay:
yay -S dscb
# Or install using paru:
paru -S dscb
Manual makepkg Installation
git clone https://aur.archlinux.org/dscb.git
cd dscb
makepkg -si
3. Command Line Interface (CLI)
Once installed, you execute your .dsc script files using the dscb command:
# Run a bot script:
dscb bot.dsc -t "YOUR_DISCORD_TOKEN" -p "$"
# Or export your token as an environment variable:
export DISCORD_TOKEN="YOUR_DISCORD_TOKEN"
dscb bot.dsc
CLI Flag Specifications
| Flag | Default | Description |
|---|---|---|
file |
Required | Path to the .dsc source script file. |
-t, --token |
$DISCORD_TOKEN |
Your Discord Bot Application Token. |
-p, --prefix |
$ |
Case-insensitive command prefix (e.g. !, $, ?). |
4. Running 24/7 as a Systemd Service
The dscb AUR package installs a built-in systemd service file (dscb.service) to run your bot 24/7 in the background.
# 1. Place your script at /var/lib/dscb/bot.dsc
sudo mkdir -p /var/lib/dscb
sudo cp bot.dsc /var/lib/dscb/bot.dsc
# 2. Enable and start the background daemon
sudo systemctl daemon-reload
sudo systemctl enable --now dscb
# 3. View live bot logs
journalctl -u dscb -f
5. Language Syntax & Tokens
DSCB supports compact 1-liner arrow syntax => and block syntax { ... }.
Comments
// Single-line double slash comment
# Single-line hash comment
/* Multi-line block comment
spanning multiple lines */
6. Variables & Data Types
Variables are dynamically typed and declared using var or let:
var name = "Server Bot"
var port = 8080
var hex_color = 0x3498db
var is_active = true
var empty_val = null
7. Built-in String Utilities
Strings in DSCB include case-insensitive methods designed specifically for checking Discord messages:
| Method | Example | Description |
|---|---|---|
.contains(str) |
msg.content.contains("badword") |
Case-insensitive substring search. |
.startswith(str) |
msg.content.startswith("!") |
Checks start of string. |
.endswith(str) |
msg.content.endswith(".png") |
Checks end of string. |
.upper() |
name.upper() |
Converts string to uppercase. |
.lower() |
name.lower() |
Converts string to lowercase. |
.length |
msg.content.length |
Returns string character length. |
8. Operators & Pratt Precedence
DSCB features a full Pratt Parser ensuring mathematical, comparison, and logical operator precedence:
var total = (10 + 5) * 2 / 4
if (amount >= 10 && is_admin == true) {
reply "Access Granted."
} else {
reply "Access Denied."
}
9. Prefix Commands
Prefix commands respond to your configured prefix (e.g. $ping or $PING). Commands are automatically case-insensitive.
// 1-liner Arrow Syntax
command "ping" => reply "Pong! 🏓"
// Block Syntax
command "info" {
reply("Running on Arch Linux via dscb!")
}
10. Application Slash Commands (/)
Slash commands automatically register and sync with Discord's Application Command Tree.
slash "hello" "Greets the user" {
reply("Hello from dynamic slash command!")
}
slash "ping" "Check bot latency" => reply "Slash Pong! 🏓"
11. Event Gateway Listeners
Listen to any Discord Gateway event by declaring an on <event> block:
// Message AutoMod Listener
on message(msg) {
if msg.author.bot {
return
}
if msg.content.contains("discord.gg") {
msg.delete()
reply "⚠️ Server invite links are not permitted here!"
}
}
// Member Join Welcome Card
on member_join(member) {
var card = embed {
title = "Welcome to the Server!",
description = "Welcome! Make sure to read the rules.",
color = 0x2ecc71
}
member.send(card)
}
12. Rich Embed Builder
Construct Discord Embed cards with a dedicated embed { ... } declaration block:
command "serverinfo" {
var card = embed {
title = "Server Status",
description = "All systems operating at peak performance.",
color = 0x3498db
}
reply(card)
}
13. Moderation Primitives
DSCB provides built-in keywords for executing moderation actions directly:
// Kick caller
command "kickme" {
reply "Kicking you now..."
kick(author)
}
// Purge messages (supports keyword arguments!)
command "purge" {
ctx.channel.purge(limit = 10)
reply "Cleaned last 10 messages!"
}
14. Embedded Python Engine
You can execute pure Python code right inside your .dsc scripts! The Python runtime has full async capabilities with pre-injected context variables.
command "fastfetch" {
python {
import subprocess
try:
out = subprocess.check_output(["fastfetch", "--logo", "none", "--pipe"]).decode()
await reply(f"```\n{out[:1900]}\n```")
except Exception as e:
await reply(f"Error: {e}")
}
}
Pre-Injected Python Scope
| Object | Type | Description |
|---|---|---|
ctx |
commands.Context |
Current command invocation context. |
bot |
commands.Bot |
The core Discord bot instance. |
author / user |
discord.Member |
The member who executed the command. |
guild |
discord.Guild |
The current Discord server instance. |
channel |
discord.TextChannel |
Current channel object. |
reply(arg) |
Coroutine |
Async safe reply helper function. |
send(arg) |
Coroutine |
Async safe channel send helper function. |
db |
DSLDatabase |
Persistent JSON document database accessor. |
15. Persistent JSON Document Database
DSCB includes a persistent JSON database (/tmp/dscb_database.json) that persists across bot restarts:
command "setdata" {
python {
db.set(str(author.id), 100)
await reply("Saved 100 points to persistent storage!")
}
}
command "getdata" {
python {
points = db.get(str(author.id), 0)
await reply(f"Your points: {points}")
}
}
16. Production Blueprint (bot.dsc)
Here is a complete, production-ready bot blueprint written entirely in DSCB:
// =========================================================
// PRODUCTION DISCORD BOT SCRIPT (.dsc)
// =========================================================
// 1. Ping Command
command "ping" => reply "Pong! 🏓 Latency active."
// 2. Help Menu Embed
command "help" {
var h = embed {
title = "Bot Command Directory",
description = "
🛡️ **Moderation:** $kickme, $purge
📊 **System:** $pysys, $fastfetch
🏓 **Utility:** $ping, $help",
color = 0x3498db
}
reply(h)
}
// 3. Moderation Commands
command "kickme" {
reply "Kicking you now..."
kick(author)
}
command "purge" {
ctx.channel.purge(limit = 10)
reply "Cleaned 10 messages!"
}
// 4. System Diagnostics via Python
command "pysys" {
python {
import platform, os
await reply(f"OS: {platform.system()} | Host: {os.uname().nodename}")
}
}
// 5. Slash Command
slash "hello" "Greets you warmly" => reply "Hey there from Slash Command!"
// 6. AutoMod Message Listener
on message(msg) {
if msg.author.bot {
return
}
if msg.content.contains("discord.gg") {
msg.delete()
reply "⚠️ Server invite links are not permitted!"
}
}