diff --git a/actions/warn.js b/actions/warn.js
index 4fcf37c..1f3dc4d 100644
--- a/actions/warn.js
+++ b/actions/warn.js
@@ -10,7 +10,10 @@ const ban = require('./ban');
module.exports = async ({ admin, userToWarn, reason }) => {
- const { warns } = await warn(userToWarn, reason);
+ const by_id = admin.id;
+ const date = new Date();
+
+ const { warns } = await warn(userToWarn, { by_id, date, reason });
const isLastWarn = ', last warning!'
.repeat(warns.length === numberOfWarnsToBan - 1);
diff --git a/handlers/commands/unwarn.js b/handlers/commands/unwarn.js
index ae9ff92..36939db 100644
--- a/handlers/commands/unwarn.js
+++ b/handlers/commands/unwarn.js
@@ -1,5 +1,7 @@
'use strict';
+const { last } = require('ramda');
+
// Utils
const { link, scheduleDeletion } = require('../../utils/tg');
@@ -63,9 +65,11 @@ const unwarnHandler = async ({ message, reply, state, telegram }) => {
// (it's an expected, non-critical failure)
}
+ const lastWarn = last(allWarns);
+
return reply(
`❎ ${link(user)} pardoned ${link(userToUnwarn)} ` +
- `for:\n\n${allWarns[allWarns.length - 1]}` +
+ `for:\n\n${lastWarn.reason || lastWarn}` +
` (${allWarns.length - 1}/${numberOfWarnsToBan})`,
replyOptions
);
diff --git a/handlers/commands/user.js b/handlers/commands/user.js
index 5f14d67..42c1e9c 100644
--- a/handlers/commands/user.js
+++ b/handlers/commands/user.js
@@ -34,7 +34,7 @@ const getWarnsHandler = async ({ message, reply, state }) => {
: '';
const userWarns = warns.length
? '\n⚠️ Warns:\n' + warns
- .map((warn, i) => `${i + 1}. ${warn}`)
+ .map((warn, i) => `${i + 1}. ${warn.reason || warn}`)
.join('\n') + '\n'
: '';
@@ -50,4 +50,3 @@ const getWarnsHandler = async ({ message, reply, state }) => {
};
module.exports = getWarnsHandler;
-