gambling-bot-shared 0.1.53 → 0.1.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ import { defaultCasinoSettings } from './defaultConfig';
2
+ export type CasinoGameId = Exclude<keyof typeof defaultCasinoSettings, 'winAnnouncements'>;
3
+ export declare const CASINO_GAME_IDS: CasinoGameId[];
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CASINO_GAME_IDS = void 0;
4
+ const defaultConfig_1 = require("./defaultConfig");
5
+ exports.CASINO_GAME_IDS = Object.keys(defaultConfig_1.defaultCasinoSettings).filter((key) => key !== 'winAnnouncements');
@@ -8,4 +8,5 @@ export * from './rouletteConfig';
8
8
  export * from './gameRecordFields';
9
9
  export * from './plinkoConfig';
10
10
  export * from './transaction';
11
+ export * from './casinoGames';
11
12
  export * from './blackjack';
@@ -24,4 +24,5 @@ __exportStar(require("./rouletteConfig"), exports);
24
24
  __exportStar(require("./gameRecordFields"), exports);
25
25
  __exportStar(require("./plinkoConfig"), exports);
26
26
  __exportStar(require("./transaction"), exports);
27
+ __exportStar(require("./casinoGames"), exports);
27
28
  __exportStar(require("./blackjack"), exports);
@@ -100,7 +100,7 @@ export declare const AtmRequestSchema: Schema<TAtmRequest, import("mongoose").Mo
100
100
  }, "id"> & {
101
101
  id: string;
102
102
  }> | undefined;
