Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update messageCount/totalMessageSent on message events #8635

Merged
merged 2 commits into from Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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