|
|
@ -120,6 +120,14 @@ class Bot {
|
|
|
|
new dblib.Column('text', sql.types.getVarchar(255),
|
|
|
|
new dblib.Column('text', sql.types.getVarchar(255),
|
|
|
|
[sql.constraints.unique, sql.constraints.notNull])
|
|
|
|
[sql.constraints.unique, sql.constraints.notNull])
|
|
|
|
]));
|
|
|
|
]));
|
|
|
|
|
|
|
|
await this.maindb.run(sql.createTableIfNotExists('messages', [
|
|
|
|
|
|
|
|
sql.templates.idcolumn,
|
|
|
|
|
|
|
|
new dblib.Column('server', sql.types.getVarchar(255)),
|
|
|
|
|
|
|
|
new dblib.Column('channel', sql.types.getVarchar(255)),
|
|
|
|
|
|
|
|
new dblib.Column('username', sql.types.getVarchar(255), [sql.constraints.notNull]),
|
|
|
|
|
|
|
|
new dblib.Column('message', sql.types.text),
|
|
|
|
|
|
|
|
new dblib.Column('timestamp', sql.types.datetime, [sql.constraints.notNull, sql.default('NOW()')])
|
|
|
|
|
|
|
|
]));
|
|
|
|
this.logger.debug('Loading Presences...');
|
|
|
|
this.logger.debug('Loading Presences...');
|
|
|
|
await this.loadPresences();
|
|
|
|
await this.loadPresences();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -232,6 +240,35 @@ class Bot {
|
|
|
|
gh.musicPlayer.checkListeners();
|
|
|
|
gh.musicPlayer.checkListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.client.on('message', async (msg) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
let sql = this.maindb.sql;
|
|
|
|
|
|
|
|
let server = null;
|
|
|
|
|
|
|
|
let channel = null;
|
|
|
|
|
|
|
|
let user = msg.author.tag;
|
|
|
|
|
|
|
|
let message = msg.content;
|
|
|
|
|
|
|
|
if (msg.guild) {
|
|
|
|
|
|
|
|
server = msg.guild.name;
|
|
|
|
|
|
|
|
channel = msg.channel.name;
|
|
|
|
|
|
|
|
await this.maindb.run(sql.insert('messages', {
|
|
|
|
|
|
|
|
server: sql.parameter(1),
|
|
|
|
|
|
|
|
channel: sql.parameter(2),
|
|
|
|
|
|
|
|
username: sql.parameter(3),
|
|
|
|
|
|
|
|
message: sql.parameter(4)
|
|
|
|
|
|
|
|
}), [server, channel, user, message]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
await this.maindb.run(sql.insert('messages', {
|
|
|
|
|
|
|
|
channel: sql.parameter(1),
|
|
|
|
|
|
|
|
username: sql.parameter(2),
|
|
|
|
|
|
|
|
message: sql.parameter(3)
|
|
|
|
|
|
|
|
}), ['PRIVATE', user, message]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
this.logger.warn(err.message);
|
|
|
|
|
|
|
|
this.logger.debug(err.stack);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|