Skip to content

Commit

Permalink
Check channel permission on tracker add
Browse files Browse the repository at this point in the history
  • Loading branch information
KwikKill committed Sep 27, 2024
1 parent c41eaf1 commit 6b511aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions commands/lol.js
Original file line number Diff line number Diff line change
Expand Up @@ -3415,6 +3415,11 @@ async function tracker_add(client, interaction) {
if (response.rowCount !== 0) {
return await interaction.editReply("A tracker channel already exists in this guild !");
}
// check if the bot has send message permission
if (!channel.permissionsFor(channel.guild.me).has(PermissionsBitField.Flags.SendMessages)) {
return await interaction.editReply("The bot doesn't have the permission to send messages in this channel !");
}

const query = "INSERT INTO trackers (channelid, guildid) VALUES ($1, $2);";
client.lol.lol_rank_manager.trackers.push(channel.id);
await client.pg.query(query, [channel.id, channel.guild.id]);
Expand Down
2 changes: 1 addition & 1 deletion util/lol_rank_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class LolRankManager {
const index = this.trackers.indexOf(x);
this.trackers.splice(index, 1);
} else {
logger.error("Unknown error while sending tracker message : " + e);
logger.error("Unknown error while sending tracker message (" + x + "): " + e);
}
}
}
Expand Down

0 comments on commit 6b511aa

Please sign in to comment.