mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
More fixes, waitForInteraction (replacement for waitForReaction)
This commit is contained in:
parent
edcfd2333f
commit
d0c6e6f411
13 changed files with 135 additions and 50 deletions
|
@ -12,6 +12,7 @@ import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
|||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { banLock } from "../../../utils/lockNameHelpers";
|
||||
import { waitForButtonConfirm } from "../../../utils/waitForInteraction";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -76,11 +77,12 @@ export const BanCmd = modActionsCmd({
|
|||
}
|
||||
|
||||
// Ask the mod if we should update the existing ban
|
||||
const alreadyBannedMsg = await msg.channel.send("User is already banned, update ban?");
|
||||
const reply = false; // await waitForReaction(pluginData.client, alreadyBannedMsg, ["✅", "❌"], msg.author.id); FIXME waiting on waitForButton
|
||||
|
||||
alreadyBannedMsg.delete().catch(noop);
|
||||
if (!reply /* || reply.name === "❌"*/) {
|
||||
const reply = await waitForButtonConfirm(
|
||||
msg.channel,
|
||||
{ content: "Failed to message the user. Log the warning anyway?" },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: msg.member.id },
|
||||
);
|
||||
if (!reply) {
|
||||
sendErrorMessage(pluginData, msg.channel, "User already banned, update cancelled by moderator");
|
||||
lock.unlock();
|
||||
return;
|
||||
|
@ -124,11 +126,12 @@ export const BanCmd = modActionsCmd({
|
|||
}
|
||||
} else {
|
||||
// Ask the mod if we should upgrade to a forceban as the user is not on the server
|
||||
const notOnServerMsg = await msg.channel.send("User not found on the server, forceban instead?");
|
||||
const reply = false; // await waitForReaction(pluginData.client, notOnServerMsg, ["✅", "❌"], msg.author.id); Waiting for waitForButton
|
||||
|
||||
notOnServerMsg.delete().catch(noop);
|
||||
if (!reply /*|| reply.name === "❌"*/) {
|
||||
const reply = await waitForButtonConfirm(
|
||||
msg.channel,
|
||||
{ content: "User not on server, forceban instead?" },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: msg.member.id },
|
||||
);
|
||||
if (!reply) {
|
||||
sendErrorMessage(pluginData, msg.channel, "User not on server, ban cancelled by moderator");
|
||||
lock.unlock();
|
||||
return;
|
||||
|
|
|
@ -5,6 +5,7 @@ import { noop, resolveMember, resolveUser } from "../../../utils";
|
|||
import { isBanned } from "../functions/isBanned";
|
||||
|
||||
import { actualMuteUserCmd } from "../functions/actualMuteUserCmd";
|
||||
import { waitForButtonConfirm } from "../../../utils/waitForInteraction";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -54,11 +55,13 @@ export const MuteCmd = modActionsCmd({
|
|||
return;
|
||||
} else {
|
||||
// Ask the mod if we should upgrade to a forcemute as the user is not on the server
|
||||
const notOnServerMsg = await msg.channel.send("User not found on the server, forcemute instead?");
|
||||
const reply = false; // await waitForReaction(pluginData.client, notOnServerMsg, ["✅", "❌"], msg.author.id); FIXME waiting on waitForButton
|
||||
const reply = await waitForButtonConfirm(
|
||||
msg.channel,
|
||||
{ content: "User not found on the server, forcemute instead?" },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: msg.member.id },
|
||||
);
|
||||
|
||||
notOnServerMsg.delete().catch(noop);
|
||||
if (!reply /*|| reply.name === "❌"*/) {
|
||||
if (!reply) {
|
||||
sendErrorMessage(pluginData, msg.channel, "User not on server, mute cancelled by moderator");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import { resolveUser, resolveMember, noop } from "../../../utils";
|
|||
import { MutesPlugin } from "../../../plugins/Mutes/MutesPlugin";
|
||||
import { actualUnmuteCmd } from "../functions/actualUnmuteUserCmd";
|
||||
import { isBanned } from "../functions/isBanned";
|
||||
import { waitForButtonConfirm } from "../../../utils/waitForInteraction";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -60,11 +61,13 @@ export const UnmuteCmd = modActionsCmd({
|
|||
return;
|
||||
} else {
|
||||
// Ask the mod if we should upgrade to a forceunmute as the user is not on the server
|
||||
const notOnServerMsg = await msg.channel.send("User not found on the server, forceunmute instead?");
|
||||
const reply = false; // await waitForReaction(pluginData.client, notOnServerMsg, ["✅", "❌"], msg.author.id); FIXME waiting on waitForButton
|
||||
const reply = await waitForButtonConfirm(
|
||||
msg.channel,
|
||||
{ content: "User not on server, forceunmute instead?" },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: msg.member.id },
|
||||
);
|
||||
|
||||
notOnServerMsg.delete().catch(noop);
|
||||
if (!reply /*|| reply.name === "❌"*/) {
|
||||
if (!reply) {
|
||||
sendErrorMessage(pluginData, msg.channel, "User not on server, unmute cancelled by moderator");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,11 +6,12 @@ import { formatReasonWithAttachments } from "../functions/formatReasonWithAttach
|
|||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { errorMessage, resolveMember, resolveUser, stripObjectToScalars } from "../../../utils";
|
||||
import { errorMessage, resolveMember, resolveUser } from "../../../utils";
|
||||
import { isBanned } from "../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../functions/readContactMethodsFromArgs";
|
||||
import { warnMember } from "../functions/warnMember";
|
||||
import { TextChannel } from "discord.js";
|
||||
import { waitForButtonConfirm } from "../../../utils/waitForInteraction";
|
||||
|
||||
export const WarnCmd = modActionsCmd({
|
||||
trigger: "warn",
|
||||
|
@ -69,13 +70,12 @@ export const WarnCmd = modActionsCmd({
|
|||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
const priorWarnAmount = await casesPlugin.getCaseTypeAmountForUserId(memberToWarn.id, CaseTypes.Warn);
|
||||
if (config.warn_notify_enabled && priorWarnAmount >= config.warn_notify_threshold) {
|
||||
const tooManyWarningsMsg = await msg.channel.send(
|
||||
config.warn_notify_message.replace("{priorWarnings}", `${priorWarnAmount}`),
|
||||
const reply = await waitForButtonConfirm(
|
||||
msg.channel,
|
||||
{ content: config.warn_notify_message.replace("{priorWarnings}", `${priorWarnAmount}`) },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: msg.member.id },
|
||||
);
|
||||
|
||||
const reply = false; // await waitForReaction(pluginData.client, tooManyWarningsMsg, ["✅", "❌"], msg.author.id); FIXME waiting on waitForButton
|
||||
tooManyWarningsMsg.delete();
|
||||
if (!reply /*|| reply.name === "❌"*/) {
|
||||
if (!reply) {
|
||||
msg.channel.send(errorMessage("Warn cancelled by moderator"));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,10 @@ export async function isBanned(
|
|||
}
|
||||
|
||||
try {
|
||||
const potentialBan = await Promise.race([pluginData.guild.bans.fetch({ user: userId }), sleep(timeout)]);
|
||||
const potentialBan = await Promise.race([
|
||||
pluginData.guild.bans.fetch({ user: userId }).catch(() => null),
|
||||
sleep(timeout),
|
||||
]);
|
||||
return potentialBan != null;
|
||||
} catch (e) {
|
||||
if (isDiscordRESTError(e) && e.code === 10026) {
|
||||
|
|
|
@ -14,7 +14,8 @@ import { CasesPlugin } from "../../Cases/CasesPlugin";
|
|||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { renderTemplate } from "../../../templateFormatter";
|
||||
import { GuildMember } from "discord.js";
|
||||
import { GuildMember, MessageOptions } from "discord.js";
|
||||
import { waitForButtonConfirm } from "../../../utils/waitForInteraction";
|
||||
|
||||
export async function warnMember(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -43,12 +44,13 @@ export async function warnMember(
|
|||
|
||||
if (!notifyResult.success) {
|
||||
if (warnOptions.retryPromptChannel && pluginData.guild.channels.resolve(warnOptions.retryPromptChannel.id)) {
|
||||
const failedMsg = await warnOptions.retryPromptChannel.send(
|
||||
"Failed to message the user. Log the warning anyway?",
|
||||
const reply = await waitForButtonConfirm(
|
||||
warnOptions.retryPromptChannel,
|
||||
{ content: "Failed to message the user. Log the warning anyway?" },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: warnOptions.caseArgs?.modId },
|
||||
);
|
||||
const reply = false; // await waitForReaction(pluginData.client, failedMsg, ["✅", "❌"]); FIXME waiting on waitForButton
|
||||
failedMsg.delete();
|
||||
if (!reply /*|| reply.name === "❌"*/) {
|
||||
|
||||
if (!reply) {
|
||||
return {
|
||||
status: "failed",
|
||||
error: "Failed to message user",
|
||||
|
@ -74,7 +76,7 @@ export async function warnMember(
|
|||
noteDetails: notifyResult.text ? [ucfirst(notifyResult.text)] : [],
|
||||
});
|
||||
|
||||
const mod = await resolveUser(pluginData.client, modId);
|
||||
const mod = await pluginData.guild.members.fetch(modId);
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_WARN, {
|
||||
mod: stripObjectToScalars(mod),
|
||||
member: stripObjectToScalars(member, ["user", "roles"]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue