spacecommands 1.0.0
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/LICENSE +21 -0
- package/README.md +519 -0
- package/dist/Command.js +384 -0
- package/dist/CommandHandler.js +339 -0
- package/dist/FeatureHandler.js +89 -0
- package/dist/SlashCommands.js +220 -0
- package/dist/command-checks/channel-specific.js +30 -0
- package/dist/command-checks/guild-only-check.js +24 -0
- package/dist/command-checks/has-entitlement.js +52 -0
- package/dist/command-checks/has-permissions.js +39 -0
- package/dist/command-checks/has-roles.js +69 -0
- package/dist/command-checks/has-valid-arguments.js +54 -0
- package/dist/command-checks/in-cooldown.js +42 -0
- package/dist/command-checks/is-enabled.js +31 -0
- package/dist/command-checks/is-not-test-only.js +8 -0
- package/dist/command-checks/owner-only-check.js +22 -0
- package/dist/commands/channelonly.js +88 -0
- package/dist/commands/command.js +87 -0
- package/dist/commands/help/!ReactionListener.js +217 -0
- package/dist/commands/help/!get-first-embed.js +57 -0
- package/dist/commands/help/help.js +97 -0
- package/dist/commands/language.js +52 -0
- package/dist/commands/prefix.js +42 -0
- package/dist/commands/requiredrole.js +61 -0
- package/dist/commands/slash.js +102 -0
- package/dist/enums/CommandErrors.js +12 -0
- package/dist/enums/Events.js +9 -0
- package/dist/features/message-upsert.js +15 -0
- package/dist/get-all-files.js +25 -0
- package/dist/handlers/AutoModHandler.js +316 -0
- package/dist/handlers/ComponentHandler.js +110 -0
- package/dist/handlers/ContextMenuHandler.js +113 -0
- package/dist/handlers/EntitlementHandler.js +193 -0
- package/dist/handlers/ModalHandler.js +71 -0
- package/dist/handlers/PollHandler.js +230 -0
- package/dist/index.js +339 -0
- package/dist/message-handler.js +118 -0
- package/dist/models/channel-commands.js +49 -0
- package/dist/models/cooldown.js +51 -0
- package/dist/models/disabled-commands.js +45 -0
- package/dist/models/languages.js +46 -0
- package/dist/models/prefixes.js +46 -0
- package/dist/models/required-roles.js +49 -0
- package/dist/mongo.js +25 -0
- package/dist/permissions.js +39 -0
- package/dist/utils/ComponentBuilder.js +144 -0
- package/dist/utils/InteractionCollector.js +80 -0
- package/messages.json +391 -0
- package/package.json +72 -0
- package/typings.d.ts +276 -0
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
36
|
+
const reqString = {
|
|
37
|
+
type: String,
|
|
38
|
+
required: true,
|
|
39
|
+
};
|
|
40
|
+
const schema = new mongoose_1.Schema({
|
|
41
|
+
// Guild ID
|
|
42
|
+
_id: reqString,
|
|
43
|
+
prefix: reqString,
|
|
44
|
+
});
|
|
45
|
+
const name = 'spacecommands-prefixes';
|
|
46
|
+
module.exports = mongoose_1.default.models[name] || mongoose_1.default.model(name, schema, name);
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
36
|
+
const reqString = {
|
|
37
|
+
type: String,
|
|
38
|
+
required: true,
|
|
39
|
+
};
|
|
40
|
+
const schema = new mongoose_1.Schema({
|
|
41
|
+
guildId: reqString,
|
|
42
|
+
command: reqString,
|
|
43
|
+
requiredRoles: {
|
|
44
|
+
type: [String],
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const name = 'spacecommands-required-roles';
|
|
49
|
+
module.exports = mongoose_1.default.models[name] || mongoose_1.default.model(name, schema, name);
|
package/dist/mongo.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getMongoConnection = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const Events_1 = __importDefault(require("./enums/Events"));
|
|
9
|
+
const results = {
|
|
10
|
+
0: 'Disconnected',
|
|
11
|
+
1: 'Connected',
|
|
12
|
+
2: 'Connecting',
|
|
13
|
+
3: 'Disconnecting',
|
|
14
|
+
};
|
|
15
|
+
exports.default = async (mongoPath, instance, dbOptions = {}) => {
|
|
16
|
+
// Mongoose 8 handles connection options automatically
|
|
17
|
+
await mongoose_1.default.connect(mongoPath, dbOptions);
|
|
18
|
+
const { connection } = mongoose_1.default;
|
|
19
|
+
const state = results[connection.readyState] || 'Unknown';
|
|
20
|
+
instance.emit(Events_1.default.DATABASE_CONNECTED, connection, state);
|
|
21
|
+
};
|
|
22
|
+
const getMongoConnection = () => {
|
|
23
|
+
return mongoose_1.default.connection;
|
|
24
|
+
};
|
|
25
|
+
exports.getMongoConnection = getMongoConnection;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PermissionsBitField = exports.permissionList = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
Object.defineProperty(exports, "PermissionsBitField", { enumerable: true, get: function () { return discord_js_1.PermissionsBitField; } });
|
|
6
|
+
const permissionList = [
|
|
7
|
+
'CreateInstantInvite',
|
|
8
|
+
'KickMembers',
|
|
9
|
+
'BanMembers',
|
|
10
|
+
'Administrator',
|
|
11
|
+
'ManageChannels',
|
|
12
|
+
'ManageGuild',
|
|
13
|
+
'AddReactions',
|
|
14
|
+
'ViewAuditLog',
|
|
15
|
+
'PrioritySpeaker',
|
|
16
|
+
'Stream',
|
|
17
|
+
'ViewChannel',
|
|
18
|
+
'SendMessages',
|
|
19
|
+
'SendTTSMessages',
|
|
20
|
+
'ManageMessages',
|
|
21
|
+
'EmbedLinks',
|
|
22
|
+
'AttachFiles',
|
|
23
|
+
'ReadMessageHistory',
|
|
24
|
+
'MentionEveryone',
|
|
25
|
+
'UseExternalEmojis',
|
|
26
|
+
'ViewGuildInsights',
|
|
27
|
+
'Connect',
|
|
28
|
+
'Speak',
|
|
29
|
+
'MuteMembers',
|
|
30
|
+
'DeafenMembers',
|
|
31
|
+
'MoveMembers',
|
|
32
|
+
'UseVAD',
|
|
33
|
+
'ChangeNickname',
|
|
34
|
+
'ManageNicknames',
|
|
35
|
+
'ManageRoles',
|
|
36
|
+
'ManageWebhooks',
|
|
37
|
+
'ManageEmojisAndStickers',
|
|
38
|
+
];
|
|
39
|
+
exports.permissionList = permissionList;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComponentUtils = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
/**
|
|
6
|
+
* Utility class for building Discord components with simplified API
|
|
7
|
+
*/
|
|
8
|
+
class ComponentUtils {
|
|
9
|
+
/**
|
|
10
|
+
* Create a button component
|
|
11
|
+
*/
|
|
12
|
+
static createButton(customId, label, style = discord_js_1.ButtonStyle.Primary, options) {
|
|
13
|
+
const button = new discord_js_1.ButtonBuilder().setCustomId(customId).setLabel(label);
|
|
14
|
+
if (options?.url) {
|
|
15
|
+
button.setStyle(discord_js_1.ButtonStyle.Link).setURL(options.url);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
button.setStyle(style);
|
|
19
|
+
}
|
|
20
|
+
if (options?.emoji) {
|
|
21
|
+
button.setEmoji(options.emoji);
|
|
22
|
+
}
|
|
23
|
+
if (options?.disabled) {
|
|
24
|
+
button.setDisabled(true);
|
|
25
|
+
}
|
|
26
|
+
return button;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a string select menu
|
|
30
|
+
*/
|
|
31
|
+
static createStringSelect(customId, placeholder, options) {
|
|
32
|
+
const select = new discord_js_1.StringSelectMenuBuilder()
|
|
33
|
+
.setCustomId(customId)
|
|
34
|
+
.setPlaceholder(placeholder)
|
|
35
|
+
.addOptions(options);
|
|
36
|
+
return select;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a user select menu
|
|
40
|
+
*/
|
|
41
|
+
static createUserSelect(customId, placeholder, options) {
|
|
42
|
+
const select = new discord_js_1.UserSelectMenuBuilder()
|
|
43
|
+
.setCustomId(customId)
|
|
44
|
+
.setPlaceholder(placeholder);
|
|
45
|
+
if (options?.minValues)
|
|
46
|
+
select.setMinValues(options.minValues);
|
|
47
|
+
if (options?.maxValues)
|
|
48
|
+
select.setMaxValues(options.maxValues);
|
|
49
|
+
if (options?.disabled)
|
|
50
|
+
select.setDisabled(true);
|
|
51
|
+
return select;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create a role select menu
|
|
55
|
+
*/
|
|
56
|
+
static createRoleSelect(customId, placeholder, options) {
|
|
57
|
+
const select = new discord_js_1.RoleSelectMenuBuilder()
|
|
58
|
+
.setCustomId(customId)
|
|
59
|
+
.setPlaceholder(placeholder);
|
|
60
|
+
if (options?.minValues)
|
|
61
|
+
select.setMinValues(options.minValues);
|
|
62
|
+
if (options?.maxValues)
|
|
63
|
+
select.setMaxValues(options.maxValues);
|
|
64
|
+
if (options?.disabled)
|
|
65
|
+
select.setDisabled(true);
|
|
66
|
+
return select;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a channel select menu
|
|
70
|
+
*/
|
|
71
|
+
static createChannelSelect(customId, placeholder, options) {
|
|
72
|
+
const select = new discord_js_1.ChannelSelectMenuBuilder()
|
|
73
|
+
.setCustomId(customId)
|
|
74
|
+
.setPlaceholder(placeholder);
|
|
75
|
+
if (options?.minValues)
|
|
76
|
+
select.setMinValues(options.minValues);
|
|
77
|
+
if (options?.maxValues)
|
|
78
|
+
select.setMaxValues(options.maxValues);
|
|
79
|
+
if (options?.disabled)
|
|
80
|
+
select.setDisabled(true);
|
|
81
|
+
if (options?.channelTypes)
|
|
82
|
+
select.setChannelTypes(options.channelTypes);
|
|
83
|
+
return select;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Create a mentionable select menu (users and roles)
|
|
87
|
+
*/
|
|
88
|
+
static createMentionableSelect(customId, placeholder, options) {
|
|
89
|
+
const select = new discord_js_1.MentionableSelectMenuBuilder()
|
|
90
|
+
.setCustomId(customId)
|
|
91
|
+
.setPlaceholder(placeholder);
|
|
92
|
+
if (options?.minValues)
|
|
93
|
+
select.setMinValues(options.minValues);
|
|
94
|
+
if (options?.maxValues)
|
|
95
|
+
select.setMaxValues(options.maxValues);
|
|
96
|
+
if (options?.disabled)
|
|
97
|
+
select.setDisabled(true);
|
|
98
|
+
return select;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create an action row with components
|
|
102
|
+
*/
|
|
103
|
+
static createActionRow(...components) {
|
|
104
|
+
return new discord_js_1.ActionRowBuilder().addComponents(...components);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create a modal
|
|
108
|
+
*/
|
|
109
|
+
static createModal(customId, title, ...components) {
|
|
110
|
+
return new discord_js_1.ModalBuilder()
|
|
111
|
+
.setCustomId(customId)
|
|
112
|
+
.setTitle(title)
|
|
113
|
+
.addComponents(...components);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Create a text input for modals
|
|
117
|
+
*/
|
|
118
|
+
static createTextInput(customId, label, style = discord_js_1.TextInputStyle.Short, options) {
|
|
119
|
+
const input = new discord_js_1.TextInputBuilder()
|
|
120
|
+
.setCustomId(customId)
|
|
121
|
+
.setLabel(label)
|
|
122
|
+
.setStyle(style);
|
|
123
|
+
if (options?.placeholder)
|
|
124
|
+
input.setPlaceholder(options.placeholder);
|
|
125
|
+
if (options?.required !== undefined)
|
|
126
|
+
input.setRequired(options.required);
|
|
127
|
+
if (options?.minLength)
|
|
128
|
+
input.setMinLength(options.minLength);
|
|
129
|
+
if (options?.maxLength)
|
|
130
|
+
input.setMaxLength(options.maxLength);
|
|
131
|
+
if (options?.value)
|
|
132
|
+
input.setValue(options.value);
|
|
133
|
+
return input;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Create a text input wrapped in an action row (for modals)
|
|
137
|
+
*/
|
|
138
|
+
static createTextInputRow(customId, label, style = discord_js_1.TextInputStyle.Short, options) {
|
|
139
|
+
const input = this.createTextInput(customId, label, style, options);
|
|
140
|
+
return new discord_js_1.ActionRowBuilder().addComponents(input);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.ComponentUtils = ComponentUtils;
|
|
144
|
+
exports.default = ComponentUtils;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InteractionCollectorUtils = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
/**
|
|
6
|
+
* Utility functions for creating interaction collectors
|
|
7
|
+
*/
|
|
8
|
+
class InteractionCollectorUtils {
|
|
9
|
+
/**
|
|
10
|
+
* Create a button collector for a message
|
|
11
|
+
*/
|
|
12
|
+
static createButtonCollector(message, filter, options) {
|
|
13
|
+
const collector = message.createMessageComponentCollector({
|
|
14
|
+
componentType: discord_js_1.ComponentType.Button,
|
|
15
|
+
filter: filter,
|
|
16
|
+
...options,
|
|
17
|
+
});
|
|
18
|
+
return collector;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a select menu collector for a message
|
|
22
|
+
*/
|
|
23
|
+
static createSelectMenuCollector(message, filter, options) {
|
|
24
|
+
const collector = message.createMessageComponentCollector({
|
|
25
|
+
componentType: discord_js_1.ComponentType.StringSelect,
|
|
26
|
+
filter: filter,
|
|
27
|
+
...options,
|
|
28
|
+
});
|
|
29
|
+
return collector;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Wait for a button click
|
|
33
|
+
*/
|
|
34
|
+
static async awaitButton(message, filter, time = 60000) {
|
|
35
|
+
try {
|
|
36
|
+
const interaction = await message.awaitMessageComponent({
|
|
37
|
+
componentType: discord_js_1.ComponentType.Button,
|
|
38
|
+
filter,
|
|
39
|
+
time,
|
|
40
|
+
});
|
|
41
|
+
return interaction;
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Wait for a select menu selection
|
|
49
|
+
*/
|
|
50
|
+
static async awaitSelectMenu(message, filter, time = 60000) {
|
|
51
|
+
try {
|
|
52
|
+
const interaction = await message.awaitMessageComponent({
|
|
53
|
+
componentType: discord_js_1.ComponentType.StringSelect,
|
|
54
|
+
filter,
|
|
55
|
+
time,
|
|
56
|
+
});
|
|
57
|
+
return interaction;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Wait for any component interaction
|
|
65
|
+
*/
|
|
66
|
+
static async awaitComponent(message, filter, time = 60000) {
|
|
67
|
+
try {
|
|
68
|
+
const interaction = await message.awaitMessageComponent({
|
|
69
|
+
filter,
|
|
70
|
+
time,
|
|
71
|
+
});
|
|
72
|
+
return interaction;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.InteractionCollectorUtils = InteractionCollectorUtils;
|
|
80
|
+
exports.default = InteractionCollectorUtils;
|