Improve permission checks on several plugins (#1746)

Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
Hugo C 2023-09-24 16:42:53 +02:00 committed by GitHub
parent 0b7fca864a
commit 044f64e446
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 41 additions and 25 deletions

View file

@ -20,7 +20,7 @@ import { addButton, removeButton } from "@api/MessagePopover";
import { Devs } from "@utils/constants";
import { insertTextIntoChatInputBox } from "@utils/discord";
import definePlugin from "@utils/types";
import { ChannelStore } from "@webpack/common";
import { ChannelStore, PermissionsBits, PermissionStore } from "@webpack/common";
export default definePlugin({
name: "QuickMention",
@ -30,11 +30,14 @@ export default definePlugin({
start() {
addButton("QuickMention", msg => {
const channel = ChannelStore.getChannel(msg.channel_id);
if (!PermissionStore.can(PermissionsBits.SEND_MESSAGES, channel)) return null;
return {
label: "Quick Mention",
icon: this.Icon,
message: msg,
channel: ChannelStore.getChannel(msg.channel_id),
channel,
onClick: () => insertTextIntoChatInputBox(`<@${msg.author.id}> `)
};
});