Skip to content

Commit

Permalink
Check permissions on /restock channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Razzmatazzz committed Jan 26, 2024
1 parent cde865f commit c09fd5b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions commands/restock.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ const subCommands = {
content: `✅ ${t('Restock alert channel disabled for this server.')}`
});
}
const botMember = channel.members.find(user => user.id === interaction.client.user.id);
if (!botMember) {
return interaction.editReply({
content: `❌ ${t('Stash bot does not have access to #{{channelName}}.', {channelName: channel.name})}`,
});
}
const hasSendMessagesPermission = botMember.permissionsIn(channel) & PermissionFlagsBits.SendMessages;
if (!hasSendMessagesPermission) {
return interaction.editReply({
content: `❌ ${t('Stash bot does not have permission to send messages in #{{channelName}}.', {channelName: channel.name})}`,
});
}
const locale = interaction.options.getString('locale') || 'en';
await progress.setRestockAlertChannel(interaction.guildId, channel?.id, locale);
return interaction.editReply({
Expand Down
2 changes: 2 additions & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
"Spawn Locations": "Spawn Locations",
"Special Loot": "Special Loot",
"Stash - An Escape from Tarkov Discord bot!": "Stash - An Escape from Tarkov Discord bot!",
"Stash bot does not have access to #{{channelName}}.": "Stash bot does not have access to #{{channelName}}.",
"Stash bot does not have permission to send messages in #{{channelName}}.": "Stash bot does not have permission to send messages in #{{channelName}}.",
"Stash Invite Link": "Stash Invite Link",
"Stash Uptime": "Stash Uptime",
"TarkovTracker account unlinked.": "TarkovTracker account unlinked.",
Expand Down

0 comments on commit c09fd5b

Please sign in to comment.