Skip to content

Commit

Permalink
fix(bot): add missing implicit permissions checks (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarelessInternet authored Feb 12, 2024
1 parent fd9ecf5 commit db71663
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 63 deletions.
6 changes: 4 additions & 2 deletions apps/bot/src/commands/thread-ticketing/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ export class ModalInteraction extends Modal.Interaction {
const logsChannel = await guild.channels.fetch(configuration.ticketThreadsCategories.logsChannelId);

if (!logsChannel?.isTextBased()) return;
if (!logsChannel.permissionsFor(me).has([PermissionFlagsBits.SendMessages])) return;
if (!logsChannel.permissionsFor(me).has([PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages]))
return;

await logsChannel.send({
embeds: [
Expand Down Expand Up @@ -572,7 +573,8 @@ export class ModalInteraction extends Modal.Interaction {
const logsChannel = await guild.channels.fetch(row.logsChannelId);

if (!logsChannel?.isTextBased()) return;
if (!logsChannel.permissionsFor(me).has([PermissionFlagsBits.SendMessages])) return;
if (!logsChannel.permissionsFor(me).has([PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages]))
return;

void logsChannel.send({
embeds: [
Expand Down
2 changes: 1 addition & 1 deletion apps/bot/src/events/guild/GuildMemberAdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class extends Event.Handler {

if (data.welcomeNewMemberRoles.length > 0) {
const highestRoleWithManageRoles = me.roles.cache
.filter((role) => role.permissions.has(PermissionFlagsBits.ManageRoles))
.filter((role) => role.permissions.has([PermissionFlagsBits.ManageRoles]))
.sort((a, b) => b.position - a.position)
.at(0);

Expand Down
2 changes: 1 addition & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@vercel/analytics": "^1.1.3",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.323.0",
"lucide-react": "^0.330.0",
"next": "14.1.0",
"next-themes": "^0.2.1",
"react": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"private": true,
"main": "index.cjs",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint-config-next": "^14.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^1.12.3",
Expand Down
Loading

0 comments on commit db71663

Please sign in to comment.