3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 22:21:51 +00:00

Fix muteUser() sometimes operating on stale member info

This commit is contained in:
Dragory 2020-12-17 03:50:02 +02:00
parent 4a555823fc
commit ac7935e24d
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 3 additions and 3 deletions

View file

@ -47,7 +47,7 @@ export async function muteUser(
throw new RecoverablePluginError(ERRORS.INVALID_USER); throw new RecoverablePluginError(ERRORS.INVALID_USER);
} }
const member = await resolveMember(pluginData.client, pluginData.guild, user.id); // Grab the fresh member so we don't have stale role info const member = await resolveMember(pluginData.client, pluginData.guild, user.id, true); // Grab the fresh member so we don't have stale role info
const config = pluginData.config.getMatchingConfig({ member, userId }); const config = pluginData.config.getMatchingConfig({ member, userId });
if (member) { if (member) {

View file

@ -1088,12 +1088,12 @@ export async function resolveUser<T>(bot, value) {
* Resolves a guild Member from the passed user id, user mention, or full username (with discriminator). * Resolves a guild Member from the passed user id, user mention, or full username (with discriminator).
* If the member is not found in the cache, it's fetched from the API. * If the member is not found in the cache, it's fetched from the API.
*/ */
export async function resolveMember(bot: Client, guild: Guild, value: string): Promise<Member | null> { export async function resolveMember(bot: Client, guild: Guild, value: string, fresh = false): Promise<Member | null> {
const userId = resolveUserId(bot, value); const userId = resolveUserId(bot, value);
if (!userId) return null; if (!userId) return null;
// If we have the member cached, return that directly // If we have the member cached, return that directly
if (guild.members.has(userId)) { if (guild.members.has(userId) && !fresh) {
return guild.members.get(userId) || null; return guild.members.get(userId) || null;
} }