103
- logChannelId?: import("mongoose").SchemaDefinitionProperty<string, TAtmRequest, import("mongoose").Document<unknown, {}, TAtmRequest, {
103
+ notes?: import("mongoose").SchemaDefinitionProperty<string | undefined, TAtmRequest, import("mongoose").Document<unknown, {}, TAtmRequest, {
104
104
  id: string;
105
105
  }, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & Omit<TAtmRequest & {
106
106
  _id: import("mongoose").Types.ObjectId;
@@ -109,7 +109,25 @@ export declare const AtmRequestSchema: Schema<TAtmRequest, import("mongoose").Mo
109
109
  }, "id"> & {
110
110
  id: string;
111
111
  }> | undefined;
112
- logMessageId?: import("mongoose").SchemaDefinitionProperty<string, TAtmRequest, import("mongoose").Document<unknown, {}, TAtmRequest, {
112
+ logChannelId?: import("mongoose").SchemaDefinitionProperty<string | undefined, TAtmRequest, import("mongoose").Document<unknown, {}, TAtmRequest, {
113
+ id: string;
114
+ }, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & Omit<TAtmRequest & {
115
+ _id: import("mongoose").Types.ObjectId;
116
+ } & {
117
+ __v: number;
118
+ }, "id"> & {
119
+ id: string;
120
+ }> | undefined;
121
+ logMessageId?: import("mongoose").SchemaDefinitionProperty<string | undefined, TAtmRequest, import("mongoose").Document<unknown, {}, TAtmRequest, {
122
+ id: string;
123
+ }, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & Omit<TAtmRequest & {
124
+ _id: import("mongoose").Types.ObjectId;
125
+ } & {
126
+ __v: number;
127
+ }, "id"> & {
128
+ id: string;
129
+ }> | undefined;
130
+ meta?: import("mongoose").SchemaDefinitionProperty<Record<string, unknown> | undefined, TAtmRequest, import("mongoose").Document<unknown, {}, TAtmRequest, {
113
131
  id: string;
114
132
  }, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & Omit<TAtmRequest & {
115
133
  _id: import("mongoose").Types.ObjectId;
@@ -18,6 +18,9 @@ exports.AtmRequestSchema = new mongoose_1.Schema({
18
18
  },
19
19
  handledBy: { type: String },
20
20
  handledAt: { type: Date },
21
+ notes: { type: String },
21
22
  logChannelId: { type: String },
22
- logMessageId: { type: String }
23
+ logMessageId: { type: String },
24
+ meta: { type: mongoose_1.Schema.Types.Mixed }
23
25
  }, { timestamps: true });
26
+ exports.AtmRequestSchema.index({ guildId: 1, status: 1, createdAt: -1 });
@@ -73,7 +73,7 @@ export declare const PredictionSchema: Schema<TPrediction, import("mongoose").Mo
73
73
  }, "id"> & {
74
74
  id: string;
75
75
  }> | undefined;
76
- status?: import("mongoose").SchemaDefinitionProperty<"active" | "ended" | "paid" | "canceled", TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
76
+ status?: import("mongoose").SchemaDefinitionProperty<"active" | "ended" | "paying" | "paid" | "canceled", TPrediction, import("mongoose").Document<unknown, {}, TPrediction, {
77
77
  id: string;
78
78
  }, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & Omit<TPrediction & {
79
79
  _id: import("mongoose").Types.ObjectId;
@@ -30,14 +30,15 @@ exports.PredictionSchema = new mongoose_1.Schema({
30
30
  bets: [
31
31
  {
32
32
  userId: { type: String, required: true },
33
- amount: { type: Number, required: true }
33
+ amount: { type: Number, required: true },
34
+ betId: { type: String, required: true }
34
35
  }
35
36
  ]
36
37
  }
37
38
  ],
38
39
  status: {
39
40
  type: String,
40
- enum: ['active', 'ended', 'paid', 'canceled'],
41
+ enum: ['active', 'ended', 'paying', 'paid', 'canceled'],
41
42
  default: 'active'
42
43
  },
43
44
  autolock: {
@@ -64,7 +64,7 @@ export declare const TransactionSchema: Schema<TTransaction, import("mongoose").
64
64
  }, "id"> & {
65
65
  id: string;
66
66
  }> | undefined;
67
- meta?: import("mongoose").SchemaDefinitionProperty<Record<string, unknown> | undefined, TTransaction, import("mongoose").Document<unknown, {}, TTransaction, {
67
+ meta?: import("mongoose").SchemaDefinitionProperty<import("../types").TransactionMeta | undefined, TTransaction, import("mongoose").Document<unknown, {}, TTransaction, {
68
68
  id: string;
69
69
  }, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & Omit<TTransaction & {
70
70
  _id: import("mongoose").Types.ObjectId;
@@ -8,8 +8,10 @@ export type TAtmRequest = {
8
8
  status: 'pending' | 'approved' | 'rejected';
9
9
  handledBy?: string;
10
10
  handledAt?: Date;
11
- logChannelId: string;
12
- logMessageId: string;
11
+ notes?: string;
12
+ logChannelId?: string;
13
+ logMessageId?: string;
14
+ meta?: Record<string, unknown>;
13
15
  createdAt: Date;
14
16
  updatedAt: Date;
15
17
  };
@@ -4,6 +4,7 @@ export type TPredictionOption = {
4
4
  bets: {
5
5
  userId: string;
6
6
  amount: number;
7
+ betId: string;
7
8
  }[];
8
9
  };
9
10
  export type TPrediction = {
@@ -13,7 +14,7 @@ export type TPrediction = {
13
14
  creatorId: string;
14
15
  title: string;
15
16
  choices: TPredictionOption[];
16
- status: 'active' | 'ended' | 'paid' | 'canceled';
17
+ status: 'active' | 'ended' | 'paying' | 'paid' | 'canceled';
17
18
  autolock?: Date | null;
18
19
  createdAt: Date;
19
20
  updatedAt: Date;
@@ -1,10 +1,14 @@
1
+ import type { CasinoGameId } from '../constants/casinoGames';
2
+ export type TransactionMeta = {
3
+ game?: CasinoGameId;
4
+ } & Record<string, unknown>;
1
5
  export type TTransaction = {
2
6
  userId: string;
3
7
  guildId: string;
4
8
  amount: number;
5
9
  type: 'deposit' | 'withdraw' | 'bet' | 'win' | 'refund' | 'bonus' | 'vip';
6
10
  source: 'command' | 'manual' | 'web' | 'system' | 'casino';
7
- meta?: Record<string, unknown>;
11
+ meta?: TransactionMeta;
8
12
  betId?: string;
9
13
  handledBy?: string;
10
14
  createdAt: Date;
@@ -1,5 +1,6 @@
1
1
  export declare const canClaimDailyBonus: (lastClaim: Date | null, now: Date) => boolean;
2
2
  export declare const getStreakAfterClaim: (lastClaim: Date | null, now: Date, currentStreak: number) => number;
3
+ export declare const getEffectiveStreak: (lastClaim: Date | null, now: Date, storedStreak: number) => number;
3
4
  export declare const getStreakDisplay: (lastClaim: Date | null, now: Date, streak: number) => {
4
5
  currentStreak: number;
5
6
  nextStreak: number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStreakDisplay = exports.getStreakAfterClaim = exports.canClaimDailyBonus = void 0;
3
+ exports.getStreakDisplay = exports.getEffectiveStreak = exports.getStreakAfterClaim = exports.canClaimDailyBonus = void 0;
4
4
  const DAY_MS = 24 * 60 * 60 * 1000;
5
5
  const canClaimDailyBonus = (lastClaim, now) => {
6
6
  if (!lastClaim)
@@ -17,6 +17,15 @@ const getStreakAfterClaim = (lastClaim, now, currentStreak) => {
17
17
  return 1;
18
18
  };
19
19
  exports.getStreakAfterClaim = getStreakAfterClaim;
20
+ const getEffectiveStreak = (lastClaim, now, storedStreak) => {
21
+ if (!lastClaim)
22
+ return 0;
23
+ const diff = now.getTime() - lastClaim.getTime();
24
+ if (diff >= 2 * DAY_MS)
25
+ return 0;
26
+ return storedStreak;
27
+ };
28
+ exports.getEffectiveStreak = getEffectiveStreak;
20
29
  const getStreakDisplay = (lastClaim, now, streak) => {
21
30
  if (!lastClaim) {
22
31
  return { currentStreak: 0, nextStreak: 1 };
@@ -10,4 +10,5 @@ export type CalculateBonusRewardResult = {
10
10
  monthly: number;
11
11
  isReset: boolean;
12
12
  };
13
+ export declare const getBonusCycleLength: (rewardMode: BonusSettings["rewardMode"], baseReward: number, maxReward: number, streakIncrement: number, streakMultiplier: number) => number;
13
14
  export declare const calculateBonusReward: ({ streak, settings }: CalculateBonusRewardInput) => CalculateBonusRewardResult;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateBonusReward = void 0;
4
- const getCycleLength = (rewardMode, baseReward, maxReward, streakIncrement, streakMultiplier) => {
3
+ exports.calculateBonusReward = exports.getBonusCycleLength = void 0;
4
+ const getBonusCycleLength = (rewardMode, baseReward, maxReward, streakIncrement, streakMultiplier) => {
5
5
  if (rewardMode === 'linear') {
6
6
  return streakIncrement > 0
7
7
  ? Math.floor((maxReward - baseReward) / streakIncrement) + 1
@@ -11,6 +11,7 @@ const getCycleLength = (rewardMode, baseReward, maxReward, streakIncrement, stre
11
11
  ? Math.floor(Math.log(maxReward / baseReward) / Math.log(streakMultiplier)) + 1
12
12
  : 1;
13
13
  };
14
+ exports.getBonusCycleLength = getBonusCycleLength;
14
15
  const calculateBonusReward = ({ streak, settings }) => {
15
16
  const { rewardMode, baseReward, streakIncrement = 0, streakMultiplier = 1, maxReward, resetOnMax, milestoneBonus } = settings;
16
17
  let base = rewardMode === 'linear'
@@ -18,7 +19,7 @@ const calculateBonusReward = ({ streak, settings }) => {
18
19
  : baseReward * Math.pow(streakMultiplier, streak - 1);
19
20
  let isReset = false;
20
21
  if (maxReward > 0 && resetOnMax && base > maxReward) {
21
- const cycle = getCycleLength(rewardMode, baseReward, maxReward, streakIncrement, streakMultiplier);
22
+ const cycle = (0, exports.getBonusCycleLength)(rewardMode, baseReward, maxReward, streakIncrement, streakMultiplier);
22
23
  const cycleStreak = ((streak - 1) % cycle) + 1;
23
24
  isReset = streak > cycle && cycleStreak === 1;
24
25
  base =
@@ -97,9 +97,12 @@ const calculateRTP = (game, settings) => {
97
97
  const { winMultiplier, oneInChance } = settings;
98
98
  return (toNumber(winMultiplier) / toNumber(oneInChance)) * 100;
99
99
  }
100
+ case 'raffle': {
101
+ const { casinoCut } = settings;
102
+ return (1 - toNumber(casinoCut)) * 100;
103
+ }
100
104
  case 'blackjack':
101
105
  case 'prediction':
102
- case 'raffle':
103
106
  return 0;
104
107
  case 'plinko': {
105
108
  const { binMultipliers } = settings;
@@ -114,7 +117,9 @@ const calculateRTP = (game, settings) => {
114
117
  return rtp * 100;
115
118
  }
116
119
  default:
117
- console.warn(`RTP for ${game} not implemented`);
120
+ if (game !== 'winAnnouncements') {
121
+ console.warn(`RTP for ${game} not implemented`);
122
+ }
118
123
  return 0;
119
124
  }
120
125
  };
@@ -11,3 +11,6 @@ export declare const getReadableName: (key: string, map: {
11
11
  name: string;
12
12
  value: string;
13
13
  }[]) => string;
14
+ export declare const formatCasinoGameLabel: (gameId: string) => string;
15
+ export declare const formatTransactionSourceLabel: (source: string) => string;
16
+ export declare const formatTransactionTypeLabel: (type: string) => string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getReadableName = exports.formatNumberToPercentage = exports.formatMoneyExact = exports.formatMoney = exports.formatNumberWithSpaces = exports.parseReadableStringToNumber = exports.formatNumberToReadableString = void 0;
3
+ exports.formatTransactionTypeLabel = exports.formatTransactionSourceLabel = exports.formatCasinoGameLabel = exports.getReadableName = exports.formatNumberToPercentage = exports.formatMoneyExact = exports.formatMoney = exports.formatNumberWithSpaces = exports.parseReadableStringToNumber = exports.formatNumberToReadableString = void 0;
4
+ const defaultConfig_1 = require("../constants/defaultConfig");
4
5
  const globalSettings_1 = require("./globalSettings");
5
6
  const formatAmountWithCurrency = (amount, formattedAbsAmount, globalSettings) => {
6
7
  const negative = amount < 0;
@@ -68,3 +69,9 @@ const getReadableName = (key, map) => {
68
69
  return found ? found.name : key;
69
70
  };
70
71
  exports.getReadableName = getReadableName;
72
+ const formatCasinoGameLabel = (gameId) => (0, exports.getReadableName)(gameId, defaultConfig_1.readableGameNames).toUpperCase();
73
+ exports.formatCasinoGameLabel = formatCasinoGameLabel;
74
+ const formatTransactionSourceLabel = (source) => source.toUpperCase();
75
+ exports.formatTransactionSourceLabel = formatTransactionSourceLabel;
76
+ const formatTransactionTypeLabel = (type) => type.toUpperCase();
77
+ exports.formatTransactionTypeLabel = formatTransactionTypeLabel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gambling-bot-shared",
3
- "version": "0.1.53",
3
+ "version": "0.1.54",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "MIT",
@@ -60,5 +60,5 @@
60
60
  "luxon": "^3.7.2",
61
61
  "zod": "^4.3.6"
62
62
  },
63
- "packageManager": "pnpm@10.28.0"
63
+ "packageManager": "pnpm@11.5.0"
64
64
  }