spacecommands 3.0.0 → 3.0.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/index.js +1 -49
- package/dist/supabase.js +9 -18
- package/package.json +4 -4
- package/typings.d.ts +4 -14
package/dist/index.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -89,8 +56,7 @@ class SpaceCommands extends events_1.EventEmitter {
|
|
|
89
56
|
if (!client) {
|
|
90
57
|
throw new Error('No Discord JS Client provided as first argument!');
|
|
91
58
|
}
|
|
92
|
-
let { commandsDir = '', commandDir = '', featuresDir = '', featureDir = '', componentsDir, modalsDir, contextMenusDir, messagesPath, supabaseUrl, supabaseKey,
|
|
93
|
-
showWarns = true, delErrMsgCooldown = -1, defaultLanguage = 'english', ignoreBots = true, dbOptions, testServers, botOwners, disabledDefaultCommands = [], typeScript = false, ephemeral = true, debug = false, } = options || {};
|
|
59
|
+
let { commandsDir = '', commandDir = '', featuresDir = '', featureDir = '', componentsDir, modalsDir, contextMenusDir, messagesPath, supabaseUrl, supabaseKey, showWarns = true, delErrMsgCooldown = -1, defaultLanguage = 'english', ignoreBots = true, dbOptions, testServers, botOwners, disabledDefaultCommands = [], typeScript = false, ephemeral = true, debug = false, } = options || {};
|
|
94
60
|
// Support for Supabase (recommended) or MongoDB (deprecated)
|
|
95
61
|
if (supabaseUrl && supabaseKey) {
|
|
96
62
|
this._supabaseClient = await (0, supabase_1.default)(supabaseUrl, supabaseKey, this);
|
|
@@ -101,20 +67,6 @@ class SpaceCommands extends events_1.EventEmitter {
|
|
|
101
67
|
this._prefixes[_id] = prefix;
|
|
102
68
|
}
|
|
103
69
|
}
|
|
104
|
-
else if (mongoUri) {
|
|
105
|
-
// MongoDB support deprecated but still available
|
|
106
|
-
if (showWarns) {
|
|
107
|
-
console.warn('SpaceCommands > MongoDB support is deprecated. Please migrate to Supabase. See documentation for details.');
|
|
108
|
-
}
|
|
109
|
-
const mongo = await Promise.resolve().then(() => __importStar(require('./mongo')));
|
|
110
|
-
await mongo.default(mongoUri, this, dbOptions);
|
|
111
|
-
this._supabaseClient = null;
|
|
112
|
-
const results = await prefixes_1.default.find({});
|
|
113
|
-
for (const result of results) {
|
|
114
|
-
const { _id, prefix } = result;
|
|
115
|
-
this._prefixes[_id] = prefix;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
70
|
else {
|
|
119
71
|
if (showWarns) {
|
|
120
72
|
console.warn('SpaceCommands > No database connection provided. Some features might not work! Please provide supabaseUrl and supabaseKey.');
|
package/dist/supabase.js
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getSupabaseClient = void 0;
|
|
7
|
-
// @ts-nocheck
|
|
3
|
+
exports.getSupabaseClient = exports.initSupabase = void 0;
|
|
8
4
|
const supabase_js_1 = require("@supabase/supabase-js");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const { error } = await supabaseClient.from('spacecommands_prefixes').select('count').limit(1);
|
|
15
|
-
if (error && error.code !== 'PGRST116') { // PGRST116 is "no rows returned" which is fine
|
|
16
|
-
console.error('SpaceCommands > Supabase connection error:', error);
|
|
17
|
-
instance.emit(Events_1.default.DATABASE_CONNECTED, null, 'Error');
|
|
18
|
-
throw new Error(`Failed to connect to Supabase: ${error.message}`);
|
|
5
|
+
let supabase = null;
|
|
6
|
+
const initSupabase = (url, key) => {
|
|
7
|
+
if (!url || !key) {
|
|
8
|
+
console.warn('SpaceCommands > Supabase URL or Key not provided.');
|
|
9
|
+
return;
|
|
19
10
|
}
|
|
20
|
-
|
|
21
|
-
return supabaseClient;
|
|
11
|
+
supabase = (0, supabase_js_1.createClient)(url, key);
|
|
22
12
|
};
|
|
13
|
+
exports.initSupabase = initSupabase;
|
|
23
14
|
const getSupabaseClient = () => {
|
|
24
|
-
return
|
|
15
|
+
return supabase;
|
|
25
16
|
};
|
|
26
17
|
exports.getSupabaseClient = getSupabaseClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spacecommands",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "./typings.d.ts",
|
|
6
6
|
"typings": "./typings.d.ts",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"author": "SpaceCommands Contributors",
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
41
|
+
"@supabase/supabase-js": "^2.89.0",
|
|
42
|
+
"discord.js": "^14.0.0",
|
|
43
|
+
"dotenv": "^16.4.7"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^22.10.5",
|
package/typings.d.ts
CHANGED
|
@@ -18,8 +18,6 @@ export default class SpaceCommands extends EventEmitter {
|
|
|
18
18
|
private _defaultPrefix: string
|
|
19
19
|
private _commandsDir: string
|
|
20
20
|
private _featuresDir: string
|
|
21
|
-
private _mongo: string | undefined
|
|
22
|
-
private _mongoConnection: Connection | null
|
|
23
21
|
private _displayName: string
|
|
24
22
|
private _prefixes: { [name: string]: string }
|
|
25
23
|
private _categories: Map<String, String | GuildEmoji>
|
|
@@ -45,8 +43,6 @@ export default class SpaceCommands extends EventEmitter {
|
|
|
45
43
|
|
|
46
44
|
constructor(client: Client, options?: Options)
|
|
47
45
|
|
|
48
|
-
public get mongoPath(): string
|
|
49
|
-
public setMongoPath(mongoPath: string | undefined): SpaceCommands
|
|
50
46
|
public get client(): Client
|
|
51
47
|
public get displayName(): string
|
|
52
48
|
public setDisplayName(displayName: string): SpaceCommands
|
|
@@ -67,10 +63,6 @@ export default class SpaceCommands extends EventEmitter {
|
|
|
67
63
|
): SpaceCommands
|
|
68
64
|
public isEmojiUsed(emoji: string): boolean
|
|
69
65
|
public get commandHandler(): CommandHandler
|
|
70
|
-
public get mongoConnection(): Connection | null
|
|
71
|
-
public isDBConnected(): boolean
|
|
72
|
-
public setTagPeople(tagPeople: boolean): SpaceCommands
|
|
73
|
-
public get tagPeople(): boolean
|
|
74
66
|
public get showWarns(): boolean
|
|
75
67
|
public get delErrMsgCooldown(): number
|
|
76
68
|
public get ignoreBots(): boolean
|
|
@@ -99,9 +91,8 @@ interface OptionsWithS {
|
|
|
99
91
|
modalsDir?: string
|
|
100
92
|
contextMenusDir?: string
|
|
101
93
|
messagesPath?: string
|
|
102
|
-
supabaseUrl
|
|
103
|
-
supabaseKey
|
|
104
|
-
mongoUri?: string // Deprecated - use supabaseUrl and supabaseKey
|
|
94
|
+
supabaseUrl: string
|
|
95
|
+
supabaseKey: string
|
|
105
96
|
showWarns?: boolean
|
|
106
97
|
delErrMsgCooldown?: number
|
|
107
98
|
defaultLanguage?: string
|
|
@@ -125,9 +116,8 @@ interface OptionsWithoutS {
|
|
|
125
116
|
modalsDir?: string
|
|
126
117
|
contextMenusDir?: string
|
|
127
118
|
messagesPath?: string
|
|
128
|
-
supabaseUrl
|
|
129
|
-
supabaseKey
|
|
130
|
-
mongoUri?: string // Deprecated - use supabaseUrl and supabaseKey
|
|
119
|
+
supabaseUrl: string
|
|
120
|
+
supabaseKey: string
|
|
131
121
|
showWarns?: boolean
|
|
132
122
|
delErrMsgCooldown?: number
|
|
133
123
|
defaultLanguage?: string
|