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 { createModerationActionEmbed } from '$/utils/discord/embeds'
|
||||||
import { sendModerationReplyAndLogs } from '$/utils/discord/moderation'
|
import { sendModerationReplyAndLogs } from '$/utils/discord/moderation'
|
||||||
import { applyRolePreset, removeRolePreset } from '$/utils/discord/rolePresets'
|
import { applyRolePreset, removeRolePreset } from '$/utils/discord/rolePresets'
|
||||||
import { parseDuration } from '$/utils/duration'
|
import { isSafeTimeoutDuration, parseDuration } from '$/utils/duration'
|
||||||
|
|
||||||
export default new ModerationCommand({
|
export default new ModerationCommand({
|
||||||
name: 'mute',
|
name: 'mute',
|
||||||
@@ -63,7 +63,7 @@ export default new ModerationCommand({
|
|||||||
createModerationActionEmbed('Muted', user, executor.user, reason, Math.ceil(expires / 1000)),
|
createModerationActionEmbed('Muted', user, executor.user, reason, Math.ceil(expires / 1000)),
|
||||||
)
|
)
|
||||||
|
|
||||||
if (Number.isSafeInteger(expires))
|
if (isSafeTimeoutDuration(duration))
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
removeRolePreset(member, 'mute')
|
removeRolePreset(member, 'mute')
|
||||||
}, duration)
|
}, duration)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ModerationCommand } from '$/classes/Command'
|
|||||||
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
||||||
import { sendPresetReplyAndLogs } from '$/utils/discord/moderation'
|
import { sendPresetReplyAndLogs } from '$/utils/discord/moderation'
|
||||||
import { applyRolePreset, removeRolePreset } from '$/utils/discord/rolePresets'
|
import { applyRolePreset, removeRolePreset } from '$/utils/discord/rolePresets'
|
||||||
import { parseDuration } from '$/utils/duration'
|
import { isSafeTimeoutDuration, parseDuration } from '$/utils/duration'
|
||||||
|
|
||||||
const SubcommandOptions = {
|
const SubcommandOptions = {
|
||||||
member: {
|
member: {
|
||||||
@@ -78,7 +78,7 @@ export default new ModerationCommand({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Number.isSafeInteger(expires))
|
if (expires && isSafeTimeoutDuration(expires))
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
removeRolePreset(member, preset)
|
removeRolePreset(member, preset)
|
||||||
}, expires)
|
}, expires)
|
||||||
|
|||||||
@@ -38,3 +38,7 @@ export const durationToString = (duration: number) => {
|
|||||||
left: '',
|
left: '',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isSafeTimeoutDuration(duration: number) {
|
||||||
|
return duration > 0 && duration < 2 ** 31 - 1
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user