@mostfeatured/dbi 0.0.32 → 0.0.35
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/types/Modal.d.ts +5 -1
- package/dist/types/Modal.d.ts.map +1 -1
- package/dist/types/Modal.js.map +1 -1
- package/examples/modal/dbi.js +30 -0
- package/examples/modal/login.js +15 -0
- package/examples/modal/package.json +15 -0
- package/examples/modal/publish.js +13 -0
- package/examples/modal/src/chatInput.js +39 -0
- package/examples/modal/src/components.js +18 -0
- package/examples/modal/src/event.js +20 -0
- package/examples/modal/src/interactionlocales.js +24 -0
- package/examples/modal/src/locales.js +38 -0
- package/examples/modal/src/modal.js +32 -0
- package/package.json +1 -1
- package/readme.md +2 -0
- package/src/types/Modal.ts +7 -2
package/dist/types/Modal.d.ts
CHANGED
|
@@ -5,10 +5,14 @@ export interface IDBIModalExecuteCtx extends IDBIBaseExecuteCtx {
|
|
|
5
5
|
interaction: Discord.ModalSubmitInteraction<"cached">;
|
|
6
6
|
data: TDBIReferencedData[];
|
|
7
7
|
}
|
|
8
|
+
export interface ModalComponentData {
|
|
9
|
+
title: string;
|
|
10
|
+
components: (Discord.ActionRowData<Discord.ModalActionRowComponentData>)[];
|
|
11
|
+
}
|
|
8
12
|
export declare type TDBIModalOmitted = Omit<DBIModal, "type" | "description" | "dbi" | "toJSON">;
|
|
9
13
|
export declare class DBIModal extends DBIBaseInteraction {
|
|
10
14
|
constructor(dbi: DBI, args: TDBIModalOmitted);
|
|
11
|
-
options:
|
|
15
|
+
options: ModalComponentData | ((data: TDBIReferencedData[]) => ModalComponentData);
|
|
12
16
|
onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any;
|
|
13
17
|
referenceTTL?: number;
|
|
14
18
|
toJSON(...customData: (string | number | object)[]): Discord.ModalComponentData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"m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,kBAAkB;gBAClC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,gBAAgB;IAQpC,OAAO,EAAE,kBAAkB,GAAG,CAAC,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,CAAC,CAAC;IAElF,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAExD,YAAY,CAAC,EAAE,MAAM,CAAC;IAE9B,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,kBAAkB;CAMhF"}
|
package/dist/types/Modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;AACA,+CAA2F;AAE3F,gDAAoD;
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;AACA,+CAA2F;AAE3F,gDAAoD;AAepD,MAAa,QAAS,SAAQ,gCAAkB;IAC9C,YAAY,GAAQ,EAAE,IAAsB;QAC1C,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;IACxC,CAAC;IAIQ,SAAS,CAAC,GAAwB,IAAwB,CAAC;IAAA,CAAC;IAIrE,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;YACvF,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC;SACvE,CAAC;IACX,CAAC;IAAA,CAAC;CACH;AArBD,4BAqBC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport Discord from \"discord.js\";\r\nimport { customIdBuilder } from \"../utils/customId\";\r\n\r\nexport interface IDBIModalExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ModalSubmitInteraction<\"cached\">;\r\n\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport interface ModalComponentData {\r\n title: string;\r\n components: (Discord.ActionRowData<Discord.ModalActionRowComponentData>)[];\r\n}\r\n\r\nexport type TDBIModalOmitted = Omit<DBIModal, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBIModal extends DBIBaseInteraction {\r\n constructor(dbi: DBI, args: TDBIModalOmitted) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"Modal\"\r\n });\r\n this.referenceTTL = args.referenceTTL;\r\n }\r\n\r\n declare options: ModalComponentData | ((data: TDBIReferencedData[]) => ModalComponentData);\r\n\r\n override onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any { };\r\n\r\n declare referenceTTL?: number;\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.ModalComponentData {\r\n return {\r\n ...(typeof this.options == \"function\" ? this.options(customData as any) : this.options),\r\n customId: customIdBuilder(this.dbi, this.name, customData, this.referenceTTL)\r\n } as any;\r\n };\r\n}"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const { createDBI } = require("@mostfeatured/dbi");
|
|
2
|
+
|
|
3
|
+
let dbi = createDBI("modal-example", {
|
|
4
|
+
strict: true,
|
|
5
|
+
discord: {
|
|
6
|
+
token: "<token>",
|
|
7
|
+
options: {
|
|
8
|
+
intents: [
|
|
9
|
+
"Guilds",
|
|
10
|
+
"MessageContent",
|
|
11
|
+
"GuildMessages",
|
|
12
|
+
"GuildMessageTyping",
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
defaults: {
|
|
17
|
+
locale: "en",
|
|
18
|
+
defaultMemberPermissions: ["SendMessages"],
|
|
19
|
+
directMessages: false
|
|
20
|
+
},
|
|
21
|
+
references: {
|
|
22
|
+
autoClear: {
|
|
23
|
+
ttl: 60 * 1000 * 60,
|
|
24
|
+
check: 60 * 1000
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
module.exports = dbi;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { recursiveImport } = require("@mostfeatured/dbi");
|
|
2
|
+
const dbi = require("./dbi");
|
|
3
|
+
|
|
4
|
+
(async () => {
|
|
5
|
+
await recursiveImport("./src");
|
|
6
|
+
|
|
7
|
+
await dbi.load();
|
|
8
|
+
await dbi.login();
|
|
9
|
+
|
|
10
|
+
await dbi.client.user.setActivity({
|
|
11
|
+
name: "hello world!"
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
console.log(`Logged in! ${dbi.client.user.tag} (${dbi.client.user.id})`);
|
|
15
|
+
})();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "example-project",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "risy",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@mostfeatured/dbi": "^0.0.33",
|
|
13
|
+
"discord.js": "^14.3.0"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { recursiveImport } = require("@mostfeatured/dbi");
|
|
2
|
+
const dbi = require("./dbi");
|
|
3
|
+
|
|
4
|
+
(async () => {
|
|
5
|
+
await recursiveImport("./src");
|
|
6
|
+
|
|
7
|
+
await dbi.load();
|
|
8
|
+
await dbi.publish("Guild", "<Guild Id>");
|
|
9
|
+
// await dbi.publish("Global");
|
|
10
|
+
await dbi.unload();
|
|
11
|
+
|
|
12
|
+
console.log("Published!");
|
|
13
|
+
})();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const dbi = require("../dbi");
|
|
2
|
+
const Discord = require("discord.js");
|
|
3
|
+
|
|
4
|
+
dbi.register(({ ChatInput, ChatInputOptions }) => {
|
|
5
|
+
ChatInput({
|
|
6
|
+
name: "cinsiyet seç",
|
|
7
|
+
description: "Cinsiyet seçmenizi sağlar.",
|
|
8
|
+
onExecute({ interaction, locale }) {
|
|
9
|
+
let gender = interaction.options.get("cinsiyet").value;
|
|
10
|
+
let genderNames = locale.user.data.genders;
|
|
11
|
+
let genderText = locale.user.data.genderText(interaction.user, genderNames[gender]());
|
|
12
|
+
const clickText = locale.user.data.clickText();
|
|
13
|
+
|
|
14
|
+
interaction.reply({
|
|
15
|
+
content: genderText,
|
|
16
|
+
components: [
|
|
17
|
+
{
|
|
18
|
+
type: Discord.ComponentType.ActionRow,
|
|
19
|
+
components: [
|
|
20
|
+
dbi.interaction("viewGender").toJSON({ gender, clickText }),
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
options: [
|
|
27
|
+
ChatInputOptions.stringChoices({
|
|
28
|
+
name: "cinsiyet",
|
|
29
|
+
description: "Seçeceğiniz cinsiyet.",
|
|
30
|
+
required: true,
|
|
31
|
+
choices: [
|
|
32
|
+
{ name: "Erkek", value: "erkek" },
|
|
33
|
+
{ name: "Kadın", value: "kadın" },
|
|
34
|
+
{ name: "Diğer", value: "diğer" },
|
|
35
|
+
]
|
|
36
|
+
})
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const dbi = require("../dbi");
|
|
2
|
+
const Discord = require("discord.js");
|
|
3
|
+
|
|
4
|
+
dbi.register(({ Button }) => {
|
|
5
|
+
Button({
|
|
6
|
+
name: "viewGender",
|
|
7
|
+
onExecute({ interaction, locale }) {
|
|
8
|
+
interaction.showModal(dbi.interaction("my-modal").toJSON({locale}))
|
|
9
|
+
|
|
10
|
+
},
|
|
11
|
+
options(data) {
|
|
12
|
+
return {
|
|
13
|
+
style: Discord.ButtonStyle.Danger,
|
|
14
|
+
label: data[0].clickText,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const dbi = require("../dbi");
|
|
2
|
+
|
|
3
|
+
dbi.register(({ Event })=>{
|
|
4
|
+
Event({
|
|
5
|
+
name: "ready",
|
|
6
|
+
id: "botIsReady",
|
|
7
|
+
onExecute() {
|
|
8
|
+
console.log(`Bot ready!`);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
Event({
|
|
13
|
+
name: "messageCreate",
|
|
14
|
+
onExecute({ message }) {
|
|
15
|
+
if (dbi.client.user.id === message.author.id) return;
|
|
16
|
+
|
|
17
|
+
message.channel.send("hello !");
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const dbi = require("../dbi");
|
|
2
|
+
|
|
3
|
+
dbi.register(({ InteractionLocale })=>{
|
|
4
|
+
InteractionLocale({
|
|
5
|
+
name: "cinsiyet seç",
|
|
6
|
+
data: {
|
|
7
|
+
en: {
|
|
8
|
+
name: "select gender",
|
|
9
|
+
description: "Allows you to select a gender.",
|
|
10
|
+
options: {
|
|
11
|
+
cinsiyet: {
|
|
12
|
+
name: "gender",
|
|
13
|
+
description: "Select your gender correctly.",
|
|
14
|
+
choices: {
|
|
15
|
+
"Erkek": "Male",
|
|
16
|
+
"Kadın": "Female",
|
|
17
|
+
"Diğer": "Other"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const dbi = require("../dbi");
|
|
2
|
+
dbi.register(({ Locale })=>{
|
|
3
|
+
Locale({
|
|
4
|
+
name: "tr",
|
|
5
|
+
data: {
|
|
6
|
+
genders: {
|
|
7
|
+
erkek: "Erkek",
|
|
8
|
+
kadın: "Kadın",
|
|
9
|
+
diğer: "Diğer",
|
|
10
|
+
},
|
|
11
|
+
modal: {
|
|
12
|
+
title: "İsmin nedir ?",
|
|
13
|
+
label: "İsim",
|
|
14
|
+
text: "Senin adın {0}"
|
|
15
|
+
},
|
|
16
|
+
genderText: "{0} adlı üye {1} cinsiyetini seçti.",
|
|
17
|
+
clickText: "Bana tıkla!",
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
Locale({
|
|
22
|
+
name: "en",
|
|
23
|
+
data: {
|
|
24
|
+
genders: {
|
|
25
|
+
erkek: "Male",
|
|
26
|
+
kadın: "Female",
|
|
27
|
+
diğer: "Other"
|
|
28
|
+
},
|
|
29
|
+
modal: {
|
|
30
|
+
title: "What is your name?",
|
|
31
|
+
label: "Name",
|
|
32
|
+
text: "Your name is {0}"
|
|
33
|
+
},
|
|
34
|
+
genderText: "{0}, picked {1} gender.",
|
|
35
|
+
clickText: "Click me!",
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const dbi = require('../dbi');
|
|
2
|
+
const Discord = require("discord.js");
|
|
3
|
+
|
|
4
|
+
dbi.register(({ Modal }) => {
|
|
5
|
+
Modal({
|
|
6
|
+
name: "my-modal",
|
|
7
|
+
onExecute({ interaction, locale }) {
|
|
8
|
+
const text = locale.user.data.modal.text(interaction.fields.getField('name').value);
|
|
9
|
+
|
|
10
|
+
interaction.reply(text);
|
|
11
|
+
},
|
|
12
|
+
options(data) {
|
|
13
|
+
return {
|
|
14
|
+
title: data[0].locale.user.data.modal.title(),
|
|
15
|
+
type: Discord.ComponentType.ActionRow,
|
|
16
|
+
components: [
|
|
17
|
+
{
|
|
18
|
+
type: Discord.ComponentType.ActionRow,
|
|
19
|
+
components: [
|
|
20
|
+
{
|
|
21
|
+
customId: "name",
|
|
22
|
+
type: Discord.ComponentType.TextInput,
|
|
23
|
+
style: Discord.TextInputStyle.Short,
|
|
24
|
+
label: data[0].locale.user.data.modal.label(),
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
});
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -249,6 +249,8 @@ Bir eşsiz özelliği daha sizlere sunuyoruz. Artık her kullanıcıya özel kom
|
|
|
249
249
|
<sub>`src/interactionlocales.js` dosyası:</sub>
|
|
250
250
|
|
|
251
251
|
```js
|
|
252
|
+
const dbi = require("../dbi");
|
|
253
|
+
|
|
252
254
|
dbi.register(({ InteractionLocale })=>{
|
|
253
255
|
InteractionLocale({
|
|
254
256
|
name: "cinsiyet seç",
|
package/src/types/Modal.ts
CHANGED
|
@@ -9,6 +9,11 @@ export interface IDBIModalExecuteCtx extends IDBIBaseExecuteCtx {
|
|
|
9
9
|
data: TDBIReferencedData[];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export interface ModalComponentData {
|
|
13
|
+
title: string;
|
|
14
|
+
components: (Discord.ActionRowData<Discord.ModalActionRowComponentData>)[];
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
export type TDBIModalOmitted = Omit<DBIModal, "type" | "description" | "dbi" | "toJSON">;
|
|
13
18
|
|
|
14
19
|
export class DBIModal extends DBIBaseInteraction {
|
|
@@ -20,7 +25,7 @@ export class DBIModal extends DBIBaseInteraction {
|
|
|
20
25
|
this.referenceTTL = args.referenceTTL;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
declare options:
|
|
28
|
+
declare options: ModalComponentData | ((data: TDBIReferencedData[]) => ModalComponentData);
|
|
24
29
|
|
|
25
30
|
override onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any { };
|
|
26
31
|
|
|
@@ -28,7 +33,7 @@ export class DBIModal extends DBIBaseInteraction {
|
|
|
28
33
|
|
|
29
34
|
toJSON(...customData: (string | number | object)[]): Discord.ModalComponentData {
|
|
30
35
|
return {
|
|
31
|
-
...(typeof this.options == "function" ? this.options(customData) : this.options),
|
|
36
|
+
...(typeof this.options == "function" ? this.options(customData as any) : this.options),
|
|
32
37
|
customId: customIdBuilder(this.dbi, this.name, customData, this.referenceTTL)
|
|
33
38
|
} as any;
|
|
34
39
|
};
|