djs-builder 0.7.19 → 0.7.20
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/README.md +40 -1
- package/function/function.js +8 -0
- package/function/giveaway.js +15 -5
- package/index.d.ts +123 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
**Welcome to the ultimate Discord Bot Utilities package! 🥏**
|
|
6
6
|
Boost your Discord bot development with ease, speed, and all-in-one features.
|
|
7
7
|
|
|
8
|
-
[](https://discord.gg/myRzt9XCh2)
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -726,6 +726,10 @@ const components = await CreateComponents(true, [
|
|
|
726
726
|
type: "separator",
|
|
727
727
|
divider: true,
|
|
728
728
|
},
|
|
729
|
+
{
|
|
730
|
+
type: "color",
|
|
731
|
+
color: "#ff0000",
|
|
732
|
+
},
|
|
729
733
|
{
|
|
730
734
|
type: "section",
|
|
731
735
|
content: "Check out our latest updates and news!",
|
|
@@ -1358,6 +1362,36 @@ const { ChannelType } = require("discord.js");
|
|
|
1358
1362
|
|
|
1359
1363
|
|
|
1360
1364
|
|
|
1365
|
+
</details>
|
|
1366
|
+
|
|
1367
|
+
---
|
|
1368
|
+
|
|
1369
|
+
<details>
|
|
1370
|
+
<summary>🎨 Color Component Examples</summary>
|
|
1371
|
+
|
|
1372
|
+
**🎨 Color – Set an accent color for the container (Requires Container Mode)**
|
|
1373
|
+
|
|
1374
|
+
You can add an accent color line to your container. The color can be an integer or a hexadecimal string (`#ff0000`).
|
|
1375
|
+
|
|
1376
|
+
#### 📌 Container with Color:
|
|
1377
|
+
|
|
1378
|
+
```js
|
|
1379
|
+
const { CreateComponents } = require("djs-builder");
|
|
1380
|
+
|
|
1381
|
+
const components = await CreateComponents(true, [
|
|
1382
|
+
{
|
|
1383
|
+
type: "text",
|
|
1384
|
+
content: "Welcome to our server! 🎉",
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
type: "color",
|
|
1388
|
+
color: "#ff0000", // You can use Hex strings like "#ff0000" or an integer like 0xff0000
|
|
1389
|
+
}
|
|
1390
|
+
]);
|
|
1391
|
+
|
|
1392
|
+
await interaction.reply({ components, flags: 32768 });
|
|
1393
|
+
```
|
|
1394
|
+
|
|
1361
1395
|
</details>
|
|
1362
1396
|
|
|
1363
1397
|
---
|
|
@@ -1398,6 +1432,11 @@ const { ChannelType } = require("discord.js");
|
|
|
1398
1432
|
- `style` → 1: Primary, 2: Secondary, 3: Success, 4: Danger, 5: Link
|
|
1399
1433
|
- `label` → Button text
|
|
1400
1434
|
- `emoji` → Button emoji
|
|
1435
|
+
|
|
1436
|
+
#### 🔹 Color
|
|
1437
|
+
|
|
1438
|
+
- `type` → `"color"`
|
|
1439
|
+
- `color` → An Accent Color (Hex string like `"#ff0000"` or number)
|
|
1401
1440
|
- `disabled` → Disable button (true/false)
|
|
1402
1441
|
- `url` → URL for link buttons (style: 5)
|
|
1403
1442
|
|
package/function/function.js
CHANGED
|
@@ -464,6 +464,14 @@ async function CreateComponents(container, components) {
|
|
|
464
464
|
} else {
|
|
465
465
|
result.push(section);
|
|
466
466
|
}
|
|
467
|
+
} else if (item.type === "color") {
|
|
468
|
+
if (container === true) {
|
|
469
|
+
let colorValue = item.color;
|
|
470
|
+
if (typeof colorValue === "string") {
|
|
471
|
+
colorValue = parseInt(colorValue.replace("#", ""), 16);
|
|
472
|
+
}
|
|
473
|
+
result.setAccentColor(colorValue);
|
|
474
|
+
}
|
|
467
475
|
}
|
|
468
476
|
});
|
|
469
477
|
|
package/function/giveaway.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const { Schema, model } = mongoose;
|
|
2
3
|
const { EmbedBuilder } = require("discord.js");
|
|
3
4
|
const { CreateRow } = require("../function/function");
|
|
4
5
|
const giveawaySchema = new Schema({
|
|
@@ -173,11 +174,20 @@ async function Gstart({
|
|
|
173
174
|
|
|
174
175
|
async function Gcheck(client) {
|
|
175
176
|
const check = async () => {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
// Skip if MongoDB is not connected (prevents buffering timeout errors)
|
|
178
|
+
if (mongoose.connection.readyState !== 1) return;
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
const giveaways = await giveaway.find({ ended: false, paused: false });
|
|
182
|
+
for (let g of giveaways) {
|
|
183
|
+
if (Date.now() >= g.endTime) {
|
|
184
|
+
await giveaway_end(client, g);
|
|
185
|
+
}
|
|
180
186
|
}
|
|
187
|
+
} catch (e) {
|
|
188
|
+
// Silently ignore buffering/connection errors to prevent console spam
|
|
189
|
+
if (e.name === 'MongooseError' || e.name === 'MongoServerError' || e.name === 'MongoNetworkError') return;
|
|
190
|
+
console.error('❌ Giveaway check error:', e);
|
|
181
191
|
}
|
|
182
192
|
};
|
|
183
193
|
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Client, Message, Role, GuildMember, TextChannel, VoiceState, Guild, User } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
export interface LevelOptions {
|
|
4
|
+
mode?: 'dashboard' | 'code';
|
|
5
|
+
calculationType?: 'line' | 'exponential' | 'balanced' | 'custom';
|
|
6
|
+
cooldown?: number;
|
|
7
|
+
roleRewards?: { level: number, roleId: string }[];
|
|
8
|
+
onLevelUp?: (message: Message, newLevel: number) => void;
|
|
9
|
+
onRoleReward?: (message: Message, role: Role) => void;
|
|
10
|
+
onXP?: (message: Message, xpAdded: number) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface VoiceXPOptions {
|
|
14
|
+
xpPerTick?: number;
|
|
15
|
+
tickInterval?: number;
|
|
16
|
+
ignoreMuted?: boolean;
|
|
17
|
+
ignoreDeafened?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DashboardOptions {
|
|
21
|
+
port?: number;
|
|
22
|
+
clientSecret: string;
|
|
23
|
+
redirectUri: string;
|
|
24
|
+
sessionSecret?: string;
|
|
25
|
+
viewsPath?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface GiveawayOptions {
|
|
29
|
+
messages?: {
|
|
30
|
+
giveaway?: string;
|
|
31
|
+
giveawayEnded?: string;
|
|
32
|
+
inviteToParticipate?: string;
|
|
33
|
+
winMessage?: string;
|
|
34
|
+
noWinner?: string;
|
|
35
|
+
};
|
|
36
|
+
updateInterval?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface SecurityOptions {
|
|
40
|
+
antiSpam?: boolean;
|
|
41
|
+
antiLink?: boolean;
|
|
42
|
+
antiSelfBot?: boolean;
|
|
43
|
+
antiRaid?: { enabled: boolean; joinLimit: number; timeWindow: number };
|
|
44
|
+
maxWarningsBeforeBan?: number;
|
|
45
|
+
logChannelId?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface LogOptions {
|
|
49
|
+
channelId: string;
|
|
50
|
+
events?: {
|
|
51
|
+
messageDelete?: boolean;
|
|
52
|
+
messageUpdate?: boolean;
|
|
53
|
+
channelCreate?: boolean;
|
|
54
|
+
channelDelete?: boolean;
|
|
55
|
+
roleCreate?: boolean;
|
|
56
|
+
roleDelete?: boolean;
|
|
57
|
+
guildBanAdd?: boolean;
|
|
58
|
+
guildBanRemove?: boolean;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function setLevel(client: Client, options?: LevelOptions): void;
|
|
63
|
+
export function Level(client: Client, options?: LevelOptions): void;
|
|
64
|
+
export function levelGuild(guildId: string, options: any): void;
|
|
65
|
+
export function addXP(userId: string, guildId: string, amount: number): Promise<any>;
|
|
66
|
+
export function UserLevel(userId: string, guildId: string): Promise<any>;
|
|
67
|
+
export function leaderboard(guildId: string, limit?: number): Promise<any[]>;
|
|
68
|
+
export function getUserRank(userId: string, guildId: string): Promise<any>;
|
|
69
|
+
export function resetUser(userId: string, guildId: string): Promise<boolean>;
|
|
70
|
+
export function resetGuild(guildId: string): Promise<boolean>;
|
|
71
|
+
export function xpNeeded(level: number): number;
|
|
72
|
+
export function calculateLevel(xp: number): number;
|
|
73
|
+
export function getLevelInfo(xp: number): { level: number; needed: number };
|
|
74
|
+
export function getGuildConfig(guildId: string): Record<string, any>;
|
|
75
|
+
export function updateGuildConfig(guildId: string, newData: Record<string, any>): boolean;
|
|
76
|
+
export function deleteGuildConfig(guildId: string): boolean;
|
|
77
|
+
export function clearConfigCache(): void;
|
|
78
|
+
|
|
79
|
+
export function addVoiceXP(client: Client, options?: VoiceXPOptions): void;
|
|
80
|
+
|
|
81
|
+
export class dashboard {
|
|
82
|
+
constructor(client: Client, options: DashboardOptions);
|
|
83
|
+
start(): void;
|
|
84
|
+
stop(): void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function giveaway(client: Client, options?: GiveawayOptions): void;
|
|
88
|
+
export function Gstart(channel: TextChannel, options: any): Promise<void>;
|
|
89
|
+
export function Gcheck(messageId: string): Promise<any>;
|
|
90
|
+
export function Greroll(messageId: string): Promise<any>;
|
|
91
|
+
export function Glist(guildId: string): Promise<any[]>;
|
|
92
|
+
export function Gpause(messageId: string): Promise<boolean>;
|
|
93
|
+
export function Gresume(messageId: string): Promise<boolean>;
|
|
94
|
+
export function Gdelete(messageId: string): Promise<boolean>;
|
|
95
|
+
export function GaddUser(messageId: string, userId: string): Promise<boolean>;
|
|
96
|
+
export function GremoveUser(messageId: string, userId: string): Promise<boolean>;
|
|
97
|
+
export function GaddTime(messageId: string, ms: number): Promise<boolean>;
|
|
98
|
+
export function GremoveTime(messageId: string, ms: number): Promise<boolean>;
|
|
99
|
+
export function Gdata(messageId: string): Promise<any>;
|
|
100
|
+
|
|
101
|
+
export function setupSecurity(client: Client, options?: SecurityOptions): void;
|
|
102
|
+
|
|
103
|
+
export function log(client: Client, options?: LogOptions): void;
|
|
104
|
+
export function Log(client: Client, options?: LogOptions): void;
|
|
105
|
+
export function getLogConfigData(guildId: string): any;
|
|
106
|
+
|
|
107
|
+
export declare const Blacklist: {
|
|
108
|
+
add: (userId: string, reason?: string) => Promise<boolean>;
|
|
109
|
+
remove: (userId: string) => Promise<boolean>;
|
|
110
|
+
check: (userId: string) => Promise<boolean>;
|
|
111
|
+
getAll: () => Promise<string[]>;
|
|
112
|
+
};
|
|
113
|
+
export function isBlacklisted(userId: string): Promise<boolean>;
|
|
114
|
+
export function addToBlacklist(userId: string, reason?: string): Promise<boolean>;
|
|
115
|
+
export function removeFromBlacklist(userId: string): Promise<boolean>;
|
|
116
|
+
export function getBlacklist(): Promise<string[]>;
|
|
117
|
+
|
|
118
|
+
export function Wait(options: { context: any; userId?: string | null; type?: "message" | "interaction" | "both"; time?: number; message_Wait?: any }): Promise<any>;
|
|
119
|
+
export function CreateBar(progress: number, max: number, options?: { length?: number; fill?: string; empty?: string; showPercent?: boolean; left?: string; right?: string; partialChar?: string }): string;
|
|
120
|
+
export function CreateRow(components: any[], rowOnly?: boolean): any[];
|
|
121
|
+
export function GetUser(message: Message): Promise<{ user: GuildMember; args: string[] } | null>;
|
|
122
|
+
export function CreateModal(options: { id: string; title: string; components: any[] }): any;
|
|
123
|
+
export function CreateComponents(container: boolean | any, components: any[]): any[];
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "djs-builder",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"note": "🎉 Package Update v0.7.
|
|
3
|
+
"version": "0.7.20",
|
|
4
|
+
"note": "🎉 Package Update v0.7.20! \n\n- 🎨 component v2 set color !\n\n- 🌐 Dashboard System!\n • Discord OAuth2 Login\n • Server, Level, Giveaway & Blacklist Management\n • Logs Management Page\n\n- <:npm:1107014411375353968> Learn more on [NPM](https://www.npmjs.com/package/djs-builder)\n- <:Discord:906936109114753024> DISCORD SERVER : [LINK](https://discord.gg/myRzt9XCh2)",
|
|
5
5
|
"description": "🎉 Full-featured Discord.js utilities: CreateComponents, CreateModal, Dashboard, Logging & more! 🥏",
|
|
6
6
|
"main": "handler/starter.js",
|
|
7
|
+
"types": "index.d.ts",
|
|
7
8
|
"author": "Abdullah",
|
|
8
9
|
"keywords": [
|
|
9
10
|
"discord.js",
|