1 |
import { ClientUser } from "discord.js"; |
2 |
import { vi } from "vitest"; |
3 |
import Client from "../../src/core/Client"; |
4 |
import { randomSnowflake } from "./snowflakes"; |
5 |
|
6 |
vi.mock("@prisma/client", () => { |
7 |
return { |
8 |
__esModule: true, |
9 |
PrismaClient: vi.fn().mockImplementation(() => { |
10 |
return { |
11 |
user: { |
12 |
findUnique: vi.fn(), |
13 |
create: vi.fn(), |
14 |
findMany: vi.fn(), |
15 |
update: vi.fn(), |
16 |
delete: vi.fn() |
17 |
}, |
18 |
troll: { |
19 |
findUnique: vi.fn(), |
20 |
create: vi.fn(), |
21 |
findMany: vi.fn(), |
22 |
update: vi.fn(), |
23 |
delete: vi.fn() |
24 |
} |
25 |
}; |
26 |
}) |
27 |
}; |
28 |
}); |
29 |
|
30 |
export function createClient() { |
31 |
const client = new Client({ |
32 |
intents: [] |
33 |
}); |
34 |
|
35 |
client.user = { |
36 |
id: randomSnowflake(), |
37 |
username: "SudoBot", |
38 |
discriminator: "0000", |
39 |
tag: "SudoBot#0000", |
40 |
avatar: "avatar", |
41 |
bot: true, |
42 |
system: false, |
43 |
client, |
44 |
toString() { |
45 |
return `<@${this.id}>`; |
46 |
} |
47 |
} as unknown as ClientUser; |
48 |
|
49 |
return client as Client<true>; |
50 |
} |