Update command registration to use subcommands for better organization

Replaces old command registration with a new structure using subcommands and options in `bot.js` to align with Discord API expectations.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: aed2e46d-25bb-4b73-81a1-bb9e8437c261
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 530794e9-5492-44ab-899c-d1afca836a4a
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3bdfff67-975a-46ad-9845-fbb6b4a4c4b5/aed2e46d-25bb-4b73-81a1-bb9e8437c261/mYZvK75
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
sirpiglr 2025-12-08 01:47:09 +00:00
parent 7316b930e6
commit 5e89a22eef
4 changed files with 145 additions and 180 deletions

View file

@ -22,6 +22,10 @@ externalPort = 80
localPort = 8080
externalPort = 8080
[[ports]]
localPort = 46429
externalPort = 3000
[workflows]
runButton = "Project"

View file

@ -269,182 +269,12 @@ client.on("interactionCreate", async (interaction) => {
});
// =============================================================================
// COMMANDS FOR REGISTRATION (Modified: Added Sentinel commands)
// COMMANDS FOR REGISTRATION (Uses actual command file definitions)
// =============================================================================
const COMMANDS_TO_REGISTER = [
{
name: "verify",
description: "Link your Discord account to AeThex",
},
{
name: "set-realm",
description: "Choose your primary arm/realm (Labs, GameForge, Corp, etc.)",
options: [
{
name: "realm",
type: 3,
description: "Your primary realm",
required: true,
choices: [
{ name: "Labs", value: "labs" },
{ name: "GameForge", value: "gameforge" },
{ name: "Corp", value: "corp" },
{ name: "Foundation", value: "foundation" },
{ name: "Dev-Link", value: "devlink" },
],
},
],
},
{
name: "profile",
description: "View your linked AeThex profile",
},
{
name: "unlink",
description: "Disconnect your Discord account from AeThex",
},
{
name: "verify-role",
description: "Check your assigned Discord roles",
},
{
name: "help",
description: "View all AeThex bot commands and features",
},
{
name: "stats",
description: "View your AeThex statistics and activity",
},
{
name: "leaderboard",
description: "View the top AeThex contributors",
options: [
{
name: "category",
type: 3,
description: "Leaderboard category",
required: false,
choices: [
{ name: "Most Active (Posts)", value: "posts" },
{ name: "Most Liked", value: "likes" },
{ name: "Top Creators", value: "creators" },
],
},
],
},
{
name: "post",
description: "Create a post in the AeThex community feed",
options: [
{
name: "content",
type: 3,
description: "Your post content",
required: true,
max_length: 500,
},
{
name: "category",
type: 3,
description: "Post category",
required: false,
choices: [
{ name: "General", value: "general" },
{ name: "Project Update", value: "project_update" },
{ name: "Question", value: "question" },
{ name: "Idea", value: "idea" },
{ name: "Announcement", value: "announcement" },
],
},
{
name: "image",
type: 11,
description: "Attach an image to your post",
required: false,
},
],
},
{
name: "refresh-roles",
description: "Refresh your Discord roles based on your AeThex profile",
},
// Sentinel Commands
{
name: "admin",
description: "Admin controls for bot management",
options: [
{
name: "action",
type: 3,
description: "Admin action to perform",
required: true,
choices: [
{ name: "Status", value: "status" },
{ name: "Heat Check", value: "heat" },
{ name: "Servers", value: "servers" },
{ name: "Threats", value: "threats" },
{ name: "Federation", value: "federation" },
],
},
{
name: "user",
type: 6,
description: "Target user (for heat check)",
required: false,
},
],
},
{
name: "federation",
description: "Manage federation role sync",
options: [
{
name: "action",
type: 3,
description: "Federation action",
required: true,
choices: [
{ name: "Link Role", value: "link" },
{ name: "Unlink Role", value: "unlink" },
{ name: "List Linked", value: "list" },
],
},
{
name: "role",
type: 8,
description: "Role to link/unlink",
required: false,
},
],
},
{
name: "status",
description: "View network status and bot information",
},
{
name: "ticket",
description: "Create or close support tickets",
options: [
{
name: "action",
type: 3,
description: "Ticket action",
required: true,
choices: [
{ name: "Create", value: "create" },
{ name: "Close", value: "close" },
],
},
{
name: "reason",
type: 3,
description: "Reason for ticket (when creating)",
required: false,
},
],
},
];
function getCommandsToRegister() {
return Array.from(client.commands.values()).map(cmd => cmd.data.toJSON());
}
// =============================================================================
// COMMAND REGISTRATION FUNCTION
@ -456,14 +286,15 @@ async function registerDiscordCommands() {
process.env.DISCORD_BOT_TOKEN,
);
const commandsToRegister = getCommandsToRegister();
console.log(
`Registering ${COMMANDS_TO_REGISTER.length} slash commands...`,
`Registering ${commandsToRegister.length} slash commands...`,
);
try {
const data = await rest.put(
Routes.applicationCommands(process.env.DISCORD_CLIENT_ID),
{ body: COMMANDS_TO_REGISTER },
{ body: commandsToRegister },
);
console.log(`Successfully registered ${data.length} slash commands`);
@ -478,7 +309,7 @@ async function registerDiscordCommands() {
let successCount = 0;
let skipCount = 0;
for (const command of COMMANDS_TO_REGISTER) {
for (const command of commandsToRegister) {
try {
const posted = await rest.post(
Routes.applicationCommands(process.env.DISCORD_CLIENT_ID),
@ -690,13 +521,14 @@ http
return;
}
const cmds = getCommandsToRegister();
const stats = {
commands: COMMANDS_TO_REGISTER.map((cmd) => ({
commands: cmds.map((cmd) => ({
name: cmd.name,
description: cmd.description,
options: cmd.options?.length || 0,
})),
totalCommands: COMMANDS_TO_REGISTER.length,
totalCommands: cmds.length,
};
res.writeHead(200);
@ -867,7 +699,7 @@ http
<body>
<div class="container">
<h1>Discord Commands Registration</h1>
<p>Click to register all ${COMMANDS_TO_REGISTER.length} slash commands</p>
<p>Click to register all ${client.commands.size} slash commands</p>
<button id="registerBtn" onclick="registerCommands()">Register Commands</button>
<div id="loading">Registering... please wait...</div>
<div id="result"></div>

View file

@ -0,0 +1,129 @@
2025-12-07 18:41:52.51
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:41:52.52
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:42:02.68
7cd3339c
System
crash loop detected
2025-12-07 18:42:26.92
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:42:26.92
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:42:32.45
7cd3339c
System
crash loop detected
2025-12-07 18:42:37.35
7cd3339c
System
metasidecar: loaded enterprise status from environment is_enterprise=false
2025-12-07 18:42:37.35
7cd3339c
System
starting up user application
2025-12-07 18:42:37.42
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:42:37.43
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:42:37.53
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:42:37.54
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:42:37.60
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:42:37.61
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:42:37.76
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:42:37.76
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:42:38.47
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:42:38.47
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:42:39.01
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:42:39.02
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:42:41.64
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:42:41.65
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:42:46.04
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:42:46.04
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:42:47.19
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:42:47.20
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:42:47.35
7cd3339c
System
initializing deployment without listening for application ports
2025-12-07 18:42:47.35
7cd3339c
System
initializing deployment without listening for application ports
2025-12-07 18:42:55.20
7cd3339c
User
python: can't open file '/home/runner/workspace/main.py': [Errno 2] No such file or directory
2025-12-07 18:42:55.20
7cd3339c
System
command finished with error [python main.py]: exit status 2
2025-12-07 18:43:00.79
7cd3339c
System
crash loop detected
2025-12-07 18:43:00.79
7cd3339c
System
crash loop detected

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB