This commit is contained in:
Flummi 2018-02-27 17:52:18 +01:00
parent e99f318125
commit 70ce50fc9b
2 changed files with 19 additions and 3 deletions

View File

@ -13,8 +13,25 @@ export class discord extends EventEmitter {
this.bot = new Discord.Client();
this.bot.login(this.token);
this.server = {
channel: new Map(),
user: new Map(),
me: {}
};
this.bot.on("ready", () => {
this.server.me = {
nickname: this.bot.user.username,
username: this.bot.user.username,
account: this.bot.user.id.toString(),
prefix: `${this.bot.user.username}!${this.bot.user.id.toString()}`,
id: this.bot.user.id.toString()
};
});
this.bot.on("message", msg => {
this.emit("data", ["message", this.reply(msg)]);
if(msg.author.id !== this.server.me.id)
this.emit("data", ["message", this.reply(msg)]);
});
}
reply(tmp) {
@ -37,7 +54,6 @@ export class discord extends EventEmitter {
},
message: tmp.content,
time: ~~(Date.now() / 1000),
//raw: tmp,
reply: msg => this.send(tmp, this.format(msg)),
replyAction: msg => this.send(tmp, this.format(`*${msg}*`), "normal"),
replyNotice: msg => this.send(tmp, this.format(msg))

View File

@ -11,7 +11,7 @@ export default bot => {
bot._trigger.set("cfg", new bot.trigger({
call: /^\!cfg/i,
level: 100,
clients: ["irc"],
clients: ["irc", "discord"],
f: e => {
let args = e.message.substring(5);
let opts = {};