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",
|
||||
async listener({ pluginData, args: { member } }) {
|
||||
const mute = await pluginData.state.mutes.findExistingMuteForUserId(member.id);
|
||||
const logs = pluginData.getPlugin(LogsPlugin);
|
||||
if (!mute) {
|
||||
return;
|
||||
}
|
||||
|
@ -26,11 +27,17 @@ export const ReapplyActiveMuteOnJoinEvt = mutesEvt({
|
|||
if (!member.isCommunicationDisabled()) {
|
||||
const expiresAt = mute.expires_at ? moment.utc(mute.expires_at).valueOf() : null;
|
||||
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,
|
||||
});
|
||||
},
|
||||
|
|
|
@ -4,6 +4,7 @@ import moment from "moment-timezone";
|
|||
import { MAX_TIMEOUT_DURATION } from "../../../data/Mutes";
|
||||
import { Mute } from "../../../data/entities/Mute";
|
||||
import { DBDateFormat, noop, resolveMember } from "../../../utils";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
|
||||
import { MutesPluginType } from "../types";
|
||||
|
||||
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();
|
||||
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 pluginData.state.mutes.updateTimeoutExpiresAt(mute.user_id, expiryTimestamp);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue