xernerx 3.3.0 → 3.3.1

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
@@ -11,7 +11,7 @@ Xernerx is a class based discord.js framework. \[BETA\]
11
11
  > - Inhibitor handler
12
12
  > - Custom utilities
13
13
  > - Message command handles
14
- > - Webhook handler for Top.gg
14
+ > - Extension support
15
15
 
16
16
  You can checkout the docs [here](https://thedummi.github.io/xernerx/home.html)
17
17
 
@@ -1,6 +1,6 @@
1
- import Discord, { ChannelType, Interaction } from "discord.js";
2
- import { XernerxClient } from "../main.js";
3
- import { SlashCommandOptions } from "../types/options.js";
1
+ import Discord, { ChannelType, Interaction } from 'discord.js';
2
+ import { XernerxClient } from '../main.js';
3
+ import { SlashCommandOptions } from '../types/options.js';
4
4
  /**
5
5
  * @description - The command builder for slash commands.
6
6
  * @param {String} id - The unique ID of the command.
@@ -1,7 +1,7 @@
1
- import Discord, { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, } from "discord.js";
2
- import { s } from "@sapphire/shapeshift";
3
- import { XernerxClient } from "../main.js";
4
- import XernerxError from "../tools/XernerxError.js";
1
+ import Discord, { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from 'discord.js';
2
+ import { s } from '@sapphire/shapeshift';
3
+ import { XernerxClient } from '../main.js';
4
+ import XernerxError from '../tools/XernerxError.js';
5
5
  /**
6
6
  * @description - The command builder for slash commands.
7
7
  * @param {String} id - The unique ID of the command.
@@ -28,9 +28,7 @@ export default class SlashCommandBuilder {
28
28
  client;
29
29
  constructor(id, options) {
30
30
  this.id = id;
31
- this.data = new Discord.SlashCommandBuilder()
32
- .setName(options.name)
33
- .setDescription(options.description);
31
+ this.data = new Discord.SlashCommandBuilder().setName(options.name).setDescription(options.description);
34
32
  if (options.args && options?.args?.length > 0) {
35
33
  this.#addArgs(this.data, options.args);
36
34
  }
@@ -77,21 +75,12 @@ export default class SlashCommandBuilder {
77
75
  async conditions(interaction) { }
78
76
  async exec(interaction) { }
79
77
  #addArgs(command, args) {
80
- const types = [
81
- "boolean",
82
- "integer",
83
- "number",
84
- "string",
85
- "user",
86
- "role",
87
- "channel",
88
- "mentionable",
89
- ];
78
+ const types = ['boolean', 'integer', 'number', 'string', 'user', 'role', 'channel', 'mentionable'];
90
79
  for (const argument of args) {
91
80
  if (!types.includes(argument.type.toLowerCase()))
92
- throw new XernerxError(`Expected one of ${types.join(", ")}, received ${argument.type} instead.`);
81
+ throw new XernerxError(`Expected one of ${types.join(', ')}, received ${argument.type} instead.`);
93
82
  let slashArgumentType = `${argument.type.slice(0, 1).toUpperCase()}${argument.type.slice(1).toLowerCase()}`;
94
- command[(`add${slashArgumentType}Option`)]((option) => {
83
+ command[`add${slashArgumentType}Option`]((option) => {
95
84
  option
96
85
  .setName(argument.name)
97
86
  .setDescription(argument.description)
@@ -104,9 +93,7 @@ export default class SlashCommandBuilder {
104
93
  }
105
94
  #addSubcommands(method, subcommands) {
106
95
  for (const subcommand of subcommands) {
107
- let sub = new SlashCommandSubcommandBuilder()
108
- .setName(subcommand.name)
109
- .setDescription(subcommand.description);
96
+ let sub = new SlashCommandSubcommandBuilder().setName(subcommand.name).setDescription(subcommand.description);
110
97
  if (subcommand.args?.length > 0)
111
98
  this.#addArgs(sub, subcommand.args);
112
99
  method.addSubcommand(sub);
@@ -114,9 +101,7 @@ export default class SlashCommandBuilder {
114
101
  }
115
102
  #addSubcommandGroups(groups) {
116
103
  for (const group of groups) {
117
- let subcommandGroup = new SlashCommandSubcommandGroupBuilder()
118
- .setName(group.name)
119
- .setDescription(group.description);
104
+ let subcommandGroup = new SlashCommandSubcommandGroupBuilder().setName(group.name).setDescription(group.description);
120
105
  if (group.subcommands?.length > 0)
121
106
  this.#addSubcommands(subcommandGroup, group.subcommands);
122
107
  this.data.addSubcommandGroup(subcommandGroup);
@@ -1,10 +1,10 @@
1
- import { Client, Collection } from "discord.js";
2
- import { ClientUtil } from "../utils/ClientUtil.js";
3
- import { ClientOptions, DiscordOptions, ExtensionOptions, HandlerOptions } from "../types/options.js";
4
- import { ClientCache, ClientCommands, ClientModules } from "../types/interfaces.js";
5
- import EventBuilder from "../build/EventBuilder.js";
6
- import ExtensionBuilder from "../build/ExtensionBuilder.js";
7
- import InhibitorBuilder from "../build/InhibitorBuilder.js";
1
+ import { Client, Collection } from 'discord.js';
2
+ import { ClientUtil } from '../utils/ClientUtil.js';
3
+ import { ClientOptions, DiscordOptions, ExtensionOptions, HandlerOptions } from '../types/options.js';
4
+ import { ClientCache, ClientCommands, ClientModules } from '../types/interfaces.js';
5
+ import EventBuilder from '../build/EventBuilder.js';
6
+ import ExtensionBuilder from '../build/ExtensionBuilder.js';
7
+ import InhibitorBuilder from '../build/InhibitorBuilder.js';
8
8
  /**
9
9
  * @description - The Client.
10
10
  * @param {DiscordOptions} discordOptions - The options for discord.js.
@@ -1,11 +1,11 @@
1
- import { Client, Collection } from "discord.js";
2
- import { s } from "@sapphire/shapeshift";
3
- import CommandHandler from "../handlers/CommandHandler.js";
4
- import EventHandler from "../handlers/EventHandler.js";
5
- import InhibitorHandler from "../handlers/InhibitorHandler.js";
6
- import { ClientUtil } from "../utils/ClientUtil.js";
7
- import { Style } from "dumfunctions";
8
- import Extensions from "../models/Extensions.js";
1
+ import { Client, Collection } from 'discord.js';
2
+ import { s } from '@sapphire/shapeshift';
3
+ import CommandHandler from '../handlers/CommandHandler.js';
4
+ import EventHandler from '../handlers/EventHandler.js';
5
+ import InhibitorHandler from '../handlers/InhibitorHandler.js';
6
+ import { ClientUtil } from '../utils/ClientUtil.js';
7
+ import { Style } from 'dumfunctions';
8
+ import Extensions from '../models/Extensions.js';
9
9
  /**
10
10
  * @description - The Client.
11
11
  * @param {DiscordOptions} discordOptions - The options for discord.js.
@@ -63,9 +63,11 @@ export default class XernerxClient extends Client {
63
63
  this.util = new ClientUtil(this);
64
64
  this.handlerOptions = {};
65
65
  if (this.settings.logging) {
66
- this.once("ready", async (client) => {
66
+ this.once('ready', async (client) => {
67
67
  const size = (await client.guilds.fetch()).size;
68
- console.info(Style.log(`Xernerx | ${client.user.tag} signed in watching ${size} server${size > 1 ? "s" : ""}. ${(this.handlerOptions.slash || this.handlerOptions.context)?.guildId ? `Using ${(await this.guilds.fetch((this.handlerOptions.slash || this.handlerOptions.context)?.guildId || "0")).name} as local guild.` : ""}`, { color: Style.TextColor.Purple }));
68
+ console.info(Style.log(`Xernerx | ${client.user.tag} signed in watching ${size} server${size > 1 ? 's' : ''}. ${(this.handlerOptions.slash || this.handlerOptions.context)?.guildId
69
+ ? `Using ${(await this.guilds.fetch((this.handlerOptions.slash || this.handlerOptions.context)?.guildId || '0')).name} as local guild.`
70
+ : ''}`, { color: Style.TextColor.Purple }));
69
71
  });
70
72
  }
71
73
  this.register = this.register;
@@ -1,6 +1,6 @@
1
- import XernerxClient from "../client/XernerxClient.js";
2
- import { InhibitorHandlerOptions } from "../types/options.js";
3
- import { Handler } from "./Handler.js";
1
+ import XernerxClient from '../client/XernerxClient.js';
2
+ import { InhibitorHandlerOptions } from '../types/options.js';
3
+ import { Handler } from './Handler.js';
4
4
  /**
5
5
  * @description - Inhibitor loader.
6
6
  * @param {XernerxClient} client - The XernerxClient.
@@ -1,4 +1,4 @@
1
- import { Handler } from "./Handler.js";
1
+ import { Handler } from './Handler.js';
2
2
  /**
3
3
  * @description - Inhibitor loader.
4
4
  * @param {XernerxClient} client - The XernerxClient.
package/dist/main.d.ts CHANGED
@@ -1,13 +1,14 @@
1
- import Discord from "discord.js";
2
- import DumFunctions from "dumfunctions";
3
- import XernerxClient from "./client/XernerxClient.js";
4
- import EventBuilder from "./build/EventBuilder.js";
5
- import InhibitorBuilder from "./build/InhibitorBuilder.js";
6
- import MessageCommandBuilder from "./build/MessageCommandBuilder.js";
7
- import ContextCommandBuilder from "./build/ContextCommandBuilder.js";
8
- import SlashCommandBuilder from "./build/SlashCommandBuilder.js";
9
- import { CommandType, EventEmitterType, ContextCommandType, InhibitorType } from "./types/enums.js";
10
- import ExtensionBuilder from "./build/ExtensionBuilder.js";
1
+ import Discord from 'discord.js';
2
+ import DumFunctions from 'dumfunctions';
3
+ import XernerxClient from './client/XernerxClient.js';
4
+ import EventBuilder from './build/EventBuilder.js';
5
+ import InhibitorBuilder from './build/InhibitorBuilder.js';
6
+ import MessageCommandBuilder from './build/MessageCommandBuilder.js';
7
+ import ContextCommandBuilder from './build/ContextCommandBuilder.js';
8
+ import SlashCommandBuilder from './build/SlashCommandBuilder.js';
9
+ import { CommandType, EventEmitterType, ContextCommandType, InhibitorType } from './types/enums.js';
10
+ import XernerxError from './tools/XernerxError.js';
11
+ import ExtensionBuilder from './build/ExtensionBuilder.js';
11
12
  declare const version: string;
12
13
  declare const _default: {
13
14
  Discord: typeof Discord;
@@ -88,7 +89,8 @@ declare const _default: {
88
89
  SlashCommandBuilder: typeof SlashCommandBuilder;
89
90
  InhibitorBuilder: typeof InhibitorBuilder;
90
91
  ExtensionBuilder: typeof ExtensionBuilder;
92
+ XernerxError: typeof XernerxError;
91
93
  version: string;
92
94
  };
93
95
  export default _default;
94
- export { Discord, DumFunctions, XernerxClient, CommandType, EventEmitterType, InhibitorType, ContextCommandType, EventBuilder, MessageCommandBuilder, ContextCommandBuilder, SlashCommandBuilder, InhibitorBuilder, ExtensionBuilder, version, };
96
+ export { Discord, DumFunctions, XernerxClient, CommandType, EventEmitterType, InhibitorType, ContextCommandType, EventBuilder, MessageCommandBuilder, ContextCommandBuilder, SlashCommandBuilder, InhibitorBuilder, ExtensionBuilder, XernerxError, version, };
package/dist/main.js CHANGED
@@ -1,14 +1,15 @@
1
- import Discord from "discord.js";
2
- import DumFunctions from "dumfunctions";
3
- import XernerxClient from "./client/XernerxClient.js";
4
- import EventBuilder from "./build/EventBuilder.js";
5
- import InhibitorBuilder from "./build/InhibitorBuilder.js";
6
- import MessageCommandBuilder from "./build/MessageCommandBuilder.js";
7
- import ContextCommandBuilder from "./build/ContextCommandBuilder.js";
8
- import SlashCommandBuilder from "./build/SlashCommandBuilder.js";
9
- import { CommandType, EventEmitterType, ContextCommandType, InhibitorType } from "./types/enums.js";
10
- import ExtensionBuilder from "./build/ExtensionBuilder.js";
11
- import pkg from "../package.js";
1
+ import Discord from 'discord.js';
2
+ import DumFunctions from 'dumfunctions';
3
+ import XernerxClient from './client/XernerxClient.js';
4
+ import EventBuilder from './build/EventBuilder.js';
5
+ import InhibitorBuilder from './build/InhibitorBuilder.js';
6
+ import MessageCommandBuilder from './build/MessageCommandBuilder.js';
7
+ import ContextCommandBuilder from './build/ContextCommandBuilder.js';
8
+ import SlashCommandBuilder from './build/SlashCommandBuilder.js';
9
+ import { CommandType, EventEmitterType, ContextCommandType, InhibitorType } from './types/enums.js';
10
+ import XernerxError from './tools/XernerxError.js';
11
+ import ExtensionBuilder from './build/ExtensionBuilder.js';
12
+ import pkg from '../package.js';
12
13
  const version = pkg.version;
13
14
  export default {
14
15
  // Imported methods
@@ -29,6 +30,7 @@ export default {
29
30
  SlashCommandBuilder,
30
31
  InhibitorBuilder,
31
32
  ExtensionBuilder,
33
+ XernerxError,
32
34
  // Constants
33
35
  version,
34
36
  };
@@ -40,6 +42,6 @@ XernerxClient,
40
42
  // Enums
41
43
  CommandType, EventEmitterType, InhibitorType, ContextCommandType,
42
44
  // Builds
43
- EventBuilder, MessageCommandBuilder, ContextCommandBuilder, SlashCommandBuilder, InhibitorBuilder, ExtensionBuilder,
45
+ EventBuilder, MessageCommandBuilder, ContextCommandBuilder, SlashCommandBuilder, InhibitorBuilder, ExtensionBuilder, XernerxError,
44
46
  // Constants
45
47
  version, };
@@ -1,5 +1,5 @@
1
- import { MessageCommandBuilder } from "../main.js";
2
- import { XernerxInteraction, XernerxMessage } from "../types/types.js";
1
+ import { MessageCommandBuilder } from '../main.js';
2
+ import { XernerxInteraction, XernerxMessage } from '../types/types.js';
3
3
  export declare class InteractionArguments {
4
4
  interaction: XernerxInteraction;
5
5
  constructor(interaction: XernerxInteraction);
@@ -13,24 +13,23 @@ export class InteractionArguments {
13
13
  const options = {};
14
14
  if (this.interaction?.options?._hoistedOptions) {
15
15
  for (const option of this.interaction.options._hoistedOptions) {
16
- options[option.name] =
17
- option.channel || option.user || option.role || option.value;
16
+ options[option.name] = option.channel || option.user || option.role || option.value;
18
17
  }
19
18
  }
20
19
  return options;
21
20
  }
22
21
  }
23
22
  export async function messageArguments(message, command) {
24
- let args = { flags: {} }, separator = command.separator || " ", i = 0;
23
+ let args = { flags: {} }, separator = command.separator || ' ', i = 0;
25
24
  if (!command.args)
26
25
  return;
27
26
  command.args
28
- .filter((c) => c.type == "flag")
27
+ .filter((c) => c.type == 'flag')
29
28
  .map((flag) => {
30
29
  args = args;
31
30
  for (const flg of message.content.matchAll(flag.content)) {
32
31
  if (flag.content == flg) {
33
- message.content = message.content.replace(flag.content, "");
32
+ message.content = message.content.replace(flag.content, '');
34
33
  args.flags[flag.name] = true;
35
34
  }
36
35
  }
@@ -43,65 +42,65 @@ export async function messageArguments(message, command) {
43
42
  .split(/ +/)
44
43
  .slice(1)
45
44
  .join(separator)
46
- .replace(new RegExp(`${separator}${separator}+`, "g"), separator)
45
+ .replace(new RegExp(`${separator}${separator}+`, 'g'), separator)
47
46
  .split(separator)
48
47
  .slice(i);
49
- if (content.join(separator) != "" && argument.type !== "flag") {
48
+ if (content.join(separator) != '' && argument.type !== 'flag') {
50
49
  if (argument?.content?.includes(content[0])) {
51
50
  args[argument.name] = content[0];
52
51
  }
53
- else if (argument.type == "string") {
52
+ else if (argument.type == 'string') {
54
53
  args[argument.name] = content[0];
55
54
  }
56
- else if (argument.type == "number") {
55
+ else if (argument.type == 'number') {
57
56
  args[argument.name] = parseInt(content[0]);
58
57
  }
59
- else if (argument.type == "boolean") {
60
- if (content[0]?.toLowerCase() != "true" && content[0]?.toLowerCase() != "false")
58
+ else if (argument.type == 'boolean') {
59
+ if (content[0]?.toLowerCase() != 'true' && content[0]?.toLowerCase() != 'false')
61
60
  content[0] = null;
62
61
  args[argument.name] = content[0];
63
62
  }
64
- else if (argument.type == "user") {
63
+ else if (argument.type == 'user') {
65
64
  let user = message.client.users.cache.find((u) => u?.username?.toLowerCase()?.includes(content[0])) || null;
66
65
  try {
67
- user = await message.client.users.fetch(user?.id || content[0].replace(/<@!?|>/g, "")) || null;
66
+ user = (await message.client.users.fetch(user?.id || content[0].replace(/<@!?|>/g, ''))) || null;
68
67
  }
69
68
  catch (e) {
70
69
  user = null;
71
70
  }
72
71
  args[argument.name] = user;
73
72
  }
74
- else if (argument.type == "role") {
73
+ else if (argument.type == 'role') {
75
74
  let role = message.guild?.roles.cache.find((r) => r?.name?.toLowerCase()?.includes(content[0])) || null;
76
75
  try {
77
- role = await message.guild?.roles.fetch(role?.id || content[0].replace(/<@&?|>/g, "")) || null;
76
+ role = (await message.guild?.roles.fetch(role?.id || content[0].replace(/<@&?|>/g, ''))) || null;
78
77
  }
79
78
  catch (e) {
80
79
  role = null;
81
80
  }
82
81
  args[argument.name] = role;
83
82
  }
84
- else if (argument.type == "member") {
83
+ else if (argument.type == 'member') {
85
84
  let member = message.guild?.members.cache.find((m) => m?.nickname?.toLowerCase()?.includes(content[0]) || m?.user?.username?.toLowerCase()?.includes(content[0])) || null;
86
85
  try {
87
- member = await message.guild?.members.fetch(member?.id || content[0].replace(/<@!?|>/g, "")) || null;
86
+ member = (await message.guild?.members.fetch(member?.id || content[0].replace(/<@!?|>/g, ''))) || null;
88
87
  }
89
88
  catch (e) {
90
89
  member = null;
91
90
  }
92
91
  args[argument.name] = member;
93
92
  }
94
- else if (argument.type == "channel") {
93
+ else if (argument.type == 'channel') {
95
94
  let channel = message.guild?.channels.cache.find((c) => c?.name?.toLowerCase()?.includes(content[0]));
96
95
  try {
97
- channel = await message.client.channels.fetch(channel?.id || content[0].replace(/<#|>/g, ""));
96
+ channel = await message.client.channels.fetch(channel?.id || content[0].replace(/<#|>/g, ''));
98
97
  }
99
98
  catch (e) {
100
99
  channel = null;
101
100
  }
102
101
  args[argument.name] = channel;
103
102
  }
104
- else if (argument.type == "rest") {
103
+ else if (argument.type == 'rest') {
105
104
  args[argument.name] = content.join(separator);
106
105
  break;
107
106
  }
@@ -112,11 +111,11 @@ export async function messageArguments(message, command) {
112
111
  return message.channel.send(argument.prompt.send);
113
112
  }
114
113
  else
115
- args[argument.name] = typeof argument.default == "function" ? argument.default(message) : argument.default;
114
+ args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
116
115
  i++;
117
116
  }
118
117
  else
119
- args[argument.name] = typeof argument.default == "function" ? argument.default(message) : argument.default;
118
+ args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
120
119
  }
121
120
  return args;
122
121
  }
@@ -2,7 +2,7 @@ export default class XernerxError {
2
2
  name;
3
3
  message;
4
4
  constructor(message) {
5
- this.name = "XernerxError";
6
- this.message = message || "";
5
+ this.name = 'XernerxError';
6
+ this.message = message || '';
7
7
  }
8
8
  }
@@ -1,5 +1,5 @@
1
- import { TextChannel, Message, User, Guild, GuildMember, Channel, Role, InteractionResponse } from "discord.js";
2
- import { InteractionCommandUtil, MessageCommandUtil } from "../utils/CommandUtil.js";
1
+ import { TextChannel, Message, User, Guild, GuildMember, Channel, Role, InteractionResponse } from 'discord.js';
2
+ import { InteractionCommandUtil, MessageCommandUtil } from '../utils/CommandUtil.js';
3
3
  export interface XernerxMessage extends Message {
4
4
  util?: MessageCommandUtil;
5
5
  response?: string;
@@ -29,4 +29,4 @@ export interface XernerxGuild extends Guild {
29
29
  }
30
30
  export interface XernerxMember extends GuildMember {
31
31
  }
32
- export type MessageCommandArgsTypes = "flag" | "string" | "number" | "channel" | "user" | "member" | "boolean" | "role";
32
+ export type MessageCommandArgsTypes = 'flag' | 'string' | 'number' | 'channel' | 'user' | 'member' | 'boolean' | 'role';
@@ -1,4 +1,4 @@
1
- import { SlashCommandStringOption, SlashCommandNumberOption, SlashCommandIntegerOption, SlashCommandBooleanOption, SlashCommandUserOption, SlashCommandChannelOption, SlashCommandRoleOption, SlashCommandMentionableOption } from "discord.js";
1
+ import { SlashCommandStringOption, SlashCommandNumberOption, SlashCommandIntegerOption, SlashCommandBooleanOption, SlashCommandUserOption, SlashCommandChannelOption, SlashCommandRoleOption, SlashCommandMentionableOption } from 'discord.js';
2
2
  export declare enum InhibitorType {
3
3
  Member = "Member",
4
4
  User = "User",
@@ -32,4 +32,4 @@ export declare enum EventEmitterType {
32
32
  }
33
33
  export type SlashCommandOptionChoices = SlashCommandStringOption | SlashCommandNumberOption | SlashCommandIntegerOption;
34
34
  export type SlashCommandOption = SlashCommandOptionChoices | SlashCommandBooleanOption | SlashCommandUserOption | SlashCommandChannelOption | SlashCommandRoleOption | SlashCommandMentionableOption;
35
- export type SlashArgumentTypes = "String" | "Number" | "Boolean" | "User" | "Channel" | "Role" | "Mentionable" | "Integer";
35
+ export type SlashArgumentTypes = 'String' | 'Number' | 'Boolean' | 'User' | 'Channel' | 'Role' | 'Mentionable' | 'Integer';
@@ -1,10 +1,10 @@
1
- import { Collection } from "discord.js";
2
- import CommandHandler from "../handlers/CommandHandler.js";
3
- import EventHandler from "../handlers/EventHandler.js";
4
- import InhibitorHandler from "../handlers/InhibitorHandler.js";
5
- import MessageCommandBuilder from "../build/MessageCommandBuilder.js";
6
- import ContextCommandBuilder from "../build/ContextCommandBuilder.js";
7
- import SlashCommandBuilder from "../build/SlashCommandBuilder.js";
1
+ import { Collection } from 'discord.js';
2
+ import CommandHandler from '../handlers/CommandHandler.js';
3
+ import EventHandler from '../handlers/EventHandler.js';
4
+ import InhibitorHandler from '../handlers/InhibitorHandler.js';
5
+ import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
6
+ import ContextCommandBuilder from '../build/ContextCommandBuilder.js';
7
+ import SlashCommandBuilder from '../build/SlashCommandBuilder.js';
8
8
  export interface ClientCommands {
9
9
  message: Collection<string, MessageCommandBuilder>;
10
10
  slash: Collection<string, SlashCommandBuilder>;
@@ -1,8 +1,8 @@
1
- import { CacheFactory, ChannelType, ContextMenuCommandType, MessageMentionOptions, Partials, PresenceData, RESTOptions, SweeperOptions, WebSocketOptions } from "discord.js";
2
- import { ContextCommandType, EventEmitterType, ExtensionBuilder, InhibitorType } from "../main.js";
3
- import { MessageCommandArgsTypes } from "./types.js";
1
+ import { CacheFactory, ChannelType, ContextMenuCommandType, MessageMentionOptions, Partials, PresenceData, RESTOptions, SweeperOptions, WebSocketOptions } from 'discord.js';
2
+ import { ContextCommandType, EventEmitterType, ExtensionBuilder, InhibitorType } from '../main.js';
3
+ import { MessageCommandArgsTypes } from './types.js';
4
4
  export interface DiscordOptions {
5
- shards?: number | number[] | "auto";
5
+ shards?: number | number[] | 'auto';
6
6
  closeTimeout?: number;
7
7
  shardCount?: number;
8
8
  makeCache?: CacheFactory;
@@ -76,10 +76,10 @@ export interface ContextCommandOptions {
76
76
  defaultMemberPermissions?: bigint | number | bigint | null | undefined;
77
77
  DMPermission?: undefined | null | boolean;
78
78
  nameLocalization?: {
79
- locale: "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi";
79
+ locale: 'en-US' | 'en-GB' | 'bg' | 'zh-CN' | 'zh-TW' | 'hr' | 'cs' | 'da' | 'nl' | 'fi' | 'fr' | 'de' | 'el' | 'hi' | 'hu' | 'it' | 'ja' | 'ko' | 'lt' | 'no' | 'pl' | 'pt-BR' | 'ro' | 'ru' | 'es-ES' | 'sv-SE' | 'th' | 'tr' | 'uk' | 'vi';
80
80
  localizedName: null | string;
81
81
  };
82
- nameLocalizations?: null | Partial<Record<"en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", null | string>>;
82
+ nameLocalizations?: null | Partial<Record<'en-US' | 'en-GB' | 'bg' | 'zh-CN' | 'zh-TW' | 'hr' | 'cs' | 'da' | 'nl' | 'fi' | 'fr' | 'de' | 'el' | 'hi' | 'hu' | 'it' | 'ja' | 'ko' | 'lt' | 'no' | 'pl' | 'pt-BR' | 'ro' | 'ru' | 'es-ES' | 'sv-SE' | 'th' | 'tr' | 'uk' | 'vi', null | string>>;
83
83
  commandType?: string;
84
84
  defer?: {
85
85
  reply?: boolean;
@@ -98,7 +98,7 @@ export interface MessageArgOptions {
98
98
  default: string | Function;
99
99
  }
100
100
  export interface SlashArgOptions {
101
- type: "string" | "number" | "boolean" | "user" | "channel" | "role" | "mentionable" | "integer";
101
+ type: 'string' | 'number' | 'boolean' | 'user' | 'channel' | 'role' | 'mentionable' | 'integer';
102
102
  name: string;
103
103
  choices: Array<{
104
104
  name: string;
@@ -1,5 +1,5 @@
1
- import { ActivityType, ClientPresenceStatus } from "discord.js";
2
- import XernerxClient from "../client/XernerxClient.js";
1
+ import { ActivityType, ClientPresenceStatus } from 'discord.js';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
3
  interface Presence {
4
4
  text?: string;
5
5
  type?: ActivityType.Playing | ActivityType.Streaming | ActivityType.Listening | ActivityType.Watching | ActivityType.Competing;
@@ -1,4 +1,4 @@
1
- import XernerxError from "../tools/XernerxError.js";
1
+ import XernerxError from '../tools/XernerxError.js';
2
2
  export class ClientUtil {
3
3
  client;
4
4
  constructor(client) {
@@ -39,7 +39,7 @@ export class ClientUtil {
39
39
  return `${seconds}s`;
40
40
  }
41
41
  getSubcommands(name) {
42
- if (!name || typeof name !== "string")
42
+ if (!name || typeof name !== 'string')
43
43
  throw new XernerxError(`Expected name to be of type string, received ${typeof name} instead!`);
44
44
  const commands = [];
45
45
  this.getAllCommands()
@@ -105,11 +105,11 @@ export class ClientUtil {
105
105
  }
106
106
  isOwner(userId) {
107
107
  if (!userId)
108
- throw new XernerxError("No ID specified");
108
+ throw new XernerxError('No ID specified');
109
109
  let owners = this.client.settings.ownerId;
110
110
  if (!owners)
111
111
  return false;
112
- if (typeof owners === "string")
112
+ if (typeof owners === 'string')
113
113
  owners = [owners];
114
114
  return owners.includes(userId);
115
115
  }
@@ -159,20 +159,14 @@ export class ClientUtil {
159
159
  getCooldowns(id, command) {
160
160
  let cooldowns = [];
161
161
  for (const [key, value] of Object.entries(this.client.cache)) {
162
- if (![
163
- "cooldowns",
164
- "messageCommands",
165
- "slashCommands",
166
- "contextCommands",
167
- "commands",
168
- ].includes(key))
162
+ if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key))
169
163
  continue;
170
- if (key === "commands") {
164
+ if (key === 'commands') {
171
165
  if (command) {
172
166
  value.map((x) => {
173
167
  const name = x.name.split(/-/);
174
168
  name.pop();
175
- if (name.join("-") === id + "-" + command) {
169
+ if (name.join('-') === id + '-' + command) {
176
170
  cooldowns.push(x);
177
171
  }
178
172
  });
@@ -197,20 +191,14 @@ export class ClientUtil {
197
191
  getCooldownTimers(id, command) {
198
192
  let cooldowns = [];
199
193
  for (const [key, value] of Object.entries(this.client.cache)) {
200
- if (![
201
- "cooldowns",
202
- "messageCommands",
203
- "slashCommands",
204
- "contextCommands",
205
- "commands",
206
- ].includes(key))
194
+ if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key))
207
195
  continue;
208
- if (key === "commands") {
196
+ if (key === 'commands') {
209
197
  if (command) {
210
198
  value.map((x) => {
211
199
  const name = x.name.split(/-/);
212
200
  name.pop();
213
- if (name.join("-") === id + "-" + command) {
201
+ if (name.join('-') === id + '-' + command) {
214
202
  cooldowns.push({ [x.commandName]: x.endsAt - Date.now() });
215
203
  }
216
204
  });
@@ -230,9 +218,7 @@ export class ClientUtil {
230
218
  }
231
219
  }
232
220
  }
233
- const sort = cooldowns
234
- .map((x) => Object.entries(x).shift())
235
- .sort((a, b) => b[1] - a[1]);
221
+ const sort = cooldowns.map((x) => Object.entries(x).shift()).sort((a, b) => b[1] - a[1]);
236
222
  cooldowns = [];
237
223
  sort.map(([key, value]) => cooldowns.push({ [key]: value }));
238
224
  return cooldowns;
@@ -1,6 +1,6 @@
1
- import { ActionRowBuilder, ButtonBuilder, EmbedBuilder, Interaction, Message, MessagePayload, StringSelectMenuBuilder } from "discord.js";
2
- import XernerxClient from "../client/XernerxClient.js";
3
- import { XernerxMessage } from "../types/types.js";
1
+ import { ActionRowBuilder, ButtonBuilder, EmbedBuilder, Interaction, Message, MessagePayload, StringSelectMenuBuilder } from 'discord.js';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ import { XernerxMessage } from '../types/types.js';
4
4
  interface SelectMenuOptions {
5
5
  index?: EmbedBuilder;
6
6
  row?: ActionRowBuilder;
@@ -1,5 +1,5 @@
1
- import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, StringSelectMenuBuilder, } from "discord.js";
2
- import XernerxError from "../tools/XernerxError.js";
1
+ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, StringSelectMenuBuilder } from 'discord.js';
2
+ import XernerxError from '../tools/XernerxError.js';
3
3
  export class MessageCommandUtil {
4
4
  client;
5
5
  message;
@@ -13,8 +13,7 @@ export class MessageCommandUtil {
13
13
  if (!existingMessage) {
14
14
  const msg = await this.message.reply(content);
15
15
  this.message.response = msg.id;
16
- if (this.client.handlerOptions.message?.handleEdits ||
17
- this.client.handlerOptions.message?.handleDeletes) {
16
+ if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
18
17
  this.client.cache.messages.set(this.message.id, this.message);
19
18
  setInterval(() => {
20
19
  this.client.cache.messages.delete(this.message.id);
@@ -31,8 +30,7 @@ export class MessageCommandUtil {
31
30
  catch {
32
31
  const msg = await this.message.reply(content);
33
32
  this.message.response = msg.id;
34
- if (this.client.handlerOptions.message?.handleEdits ||
35
- this.client.handlerOptions.message?.handleDeletes) {
33
+ if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
36
34
  this.client.cache.messages.set(this.message.id, this.message);
37
35
  setInterval(() => {
38
36
  this.client.cache.messages.delete(this.message.id);
@@ -47,8 +45,7 @@ export class MessageCommandUtil {
47
45
  if (!existingMessage) {
48
46
  const msg = await this.message.channel.send(content);
49
47
  this.message.response = msg.id;
50
- if (this.client.handlerOptions.message?.handleEdits ||
51
- this.client.handlerOptions.message?.handleDeletes) {
48
+ if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
52
49
  this.client.cache.messages.set(this.message.id, this.message);
53
50
  setInterval(() => {
54
51
  this.client.cache.messages.delete(this.message.id);
@@ -65,8 +62,7 @@ export class MessageCommandUtil {
65
62
  catch {
66
63
  const msg = await this.message.channel.send(content);
67
64
  this.message.response = msg.id;
68
- if (this.client.handlerOptions.message?.handleEdits ||
69
- this.client.handlerOptions.message?.handleDeletes) {
65
+ if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
70
66
  this.client.cache.messages.set(this.message.id, this.message);
71
67
  setInterval(() => {
72
68
  this.client.cache.messages.delete(this.message.id);
@@ -98,9 +94,7 @@ export class InteractionCommandUtil {
98
94
  this.interaction = interaction;
99
95
  }
100
96
  reply(content) {
101
- return this.interaction.replied || this.interaction.deferred
102
- ? this.interaction.editReply(content)
103
- : this.interaction.reply(content);
97
+ return this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content);
104
98
  }
105
99
  async defer(time) {
106
100
  return new Promise((resolve) => setTimeout(resolve, time));
@@ -117,17 +111,17 @@ export class InteractionCommandUtil {
117
111
  throw new XernerxError(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
118
112
  if (embeds.length > 25)
119
113
  throw new XernerxError(`Max select menu length is 25.`);
120
- if (typeof options !== "object")
114
+ if (typeof options !== 'object')
121
115
  options = {};
122
116
  if (!Array.isArray(options.components))
123
117
  options.components = [];
124
118
  if (!options.index) {
125
- options.index = new EmbedBuilder().setTitle("Index").setColor("Random");
119
+ options.index = new EmbedBuilder().setTitle('Index').setColor('Random');
126
120
  for (const embed of embeds) {
127
121
  options.index.addFields([
128
122
  {
129
- name: embed.data.title || "No Name",
130
- value: embed.data.description || "Page",
123
+ name: embed.data.title || 'No Name',
124
+ value: embed.data.description || 'Page',
131
125
  inline: embeds.length > 25 / 2 ? true : false,
132
126
  },
133
127
  ]);
@@ -137,15 +131,10 @@ export class InteractionCommandUtil {
137
131
  options.row = new ActionRowBuilder();
138
132
  if (!options.id)
139
133
  options.id = `${this.interaction.id}-menu`;
140
- options.component = new StringSelectMenuBuilder()
141
- .setCustomId(options.id)
142
- .setMaxValues(1)
143
- .setMinValues(1)
144
- .setPlaceholder("Select a page.")
145
- .addOptions({ label: "index", value: "0" });
134
+ options.component = new StringSelectMenuBuilder().setCustomId(options.id).setMaxValues(1).setMinValues(1).setPlaceholder('Select a page.').addOptions({ label: 'index', value: '0' });
146
135
  embeds.map((embed, i = 0) => {
147
136
  options?.component?.addOptions({
148
- label: embed.data.title || "No Name",
137
+ label: embed.data.title || 'No Name',
149
138
  description: embed.data.description || `Page ${i}`,
150
139
  value: String(i + 1),
151
140
  });
@@ -158,24 +147,20 @@ export class InteractionCommandUtil {
158
147
  components: [options.row, ...options.components],
159
148
  ephemeral: !!options.ephemeral,
160
149
  };
161
- (options.reply === undefined || options.reply === true
162
- ? this.interaction.util.reply(content)
163
- : this.interaction.channel.send(content)).then(() => {
150
+ (options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then(() => {
164
151
  const collector = this.interaction.channel
165
152
  .createMessageComponentCollector({
166
153
  filter: options?.filter,
167
154
  time: options?.time || 60000,
168
155
  })
169
- .on("collect", (interaction) => {
156
+ .on('collect', (interaction) => {
170
157
  if (!interaction.customId.startsWith(this.interaction.id))
171
158
  return;
172
159
  interaction.update({
173
- embeds: [
174
- embeds[parseInt(interaction.values[0])],
175
- ],
160
+ embeds: [embeds[parseInt(interaction.values[0])]],
176
161
  });
177
162
  })
178
- .on("end", () => {
163
+ .on('end', () => {
179
164
  this.interaction.editReply({ components: [] });
180
165
  });
181
166
  });
@@ -185,7 +170,7 @@ export class InteractionCommandUtil {
185
170
  throw new XernerxError(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
186
171
  if (embeds.length <= 0)
187
172
  throw new XernerxError(`The minimum embeds is 1.`);
188
- if (typeof options !== "object")
173
+ if (typeof options !== 'object')
189
174
  options = {};
190
175
  if (!Array.isArray(options.components))
191
176
  options.components = [];
@@ -195,7 +180,7 @@ export class InteractionCommandUtil {
195
180
  options.id = `${this.interaction.id}-menu`;
196
181
  }
197
182
  if (!options.buttons)
198
- options.buttons = ["⏮️", "◀️", "⏹️", "▶️", "⏭️"];
183
+ options.buttons = ['⏮️', '◀️', '⏹️', '▶️', '⏭️'];
199
184
  for (const button of options.buttons) {
200
185
  options.row.addComponents(new ButtonBuilder()
201
186
  .setCustomId(`${this.interaction.id}-${options.buttons.indexOf(button)}`)
@@ -208,15 +193,13 @@ export class InteractionCommandUtil {
208
193
  components: [options.row, ...options.components],
209
194
  ephemeral: !!options.ephemeral,
210
195
  };
211
- (options.reply === undefined || options.reply === true
212
- ? this.interaction.util.reply(content)
213
- : this.interaction.channel.send(content)).then((message) => {
196
+ (options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then((message) => {
214
197
  const collector = message.channel
215
198
  .createMessageComponentCollector({
216
199
  filter: options.filter,
217
200
  time: options?.time || 60000,
218
201
  })
219
- .on("collect", (interaction) => {
202
+ .on('collect', (interaction) => {
220
203
  let stop = false;
221
204
  if (interaction.customId.startsWith(this.interaction.id)) {
222
205
  switch (Number(interaction.customId.split(/-/).pop())) {
@@ -225,8 +208,7 @@ export class InteractionCommandUtil {
225
208
  break;
226
209
  }
227
210
  case 1: {
228
- embed =
229
- embeds[embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0];
211
+ embed = embeds[embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0];
230
212
  break;
231
213
  }
232
214
  case 2: {
@@ -235,10 +217,7 @@ export class InteractionCommandUtil {
235
217
  break;
236
218
  }
237
219
  case 3: {
238
- embed =
239
- embeds[embeds.indexOf(embed) < embeds.length - 1
240
- ? embeds.indexOf(embed) + 1
241
- : embeds.length - 1];
220
+ embed = embeds[embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1];
242
221
  break;
243
222
  }
244
223
  case 4: {
@@ -256,7 +235,7 @@ export class InteractionCommandUtil {
256
235
  });
257
236
  }
258
237
  })
259
- .on("end", () => {
238
+ .on('end', () => {
260
239
  this.interaction.editReply({ components: [] });
261
240
  });
262
241
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "type": "module",
5
5
  "description": "A bot framework for discord.js.",
6
6
  "main": "dist/main.js",