gambling-bot-shared 1.0.5 → 1.0.7
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.
- package/dist/dev/guildDataWipe.d.ts +29 -0
- package/dist/dev/guildDataWipe.js +77 -0
- package/dist/dev/index.d.ts +1 -0
- package/dist/dev/index.js +1 -0
- package/dist/guild/guildConfiguration.mongoose.d.ts +9 -0
- package/dist/guild/guildConfiguration.mongoose.js +4 -0
- package/dist/guild/schemas/guild.forms.d.ts +1 -0
- package/dist/guild/schemas/guild.forms.js +2 -1
- package/dist/guild/types/guildConfiguration.d.ts +1 -0
- package/dist/transactions/constants/staffAudit.d.ts +4 -1
- package/dist/transactions/constants/staffAudit.js +6 -2
- package/dist/user/index.d.ts +1 -0
- package/dist/user/index.js +1 -0
- package/dist/user/types/user.d.ts +17 -0
- package/dist/user/user.mongoose.d.ts +45 -0
- package/dist/user/user.mongoose.js +18 -1
- package/dist/user/utils/userModeration.d.ts +16 -0
- package/dist/user/utils/userModeration.js +44 -0
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type GuildWipeEntity = 'all' | 'users' | 'transactions' | 'atm' | 'raffles' | 'predictions' | 'vip' | 'blackjack';
|
|
2
|
+
export type GuildDataWipeDeleteResult = {
|
|
3
|
+
deletedCount?: number;
|
|
4
|
+
};
|
|
5
|
+
export type GuildDataWipeModel = {
|
|
6
|
+
deleteMany: (filter: {
|
|
7
|
+
guildId: string;
|
|
8
|
+
}) => Promise<GuildDataWipeDeleteResult>;
|
|
9
|
+
};
|
|
10
|
+
export type GuildDataWipeModels = {
|
|
11
|
+
transactions: GuildDataWipeModel;
|
|
12
|
+
atmRequests: GuildDataWipeModel;
|
|
13
|
+
raffles: GuildDataWipeModel;
|
|
14
|
+
predictions: GuildDataWipeModel;
|
|
15
|
+
vipRooms: GuildDataWipeModel;
|
|
16
|
+
blackjackGames: GuildDataWipeModel;
|
|
17
|
+
users: GuildDataWipeModel;
|
|
18
|
+
};
|
|
19
|
+
export type GuildDataWipeSummary = {
|
|
20
|
+
entities: GuildWipeEntity[];
|
|
21
|
+
deleted: Record<string, number>;
|
|
22
|
+
};
|
|
23
|
+
export declare function normalizeGuildWipeEntities(entities: GuildWipeEntity[]): Exclude<GuildWipeEntity, 'all'>[];
|
|
24
|
+
export declare function runGuildDataWipe({ guildId, entities, models }: {
|
|
25
|
+
guildId: string;
|
|
26
|
+
entities: GuildWipeEntity[];
|
|
27
|
+
models: GuildDataWipeModels;
|
|
28
|
+
}): Promise<GuildDataWipeSummary>;
|
|
29
|
+
export declare function formatGuildDataWipeSummary(summary: GuildDataWipeSummary): string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeGuildWipeEntities = normalizeGuildWipeEntities;
|
|
4
|
+
exports.runGuildDataWipe = runGuildDataWipe;
|
|
5
|
+
exports.formatGuildDataWipeSummary = formatGuildDataWipeSummary;
|
|
6
|
+
const formatters_1 = require("../common/formatters");
|
|
7
|
+
const WIPE_ENTITY_ORDER = [
|
|
8
|
+
'transactions',
|
|
9
|
+
'atm',
|
|
10
|
+
'raffles',
|
|
11
|
+
'predictions',
|
|
12
|
+
'vip',
|
|
13
|
+
'blackjack',
|
|
14
|
+
'users'
|
|
15
|
+
];
|
|
16
|
+
const ENTITY_TO_MODEL_KEY = {
|
|
17
|
+
transactions: 'transactions',
|
|
18
|
+
atm: 'atmRequests',
|
|
19
|
+
raffles: 'raffles',
|
|
20
|
+
predictions: 'predictions',
|
|
21
|
+
vip: 'vipRooms',
|
|
22
|
+
blackjack: 'blackjackGames',
|
|
23
|
+
users: 'users'
|
|
24
|
+
};
|
|
25
|
+
const WIPE_LABELS = {
|
|
26
|
+
transactions: 'Transactions',
|
|
27
|
+
atmRequests: 'ATM requests',
|
|
28
|
+
raffles: 'Raffles',
|
|
29
|
+
predictions: 'Predictions',
|
|
30
|
+
vipRooms: 'VIP rooms',
|
|
31
|
+
blackjackGames: 'Blackjack games',
|
|
32
|
+
users: 'Users'
|
|
33
|
+
};
|
|
34
|
+
async function countDeleted(result) {
|
|
35
|
+
return result.deletedCount ?? 0;
|
|
36
|
+
}
|
|
37
|
+
function normalizeGuildWipeEntities(entities) {
|
|
38
|
+
const withoutAll = entities.filter((entity) => entity !== 'all');
|
|
39
|
+
if (withoutAll.length !== entities.length) {
|
|
40
|
+
return [...WIPE_ENTITY_ORDER];
|
|
41
|
+
}
|
|
42
|
+
const selected = new Set(withoutAll);
|
|
43
|
+
return WIPE_ENTITY_ORDER.filter((entity) => selected.has(entity));
|
|
44
|
+
}
|
|
45
|
+
function buildWipeTargets(guildId, entities, models) {
|
|
46
|
+
const selected = new Set(entities);
|
|
47
|
+
return WIPE_ENTITY_ORDER.filter((entity) => selected.has(entity)).map((entity) => {
|
|
48
|
+
const key = ENTITY_TO_MODEL_KEY[entity];
|
|
49
|
+
return {
|
|
50
|
+
key,
|
|
51
|
+
label: WIPE_LABELS[key],
|
|
52
|
+
entity,
|
|
53
|
+
run: async () => countDeleted(await models[key].deleteMany({ guildId }))
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async function runGuildDataWipe({ guildId, entities, models }) {
|
|
58
|
+
const normalizedEntities = normalizeGuildWipeEntities(entities);
|
|
59
|
+
const targets = buildWipeTargets(guildId, normalizedEntities, models);
|
|
60
|
+
const deleted = {};
|
|
61
|
+
for (const target of targets) {
|
|
62
|
+
deleted[target.key] = await target.run();
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
entities: normalizedEntities,
|
|
66
|
+
deleted
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function formatGuildDataWipeSummary(summary) {
|
|
70
|
+
const lines = Object.entries(summary.deleted)
|
|
71
|
+
.filter(([, count]) => count > 0)
|
|
72
|
+
.map(([key, count]) => `• **${WIPE_LABELS[key] ?? key}**: ${(0, formatters_1.formatNumberToReadableString)(count)} removed`);
|
|
73
|
+
if (lines.length === 0) {
|
|
74
|
+
return 'Nothing to remove — guild operational data was already empty.';
|
|
75
|
+
}
|
|
76
|
+
return lines.join('\n');
|
|
77
|
+
}
|
package/dist/dev/index.d.ts
CHANGED
package/dist/dev/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./devAccess"), exports);
|
|
18
18
|
__exportStar(require("./bonusStressTest"), exports);
|
|
19
19
|
__exportStar(require("./casinoMonteCarlo"), exports);
|
|
20
|
+
__exportStar(require("./guildDataWipe"), exports);
|
|
20
21
|
__exportStar(require("./yieldToEventLoop"), exports);
|
|
@@ -81,6 +81,15 @@ export declare const GuildConfigurationSchema: Schema<TGuildConfiguration, impor
|
|
|
81
81
|
}, "id"> & {
|
|
82
82
|
id: string;
|
|
83
83
|
}> | undefined;
|
|
84
|
+
bannedRoleId?: import("mongoose").SchemaDefinitionProperty<string, TGuildConfiguration, import("mongoose").Document<unknown, {}, TGuildConfiguration, {
|
|
85
|
+
id: string;
|
|
86
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TGuildConfiguration & {
|
|
87
|
+
_id: import("mongoose").Types.ObjectId;
|
|
88
|
+
} & {
|
|
89
|
+
__v: number;
|
|
90
|
+
}, "id"> & {
|
|
91
|
+
id: string;
|
|
92
|
+
}> | undefined;
|
|
84
93
|
casinoSettings?: import("mongoose").SchemaDefinitionProperty<{
|
|
85
94
|
dice: {
|
|
86
95
|
winMultiplier: number;
|
|
@@ -53,6 +53,10 @@ exports.GuildConfigurationSchema = new mongoose_1.Schema({
|
|
|
53
53
|
type: String,
|
|
54
54
|
default: ''
|
|
55
55
|
},
|
|
56
|
+
bannedRoleId: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: ''
|
|
59
|
+
},
|
|
56
60
|
casinoSettings: {
|
|
57
61
|
type: mongoose_1.Schema.Types.Mixed,
|
|
58
62
|
default: defaultConfig_1.defaultCasinoSettings
|
|
@@ -19,6 +19,7 @@ export declare const channelsFormSchema: z.ZodObject<{
|
|
|
19
19
|
}, z.core.$strip>;
|
|
20
20
|
export declare const managerRoleFormSchema: z.ZodObject<{
|
|
21
21
|
managerRoleId: z.ZodString;
|
|
22
|
+
bannedRoleId: z.ZodString;
|
|
22
23
|
}, z.core.$strip>;
|
|
23
24
|
export declare const globalSettingsFormSchema: z.ZodObject<{
|
|
24
25
|
disableRegistrations: z.ZodBoolean;
|
|
@@ -17,7 +17,8 @@ exports.channelsFormSchema = zod_1.default.object({
|
|
|
17
17
|
raffle: raffle_forms_1.raffleChannelsFormSchema
|
|
18
18
|
});
|
|
19
19
|
exports.managerRoleFormSchema = zod_1.default.object({
|
|
20
|
-
managerRoleId: zod_1.default.string()
|
|
20
|
+
managerRoleId: zod_1.default.string(),
|
|
21
|
+
bannedRoleId: zod_1.default.string()
|
|
21
22
|
});
|
|
22
23
|
exports.globalSettingsFormSchema = zod_1.default.object({
|
|
23
24
|
disableRegistrations: zod_1.default.boolean(),
|
|
@@ -8,7 +8,10 @@ export declare const STAFF_ADMIN_ACTIONS: {
|
|
|
8
8
|
readonly PREDICTION_PAYOUT: "prediction-payout";
|
|
9
9
|
readonly PREDICTION_CANCEL: "prediction-cancel";
|
|
10
10
|
readonly ATM_REJECT: "atm-reject";
|
|
11
|
+
readonly USER_BAN: "user-ban";
|
|
12
|
+
readonly USER_UNBAN: "user-unban";
|
|
13
|
+
readonly USER_NOTE: "user-note";
|
|
11
14
|
};
|
|
12
15
|
export type StaffAdminAction = (typeof STAFF_ADMIN_ACTIONS)[keyof typeof STAFF_ADMIN_ACTIONS];
|
|
13
|
-
export declare const STAFF_ACTION_CATEGORIES: readonly ["balance", "atm", "vip", "raffle", "prediction"];
|
|
16
|
+
export declare const STAFF_ACTION_CATEGORIES: readonly ["balance", "atm", "vip", "raffle", "prediction", "user"];
|
|
14
17
|
export type StaffActionCategory = (typeof STAFF_ACTION_CATEGORIES)[number];
|
|
@@ -10,12 +10,16 @@ exports.STAFF_ADMIN_ACTIONS = {
|
|
|
10
10
|
PREDICTION_END: 'prediction-end',
|
|
11
11
|
PREDICTION_PAYOUT: 'prediction-payout',
|
|
12
12
|
PREDICTION_CANCEL: 'prediction-cancel',
|
|
13
|
-
ATM_REJECT: 'atm-reject'
|
|
13
|
+
ATM_REJECT: 'atm-reject',
|
|
14
|
+
USER_BAN: 'user-ban',
|
|
15
|
+
USER_UNBAN: 'user-unban',
|
|
16
|
+
USER_NOTE: 'user-note'
|
|
14
17
|
};
|
|
15
18
|
exports.STAFF_ACTION_CATEGORIES = [
|
|
16
19
|
'balance',
|
|
17
20
|
'atm',
|
|
18
21
|
'vip',
|
|
19
22
|
'raffle',
|
|
20
|
-
'prediction'
|
|
23
|
+
'prediction',
|
|
24
|
+
'user'
|
|
21
25
|
];
|
package/dist/user/index.d.ts
CHANGED
package/dist/user/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
export type TUserStaffNote = {
|
|
2
|
+
text: string;
|
|
3
|
+
authorId: string;
|
|
4
|
+
createdAt: Date;
|
|
5
|
+
};
|
|
6
|
+
export type TUserBanHistoryEntry = {
|
|
7
|
+
bannedAt: Date;
|
|
8
|
+
bannedBy: string;
|
|
9
|
+
unbannedAt: Date | null;
|
|
10
|
+
unbannedBy: string | null;
|
|
11
|
+
reason?: string;
|
|
12
|
+
};
|
|
1
13
|
export type TUser = {
|
|
2
14
|
userId: string;
|
|
3
15
|
guildId: string;
|
|
@@ -6,6 +18,11 @@ export type TUser = {
|
|
|
6
18
|
lockedBalance: number;
|
|
7
19
|
lastDailyClaim: Date | null;
|
|
8
20
|
dailyStreak: number;
|
|
21
|
+
banned: boolean;
|
|
22
|
+
bannedAt: Date | null;
|
|
23
|
+
bannedBy: string | null;
|
|
24
|
+
banHistory: TUserBanHistoryEntry[];
|
|
25
|
+
staffNotes: TUserStaffNote[];
|
|
9
26
|
createdAt: Date;
|
|
10
27
|
updatedAt: Date;
|
|
11
28
|
};
|
|
@@ -72,6 +72,51 @@ export declare const UserSchema: Schema<TUser, import("mongoose").Model<TUser, a
|
|
|
72
72
|
}, "id"> & {
|
|
73
73
|
id: string;
|
|
74
74
|
}> | undefined;
|
|
75
|
+
banned?: import("mongoose").SchemaDefinitionProperty<boolean, TUser, import("mongoose").Document<unknown, {}, TUser, {
|
|
76
|
+
id: string;
|
|
77
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TUser & {
|
|
78
|
+
_id: import("mongoose").Types.ObjectId;
|
|
79
|
+
} & {
|
|
80
|
+
__v: number;
|
|
81
|
+
}, "id"> & {
|
|
82
|
+
id: string;
|
|
83
|
+
}> | undefined;
|
|
84
|
+
bannedAt?: import("mongoose").SchemaDefinitionProperty<Date | null, TUser, import("mongoose").Document<unknown, {}, TUser, {
|
|
85
|
+
id: string;
|
|
86
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TUser & {
|
|
87
|
+
_id: import("mongoose").Types.ObjectId;
|
|
88
|
+
} & {
|
|
89
|
+
__v: number;
|
|
90
|
+
}, "id"> & {
|
|
91
|
+
id: string;
|
|
92
|
+
}> | undefined;
|
|
93
|
+
bannedBy?: import("mongoose").SchemaDefinitionProperty<string | null, TUser, import("mongoose").Document<unknown, {}, TUser, {
|
|
94
|
+
id: string;
|
|
95
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TUser & {
|
|
96
|
+
_id: import("mongoose").Types.ObjectId;
|
|
97
|
+
} & {
|
|
98
|
+
__v: number;
|
|
99
|
+
}, "id"> & {
|
|
100
|
+
id: string;
|
|
101
|
+
}> | undefined;
|
|
102
|
+
banHistory?: import("mongoose").SchemaDefinitionProperty<import("./types/user").TUserBanHistoryEntry[], TUser, import("mongoose").Document<unknown, {}, TUser, {
|
|
103
|
+
id: string;
|
|
104
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TUser & {
|
|
105
|
+
_id: import("mongoose").Types.ObjectId;
|
|
106
|
+
} & {
|
|
107
|
+
__v: number;
|
|
108
|
+
}, "id"> & {
|
|
109
|
+
id: string;
|
|
110
|
+
}> | undefined;
|
|
111
|
+
staffNotes?: import("mongoose").SchemaDefinitionProperty<import("./types/user").TUserStaffNote[], TUser, import("mongoose").Document<unknown, {}, TUser, {
|
|
112
|
+
id: string;
|
|
113
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<TUser & {
|
|
114
|
+
_id: import("mongoose").Types.ObjectId;
|
|
115
|
+
} & {
|
|
116
|
+
__v: number;
|
|
117
|
+
}, "id"> & {
|
|
118
|
+
id: string;
|
|
119
|
+
}> | undefined;
|
|
75
120
|
createdAt?: import("mongoose").SchemaDefinitionProperty<Date, TUser, import("mongoose").Document<unknown, {}, TUser, {
|
|
76
121
|
id: string;
|
|
77
122
|
}, import("mongoose").DefaultSchemaOptions> & Omit<TUser & {
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserSchema = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
+
const UserStaffNoteSchema = new mongoose_1.Schema({
|
|
6
|
+
text: { type: String, required: true },
|
|
7
|
+
authorId: { type: String, required: true },
|
|
8
|
+
createdAt: { type: Date, required: true }
|
|
9
|
+
}, { _id: false });
|
|
10
|
+
const UserBanHistoryEntrySchema = new mongoose_1.Schema({
|
|
11
|
+
bannedAt: { type: Date, required: true },
|
|
12
|
+
bannedBy: { type: String, required: true },
|
|
13
|
+
unbannedAt: { type: Date, default: null },
|
|
14
|
+
unbannedBy: { type: String, default: null },
|
|
15
|
+
reason: { type: String }
|
|
16
|
+
}, { _id: false });
|
|
5
17
|
exports.UserSchema = new mongoose_1.Schema({
|
|
6
18
|
userId: { type: String, required: true },
|
|
7
19
|
guildId: { type: String, required: true },
|
|
@@ -9,6 +21,11 @@ exports.UserSchema = new mongoose_1.Schema({
|
|
|
9
21
|
bonusBalance: { type: Number, default: 0 }, // BONUS (non-withdrawable)
|
|
10
22
|
lockedBalance: { type: Number, default: 0 }, // ONLY for in-flight bets
|
|
11
23
|
lastDailyClaim: { type: Date, default: null },
|
|
12
|
-
dailyStreak: { type: Number, default: 0 }
|
|
24
|
+
dailyStreak: { type: Number, default: 0 },
|
|
25
|
+
banned: { type: Boolean, default: false },
|
|
26
|
+
bannedAt: { type: Date, default: null },
|
|
27
|
+
bannedBy: { type: String, default: null },
|
|
28
|
+
banHistory: { type: [UserBanHistoryEntrySchema], default: [] },
|
|
29
|
+
staffNotes: { type: [UserStaffNoteSchema], default: [] }
|
|
13
30
|
}, { timestamps: true });
|
|
14
31
|
exports.UserSchema.index({ userId: 1, guildId: 1 }, { unique: true });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TUser, TUserBanHistoryEntry, TUserStaffNote } from '../types/user';
|
|
2
|
+
export declare const USER_BANNED_ERROR = "USER_BANNED";
|
|
3
|
+
export declare const USER_BANNED_MESSAGE = "Your account is restricted. Contact server staff.";
|
|
4
|
+
export declare function isUserBanned(user: Pick<TUser, 'banned'>): boolean;
|
|
5
|
+
export declare function normalizeStaffNote(text: string): string | null;
|
|
6
|
+
export declare function appendStaffNote(notes: TUserStaffNote[], entry: TUserStaffNote, maxNotes?: number): TUserStaffNote[];
|
|
7
|
+
export declare function startBanHistoryEntry({ history, bannedBy, reason, maxEntries }: {
|
|
8
|
+
history: TUserBanHistoryEntry[];
|
|
9
|
+
bannedBy: string;
|
|
10
|
+
reason?: string;
|
|
11
|
+
maxEntries?: number;
|
|
12
|
+
}): TUserBanHistoryEntry[];
|
|
13
|
+
export declare function closeLatestBanHistoryEntry({ history, unbannedBy }: {
|
|
14
|
+
history: TUserBanHistoryEntry[];
|
|
15
|
+
unbannedBy: string;
|
|
16
|
+
}): TUserBanHistoryEntry[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USER_BANNED_MESSAGE = exports.USER_BANNED_ERROR = void 0;
|
|
4
|
+
exports.isUserBanned = isUserBanned;
|
|
5
|
+
exports.normalizeStaffNote = normalizeStaffNote;
|
|
6
|
+
exports.appendStaffNote = appendStaffNote;
|
|
7
|
+
exports.startBanHistoryEntry = startBanHistoryEntry;
|
|
8
|
+
exports.closeLatestBanHistoryEntry = closeLatestBanHistoryEntry;
|
|
9
|
+
exports.USER_BANNED_ERROR = 'USER_BANNED';
|
|
10
|
+
exports.USER_BANNED_MESSAGE = 'Your account is restricted. Contact server staff.';
|
|
11
|
+
function isUserBanned(user) {
|
|
12
|
+
return Boolean(user.banned);
|
|
13
|
+
}
|
|
14
|
+
function normalizeStaffNote(text) {
|
|
15
|
+
const trimmed = text.trim();
|
|
16
|
+
if (!trimmed)
|
|
17
|
+
return null;
|
|
18
|
+
return trimmed.slice(0, 500);
|
|
19
|
+
}
|
|
20
|
+
function appendStaffNote(notes, entry, maxNotes = 50) {
|
|
21
|
+
return [entry, ...notes].slice(0, maxNotes);
|
|
22
|
+
}
|
|
23
|
+
function startBanHistoryEntry({ history, bannedBy, reason, maxEntries = 50 }) {
|
|
24
|
+
const entry = {
|
|
25
|
+
bannedAt: new Date(),
|
|
26
|
+
bannedBy,
|
|
27
|
+
unbannedAt: null,
|
|
28
|
+
unbannedBy: null,
|
|
29
|
+
...(reason ? { reason } : {})
|
|
30
|
+
};
|
|
31
|
+
return [entry, ...history].slice(0, maxEntries);
|
|
32
|
+
}
|
|
33
|
+
function closeLatestBanHistoryEntry({ history, unbannedBy }) {
|
|
34
|
+
const openIndex = history.findIndex((entry) => entry.unbannedAt === null);
|
|
35
|
+
if (openIndex === -1)
|
|
36
|
+
return history;
|
|
37
|
+
const updated = [...history];
|
|
38
|
+
updated[openIndex] = {
|
|
39
|
+
...updated[openIndex],
|
|
40
|
+
unbannedAt: new Date(),
|
|
41
|
+
unbannedBy
|
|
42
|
+
};
|
|
43
|
+
return updated;
|
|
44
|
+
}
|