mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 01:01:39 +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
|
||||
|
||||
@@ -17,18 +17,18 @@ interface statusmessage {
|
||||
/** Ban a specific user out by another user for specified amout of time, with specific reason
|
||||
* If the user does not exist or is already banned return status: false
|
||||
* If the user is a moderator, make sure they get their status back after timeout has elapsed */
|
||||
export async function timeout(broadcasterid: string, target: HelixUser|null, duration: number, reason: string): Promise<statusmessage> {
|
||||
export async function timeout(broadcasterid: string, target: HelixUser | null, duration: number, reason: string): Promise<statusmessage> {
|
||||
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) {
|
||||
@@ -38,7 +38,7 @@ export async function timeout(broadcasterid: string, target: HelixUser|null, dur
|
||||
}
|
||||
|
||||
/** Revive a specific target for a certain amount of time */
|
||||
export async function reviveTarget(broadcasterId: string, target: HelixUser|null, duration: number): Promise<statusmessage> {
|
||||
export async function reviveTarget(broadcasterId: string, target: HelixUser | null, duration: number): Promise<statusmessage> {
|
||||
if (!target) return { status: false, reason: 'noexist' }
|
||||
const tmpapi = broadcasterApi ?? api
|
||||
const bandata = await tmpapi.moderation.getBannedUsers(broadcasterId, { userId: target.id })
|
||||
@@ -48,10 +48,10 @@ export async function reviveTarget(broadcasterId: string, target: HelixUser|null
|
||||
if (newduration < 3) { // If the target is going to be unbanned in duration + 3 seconds, unban them anyway
|
||||
await tmpapi.moderation.unbanUser(broadcasterId, target)
|
||||
if (MODS.includes(target.name)) remodMod(broadcasterId, target, 0, tmpapi)
|
||||
return {status: true, reason: 'revived'}
|
||||
return { status: true, reason: 'revived' }
|
||||
} else {
|
||||
await tmpapi.moderation.banUser(broadcasterId, { duration: newduration, reason: bandata.data[0].reason!, user: target })
|
||||
if (MODS.includes(target.name)) remodMod(broadcasterId, target, newduration * 1000 , tmpapi)
|
||||
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' }
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -78,12 +78,12 @@ 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)
|
||||
} catch (err) {} // This triggers when the timeout got shortened. try/catch so no runtime error
|
||||
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