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
|
break
|
||||||
case 'grenade':
|
case 'grenade':
|
||||||
case 'tnt':
|
case 'tnt':
|
||||||
|
await item.execute(user!, say, broadcasterId)
|
||||||
|
break
|
||||||
case 'lootbox':
|
case 'lootbox':
|
||||||
await item.execute(user!, say)
|
await item.execute(user!, say)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -17,18 +17,18 @@ interface statusmessage {
|
|||||||
/** Ban a specific user out by another user for specified amout of time, with specific reason
|
/** 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 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 */
|
* 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' }
|
if (!target) return { status: false, reason: 'noexist' }
|
||||||
const tmpapi = broadcasterApi ?? api
|
const tmpapi = broadcasterApi ?? api
|
||||||
if (target.name === process.env.BOT_NAME) return { status: false, reason: 'unknown' }
|
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 {
|
try {
|
||||||
if (await tmpapi.moderation.checkUserMod(broadcasterid, target)) {
|
if (await tmpapi.moderation.checkUserMod(broadcasterid, target.id)) {
|
||||||
await tmpapi.moderation.removeModerator(broadcasterid, target)
|
await tmpapi.moderation.removeModerator(broadcasterid, target.id)
|
||||||
remodMod(broadcasterid, target, duration * 1000, tmpapi)
|
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)
|
await DBValidation(target)
|
||||||
return { status: true, reason: '' }
|
return { status: true, reason: '' }
|
||||||
} catch (err) {
|
} 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 */
|
/** 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' }
|
if (!target) return { status: false, reason: 'noexist' }
|
||||||
const tmpapi = broadcasterApi ?? api
|
const tmpapi = broadcasterApi ?? api
|
||||||
const bandata = await tmpapi.moderation.getBannedUsers(broadcasterId, { userId: target.id })
|
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
|
if (newduration < 3) { // If the target is going to be unbanned in duration + 3 seconds, unban them anyway
|
||||||
await tmpapi.moderation.unbanUser(broadcasterId, target)
|
await tmpapi.moderation.unbanUser(broadcasterId, target)
|
||||||
if (MODS.includes(target.name)) remodMod(broadcasterId, target, 0, tmpapi)
|
if (MODS.includes(target.name)) remodMod(broadcasterId, target, 0, tmpapi)
|
||||||
return {status: true, reason: 'revived'}
|
return { status: true, reason: 'revived' }
|
||||||
} else {
|
} 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)
|
if (MODS.includes(target.name)) remodMod(broadcasterId, target, newduration * 1000, tmpapi)
|
||||||
return { status: true, reason: 'healed' }
|
return { status: true, reason: 'healed' }
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -78,12 +78,12 @@ function remodMod(broadcasterid: string, target: HelixUser, duration: number, ap
|
|||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
const bandata = await api.moderation.getBannedUsers(broadcasterid, { userId: target.id })
|
const bandata = await api.moderation.getBannedUsers(broadcasterid, { userId: target.id })
|
||||||
if (bandata.data.length !== 0) {
|
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)
|
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
|
} else { // If user is still timed out it doesn't try to remod the target
|
||||||
try {
|
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
|
} 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
|
}, duration + 3000) // callback gets called after duration of timeout + 3 seconds
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user