Skip to content

Commit

Permalink
fix: update messageCount/totalMessageSent on message events (#8635)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
almeidx and kodiakhq[bot] committed Sep 19, 2022
1 parent 8444576 commit 145eb2f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/discord.js/src/client/actions/MessageCreate.js
Expand Up @@ -10,6 +10,11 @@ class MessageCreateAction extends Action {
if (channel) {
if (!channel.isTextBased()) return {};

if (channel.isThread()) {
channel.messageCount++;
channel.totalMessageSent++;
}

const existing = channel.messages.cache.get(data.id);
if (existing) return { message: existing };
const message = channel.messages._add(data);
Expand Down
2 changes: 2 additions & 0 deletions packages/discord.js/src/client/actions/MessageDelete.js
Expand Up @@ -11,6 +11,8 @@ class MessageDeleteAction extends Action {
if (channel) {
if (!channel.isTextBased()) return {};

if (channel.isThread()) channel.messageCount--;

message = this.getMessage(data, channel);
if (message) {
channel.messages.cache.delete(message.id);
Expand Down
2 changes: 2 additions & 0 deletions packages/discord.js/src/client/actions/MessageDeleteBulk.js
Expand Up @@ -12,6 +12,8 @@ class MessageDeleteBulkAction extends Action {
if (channel) {
if (!channel.isTextBased()) return {};

if (channel.isThread()) channel.messageCount -= data.ids.length;

const ids = data.ids;
const messages = new Collection();
for (const id of ids) {
Expand Down

0 comments on commit 145eb2f

Please sign in to comment.