Skip to content

Commit

Permalink
Minor fixes to Admin Command (#203)
Browse files Browse the repository at this point in the history
* Update permission field to use new reference

* Fix function call name

* Fixes to allow functioning of admin delete command
  • Loading branch information
Domin0de authored Aug 8, 2024
1 parent 2f55736 commit fa02763
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions commands/admin-standup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { EmbedBuilder, ButtonBuilder, Permissions } = require("discord.js");
const { EmbedBuilder, ButtonBuilder, PermissionsBitField } = require("discord.js");
const paginationEmbed = require("discordjs-button-pagination");

module.exports = {
Expand Down Expand Up @@ -28,7 +28,7 @@ module.exports = {
const standupDB = global.standupDBGlobal;
const TEAM_DIRECTOR_ROLE_ID = "921348676692107274";
if (
!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR) &&
!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator) &&
!interaction.member._roles.includes(TEAM_DIRECTOR_ROLE_ID)
) {
return await interaction.reply({
Expand Down
8 changes: 4 additions & 4 deletions commands/admin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { Permissions } = require("discord.js");
const { PermissionsBitField } = require("discord.js");

const COMMAND_KICKUNVERIFIED = "kickunverified";
const COMMAND_DROPUSERTABLE = "dropusertable";
Expand All @@ -20,7 +20,7 @@ module.exports = {
),
async execute(interaction) {
try {
if (!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) {
return await interaction.reply({
content: "You do not have permission to execute this command.",
ephemeral: true,
Expand Down Expand Up @@ -63,9 +63,9 @@ module.exports = {
return await interaction.reply("Removed unverified members.");
} else if (interaction.options.getSubcommand() === COMMAND_DROPUSERTABLE) {
const userDB = global.userDB;
await userDB.drop_table();
await userDB.deleteUsers();

return await interaction.editReply("Deleted user table.");
return await interaction.reply("Deleted user table.");
}

return await interaction.reply("Error: unknown subcommand.");
Expand Down
4 changes: 2 additions & 2 deletions commands/anonymouspost.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { SlashCommandBuilder } = require("@discordjs/builders");
const { allowedChannels } = require("../config/anon_channel.json");
const paginationEmbed = require("discordjs-button-pagination");
const fs = require("fs");
const { Util, EmbedBuilder, ButtonBuilder, Permissions } = require("discord.js");
const { Util, EmbedBuilder, ButtonBuilder, PermissionsBitField } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("anonymouspost")
Expand Down Expand Up @@ -125,7 +125,7 @@ module.exports = {
}

// Admin permission check
if (!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) {
return await interaction.reply({
content: "You do not have permission to execute this command.",
ephemeral: true,
Expand Down
4 changes: 2 additions & 2 deletions commands/faqadmin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
const { SlashCommandBuilder, SlashCommandSubcommandBuilder } = require("@discordjs/builders");
const { Permissions } = require("discord.js");
const { PermissionsBitField } = require("discord.js");

// ////////////////////////////////////////////
// //////// SETTING UP THE COMMANDS ///////////
Expand Down Expand Up @@ -46,7 +46,7 @@ async function handleInteraction(interaction) {
const faqStorage = global.faqStorage;

// Admin permission check (this may not work uhm)
if (!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) {
await interaction.reply({
content: "You do not have permission to execute this command.",
ephemeral: true,
Expand Down
4 changes: 2 additions & 2 deletions commands/logreport.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { Permissions } = require("discord.js");
const { PermissionsBitField } = require("discord.js");
const path = require("path");
const nodemailer = require("nodemailer");

Expand Down Expand Up @@ -44,7 +44,7 @@ module.exports = {

async execute(interaction) {
try {
if (!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) {
await interaction.reply({
content: "You do not have permission to execute this command.",
ephemeral: true,
Expand Down
4 changes: 2 additions & 2 deletions commands/reactforrole.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { Permissions, EmbedBuilder } = require("discord.js");
const { PermissionsBitField, EmbedBuilder } = require("discord.js");

module.exports = {
data: new SlashCommandBuilder()
Expand Down Expand Up @@ -27,7 +27,7 @@ module.exports = {

async execute(interaction) {
// Only admin users should be able to execute this command
if (!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) {
return await interaction.reply({
content: "You do not have permission to execute this command.",
ephemeral: true,
Expand Down
4 changes: 2 additions & 2 deletions commands/rolesPermOverride.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { Permissions } = require("discord.js");
const { PermissionsBitField } = require("discord.js");

const is_valid_course_name = (course) => {
const reg_comp_course = /^comp\d{4}$/;
Expand Down Expand Up @@ -136,7 +136,7 @@ module.exports = {
),
async execute(interaction) {
try {
if (!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) {
return await interaction.reply({
content: "You do not have permission to execute this command.",
ephemeral: true,
Expand Down
4 changes: 2 additions & 2 deletions commands/schedulepost.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { EmbedBuilder, Permissions } = require("discord.js");
const { EmbedBuilder, PermissionsBitField } = require("discord.js");

module.exports = {
data: new SlashCommandBuilder()
Expand Down Expand Up @@ -67,7 +67,7 @@ module.exports = {

async execute(interaction) {
// Check if user has admin permission
if (!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) {
if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) {
return await interaction.reply({
content: "You do not have permission to execute this command.",
ephemeral: true,
Expand Down
1 change: 0 additions & 1 deletion events/travelguide_ready.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @ts-check
const { DBTravelguide } = require("../lib/database/dbtravelguide");
/* eslint-disable */

module.exports = {
name: "ready",
Expand Down

0 comments on commit fa02763

Please sign in to comment.