fix(bot): Transform hashes correctly (#3091)

This commit is contained in:
NeKz
2023-08-05 18:26:16 +00:00
committed by GitHub
parent 9927c5bb3d
commit 1424e5552b
2 changed files with 24 additions and 14 deletions
+12 -7
View File
@@ -1,5 +1,5 @@
import type { DiscordAuditLogEntry } from '@discordeno/types'
import type { Bot } from '../index.js'
import { iconHashToBigInt, type Bot } from '../index.js'
import type { Optionalize } from '../optionalize.js'
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
@@ -21,13 +21,8 @@ export function transformAuditLogEntry(bot: Bot, payload: DiscordAuditLogEntry)
name: val?.name,
})),
}
case 'discovery_splash_hash':
case 'banner_hash':
case 'rules_channel_id':
case 'public_updates_channel_id':
case 'icon_hash':
case 'image_hash':
case 'splash_hash':
case 'owner_id':
case 'widget_channel_id':
case 'system_channel_id':
@@ -37,13 +32,23 @@ export function transformAuditLogEntry(bot: Bot, payload: DiscordAuditLogEntry)
case 'deny':
case 'channel_id':
case 'inviter_id':
case 'avatar_hash':
case 'id':
return {
key: change.key,
old: change.old_value ? bot.transformers.snowflake(change.old_value) : undefined,
new: change.new_value ? bot.transformers.snowflake(change.new_value) : undefined,
}
case 'discovery_splash_hash':
case 'banner_hash':
case 'icon_hash':
case 'image_hash':
case 'splash_hash':
case 'avatar_hash':
return {
key: change.key,
old: change.old_value ? iconHashToBigInt(change.old_value) : undefined,
new: change.new_value ? iconHashToBigInt(change.new_value) : undefined,
}
case 'name':
case 'description':
case 'preferred_locale':
@@ -1,5 +1,5 @@
import type { DiscordAuditLogEntry } from '@discordeno/types'
import type { Bot } from '../../index.js'
import { iconBigintToHash, type Bot } from '../../index.js'
import type { AuditLogEntry } from '../auditLogEntry.js'
export function transformAuditLogEntryToDiscordAuditLogEntry(bot: Bot, payload: AuditLogEntry): DiscordAuditLogEntry {
@@ -33,13 +33,8 @@ export function transformAuditLogEntryToDiscordAuditLogEntry(bot: Bot, payload:
name: val?.name,
})),
}
case 'discovery_splash_hash':
case 'banner_hash':
case 'rules_channel_id':
case 'public_updates_channel_id':
case 'icon_hash':
case 'image_hash':
case 'splash_hash':
case 'owner_id':
case 'widget_channel_id':
case 'system_channel_id':
@@ -49,13 +44,23 @@ export function transformAuditLogEntryToDiscordAuditLogEntry(bot: Bot, payload:
case 'deny':
case 'channel_id':
case 'inviter_id':
case 'avatar_hash':
case 'id':
return {
key: change.key,
old_value: change.old ? bot.transformers.reverse.snowflake(change.old as bigint) : '',
new_value: change.new ? bot.transformers.reverse.snowflake(change.new as bigint) : '',
}
case 'discovery_splash_hash':
case 'banner_hash':
case 'icon_hash':
case 'image_hash':
case 'splash_hash':
case 'avatar_hash':
return {
key: change.key,
old_value: change.old ? iconBigintToHash(change.old as bigint) : '',
new_value: change.new ? iconBigintToHash(change.new as bigint) : '',
}
case 'name':
case 'description':
case 'preferred_locale':