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 },
|
{ triggerId: counterTrigger.id },
|
||||||
)
|
)
|
||||||
.where(`cv.value ${counterTrigger.comparison_op} :value`, { value: counterTrigger.comparison_value })
|
.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("cv.channel_id = :channelId AND cv.user_id = :userId", { channelId, userId })
|
||||||
.andWhere("triggerStates.id IS NULL")
|
.andWhere("triggerStates.id IS NULL")
|
||||||
.getOne();
|
.getOne();
|
||||||
|
@ -365,6 +366,7 @@ export class GuildCounters extends BaseGuildRepository {
|
||||||
{ triggerId: counterTrigger.id },
|
{ triggerId: counterTrigger.id },
|
||||||
)
|
)
|
||||||
.where(`cv.value ${counterTrigger.comparison_op} :value`, { value: counterTrigger.comparison_value })
|
.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")
|
.andWhere("triggerStates.id IS NULL")
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
|
@ -416,6 +418,8 @@ export class GuildCounters extends BaseGuildRepository {
|
||||||
{ triggerId: counterTrigger.id },
|
{ triggerId: counterTrigger.id },
|
||||||
)
|
)
|
||||||
.where(`cv.value ${reverseOp} :value`, { value: counterTrigger.comparison_value })
|
.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();
|
.getOne();
|
||||||
|
|
||||||
if (matchingValue) {
|
if (matchingValue) {
|
||||||
|
@ -457,6 +461,7 @@ export class GuildCounters extends BaseGuildRepository {
|
||||||
{ triggerId: counterTrigger.id },
|
{ triggerId: counterTrigger.id },
|
||||||
)
|
)
|
||||||
.where(`cv.value ${reverseOp} :value`, { value: counterTrigger.comparison_value })
|
.where(`cv.value ${reverseOp} :value`, { value: counterTrigger.comparison_value })
|
||||||
|
.andWhere(`cv.counter_id = :counterId`, { counterId: counterTrigger.counter_id })
|
||||||
.select([
|
.select([
|
||||||
"cv.id AS id",
|
"cv.id AS id",
|
||||||
"cv.user_id AS user_id",
|
"cv.user_id AS user_id",
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Column, Entity, PrimaryColumn } from "typeorm";
|
||||||
|
|
||||||
@Entity("counter_trigger_states")
|
@Entity("counter_trigger_states")
|
||||||
export class CounterTriggerState {
|
export class CounterTriggerState {
|
||||||
@Column()
|
@Column({ type: "bigint", generated: "increment" })
|
||||||
@PrimaryColumn()
|
@PrimaryColumn()
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue