djs-builder 0.1.1 → 0.1.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/README.md CHANGED
@@ -34,7 +34,7 @@ const client = new Client({
34
34
  });
35
35
 
36
36
  // Define starter options
37
- const starterOptions: StarterOptions = {
37
+ const starterOptions = {
38
38
  bot: {
39
39
  token: 'YOUR_BOT_TOKEN', // [OPTIONAL] Discord bot token
40
40
  logs: {
@@ -50,7 +50,7 @@ const starterOptions: StarterOptions = {
50
50
  avatar: 'https://your.bot/avatar.png', // [OPTIONAL] Bot avatar URL or local path image
51
51
  banner: 'https://your.bot/banner.png', // [OPTIONAL] Bot banner URL or local path image
52
52
  BotInfo: {
53
- perms: ['SEND_MESSAGES', 'READ_MESSAGES'], // [OPTIONAL] Bot permissions
53
+ perms: ['SendMessages', 'BotMessages'], // [OPTIONAL] Bot permissions to work in any server
54
54
  serverId: '123456789012345678', // [OPTIONAL] Discord server ID
55
55
  botInvite: 'https://discord.com/invite/your-bot-invite', // [OPTIONAL] Bot invite URL
56
56
  serverInvite: 'https://discord.com/invite/your-server-invite', // [OPTIONAL] Server invite URL
@@ -97,9 +97,7 @@ const starterOptions: StarterOptions = {
97
97
  events: {
98
98
  path: '/path/to/events', // Required: Path to event handlers
99
99
  baseDir: __dirname, // Required: Base directory
100
- logsId: '123456789012345678', // [OPTIONAL] Logs channel ID
101
100
  recursive: true, // [OPTIONAL] Enable recursive event loading
102
- autoLoad: true, // [OPTIONAL] Automatically load events
103
101
  eventBlacklist: ['blacklistedEvent1', 'blacklistedEvent2'] // [OPTIONAL] Blacklisted events
104
102
  },
105
103
  anticrash: {
@@ -249,3 +247,5 @@ perms.checker(userId, guild, permToCheck)
249
247
 
250
248
  ## Contributions
251
249
  Contributions are welcome! If you have any suggestions, bug reports, or feature requests, feel free to contact us on discord.
250
+
251
+ [![Discord Banner](https://api.weblutions.com/discord/invite/CS2NRSPyze/)](https://discord.gg/CS2NRSPyze)
@@ -1,4 +1,4 @@
1
- import { Client, Message, Collection, EmbedBuilder, TextChannel } from 'discord.js';
1
+ import { Client, Message, Collection, EmbedBuilder, TextChannel, PermissionResolvable } from 'discord.js';
2
2
  import { commands, aliases } from './prefix-register';
3
3
  import { PrefixOptions } from '../types/utils';
4
4
  import { getSimilarCommands } from '../functions/utils'
@@ -8,6 +8,34 @@ const cooldowns: Collection<string, Collection<string, number>> = new Collection
8
8
 
9
9
  async function handleMessageCreate(message: Message, prefix: PrefixOptions): Promise<void> {
10
10
  const botPrefix = prefix.prefix || '!';
11
+
12
+ if (message.guild?.members.me) {
13
+ const user = message.author;
14
+ const botData = new Collection<string, string | string[]>();
15
+ const permissionsArray = botData.get('permissions') as string[] | undefined;
16
+
17
+ if (!message.guild.members.me.permissions.has('SendMessages')) {
18
+ try {
19
+ user.send({ content:"I'm sorry, but I don't have permission to send messages in this server."});
20
+ } catch (error) {
21
+ return;
22
+ }
23
+ }
24
+
25
+ if (permissionsArray && permissionsArray.length > 0) {
26
+ const missingPermissions = permissionsArray.filter(permission => !message.guild?.members.me?.permissions.has(permission as PermissionResolvable));
27
+
28
+ if (missingPermissions.length > 0) {
29
+ try {
30
+ user.send({ content:`I'm sorry, but I don't have permission(s): ${missingPermissions.join(', ')} in this server.`});
31
+ } catch (error) {
32
+ return;
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+
11
39
  if (!message.content.startsWith(botPrefix) || message.author.bot) return;
12
40
 
13
41
  if (prefix.global === false && prefix.serverIds && prefix.serverIds.length > 0) {
@@ -1,4 +1,4 @@
1
- import { Client, Collection, Interaction, EmbedBuilder, Snowflake } from 'discord.js';
1
+ import { Client, Collection, Interaction, EmbedBuilder, Snowflake, PermissionResolvable } from 'discord.js';
2
2
  import { registerSlashCommands } from './slash-register';
3
3
  import { SlashOptions } from '../types/starter';
4
4
 
@@ -17,6 +17,32 @@ export async function loadSlash(client: Client, token: string, options: SlashOpt
17
17
  return;
18
18
  }
19
19
 
20
+ if (interaction.guild?.members.me) {
21
+ const user = interaction.user;
22
+ const botData = new Collection<string, string | string[]>();
23
+ const permissionsArray = botData.get('permissions') as string[] | undefined;
24
+
25
+ if (!interaction.guild.members.me.permissions.has('SendMessages')) {
26
+ try {
27
+ user.send({ content: "I'm sorry, but I don't have permission to send messages in this server."});
28
+ } catch (error) {
29
+ return;
30
+ }
31
+ }
32
+
33
+ if (permissionsArray && permissionsArray.length > 0) {
34
+ const missingPermissions = permissionsArray.filter(permission => !interaction.guild?.members.me?.permissions.has(permission as PermissionResolvable));
35
+
36
+ if (missingPermissions.length > 0) {
37
+ try {
38
+ user.send({ content:`I'm sorry, but I don't have permission(s): ${missingPermissions.join(', ')} in this server.`});
39
+ } catch (error) {
40
+ return;
41
+ }
42
+ }
43
+ }
44
+ }
45
+
20
46
  const command = slashCommands.get(interaction.commandName);
21
47
  if (!command) return;
22
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "djs-builder",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Discord.js bot builder. Supports Ts and Js.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",