mirror of
https://gitlab.com/qwerinope/qweribot.git
synced 2026-02-04 12:36:59 +01:00
fix explosives when using aliases
This commit is contained in:
@@ -18,6 +18,8 @@ for (const item of items) {
|
||||
break
|
||||
case 'grenade':
|
||||
case 'tnt':
|
||||
await item.execute(user!, say, broadcasterId)
|
||||
break
|
||||
case 'lootbox':
|
||||
await item.execute(user!, say)
|
||||
break
|
||||
|
||||
@@ -21,14 +21,14 @@ export async function timeout(broadcasterid: string, target: HelixUser|null, dur
|
||||
if (!target) return { status: false, reason: 'noexist' }
|
||||
const tmpapi = broadcasterApi ?? api
|
||||
if (target.name === process.env.BOT_NAME) return { status: false, reason: 'unknown' }
|
||||
if (await tmpapi.moderation.checkUserBan(broadcasterid, target)) return { status: false, reason: 'banned' }
|
||||
if (await tmpapi.moderation.checkUserBan(broadcasterid, target.id)) return { status: false, reason: 'banned' }
|
||||
|
||||
try {
|
||||
if (await tmpapi.moderation.checkUserMod(broadcasterid, target)) {
|
||||
await tmpapi.moderation.removeModerator(broadcasterid, target)
|
||||
if (await tmpapi.moderation.checkUserMod(broadcasterid, target.id)) {
|
||||
await tmpapi.moderation.removeModerator(broadcasterid, target.id)
|
||||
remodMod(broadcasterid, target, duration * 1000, tmpapi)
|
||||
}
|
||||
await tmpapi.moderation.banUser(broadcasterid, { duration, reason, user: target })
|
||||
await tmpapi.moderation.banUser(broadcasterid, { duration, reason, user: target.id })
|
||||
await DBValidation(target)
|
||||
return { status: true, reason: '' }
|
||||
} catch (err) {
|
||||
@@ -50,7 +50,7 @@ export async function reviveTarget(broadcasterId: string, target: HelixUser|null
|
||||
if (MODS.includes(target.name)) remodMod(broadcasterId, target, 0, tmpapi)
|
||||
return { status: true, reason: 'revived' }
|
||||
} else {
|
||||
await tmpapi.moderation.banUser(broadcasterId, { duration: newduration, reason: bandata.data[0].reason!, user: target })
|
||||
await tmpapi.moderation.banUser(broadcasterId, { duration: newduration, reason: bandata.data[0].reason!, user: target.id })
|
||||
if (MODS.includes(target.name)) remodMod(broadcasterId, target, newduration * 1000, tmpapi)
|
||||
return { status: true, reason: 'healed' }
|
||||
}
|
||||
@@ -78,11 +78,11 @@ function remodMod(broadcasterid: string, target: HelixUser, duration: number, ap
|
||||
setTimeout(async () => {
|
||||
const bandata = await api.moderation.getBannedUsers(broadcasterid, { userId: target.id })
|
||||
if (bandata.data.length !== 0) {
|
||||
const timeoutleft = Date.parse(bandata.data[0].expiryDate?.toString()!) - Date.now() + 3000 // date when timeout expires - current date + 3 seconds constant
|
||||
const timeoutleft = Date.parse(bandata.data[0].expiryDate?.toString()!) - Date.now() // date when timeout expires - current date + 3 seconds constant
|
||||
remodMod(broadcasterid, target, timeoutleft, api) // Call the current function with new time (recursion)
|
||||
} else { // If user is still timed out it doesn't try to remod the target
|
||||
try {
|
||||
await api.moderation.addModerator(broadcasterid, target)
|
||||
await api.moderation.addModerator(broadcasterid, target.id)
|
||||
} catch (err) { } // This triggers when the timeout got shortened. try/catch so no runtime error
|
||||
}
|
||||
}, duration + 3000) // callback gets called after duration of timeout + 3 seconds
|
||||
|
||||
Reference in New Issue
Block a user