Skip to content

Commit

Permalink
fix: add permissions check for logs
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Sep 25, 2021
1 parent 2c65b72 commit 1db47ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions detector/detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ module.exports = async (client, message, database, edited) => {
const logs = client.db.prepare('SELECT logs FROM guilds WHERE id = ?').get(message.guildId)?.logs;
const channel = message.guild.channels.cache.get(logs);

if (!channel.permissionsFor(client.user).has('SEND_MESSAGES') || !channel.viewable) {
return true;
}

channel?.send({
embeds: [{
title: 'G Removal',
Expand Down
4 changes: 4 additions & 0 deletions events/guildMemberUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ module.exports = {
const logs = client.db.prepare('SELECT logs FROM guilds WHERE id = ?').get(newMember.guild.id)?.logs;
const channel = newMember.guild.channels.cache.get(logs);

if (!channel.permissionsFor(client.user).has('SEND_MESSAGES') || !channel.viewable) {
return;
}

channel?.send({
embeds: [{
title: 'G Removal',
Expand Down
4 changes: 4 additions & 0 deletions events/messageReactionAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ module.exports = {
const logs = client.db.prepare('SELECT logs FROM guilds WHERE id = ?').get(reaction.message.guildId)?.logs;
const channel = reaction.message.guild.channels.cache.get(logs);

if (!channel.permissionsFor(client.user).has('SEND_MESSAGES') || !channel.viewable) {
return;
}

channel?.send({
embeds: [{
title: 'G Removal',
Expand Down

0 comments on commit 1db47ce

Please sign in to comment.