Documentation Index
Fetch the complete documentation index at: https://docs.ethone.cc/llms.txt
Use this file to discover all available pages before exploring further.
Commands API Reference
Command system API for Ethone custom scripts.
ethone.on_command()
Register a command with a callback function.
Syntax
ethone.on_command(name, description, usage, callback)
Parameters
| Parameter | Type | Description |
|---|
name | string | Command name without prefix (e.g., “hello” for “.hello”) |
description | string | Description of what the command does |
usage | string | Usage string shown in .custom command (e.g., “hello [name]“) |
callback | function | Function to execute when command is triggered |
Context Object
The callback receives a ctx (context) object:
| Property | Type | Description |
|---|
ctx.command | string | The command name that was triggered |
ctx.args | string[] | Array of arguments passed to the command |
ctx.message | Message | Full message object |
ctx.guild | Guild | Guild/server object |
ctx.channel | Channel | Channel object |
ctx.author | Author | Message author object |
Access IDs through context objects:
- Use
ctx.guild.id for guild ID
- Use
ctx.channel.id for channel ID
- Use
ctx.author.id for user ID
Guild Object Properties
| Property | Type | Description |
|---|
id | string | Guild/server ID |
name | string | Guild name |
icon_url | string | URL to guild icon image |
owner_id | string | User ID of the server owner |
member_count | number | Total number of members |
description | string | Server description |
banner_url | string | URL to guild banner image |
vanity_url_code | string | Custom vanity URL code |
verification_level | number | Verification level (0-4) |
premium_tier | number | Nitro boost tier (0-3) |
premium_subscription_count | number | Number of boosts |
Channel Object Properties
| Property | Type | Description |
|---|
id | string | Channel ID |
name | string | Channel name |
type | number | Channel type (0=text, 2=voice, 4=category, etc.) |
topic | string | Channel topic/description |
position | number | Channel position in the list |
nsfw | boolean | Whether channel is marked NSFW |
parent_id | string | Category ID (if in a category) |
guild_id | string | Guild ID this channel belongs to |
Author Object Properties
| Property | Type | Description |
|---|
id | string | User ID |
username | string | Username |
discriminator | string | User discriminator |
tag | string | Full username with discriminator |
avatar_url | string | URL to user’s avatar image |
bot | boolean | Whether the user is a bot |
global_name | string | User’s display name |
banner_url | string | URL to user’s banner image |
banner_color | string | User’s banner color hex code |
accent_color | number | User’s accent color as integer |
Message Object Properties
| Property | Type | Description |
|---|
id | string | Message ID |
content | string | Full message content |
author | Author | Author object (same as ctx.author) |
channel_id | string | Channel ID |
guild_id | string | Server/guild ID |
timestamp | string | ISO 8601 timestamp |
mentions | Author[] | Array of mentioned users |
attachments | Attachment[] | Array of file attachments |
embeds | Embed[] | Array of embed objects |
reactions | Reaction[] | Array of reaction objects |
pinned | boolean | Whether message is pinned |
Example
ethone.on_command(
"greet", // name
"Greet someone", // description
"greet <name>", // usage
function(ctx) { // callback
if (ctx.args.length === 0) {
discord.send_message(ctx.channel.id, "Usage: .greet <name>");
return;
}
var channelId = ctx.channel.id;
var name = ctx.args.join(" ");
var message = "Hello, " + name + "!";
discord.send_message(channelId, message);
}
);
ethone.on_command(
"userinfo", // name
"Get user info", // description
"userinfo <userId>", // usage
function(ctx) { // callback
if (ctx.args.length === 0) {
discord.send_message(ctx.channel.id, "Usage: .userinfo <userId>");
return;
}
var userId = ctx.args[0];
var user = discord.fetch_user(userId);
if (user) {
var channelId = ctx.channel.id;
var info = "User: " + user.username + "\n";
info += "ID: " + user.id + "\n";
info += "Bot: " + (user.bot ? "Yes" : "No");
discord.send_message(channelId, info);
}
}
);
Argument Parsing
Arguments are automatically parsed into ctx.args array.
Basic Arguments
ethone.on_command("greet", "Greet someone", "greet <name> [lastName]", function(ctx) {
var name = ctx.args.join(" ");
discord.send_message(ctx.channel.id, "Hello, " + name + "!");
});
Quoted Arguments
Arguments in quotes are treated as single values:
// User types: .say "hello world" test
// ctx.args = ["hello world", "test"]
// User types: .say one two three
// ctx.args = ["one", "two", "three"]
Required Arguments
ethone.on_command("ban", "Ban a user", "ban <user> <reason>", function(ctx) {
if (ctx.args.length < 2) {
discord.send_message(ctx.channel.id, "Usage: .ban <user> <reason>");
return;
}
var userId = ctx.args[0];
var reason = ctx.args.slice(1).join(" ");
discord.send_message(ctx.channel.id, "Banned: " + userId + " - " + reason);
});
Optional Arguments
ethone.on_command("repeat", "Repeat text", "repeat <text> [times]", function(ctx) {
var times = 1;
var text = ctx.args.join(" ");
var lastArg = ctx.args[ctx.args.length - 1];
if (!isNaN(lastArg)) {
times = parseInt(lastArg);
text = ctx.args.slice(0, -1).join(" ");
}
times = Math.min(times, 5);
for (var i = 0; i < times; i++) {
discord.send_message(ctx.channel.id, text);
}
});