Commit b4ccf8d3 authored by Neoony's avatar Neoony
Browse files

-Update README.md -Improved formatting of !cplogs message -Small bugfixes

parent 19547f21
......@@ -241,7 +241,7 @@ function SQLcomeplayLogQuery(CPlogsArgs, user, message) {
const numRows = results.length;
let CPlogsQueryMessage = '';
let CPlogsQueryMessage = '```----------DATETIME--------+---------------USER---------------+---CHANNEL---+--COMMAND--+--ACTION--+-------------------MESSAGE-------------------```';
if (numRows == 0) {
message.channel.send('No results, try different argument?');
......@@ -265,7 +265,65 @@ function SQLcomeplayLogQuery(CPlogsArgs, user, message) {
console.log('CPlogsQuery: Returned value: ', ACTION[i]);
console.log('CPlogsQuery: Returned value: ', MESSAGE[i]);
CPlogsQueryMessage += '```' + DATETIME[i] + ' ' + USER[i] + ' ' + CHANNEL[i] + ' ' + COMMAND[i] + ' ' + ACTION[i] + ' ' + MESSAGE[i] + '```';
if (DATETIME[i] == null) {
DATETIME[i] = 'null';
}
if (USER[i] == null) {
USER[i] = 'null';
}
if (CHANNEL[i] == null) {
CHANNEL[i] = 'null';
}
if (COMMAND[i] == null) {
COMMAND[i] = 'null';
}
if (ACTION[i] == null) {
ACTION[i] = 'null';
}
if (MESSAGE[i] == null) {
MESSAGE[i] = 'null';
}
const DATETIMElength = DATETIME[i].length;
const USERlength = USER[i].length;
const CHANNELlength = CHANNEL[i].length;
const COMMANDlength = COMMAND[i].length;
const ACTIONlength = ACTION[i].length;
// const MESSAGElength = MESSAGE[i].length;
const DATETIMElengthAdd = 26 - DATETIMElength;
const USERlengthAdd = 33 - USERlength;
const CHANNELlengthAdd = 12 - CHANNELlength;
const COMMANDlengthAdd = 10 - COMMANDlength;
const ACTIONlengthAdd = 9 - ACTIONlength;
// const MESSAGElengthAdd
let DATETIMElengthAddSpacer = '';
let USERlengthAddSpacer = '';
let CHANNELlengthAddSpacer = '';
let COMMANDlengthAddSpacer = '';
let ACTIONlengthAddSpacer = '';
let z;
for (z = 0; z < Math.max(DATETIMElengthAdd, USERlengthAdd, CHANNELlengthAdd, COMMANDlengthAdd, ACTIONlengthAdd); z++) {
if (DATETIMElengthAddSpacer.length < DATETIMElengthAdd) {
DATETIMElengthAddSpacer += ' ';
}
if (USERlengthAddSpacer.length < USERlengthAdd) {
USERlengthAddSpacer += ' ';
}
if (CHANNELlengthAddSpacer.length < CHANNELlengthAdd) {
CHANNELlengthAddSpacer += ' ';
}
if (COMMANDlengthAddSpacer.length < COMMANDlengthAdd) {
COMMANDlengthAddSpacer += ' ';
}
if (ACTIONlengthAddSpacer.length < ACTIONlengthAdd) {
ACTIONlengthAddSpacer += ' ';
}
}
CPlogsQueryMessage += '```' + DATETIME[i] + DATETIMElengthAddSpacer + '| ' + USER[i] + USERlengthAddSpacer + '| ' + CHANNEL[i] + CHANNELlengthAddSpacer + '| ' + COMMAND[i] + COMMANDlengthAddSpacer + '| ' + ACTION[i] + ACTIONlengthAddSpacer + '| ' + MESSAGE[i] + '```';
}
message.channel.send(CPlogsQueryMessage + '```CSS\nPage number ' + CPlogsPage + '\nType !cplogs ' + CPlogsNextPage + ' for next page```');
......@@ -666,12 +724,17 @@ function ComePlayNotifier() {
const path = 'CPNotifCounter.txt';
const content = fs.readFileSync('CPNotifCounter.txt', 'utf8', function(err) {
let content = fs.readFileSync('CPNotifCounter.txt', 'utf8', function(err) {
if (err) console.log(err);
});
GetDateAndTime();
console.log(DateAndTime + ': ' + 'File content: ' + content);
if (content == 'NaN') {
console.log(DateAndTime + ': ' + 'File content NaN, setting back to default value');
content = CPNotifHowOftenInSeconds;
}
CPNotifCounter = content - 10;
CPNotifCounter = CPNotifCounter.toString();
console.log(DateAndTime + ': ' + 'CPNotifCounter after ' + CPNotifCounter);
......
......@@ -29,4 +29,10 @@ If bot has permission SEND_MESSAGES in come-play channel then he will send notif
If bot has permission MENTION_EVERYONE in come-play channel then he will also mention @here
This message can only happen once in 12 hours
Only if Lobby has 6 or more players, or only if regular server has 12 or more players
![Come-Play Notifier](https://i.imgur.com/NoDAvV7.png)
\ No newline at end of file
![Come-Play Notifier](https://i.imgur.com/NoDAvV7.png)
# **!cplogs**
Users with MANAGE_ROLES permission on the Discord server can type !cplogs to show logs of usage of !cpjoin / !cpleave
!cplogs without arguments will show page 0 (latest records)
!cplogs 1 will show the next page and so on
![Come-Play Notifier](https://i.imgur.com/wVJREtx.png)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment