blob: 771e3db0eb67787aebe2705447154fe71655e3c3 (
plain)
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
|
#!/usr/bin/node
/* jshint esnext:true */
"use strict";
const util = require("../util");
module.exports = class {
constructor(msg) {
// command message
this.msg = msg;
// response (d'oh)
this.response = undefined;
this.hasButtons = false;
}
static async text() {
// return the markdown or an array of [title, markdown]
return "";
}
async embed() {
// return an embed using `text()` and `help()`
return util.vainsocialEmbed("title", "url");
}
async help() {
// return explanation for buttons
return "";
}
async buttons() {
// return buttons pointing to different views
// key: emoji, value: async func
return {};
}
async respond() {
// reply with embed + buttons
this.response = await util.respond(this.msg,
await this.embed(), this.response);
if (!this.hasButtons) {
await util.reactionButtons(this.response, await this.buttons(), this.msg);
this.hasButtons = true;
}
return this.response;
}
async error(text) {
// reply with error
this.response = await util.respond(this.msg, text, this.response);
return this.response;
}
};
|