diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-12-30 13:11:06 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-12-30 13:11:06 +0100 |
| commit | c6c5027865743328d0542246fef70e0fafe0f0f1 (patch) | |
| tree | 9348d4afa900c170aa534f602b6f7a823292a831 /views/view.js | |
| parent | abd33f47fbbcc92610b83341c61f5d1911eed590 (diff) | |
| parent | 1881a2ecd48be772fd83b20068fe9946f1365eeb (diff) | |
| download | discordbot-c6c5027865743328d0542246fef70e0fafe0f0f1.tar.gz discordbot-c6c5027865743328d0542246fef70e0fafe0f0f1.zip | |
Merge branch 'master' into developdevelop
Diffstat (limited to 'views/view.js')
| -rw-r--r-- | views/view.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/views/view.js b/views/view.js new file mode 100644 index 0000000..771e3db --- /dev/null +++ b/views/view.js @@ -0,0 +1,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; + } +}; |
