mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-06 18:47:20 +00:00
better error handling
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
a250366b02
commit
4b82bb9827
2 changed files with 17 additions and 2 deletions
|
@ -13,6 +13,7 @@ export const ReapplyActiveMuteOnJoinEvt = mutesEvt({
|
||||||
event: "guildMemberAdd",
|
event: "guildMemberAdd",
|
||||||
async listener({ pluginData, args: { member } }) {
|
async listener({ pluginData, args: { member } }) {
|
||||||
const mute = await pluginData.state.mutes.findExistingMuteForUserId(member.id);
|
const mute = await pluginData.state.mutes.findExistingMuteForUserId(member.id);
|
||||||
|
const logs = pluginData.getPlugin(LogsPlugin);
|
||||||
if (!mute) {
|
if (!mute) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -26,11 +27,17 @@ export const ReapplyActiveMuteOnJoinEvt = mutesEvt({
|
||||||
if (!member.isCommunicationDisabled()) {
|
if (!member.isCommunicationDisabled()) {
|
||||||
const expiresAt = mute.expires_at ? moment.utc(mute.expires_at).valueOf() : null;
|
const expiresAt = mute.expires_at ? moment.utc(mute.expires_at).valueOf() : null;
|
||||||
const timeoutExpiresAt = getTimeoutExpiryTime(expiresAt);
|
const timeoutExpiresAt = getTimeoutExpiryTime(expiresAt);
|
||||||
await member.disableCommunicationUntil(timeoutExpiresAt).catch(noop);
|
if (member.moderatable) {
|
||||||
|
await member.disableCommunicationUntil(timeoutExpiresAt).catch(noop);
|
||||||
|
} else {
|
||||||
|
logs.logBotAlert({
|
||||||
|
body: `Cannot mute user, specified user is not moderatable`,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginData.getPlugin(LogsPlugin).logMemberMuteRejoin({
|
logs.logMemberMuteRejoin({
|
||||||
member,
|
member,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,6 +4,7 @@ import moment from "moment-timezone";
|
||||||
import { MAX_TIMEOUT_DURATION } from "../../../data/Mutes";
|
import { MAX_TIMEOUT_DURATION } from "../../../data/Mutes";
|
||||||
import { Mute } from "../../../data/entities/Mute";
|
import { Mute } from "../../../data/entities/Mute";
|
||||||
import { DBDateFormat, noop, resolveMember } from "../../../utils";
|
import { DBDateFormat, noop, resolveMember } from "../../../utils";
|
||||||
|
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
|
||||||
import { MutesPluginType } from "../types";
|
import { MutesPluginType } from "../types";
|
||||||
|
|
||||||
export async function renewTimeoutMute(pluginData: GuildPluginData<MutesPluginType>, mute: Mute) {
|
export async function renewTimeoutMute(pluginData: GuildPluginData<MutesPluginType>, mute: Mute) {
|
||||||
|
@ -24,6 +25,13 @@ export async function renewTimeoutMute(pluginData: GuildPluginData<MutesPluginTy
|
||||||
}
|
}
|
||||||
|
|
||||||
const expiryTimestamp = moment.utc(newExpiryTime).valueOf();
|
const expiryTimestamp = moment.utc(newExpiryTime).valueOf();
|
||||||
|
if (!member.moderatable) {
|
||||||
|
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||||
|
body: `Cannot renew user's timeout, specified user is not moderatable`,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await member.disableCommunicationUntil(expiryTimestamp).catch(noop);
|
await member.disableCommunicationUntil(expiryTimestamp).catch(noop);
|
||||||
await pluginData.state.mutes.updateTimeoutExpiresAt(mute.user_id, expiryTimestamp);
|
await pluginData.state.mutes.updateTimeoutExpiresAt(mute.user_id, expiryTimestamp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue