Skip to content

Commit

Permalink
Merge pull request #273 from the-hideout/restock-check-perms
Browse files Browse the repository at this point in the history
Check permissions on /restock channel
  • Loading branch information
Razzmatazzz authored Feb 8, 2024
2 parents cde865f + 6b6cbbc commit 3658fc2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion commands/boss.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const defaultFunction = {
});

let loot = Object.values(allLoot).filter(item => {
if (item.types.includes('noFlea')) {
if (item.types.includes('noFlea') && !item.types.includes('ammoBox') && !item.types.includes('ammo') && !item.normalizedName.includes('christmas-tree-ornament')) {
return true;
}
});
Expand Down
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: 1 addition & 1 deletion modules/progress.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const startRestockAlerts = async () => {
const setRestockTimers = async () => {
const traders = await gameData.traders.getAll();
// traders to skip restock timers for
const skipTraders = ['fence', 'lightkeeper'];
const skipTraders = ['fence', 'lightkeeper', 'btr-driver'];
for (const trader of traders) {
const currentTimer = restockTimers[trader.id];
if (currentTimer != trader.resetTime) {
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 3658fc2

Please sign in to comment.