-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
57 lines (49 loc) · 1.74 KB
/
Copy pathindex.js
File metadata and controls
57 lines (49 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"use strict";
const CaseSchema = require("./models/case");
const NoteSchema = require("./models/note");
const TicketSchema = require("./models/ticket");
const commands = [
require("./commands/ban"),
require("./commands/unban"),
require("./commands/kick"),
require("./commands/timeout"),
require("./commands/untimeout"),
require("./commands/warn"),
require("./commands/warnings"),
require("./commands/clearwarnings"),
require("./commands/note"),
require("./commands/purge"),
require("./commands/slowmode"),
require("./commands/lock"),
require("./commands/unlock"),
require("./commands/case"),
require("./commands/history"),
require("./commands/modstats"),
require("./commands/ticket"),
];
/**
* Plugin entry point called by the ADB plugin loader.
* @param {object} ctx — plugin context
*/
async function load(ctx) {
// Define mongoose models (namespaced internally by ADB)
const CaseModel = ctx.defineModel("Case", CaseSchema);
const NoteModel = ctx.defineModel("Note", NoteSchema);
const TicketModel = ctx.defineModel("Ticket", TicketSchema);
// ctx is frozen by the core loader — build a local extension carrying the
// models instead of mutating it. Commands read pctx.models.*
const pctx = { ...ctx, models: { Case: CaseModel, Note: NoteModel, Ticket: TicketModel } };
// Register all slash commands
for (const cmd of commands) {
ctx.registerCommand({
data: cmd.data,
execute: (interaction) => cmd.execute(interaction, pctx),
});
}
// Cleanup hook
ctx.hooks.on("onPluginUnload", () => {
ctx.logger.info("[moderation] Plugin unloaded.");
});
ctx.logger.info("[moderation] Moderation plugin loaded — registered " + commands.length + " commands.");
}
module.exports = { load };