Skip to content

Commit

Permalink
Merge pull request #47 from AlecM33/change-restricted-command-check
Browse files Browse the repository at this point in the history
Simplify restricted command check
  • Loading branch information
AlecM33 authored Feb 21, 2025
2 parents 816f885 + ca9faad commit a78f1eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion config/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ module.exports = {
HIGHLIGHTS_PER_MESSAGE: 8,
SCORING_PLAYS_PER_MESSAGE: 8,
DATE: null,
ADMIN_ROLES: [ "Mod", "Moderator" ],
TEAM_COLOR_CONTRAST_RATIO: 1.5,
HOME_RUN_PARKS_MIN: 5,
HOME_RUN_PARKS_MAX: 25,
Expand Down
10 changes: 5 additions & 5 deletions modules/interaction-handlers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { AttachmentBuilder, EmbedBuilder } = require('discord.js');
const { AttachmentBuilder, EmbedBuilder, PermissionsBitField } = require('discord.js');
const globalCache = require('./global-cache');
const mlbAPIUtil = require('./MLB-API-util');
const { joinImages } = require('join-images');
Expand Down Expand Up @@ -160,7 +160,7 @@ module.exports = {

subscribeGamedayHandler: async (interaction) => {
console.info(`SUBSCRIBE GAMEDAY command invoked by guild: ${interaction.guildId}`);
if (!interaction.member.roles.cache.some(role => globals.ADMIN_ROLES.includes(role.name))) {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) {
await interaction.reply({
ephemeral: true,
content: 'You do not have permission to subscribe channels to the Gameday feed.'
Expand Down Expand Up @@ -205,7 +205,7 @@ module.exports = {

testGamedayReportingHandler: async (interaction) => {
console.info(`TEST GAMEDAY REPORTING command invoked by guild: ${interaction.guildId}`);
if (!interaction.member.roles.cache.some(role => globals.ADMIN_ROLES.includes(role.name))) {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) {
await interaction.reply({
ephemeral: true,
content: 'You do not have permission to use this command.'
Expand Down Expand Up @@ -254,7 +254,7 @@ module.exports = {

gamedayPreferenceHandler: async (interaction) => {
console.info(`GAMEDAY PREFERENCE command invoked by guild: ${interaction.guildId}`);
if (!interaction.member.roles.cache.some(role => globals.ADMIN_ROLES.includes(role.name))) {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) {
await interaction.reply({
ephemeral: true,
content: 'You do not have permission to use this command.'
Expand Down Expand Up @@ -301,7 +301,7 @@ module.exports = {

unSubscribeGamedayHandler: async (interaction) => {
console.info(`UNSUBSCRIBE GAMEDAY command invoked by guild: ${interaction.guildId}`);
if (!interaction.member.roles.cache.some(role => globals.ADMIN_ROLES.includes(role.name))) {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) {
await interaction.reply({
ephemeral: true,
content: 'You do not have permission to un-subscribe channels to the Gameday feed.'
Expand Down

0 comments on commit a78f1eb

Please sign in to comment.