aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2022-01-29 11:27:39 -0500
committerMax Isom <[email protected]>2022-01-29 11:27:39 -0500
commitfc5c1ee002260335971855eb31589d5aed25620a (patch)
tree3a798463bcdef036d872f60d60755a4f82352d51 /src
parent1621b2c2815f7458df19320361a4a5a41c9cf4d3 (diff)
downloadmuse-fc5c1ee002260335971855eb31589d5aed25620a.tar.xz
muse-fc5c1ee002260335971855eb31589d5aed25620a.zip
Handle ownership transfer events
Diffstat (limited to 'src')
-rw-r--r--src/bot.ts2
-rw-r--r--src/events/handle-guild-update.ts10
2 files changed, 12 insertions, 0 deletions
diff --git a/src/bot.ts b/src/bot.ts
index d6bf02f..29cf818 100644
--- a/src/bot.ts
+++ b/src/bot.ts
@@ -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);
}
diff --git a/src/events/handle-guild-update.ts b/src/events/handle-guild-update.ts
new file mode 100644
index 0000000..837bbbe
--- /dev/null
+++ b/src/events/handle-guild-update.ts
@@ -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;