mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
fix(bots/discord): fix timeout overflow check for role presets
This commit is contained in:
@@ -3,7 +3,7 @@ import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
||||
import { createModerationActionEmbed } from '$/utils/discord/embeds'
|
||||
import { sendModerationReplyAndLogs } from '$/utils/discord/moderation'
|
||||
import { applyRolePreset, removeRolePreset } from '$/utils/discord/rolePresets'
|
||||
import { parseDuration } from '$/utils/duration'
|
||||
import { isSafeTimeoutDuration, parseDuration } from '$/utils/duration'
|
||||
|
||||
export default new ModerationCommand({
|
||||
name: 'mute',
|
||||
@@ -63,7 +63,7 @@ export default new ModerationCommand({
|
||||
createModerationActionEmbed('Muted', user, executor.user, reason, Math.ceil(expires / 1000)),
|
||||
)
|
||||
|
||||
if (Number.isSafeInteger(expires))
|
||||
if (isSafeTimeoutDuration(duration))
|
||||
setTimeout(() => {
|
||||
removeRolePreset(member, 'mute')
|
||||
}, duration)
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ModerationCommand } from '$/classes/Command'
|
||||
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
||||
import { sendPresetReplyAndLogs } from '$/utils/discord/moderation'
|
||||
import { applyRolePreset, removeRolePreset } from '$/utils/discord/rolePresets'
|
||||
import { parseDuration } from '$/utils/duration'
|
||||
import { isSafeTimeoutDuration, parseDuration } from '$/utils/duration'
|
||||
|
||||
const SubcommandOptions = {
|
||||
member: {
|
||||
@@ -78,7 +78,7 @@ export default new ModerationCommand({
|
||||
)
|
||||
}
|
||||
|
||||
if (Number.isSafeInteger(expires))
|
||||
if (expires && isSafeTimeoutDuration(expires))
|
||||
setTimeout(() => {
|
||||
removeRolePreset(member, preset)
|
||||
}, expires)
|
||||
|
||||
@@ -38,3 +38,7 @@ export const durationToString = (duration: number) => {
|
||||
left: '',
|
||||
})
|
||||
}
|
||||
|
||||
export function isSafeTimeoutDuration(duration: number) {
|
||||
return duration > 0 && duration < 2 ** 31 - 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user