Skip to content

Commit

Permalink
Merge pull request #15 from Muril-o/fix-avatar-update
Browse files Browse the repository at this point in the history
Fix avatar update
  • Loading branch information
Muril-o authored Jan 26, 2023
2 parents 7b5473d + 6f53ac0 commit 7a9bcdc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/events/guildMemberUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export const event: Event = {
boost(newMember);
}

const av = newMember.user.displayAvatarURL({
const av = newMember.displayAvatarURL({
extension: 'png',
forceStatic: false,
size: 1024,
}) as string;

// Audit logs
if (oldMember.user.avatar !== newMember.user.avatar) {
if (oldMember.avatar !== newMember.avatar) {
sendLog(
{
thumbnail: {
Expand All @@ -37,7 +37,7 @@ export const event: Event = {
},
color: 4437377,
timestamp: new Date().toISOString(),
title: 'Avatar Update',
title: 'Server Avatar Update',
author: {
name: newMember.user.tag,
icon_url: av,
Expand All @@ -48,6 +48,7 @@ export const event: Event = {
);
}

// Might wanna move this to userUpdate.ts
if (oldMember.user.tag !== newMember.user.tag) {
sendLog(
{
Expand Down
38 changes: 38 additions & 0 deletions src/events/userUpdate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { Event } from '../struct/types';
import { Events, type User } from 'discord.js';
import { LogDestination, sendLog } from '../util';

export const event: Event = {
name: Events.UserUpdate,
once: false,
async handle(oldUser: User, newUser: User) {
const av = newUser.displayAvatarURL({
extension: 'png',
forceStatic: false,
size: 1024,
}) as string;

// Audit logs
if (oldUser.avatar !== newUser.avatar) {
sendLog(
{
thumbnail: {
url: av,
},
footer: {
text: `ID: ${newUser.id}`,
},
color: 4437377,
timestamp: new Date().toISOString(),
title: 'User Avatar Update',
author: {
name: newUser.tag,
icon_url: av,
},
description: `<@${newUser.id}>`,
},
LogDestination.activity,
);
}
},
};

0 comments on commit 7a9bcdc

Please sign in to comment.