From b65a1bd70c01602f13b1ec92fd7f3fe5e73b4379 Mon Sep 17 00:00:00 2001 From: janderedev Date: Sat, 30 Apr 2022 22:38:16 +0200 Subject: [PATCH] add missing permission warning to bridge setup --- bot/src/bot/commands/bridge.ts | 20 +++++++++++++++----- bridge/src/discord/events.ts | 4 ++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/bot/src/bot/commands/bridge.ts b/bot/src/bot/commands/bridge.ts index 7016f08..7943d15 100644 --- a/bot/src/bot/commands/bridge.ts +++ b/bot/src/bot/commands/bridge.ts @@ -31,11 +31,21 @@ export default { expires: Date.now() + (1000 * 60 * 15), }); - await message.reply(`### Link request created.\n` - + `Request ID: \`${reqId}\`\n\n` - + `[Invite the bridge bot to your Discord server](<${DISCORD_INVITE_URL}>) ` - + `and run \`/bridge confirm ${reqId}\` in the channel you wish to link.\n` - + `This request expires in 15 minutes.`); + let text = `### Link request created.\n` + + `Request ID: \`${reqId}\`\n\n` + + `[Invite the bridge bot to your Discord server](<${DISCORD_INVITE_URL}>) ` + + `and run \`/bridge confirm ${reqId}\` in the channel you wish to link.\n` + + `This request expires in 15 minutes.`; + + if (!message.channel!.havePermission('Masquerade') + || !message.channel!.havePermission('SendEmbeds') + || !message.channel!.havePermission('UploadFiles')) { + text += '\n\n> :warning: I currently don\'t have all required permissions in this ' + + 'channel for the bridge to work. Please make sure to grant the "Masquerade", ' + + '"Upload Files" and "Send Embeds" permission.' + } + + await message.reply(text, false); break; } diff --git a/bridge/src/discord/events.ts b/bridge/src/discord/events.ts index 57b7175..9814439 100644 --- a/bridge/src/discord/events.ts +++ b/bridge/src/discord/events.ts @@ -93,6 +93,10 @@ client.on('messageCreate', async message => { return logger.debug(`Discord: Lacking SendEmbeds permission; refusing to send`); } + if (!(channel.havePermission('UploadFiles'))) { + return logger.debug(`Discord: Lacking UploadFiles permission; refusing to send`); + } + if (!(channel.havePermission('Masquerade'))) { return logger.debug(`Discord: Lacking Masquerade permission; refusing to send`); }