-
Notifications
You must be signed in to change notification settings - Fork 0
/
moduleBase.js
103 lines (100 loc) · 2.89 KB
/
moduleBase.js
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//moduleBase.js: Base module code
//Copyright (c) 2018-2019 BlaCoiso
//This file is part of thingBot, licensed under GPL v3.0
//jshint esversion:6
const Discord = require("discord.js");
const OutputObject = {
/** Send output to DM */
sendDM: false,
/** Reply to user */
reply: false,
split: false,
disableEveryone: false,
tts: false,
code: null,
options: {},
text: "output message contents",
embed: null,
attachment: null
};
class BaseModule {
constructor() {
/** Module's name */
this.name = "Module";
/** Module's description */
this.description = "";
/**
* Events handled by this module
* @type {string|string[]?}
*/
this.events = null;
/**
* Commands used by this module
* @type {ModuleCommand[]?}
*/
this.commands = null;
}
/** Initializes the module */
init(logger, DB) {
this.logger = logger;
this.DB = DB;
}
/**
* Handles a Discord event
* @param {string} event Name of the event
* @param {Discord.Client} client Discord Client object
* @param {DatabaseManager} DB Database object
* @param {...any} args Event arguments
*/
handle(event, client, DB, ...args) {
}
}
class ModuleCommand {
constructor() {
/** Command's name */
this.name = "command";
/** Command's description */
this.description = "description";
//TODO: Multiple usage strings
this.usage = "[optional] {required} {opt1|opt2|opt3}";
/**
* Aliases for this command
* @type {string|string[]?}
*/
this.aliases = ["alias1", "alias2"];
/**
* Output of the command (static response),
* Command.run is used instead if not defined
* @type {OutputObject|string?}
*/
this.output = "Command output";
/** If true, the command is disabled on DMs */
this.disableDM = false;
/** If true, will reply to the user with the response */
this.reply = false;
/** If true, will send the response into the user's DMs */
this.sendDM = false;
/**
* List of DB paths to prefetch before executing command
* @type {string|string[]?}
*/
this.prefetch = ["module.var1", "guild.module.var2"];
/**
* List of permissions required to use the command (user must have at least one of them)
* @type {string|string[]?}
*/
this.perms = ["perm1", "perm2"];
}
/**
* Run the command
* @param {Discord.Message} message
* @param {} args
*/
run(message, args) {
//Expected return values:
//String: send string to channel
//Promise: send resolved promise results to channel
//Object: check OutputObject
}
}
module.exports = BaseModule;