Standalone bot/ service (its own package.json/Dockerfile) managed entirely through a new admin-only Discord Bot panel — token stored encrypted in the DB and pushed to the bot process in-memory, never an env var. Built in phases, each independently verified against a live Discord guild: - Bot skeleton: gateway connection, internal shared-secret API, self-heals on its own restart by pulling config from the site - Moderation core: /ban /kick /mute /warn /warnings + mod-log channel - Word/invite/spam filtering with leetspeak-resistant normalization and a staff role/channel allowlist - Scheduled messages: recurring (cron) and one-off channel posts - Role assignment: button role menus, auto-role on join, temp roles, bulk role ops - Auto-rotating primary invite with an audit log - Site integration: news-publish -> Discord announce webhook, manual /announce, read-only /wiki search Also fixes a pre-existing bug in both DB pools (server + bot): the mariadb driver defaulted to timezone 'local', silently mis-serializing bound Date params by the host's local offset instead of the DB's UTC session. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
41 lines
1.6 KiB
JavaScript
41 lines
1.6 KiB
JavaScript
const { ApplicationCommandOptionType } = require('discord.js')
|
|
|
|
const siteApiClient = require('../../site/siteApiClient')
|
|
|
|
// Public command — no default_member_permissions restriction. Read-only:
|
|
// searches wiki titles/content and links to the best match. Never posts to or
|
|
// edits the wiki. Category-scoped search (spec's optional "/wiki spells
|
|
// fireball") is deferred — the site's public search endpoint currently
|
|
// ignores category filters whenever a text query is given.
|
|
function siteOrigin() {
|
|
const base = process.env.SITE_PUBLIC_URL || 'http://localhost:3000/api/v1/public'
|
|
return new URL(base).origin
|
|
}
|
|
|
|
module.exports = {
|
|
data: {
|
|
name: 'wiki',
|
|
description: 'Search the wiki.',
|
|
options: [{ name: 'query', description: 'What to search for', type: ApplicationCommandOptionType.String, required: true }],
|
|
},
|
|
async execute(interaction) {
|
|
const query = interaction.options.getString('query', true)
|
|
await interaction.deferReply()
|
|
|
|
const result = await siteApiClient.searchWiki(query)
|
|
if (result.maintenance) {
|
|
await interaction.editReply({ content: `The wiki is unavailable right now: ${result.message || 'maintenance mode'}` })
|
|
return
|
|
}
|
|
if (!result.ok || !result.data || result.data.length === 0) {
|
|
await interaction.editReply({ content: `No wiki results for "${query}".` })
|
|
return
|
|
}
|
|
|
|
const best = result.data[0]
|
|
const url = `${siteOrigin()}/wiki/${best.slug}`
|
|
const content = best.excerpt ? `**${best.title}**\n${best.excerpt}\n${url}` : `**${best.title}**\n${url}`
|
|
await interaction.editReply({ content })
|
|
},
|
|
}
|