Skip to content

Commit

Permalink
fix: channel can be null when checking permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Sep 27, 2021
1 parent 7b03d02 commit 2c3b268
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion detector/detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ 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) {
if (!channel?.permissionsFor(client.user).has('SEND_MESSAGES') || !channel.viewable) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion events/guildMemberUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ 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) {
if (!channel?.permissionsFor(client.user).has('SEND_MESSAGES') || !channel.viewable) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion events/messageReactionAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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) {
if (!channel?.permissionsFor(client.user).has('SEND_MESSAGES') || !channel.viewable) {
return;
}

Expand Down

0 comments on commit 2c3b268

Please sign in to comment.