Skip to main content

Introduction

Welcome to the Ethone Custom Scripts documentation. Custom scripts allow you to extend your Discord experience with JavaScript code that runs on your client.

How It Works

Scripts are written in JavaScript and executed by the Go client using an embedded JavaScript engine (Goja). Your JavaScript code is interpreted and runs natively within the Go runtime, providing fast and secure execution.

What are Custom Scripts?

Custom scripts are JavaScript programs that can:
  • Listen to Discord events (messages, member joins, etc.)
  • Send and manage messages automatically
  • Create custom commands with your prefix
  • Make HTTP requests to external APIs
  • Log information for debugging

Quick Start

// Create a simple command
ethone.on_command("hello", "Say hello", "hello", function(ctx) {
    discord.send_message(ctx.channel.id, "Hello, " + ctx.author.username + "!");
});

// Listen for messages (with full context!)
discord.on_message = function(ctx) {
    ethone.log("Received: " + ctx.content + " from " + ctx.author.username);
};

Important Rules

Never use blocking code at the top level of your script
// BAD - Will timeout
while (true) {
    ethone.log("This will freeze!");
}

// BAD - Will timeout
ethone.sleep(5000); // at top level

// GOOD - Inside event handler
discord.on_message = function(ctx) {
    ethone.sleep(1000); // OK here!
    discord.send_message(ctx.channel.id, "Delayed response");
};

Available APIs

Examples

Check out the Examples section for common use cases and patterns.