This commit is contained in:
Raven Scott
2026-08-13 14:36:15 -04:00
parent 993514f796
commit 879ad78bed
17 changed files with 2601 additions and 327 deletions
@@ -5,7 +5,7 @@
"synopsis": [
"discord-bot [--env PATH] [--token TOKEN] [--guild ID] [--check] [--debug] [--message-content] [--login-timeout MS]"
],
"description": "Bare OS Discord bot via ctx.bare.discordJS. Commands run as the unlocked session user (not guest). /run is a non-interactive shell: persistent cwd per Discord user, command history, autocomplete for commands/paths/flags, pipes and cd. Slash commands also include /settings, /files, /panel, /edit, /create, /bare, /sys, /svc, /fs, /net, /man, /say, /journal, /ping. Replies are embeds that paginate when large and expire after 2 minutes idle. Token from --token, DISCORD_TOKEN, or ~/.discord/.env. DISCORD_ID_WHITELIST restricts who may use the bot (required once /run is a full shell). The initd unit bare-os-discord is listed by systemctl only when ~/.discord/.env exists.",
"description": "Bare OS Discord bot via ctx.bare.discordJS. Commands run as the unlocked session user (not guest). /run is a non-interactive shell (cwd, history, autocomplete). /plugins loads JSON or JS from ~/.discord/plugins (see developer-guide ch.21). Also /settings, /files, /panel, /edit, /create, /bare, /sys, /svc, /fs, /net, /man, /say, /journal, /ping. Embeds paginate when large and expire after 2 minutes idle. Token from --token, DISCORD_TOKEN, or ~/.discord/.env. DISCORD_ID_WHITELIST restricts who may use the bot. The initd unit bare-os-discord is listed by systemctl only when ~/.discord/.env exists.",
"options": [
{
"flag": "--env PATH",
+17 -2
View File
@@ -365,15 +365,30 @@ async function run(ctx, argv) {
}
}
})
const slashBody =
const slashBody = await Promise.resolve(
typeof discordBuildSlashCommands === 'function'
? discordBuildSlashCommands(dj)
? discordBuildSlashCommands(dj, ctx)
: [
new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with pong.')
.toJSON()
]
)
if (typeof discordPluginsSetRegistrar === 'function') {
discordPluginsSetRegistrar(async function () {
const body = await Promise.resolve(discordBuildSlashCommands(dj, ctx))
const rest = new REST().setToken(loaded.token)
const appId = client.user && client.user.id
if (!appId) return
if (guildId) {
await rest.put(Routes.applicationGuildCommands(appId, guildId), { body: body })
} else {
await rest.put(Routes.applicationCommands(appId), { body: body })
}
})
}
client.once(Events.ClientReady, async function (readyClient) {
ctx.console.log('Logged in as ' + readyClient.user.tag)