bridge: send warning message when missing perms

This commit is contained in:
janderedev 2022-05-07 20:41:45 +02:00
parent ed85be6cdb
commit 2edc1581f4
No known key found for this signature in database
GPG key ID: 5D5E18ACB990F57A

View file

@ -89,16 +89,13 @@ client.on('messageCreate', async message => {
return logger.debug(`Discord: Lacking SendMessage permission; refusing to send`); return logger.debug(`Discord: Lacking SendMessage permission; refusing to send`);
} }
if (!(channel.havePermission('SendEmbeds'))) { for (const perm of [ 'SendEmbeds', 'UploadFiles', 'Masquerade' ]) {
return logger.debug(`Discord: Lacking SendEmbeds permission; refusing to send`); 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 `
if (!(channel.havePermission('UploadFiles'))) { + `which is required to bridge a message sent by \`${message.author.tag}\` on Discord.`);
return logger.debug(`Discord: Lacking UploadFiles permission; refusing to send`); return logger.debug(`Discord: Lacking ${perm} permission; refusing to send`);
} }
if (!(channel.havePermission('Masquerade'))) {
return logger.debug(`Discord: Lacking Masquerade permission; refusing to send`);
} }
// Setting a known nonce allows us to ignore bridged // Setting a known nonce allows us to ignore bridged