mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Fix trigger checks matching across different counters
This commit is contained in:
parent
93912541b4
commit
0c27795fd9
2 changed files with 6 additions and 1 deletions
|
@ -328,6 +328,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
{ triggerId: counterTrigger.id },
|
||||
)
|
||||
.where(`cv.value ${counterTrigger.comparison_op} :value`, { value: counterTrigger.comparison_value })
|
||||
.andWhere(`cv.counter_id = :counterId`, { counterId: counterTrigger.counter_id })
|
||||
.andWhere("cv.channel_id = :channelId AND cv.user_id = :userId", { channelId, userId })
|
||||
.andWhere("triggerStates.id IS NULL")
|
||||
.getOne();
|
||||
|
@ -365,6 +366,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
{ triggerId: counterTrigger.id },
|
||||
)
|
||||
.where(`cv.value ${counterTrigger.comparison_op} :value`, { value: counterTrigger.comparison_value })
|
||||
.andWhere(`cv.counter_id = :counterId`, { counterId: counterTrigger.counter_id })
|
||||
.andWhere("triggerStates.id IS NULL")
|
||||
.getMany();
|
||||
|
||||
|
@ -416,6 +418,8 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
{ triggerId: counterTrigger.id },
|
||||
)
|
||||
.where(`cv.value ${reverseOp} :value`, { value: counterTrigger.comparison_value })
|
||||
.andWhere(`cv.counter_id = :counterId`, { counterId: counterTrigger.counter_id })
|
||||
.andWhere(`cv.channel_id = :channelId AND cv.user_id = :userId`, { channelId, userId })
|
||||
.getOne();
|
||||
|
||||
if (matchingValue) {
|
||||
|
@ -457,6 +461,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
{ triggerId: counterTrigger.id },
|
||||
)
|
||||
.where(`cv.value ${reverseOp} :value`, { value: counterTrigger.comparison_value })
|
||||
.andWhere(`cv.counter_id = :counterId`, { counterId: counterTrigger.counter_id })
|
||||
.select([
|
||||
"cv.id AS id",
|
||||
"cv.user_id AS user_id",
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Column, Entity, PrimaryColumn } from "typeorm";
|
|||
|
||||
@Entity("counter_trigger_states")
|
||||
export class CounterTriggerState {
|
||||
@Column()
|
||||
@Column({ type: "bigint", generated: "increment" })
|
||||
@PrimaryColumn()
|
||||
id: string;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue