@open-discord-bots/framework 0.3.1 → 0.3.2
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/api/main.js +1 -1
- package/dist/utilities/index.d.ts +7 -0
- package/dist/utilities/index.js +27 -0
- package/package.json +1 -1
- package/src/api/main.ts +1 -1
- package/src/utilities/index.ts +22 -0
package/dist/api/main.js
CHANGED
|
@@ -43,7 +43,7 @@ export class ODMain {
|
|
|
43
43
|
constructor(managers, project) {
|
|
44
44
|
this.project = project;
|
|
45
45
|
this.versions = managers.versions;
|
|
46
|
-
this.versions.add(ODVersion.fromString("opendiscord:api", "v0.3.
|
|
46
|
+
this.versions.add(ODVersion.fromString("opendiscord:api", "v0.3.2"));
|
|
47
47
|
this.versions.add(ODVersion.fromString("opendiscord:livestatus", "v2.0.0"));
|
|
48
48
|
this.debugfile = managers.debugfile;
|
|
49
49
|
this.console = managers.console;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as api from "../api/index.js";
|
|
2
|
+
import * as discord from "discord.js";
|
|
2
3
|
/**## sharedFuses `utility variable`
|
|
3
4
|
* All shared fuses from Open Discord. Please use `opendiscord.sharedFuses` instead!
|
|
4
5
|
*/
|
|
@@ -55,6 +56,12 @@ export declare function ordinalNumber(num: number): string;
|
|
|
55
56
|
* Trim/remove all emoji's from a Javascript string.
|
|
56
57
|
*/
|
|
57
58
|
export declare function trimEmojis(text: string): string;
|
|
59
|
+
/**## getMessageFromBuildResult `utility function`
|
|
60
|
+
* Get the final `messageCreateOptions` from a returned build result from builders/components.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getMessageFromBuildResult(build: api.ODMessageBuildResult | api.ODMessageComponentBuildResult, type: "interaction" | "message"): discord.MessageCreateOptions & {
|
|
63
|
+
flags: number[];
|
|
64
|
+
};
|
|
58
65
|
/**## easterEggs `utility object`
|
|
59
66
|
* Object containing data for Open Ticket easter eggs.
|
|
60
67
|
*/
|
package/dist/utilities/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import ansis from "ansis";
|
|
3
3
|
import * as api from "../api/index.js";
|
|
4
|
+
import * as discord from "discord.js";
|
|
4
5
|
/**## sharedFuses `utility variable`
|
|
5
6
|
* All shared fuses from Open Discord. Please use `opendiscord.sharedFuses` instead!
|
|
6
7
|
*/
|
|
@@ -163,6 +164,32 @@ export function ordinalNumber(num) {
|
|
|
163
164
|
export function trimEmojis(text) {
|
|
164
165
|
return text.replace(/(\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?)*)/gu, "");
|
|
165
166
|
}
|
|
167
|
+
/**## getMessageFromBuildResult `utility function`
|
|
168
|
+
* Get the final `messageCreateOptions` from a returned build result from builders/components.
|
|
169
|
+
*/
|
|
170
|
+
export function getMessageFromBuildResult(build, type) {
|
|
171
|
+
const msgFlags = [];
|
|
172
|
+
let msgData;
|
|
173
|
+
if ('message' in build) {
|
|
174
|
+
//USING BUILDERS (deprecated)
|
|
175
|
+
msgData = build.message;
|
|
176
|
+
if (build.ephemeral)
|
|
177
|
+
msgFlags.push(discord.MessageFlags.Ephemeral);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
//USING COMPONENTS
|
|
181
|
+
msgData = build.msg;
|
|
182
|
+
if (type == "interaction" && build.ephemeral)
|
|
183
|
+
msgFlags.push(discord.MessageFlags.Ephemeral); //disabled with regular messages
|
|
184
|
+
if (build.componentsV2)
|
|
185
|
+
msgFlags.push(discord.MessageFlags.IsComponentsV2);
|
|
186
|
+
if (build.supressEmbeds)
|
|
187
|
+
msgFlags.push(discord.MessageFlags.SuppressEmbeds);
|
|
188
|
+
if (build.supressNotifications)
|
|
189
|
+
msgFlags.push(discord.MessageFlags.SuppressNotifications);
|
|
190
|
+
}
|
|
191
|
+
return Object.assign(msgData, { flags: msgFlags });
|
|
192
|
+
}
|
|
166
193
|
/**## easterEggs `utility object`
|
|
167
194
|
* Object containing data for Open Ticket easter eggs.
|
|
168
195
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-discord-bots/framework",
|
|
3
3
|
"author": "DJj123dj",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"description": "The core framework of the popular open-source discord bots: Open Ticket & Open Moderation.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
package/src/api/main.ts
CHANGED
|
@@ -150,7 +150,7 @@ export abstract class ODMain implements ODMainManagers {
|
|
|
150
150
|
constructor(managers:ODMainManagers,project:ODProjectType){
|
|
151
151
|
this.project = project
|
|
152
152
|
this.versions = managers.versions
|
|
153
|
-
this.versions.add(ODVersion.fromString("opendiscord:api","v0.3.
|
|
153
|
+
this.versions.add(ODVersion.fromString("opendiscord:api","v0.3.2"))
|
|
154
154
|
this.versions.add(ODVersion.fromString("opendiscord:livestatus","v2.0.0"))
|
|
155
155
|
|
|
156
156
|
this.debugfile = managers.debugfile
|
package/src/utilities/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from "fs"
|
|
2
2
|
import ansis from "ansis"
|
|
3
3
|
import * as api from "../api/index.js"
|
|
4
|
+
import * as discord from "discord.js"
|
|
4
5
|
|
|
5
6
|
/**## sharedFuses `utility variable`
|
|
6
7
|
* All shared fuses from Open Discord. Please use `opendiscord.sharedFuses` instead!
|
|
@@ -166,6 +167,27 @@ export function trimEmojis(text:string){
|
|
|
166
167
|
return text.replace(/(\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?)*)/gu,"")
|
|
167
168
|
}
|
|
168
169
|
|
|
170
|
+
/**## getMessageFromBuildResult `utility function`
|
|
171
|
+
* Get the final `messageCreateOptions` from a returned build result from builders/components.
|
|
172
|
+
*/
|
|
173
|
+
export function getMessageFromBuildResult(build:api.ODMessageBuildResult|api.ODMessageComponentBuildResult,type:"interaction"|"message"){
|
|
174
|
+
const msgFlags: number[] = []
|
|
175
|
+
let msgData: discord.MessageCreateOptions
|
|
176
|
+
if ('message' in build){
|
|
177
|
+
//USING BUILDERS (deprecated)
|
|
178
|
+
msgData = build.message
|
|
179
|
+
if (build.ephemeral) msgFlags.push(discord.MessageFlags.Ephemeral)
|
|
180
|
+
}else{
|
|
181
|
+
//USING COMPONENTS
|
|
182
|
+
msgData = build.msg
|
|
183
|
+
if (type == "interaction" && build.ephemeral) msgFlags.push(discord.MessageFlags.Ephemeral) //disabled with regular messages
|
|
184
|
+
if (build.componentsV2) msgFlags.push(discord.MessageFlags.IsComponentsV2)
|
|
185
|
+
if (build.supressEmbeds) msgFlags.push(discord.MessageFlags.SuppressEmbeds)
|
|
186
|
+
if (build.supressNotifications) msgFlags.push(discord.MessageFlags.SuppressNotifications)
|
|
187
|
+
}
|
|
188
|
+
return Object.assign(msgData,{flags:msgFlags})
|
|
189
|
+
}
|
|
190
|
+
|
|
169
191
|
/**## easterEggs `utility object`
|
|
170
192
|
* Object containing data for Open Ticket easter eggs.
|
|
171
193
|
*/
|