From d6c9d4b1128c5cddda74b3a84575388670edf221 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 29 Jan 2022 11:36:24 -0500 Subject: Update invite permissions, send message to owner --- src/bot.ts | 4 ++-- src/events/guild-create.ts | 4 ++++ src/events/guild-update.ts | 10 ++++++++++ src/events/handle-guild-update.ts | 10 ---------- 4 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 src/events/guild-update.ts delete mode 100644 src/events/handle-guild-update.ts (limited to 'src') diff --git a/src/bot.ts b/src/bot.ts index 29cf818..0a041ec 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -7,6 +7,7 @@ import Command from './commands/index.js'; import debug from './utils/debug.js'; import handleGuildCreate from './events/guild-create.js'; import handleVoiceStateUpdate from './events/voice-state-update.js'; +import handleGuildUpdate from './events/guild-update.js'; import errorMsg from './utils/error-msg.js'; import {isUserInVoice} from './utils/channels.js'; import Config from './services/config.js'; @@ -14,7 +15,6 @@ 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 { @@ -152,7 +152,7 @@ export default class { spinner.text = '📡 updating permissions...'; await Promise.all(this.client.guilds.cache.map(async guild => updatePermissionsForGuild(guild))); - spinner.succeed(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.client.user?.id ?? ''}&scope=bot%20applications.commands&permissions=2184236096`); + spinner.succeed(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.client.user?.id ?? ''}&scope=bot%20applications.commands&permissions=36700160`); }); this.client.on('error', console.error); diff --git a/src/events/guild-create.ts b/src/events/guild-create.ts index 8db7e2f..630d6cb 100644 --- a/src/events/guild-create.ts +++ b/src/events/guild-create.ts @@ -32,4 +32,8 @@ export default async (guild: Guild): Promise => { {body: container.getAll(TYPES.Command).map(command => command.slashCommand.toJSON())}, ); } + + const owner = await guild.fetchOwner(); + + await owner.send('👋 Hi! Someone (probably you) just invited me to a server you own. I can\'t be used by your server members until you complete setup by running /config set-role in your server.'); }; diff --git a/src/events/guild-update.ts b/src/events/guild-update.ts new file mode 100644 index 0000000..837bbbe --- /dev/null +++ b/src/events/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; diff --git a/src/events/handle-guild-update.ts b/src/events/handle-guild-update.ts deleted file mode 100644 index 837bbbe..0000000 --- a/src/events/handle-guild-update.ts +++ /dev/null @@ -1,10 +0,0 @@ -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; -- cgit v1.2.3