Skip to content

Commit

Permalink
fix: parse MAX_MESSAGE_COUNT value to integer
Browse files Browse the repository at this point in the history
so it can pass strict comparison
  • Loading branch information
andrerahardjo97 committed Jan 25, 2021
1 parent d958305 commit 8a28cc9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const client = new Discord.Client({
},
});

const maxMessageCount = parseInt(process.env.MAX_MESSAGE_COUNT);
let lastStickyMessage = "";
let messageCount = 0;
let stickyMessageChannel = "";
Expand All @@ -27,7 +28,7 @@ client.on("message", async function (message) {
if (stickyMessageContent !== "") {
if (message.channel.id === stickyMessageChannel) {
messageCount++;
if (messageCount === process.env.MAX_MESSAGE_COUNT) {
if (messageCount === maxMessageCount) {
await lastStickyMessage.delete();
lastStickyMessage = await message.channel.send(stickyMessageContent);
messageCount = 0;
Expand Down

0 comments on commit 8a28cc9

Please sign in to comment.