mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Implement temporary permission check public functions
This commit is contained in:
parent
7cf75f3255
commit
1c8a223264
7 changed files with 46 additions and 10 deletions
|
@ -17,9 +17,9 @@ export async function cleanAction(
|
|||
channelId: interaction.channelId,
|
||||
member: executingMember,
|
||||
});
|
||||
const utility = pluginData.getPlugin(UtilityPlugin);
|
||||
|
||||
// TODO: Add perm check for can_clean in util
|
||||
if (!userCfg.can_use) {
|
||||
if (!userCfg.can_use || !(await utility.hasPermission(executingMember, interaction.channelId, "can_clean"))) {
|
||||
await interaction.followUp({ content: "Cannot clean: insufficient permissions" });
|
||||
return;
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ export async function cleanAction(
|
|||
|
||||
try {
|
||||
interaction.followUp(`Cleaning... Amount: ${amount}, User Only: ${targetUserOnly}, Pins: ${deletePins}`);
|
||||
const utility = pluginData.getPlugin(UtilityPlugin);
|
||||
utility.clean({ count: amount, user, channel: targetMessage.channel.id, "delete-pins": deletePins }, targetMessage);
|
||||
} catch (e) {
|
||||
interaction.followUp({ ephemeral: true, content: "Plugin error, please check your BOT_ALERTs" });
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ModActionsPlugin } from "src/plugins/ModActions/ModActionsPlugin";
|
||||
import { canActOn } from "src/pluginUtils";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
|
||||
|
@ -17,8 +18,8 @@ export async function muteAction(pluginData: GuildPluginData<ContextMenuPluginTy
|
|||
member: executingMember,
|
||||
});
|
||||
|
||||
// TODO: Add perm check for can_mute
|
||||
if (!userCfg.can_use) {
|
||||
const modactions = pluginData.getPlugin(ModActionsPlugin);
|
||||
if (!userCfg.can_use || !(await modactions.hasMutePermission(executingMember, interaction.channelId))) {
|
||||
await interaction.followUp({ content: "Cannot mute: insufficient permissions" });
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -9,11 +9,10 @@ export async function userInfoAction(pluginData: GuildPluginData<ContextMenuPlug
|
|||
channelId: interaction.channelId,
|
||||
member: executingMember,
|
||||
});
|
||||
const utility = pluginData.getPlugin(UtilityPlugin);
|
||||
|
||||
// TODO: Add can_userinfo perm check
|
||||
if (userCfg.can_use) {
|
||||
const util = pluginData.getPlugin(UtilityPlugin);
|
||||
const embed = await util.userInfo(interaction.targetId, interaction.user.id);
|
||||
if (userCfg.can_use && (await utility.hasPermission(executingMember, interaction.channelId, "can_userinfo"))) {
|
||||
const embed = await utility.userInfo(interaction.targetId, interaction.user.id);
|
||||
await interaction.followUp({ embeds: [embed] });
|
||||
} else {
|
||||
await interaction.followUp({ content: "Cannot info: insufficient permissions" });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue