From 2edc1581f4288a5bfc47ddd947202d7f72a78dcb Mon Sep 17 00:00:00 2001 From: janderedev Date: Sat, 7 May 2022 20:41:45 +0200 Subject: [PATCH] bridge: send warning message when missing perms --- bridge/src/discord/events.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/bridge/src/discord/events.ts b/bridge/src/discord/events.ts index 11d499a..563d312 100644 --- a/bridge/src/discord/events.ts +++ b/bridge/src/discord/events.ts @@ -89,16 +89,13 @@ client.on('messageCreate', async message => { return logger.debug(`Discord: Lacking SendMessage permission; refusing to send`); } - if (!(channel.havePermission('SendEmbeds'))) { - 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`); + for (const perm of [ 'SendEmbeds', 'UploadFiles', 'Masquerade' ]) { + if (!(channel.havePermission(perm as any))) { + // todo: maybe don't spam this on every message? + await channel.sendMessage(`Missing permission: I don't have the \`${perm}\` permission ` + + `which is required to bridge a message sent by \`${message.author.tag}\` on Discord.`); + return logger.debug(`Discord: Lacking ${perm} permission; refusing to send`); + } } // Setting a known nonce allows us to ignore bridged