Handle ownership transfer events

This commit is contained in:
Max Isom 2022-01-29 11:27:39 -05:00
parent 1621b2c281
commit fc5c1ee002
No known key found for this signature in database
GPG key ID: 25C9B1A7F6798880
2 changed files with 12 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import {generateDependencyReport} from '@discordjs/voice';
import {REST} from '@discordjs/rest';
import {Routes} from 'discord-api-types/v9';
import updatePermissionsForGuild from './utils/update-permissions-for-guild.js';
import handleGuildUpdate from './events/handle-guild-update.js';
@injectable()
export default class {
@ -159,6 +160,7 @@ export default class {
this.client.on('guildCreate', handleGuildCreate);
this.client.on('voiceStateUpdate', handleVoiceStateUpdate);
this.client.on('guildUpdate', handleGuildUpdate);
await this.client.login(this.token);
}

View file

@ -0,0 +1,10 @@
import {Guild} from 'discord.js';
import updatePermissionsForGuild from '../utils/update-permissions-for-guild.js';
const handleGuildUpdate = async (oldGuild: Guild, newGuild: Guild) => {
if (oldGuild.ownerId !== newGuild.ownerId) {
await updatePermissionsForGuild(newGuild);
}
};
export default handleGuildUpdate;