Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checks for appropriate permission before editing #79

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/events/handleModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ButtonStyle,
ActionRowBuilder,
Message,
PermissionFlagsBits,
} from "discord.js";
import { COLOR, FOOTER_VALUE } from "../config/constant";
import db from "../utils/database";
Expand Down Expand Up @@ -188,6 +189,11 @@ export default {
await interaction.reply({ content: "Invalid Image", ephemeral: true });
}
} else if (action === "edit") {
if (!interaction.memberPermissions?.has(PermissionFlagsBits.ManageMessages)) {
await interaction.reply({ content: "You don’t have permission to run this command", ephemeral: true });
return;
}

const title = interaction.fields.getTextInputValue("title") || null;
const description = interaction.fields.getTextInputValue("description") || null;
if (!messageId || !channelId || !type) {
Expand Down Expand Up @@ -227,7 +233,7 @@ export default {
} else {
await message.edit({ content: `📢 Announcement ${mention}\n# ${title}\n${description}` });
}
await interaction.reply({ content: "Edited message", ephemeral: true });
await interaction.reply({ content: "Edited message", ephemeral: false });
}
}
},
Expand Down
Loading