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(ApplicationCommandManager): update guild command cache on c/u/d #6841

Merged
merged 1 commit into from Oct 27, 2021
Merged
Changes from all commits
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
11 changes: 4 additions & 7 deletions src/managers/ApplicationCommandManager.js
Expand Up @@ -117,7 +117,7 @@ class ApplicationCommandManager extends CachedManager {
const data = await this.commandPath({ guildId }).post({
data: this.constructor.transformCommand(command),
});
return this._add(data, !guildId, guildId);
return this._add(data, true, guildId);
}

/**
Expand Down Expand Up @@ -146,10 +146,7 @@ class ApplicationCommandManager extends CachedManager {
const data = await this.commandPath({ guildId }).put({
data: commands.map(c => this.constructor.transformCommand(c)),
});
return data.reduce(
(coll, command) => coll.set(command.id, this._add(command, !guildId, guildId)),
new Collection(),
);
return data.reduce((coll, command) => coll.set(command.id, this._add(command, true, guildId)), new Collection());
}

/**
Expand All @@ -174,7 +171,7 @@ class ApplicationCommandManager extends CachedManager {
const patched = await this.commandPath({ id, guildId }).patch({
data: this.constructor.transformCommand(data),
});
return this._add(patched, !guildId, guildId);
return this._add(patched, true, guildId);
}

/**
Expand All @@ -196,7 +193,7 @@ class ApplicationCommandManager extends CachedManager {
await this.commandPath({ id, guildId }).delete();

const cached = this.cache.get(id);
if (!guildId) this.cache.delete(id);
this.cache.delete(id);
return cached ?? null;
}

Expand Down