Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

erine

Package Overview
Dependencies
Maintainers
2
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

erine - npm Package Compare versions

Comparing version 1.1.4 to 1.1.41

core/classes/Cooldowns.js

35

core/classes/Base.js

@@ -1,34 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErineClient = void 0;
const discord_js_1 = require("discord.js");
const Core_1 = require("./Core");
const Skyfold_1 = require("./Skyfold");
class ErineClient extends discord_js_1.Client {
coreback;
skyfold;
_options;
constructor(options) {
super(options);
this.skyfold = new Skyfold_1.Skyfold({ client: this });
this.coreback = new Core_1.Coreback(this);
this._options = options;
this.init();
}
async load_commands(dir) {
this.skyfold.load_commands(dir);
}
async load_events(dir) {
this.skyfold.load_events(dir);
}
async load_interactions(dir) {
this.skyfold.load_interactions(dir);
}
init() {
let m = require('../events/messageCreate').event;
let i = require('../events/interactionCreate').event;
this.on(m.name, (message) => m.code(message, this));
this.on(i.name, (int) => i.code(int, this));
}
}
exports.ErineClient = ErineClient;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ErineClient=void 0;const discord_js_1=require("discord.js"),Core_1=require("./Core"),Skyfold_1=require("./Skyfold"),Cooldowns_1=require("./Cooldowns");class ErineClient extends discord_js_1.Client{coreback;skyfold;cooldowns;_options;constructor(e){super(e),this.skyfold=new Skyfold_1.Skyfold({client:this}),this.coreback=new Core_1.Coreback(this),this.cooldowns=new Cooldowns_1.Cooldowns(this),this._options=e,this.init()}async load_commands(e){this.skyfold.load_commands(e)}async load_events(e){this.skyfold.load_events(e)}async load_interactions(e){this.skyfold.load_interactions(e)}init(){let o=require("../events/messageCreate").event,s=require("../events/interactionCreate").event;this.on(o.name,e=>o.code(e,this)),this.on(s.name,e=>s.code(e,this))}}exports.ErineClient=ErineClient;

@@ -1,29 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HybridBuilder = void 0;
class HybridBuilder {
name;
aliases;
description;
constructor(options) {
this.name = options?.name || "";
this.aliases = options?.aliases || [];
this.description = options?.description || '...';
}
setName(name) {
this.name = name;
return this;
}
setDescription(description) {
this.description = description;
return this;
}
setAliases(...aliases) {
this.aliases = aliases;
return this;
}
toJSON() {
return { "name": this.name, "description": this.description };
}
}
exports.HybridBuilder = HybridBuilder;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HybridBuilder=void 0;class HybridBuilder{name;aliases;description;constructor(e){this.name=e?.name||"",this.aliases=e?.aliases||[],this.description=e?.description||"..."}setName(e){return this.name=e,this}setDescription(e){return this.description=e,this}setAliases(...e){return this.aliases=e,this}toJSON(){return{name:this.name,description:this.description}}}exports.HybridBuilder=HybridBuilder;

@@ -1,29 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HybridGroup = void 0;
class HybridGroup {
name;
description;
commands;
constructor() {
this.name = '';
this.description = '...';
this.commands = [];
}
setName(name) {
this.name = name;
return this;
}
setDescription(description) {
this.description = description;
return this;
}
addCommand(command) {
this.commands.push(command);
return this;
}
toJSON() {
return { "name": this.name, "description": this.description, "options": [] };
}
}
exports.HybridGroup = HybridGroup;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HybridGroup=void 0;class HybridGroup{name;description;commands;constructor(){this.name="",this.description="...",this.commands=[]}setName(t){return this.name=t,this}setDescription(t){return this.description=t,this}addCommand(t){return this.commands.push(t),this}toJSON(){return{name:this.name,description:this.description,options:[]}}}exports.HybridGroup=HybridGroup;

@@ -1,45 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParamsBuilder = void 0;
const discord_js_1 = require("discord.js");
class ParamsBuilder {
strings;
numbers;
params;
constructor() {
this.strings = [];
this.numbers = [];
this.params = [];
}
addString(param) {
param.type = discord_js_1.ApplicationCommandOptionType.String;
this.params.push(param);
return this;
}
addNumber(param) {
param.type = discord_js_1.ApplicationCommandOptionType.Number;
this.params.push(param);
return this;
}
addBoolean(param) {
param.type = discord_js_1.ApplicationCommandOptionType.Boolean;
this.params.push(param);
return this;
}
addMember(param) {
param.type = discord_js_1.ApplicationCommandOptionType.User;
this.params.push(param);
return this;
}
addChannel(param) {
param.type = discord_js_1.ApplicationCommandOptionType.Channel;
this.params.push(param);
return this;
}
addRole(param) {
param.type = discord_js_1.ApplicationCommandOptionType.Role;
this.params.push(param);
return this;
}
}
exports.ParamsBuilder = ParamsBuilder;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ParamsBuilder=void 0;const discord_js_1=require("discord.js");class ParamsBuilder{strings;numbers;params;constructor(){this.strings=[],this.numbers=[],this.params=[]}addString(s){return s.type=discord_js_1.ApplicationCommandOptionType.String,this.params.push(s),this}addNumber(s){return s.type=discord_js_1.ApplicationCommandOptionType.Number,this.params.push(s),this}addBoolean(s){return s.type=discord_js_1.ApplicationCommandOptionType.Boolean,this.params.push(s),this}addMember(s){return s.type=discord_js_1.ApplicationCommandOptionType.User,this.params.push(s),this}addChannel(s){return s.type=discord_js_1.ApplicationCommandOptionType.Channel,this.params.push(s),this}addRole(s){return s.type=discord_js_1.ApplicationCommandOptionType.Role,this.params.push(s),this}addAttachment(s){return s.type=discord_js_1.ApplicationCommandOptionType.Attachment,this.params.push(s),this}}exports.ParamsBuilder=ParamsBuilder;

@@ -1,40 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrefixBuilder = void 0;
class PrefixBuilder {
names;
description;
usage;
cooldown;
category;
extra;
constructor(data) {
this.names = data?.names || [];
this.description = data?.description || null;
this.usage = data?.usage || null;
this.cooldown = data?.cooldown || 2000;
this.category = data?.category || null;
this.extra = data?.extra || null;
}
setNames(...names) {
this.names = names;
return this;
}
setDescription(data) {
this.description = data;
return this;
}
setUsage(data) {
this.usage = data;
return this;
}
setCooldown(cooldown) {
this.cooldown = cooldown * 1000;
return this;
}
setExtra(data) {
this.extra = data;
return this;
}
}
exports.PrefixBuilder = PrefixBuilder;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PrefixBuilder=void 0;class PrefixBuilder{names;description;usage;category;extra;constructor(e){this.names=e?.names||[],this.description=e?.description||null,this.usage=e?.usage||null,this.category=e?.category||null,this.extra=e?.extra||null}setNames(...e){return this.names=e,this}setDescription(e){return this.description=e,this}setUsage(e){return this.usage=e,this}setExtra(e){return this.extra=e,this}}exports.PrefixBuilder=PrefixBuilder;

@@ -1,63 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Context = void 0;
const discord_js_1 = require("discord.js");
class Context {
data;
args;
bot;
params;
parent;
command;
constructor(data, bot) {
this.data = data;
this.bot = bot;
this.args = this.data instanceof discord_js_1.Message ? [] : null;
this.params = this.data instanceof discord_js_1.Message ? [] : null;
this.parent = null;
this.command = null;
}
get message() {
return this.data instanceof discord_js_1.Message ? this.data : null;
}
get interaction() {
return this.data instanceof discord_js_1.Message ? null : this.data;
}
get author() {
return this.data instanceof discord_js_1.Message ? this.data.author : this.data.user;
}
get channel() {
return this.data.channel;
}
get member() {
return this.data.member;
}
get guild() {
return this.data.guild;
}
async send(options) {
if (this.data instanceof discord_js_1.Message) {
return (await this.data.channel?.send(options).catch(e => null));
}
else {
return (await this.data.reply(options).catch(e => null));
}
}
async defer(options) {
if (this.data instanceof discord_js_1.Message)
return this.data.channel.sendTyping();
else
return this.data.deferReply({ ephemeral: !!options?.ephemeral });
}
get(param, defaultValue = null) {
if (this.data instanceof discord_js_1.Message)
return this.params?.find(p => p.name.toLowerCase() === param.toLowerCase())?.value || defaultValue;
else {
let found = this.data.options._hoistedOptions.find(s => s.name === param.toLowerCase());
if (!found)
return null;
return found?.member || found?.channel || found?.role || found?.value || defaultValue;
}
}
}
exports.Context = Context;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Context=void 0;const discord_js_1=require("discord.js");class Context{data;args;bot;params;parent;command;constructor(t,e){this.data=t,this.bot=e,this.args=this.data instanceof discord_js_1.Message?[]:null,this.params=this.data instanceof discord_js_1.Message?[]:null,this.parent=null,this.command=null}get message(){return this.data instanceof discord_js_1.Message?this.data:null}get interaction(){return this.data instanceof discord_js_1.Message?null:this.data}get author(){return this.data instanceof discord_js_1.Message?this.data.author:this.data.user}get channel(){return this.data.channel}get member(){return this.data.member}get guild(){return this.data.guild}async send(t){return this.data instanceof discord_js_1.Message?this.data.channel?.send(t).catch(t=>null):this.data.reply(t).catch(t=>null)}async defer(t){return this.data instanceof discord_js_1.Message?this.data.channel.sendTyping():this.data.deferReply({ephemeral:!!t?.ephemeral})}async deferEdit(t){return this.data instanceof discord_js_1.Message?this.data.channel?.send(t).catch(t=>null):this.data.editReply(t).catch(t=>null)}get(e,t=null){var a;return this.data instanceof discord_js_1.Message?this.params?.find(t=>t.name.toLowerCase()===e.toLowerCase())?.value||t:(a=this.data.options._hoistedOptions.find(t=>t.name===e.toLowerCase()))?a?.attachment||a?.member||a?.channel||a?.role||a?.value||t:null}}exports.Context=Context;

@@ -1,248 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Plugins = exports.Coreback = void 0;
const tslib_1 = require("tslib");
const discord_js_1 = require("discord.js");
const Errors = tslib_1.__importStar(require("./Errors"));
class Coreback {
client;
constructor(client) {
if (!client)
throw new SyntaxError('Missing client');
this.client = client;
}
isType(obj, func) {
return func(obj);
}
async getMember(query, guild) {
if (!query)
return null;
let some_id = query.replace(/[^\d]/g, '');
let member = some_id ? guild.members.cache.get(some_id) || (await guild.members.fetch(some_id).catch(e => null)) : null;
if (!member)
member = (guild.members.cache.find(m => m.user.username.includes(query)) || null);
return member;
}
async getChannel(query, guild) {
if (!query)
return null;
let some_id = query.replace(/[^\d]/g, '');
let channel = some_id ? guild.channels.cache.get(some_id) || (await guild.channels.fetch(some_id).catch(e => null)) : null;
if (!channel)
channel = (guild.channels.cache.find(c => c.name.includes(query)) || null);
return channel;
}
async getRole(query, guild) {
if (!query)
return null;
let some_id = query.replace(/[^\d]/g, '');
let role = some_id ? guild.roles.cache.get(some_id) || (await guild.roles.fetch(some_id).catch(e => null)) : null;
if (!role)
role = (guild.roles.cache.find(r => r.name.includes(query)) || null);
return role;
}
async convertParamType(input, param, ctx) {
if (!input)
return { break: false, value: null };
if (param.choices?.length) {
let found = param.choices.find(x => x.name.toLowerCase() == input.toLowerCase());
if (!found) {
ctx.bot.emit('contextError', new Errors.InvalidParamChoice(ctx, param, param.choices));
return { break: true, value: null };
}
else
return { break: false, value: found.value };
}
if (param.type === discord_js_1.ApplicationCommandOptionType.String)
return { break: false, value: input };
else if (param.type === discord_js_1.ApplicationCommandOptionType.Number) {
let n = Number(input);
if (isNaN(n)) {
ctx.bot.emit('contextError', new Errors.NotParamNumber(ctx, param));
return { break: true, value: null };
}
else
return { break: false, value: Number(input) };
}
else if (param.type === discord_js_1.ApplicationCommandOptionType.Boolean) {
let b = input === 'false' ? false : input === 'true' ? true : null;
if (b === null) {
ctx.bot.emit('contextError', new Errors.NotParamBoolean(ctx, param));
return { break: true, value: null };
}
else
return { break: false, value: b };
}
else if (param.type === discord_js_1.ApplicationCommandOptionType.User) {
let b = await this.getMember(input, ctx.guild);
if (!b) {
ctx.bot.emit('contextError', new Errors.InvalidParamMember(ctx, param));
return { break: true, value: null };
}
else
return { break: false, value: b };
}
else if (param.type === discord_js_1.ApplicationCommandOptionType.Channel) {
let b = await this.getChannel(input, ctx.guild);
if (!b) {
ctx.bot.emit('contextError', new Errors.InvalidParamChannel(ctx, param));
}
else {
if (param.channel_types && !param.channel_types.includes(b.type)) {
ctx.bot.emit('contextError', new Errors.InvalidChannelType(ctx, param, b.type, param.channel_types));
return { break: true, value: null };
}
return { break: false, value: b };
}
}
else if (param.type === discord_js_1.ApplicationCommandOptionType.Role) {
let b = await this.getRole(input, ctx.guild);
if (!b) {
ctx.bot.emit('contextError', new Errors.InvalidParamRole(ctx, param));
return { break: true, value: null };
}
else
return { break: false, value: b };
}
return { break: false, value: null };
}
}
exports.Coreback = Coreback;
const Plugins = {
async isGuild(ctx) {
if (ctx.channel?.type == discord_js_1.ChannelType.DM) {
ctx.bot.emit('contextError', new Errors.GuildOnly(ctx));
return false;
}
else
return true;
},
async isInChannelType(...types) {
return (async (ctx) => {
let channel = ctx.channel;
if (!types.includes(ctx.channel?.type)) {
ctx.bot.emit('contextError', new Errors.NotInChannelType(ctx, types, channel));
return false;
}
else
return true;
});
},
async isNSFW(ctx) {
if (!ctx.channel.nsfw) {
ctx.bot.emit('contextError', new Errors.NotNSFW(ctx));
return false;
}
else
return true;
},
async isOwner(ctx) {
if (!ctx.bot._options.owners?.includes(ctx.author.id)) {
ctx.bot.emit('contextError', new Errors.NotOwner(ctx));
return false;
}
else
return true;
},
async hasAnyBotPerms(...perms) {
return (async (ctx) => {
if (!perms.some((perm) => (ctx.guild?.members.me).permissions.has(perm))) {
ctx.bot.emit('contextError', new Errors.MissingBotPermission(ctx, perms));
return false;
}
else
return true;
});
},
async hasBotPerms(...perms) {
return (async (ctx) => {
if (!perms.every((perm) => (ctx.guild?.members.me).permissions.has(perm))) {
ctx.bot.emit('contextError', new Errors.MissingBotPermission(ctx, perms));
return false;
}
else
return true;
});
},
async hasAnyPerms(...perms) {
return (async (ctx) => {
if (!perms.some((perm) => ctx.member.permissions.has(perm))) {
ctx.bot.emit('contextError', new Errors.MissingPermission(ctx, perms));
return false;
}
else
return true;
});
},
async hasPerms(...perms) {
return (async (ctx) => {
if (!perms.every((perm) => ctx.member.permissions.has(perm))) {
ctx.bot.emit('contextError', new Errors.MissingPermission(ctx, perms));
return false;
}
else
return true;
});
},
async hasAnyBotPermsInChannel(...perms) {
return (async (ctx) => {
let channel = ctx.channel;
let bot = ctx.guild?.members.me;
let channelPermissions = channel.permissionsFor(bot);
if (!perms.some((perm) => channelPermissions.has(perm))) {
ctx.bot.emit('contextError', new Errors.MissingBotChannelPermission(ctx, perms, channel));
return false;
}
else
return true;
});
},
async hasBotPermsInChannel(...perms) {
return (async (ctx) => {
let channel = ctx.channel;
let bot = ctx.guild?.members.me;
let channelPermissions = channel.permissionsFor(bot);
if (!perms.every((perm) => channelPermissions.has(perm))) {
ctx.bot.emit('contextError', new Errors.MissingBotChannelPermission(ctx, perms, channel));
return false;
}
else
return true;
});
},
async hasAnyPermsInChannel(...perms) {
return (async (ctx) => {
let channel = ctx.channel;
let channelPermissions = channel.permissionsFor(ctx.author.id);
if (!perms.some((perm) => channelPermissions.has(perm))) {
ctx.bot.emit('contextError', new Errors.MissingChannelPermission(ctx, perms, channel));
return false;
}
else
return true;
});
},
async hasPermsInChannel(...perms) {
return (async (ctx) => {
let channel = ctx.channel;
let channelPermissions = channel.permissionsFor(ctx.author.id);
if (!perms.every((perm) => channelPermissions.has(perm))) {
ctx.bot.emit('contextError', new Errors.MissingChannelPermission(ctx, perms, channel));
return false;
}
else
return true;
});
},
async onlyForIDs(...snowflakes) {
return (async (ctx) => {
if (!snowflakes.includes(ctx.author.id)) {
ctx.bot.emit('contextError', new Errors.OnlyForIDs(ctx, snowflakes));
return false;
}
else
return true;
});
}
};
exports.Plugins = Plugins;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Plugins=exports.Coreback=void 0;const tslib_1=require("tslib"),discord_js_1=require("discord.js"),Errors=tslib_1.__importStar(require("./Errors"));class Coreback{client;constructor(e){if(!e)throw new SyntaxError("Missing client");this.client=e}isType(e,r){return r(e)}async getMember(r,e){var n;return r&&(((n=r.replace(/[^\d]/g,""))?e.members.cache.get(n)||await e.members.fetch(n).catch(e=>null):null)||e.members.cache.find(e=>e.user.username.includes(r)))||null}async getChannel(r,e){var n;return r&&(((n=r.replace(/[^\d]/g,""))?e.channels.cache.get(n)||await e.channels.fetch(n).catch(e=>null):null)||e.channels.cache.find(e=>e.name.includes(r)))||null}async getRole(r,e){var n;return r&&(((n=r.replace(/[^\d]/g,""))?e.roles.cache.get(n)||await e.roles.fetch(n).catch(e=>null):null)||e.roles.cache.find(e=>e.name.includes(r)))||null}async convertParamType(r,e,n,t=!0){if(r||!t){if(e.choices?.length)return(t=e.choices.find(e=>e.name.toLowerCase()==r.toLowerCase()))?{break:!1,value:t.value}:(n.bot.emit("contextError",new Errors.InvalidParamChoice(n,e,e.choices)),{break:!0,value:null});if(e.type===discord_js_1.ApplicationCommandOptionType.String)return{break:!1,value:r};if(e.type===discord_js_1.ApplicationCommandOptionType.Number)return t=Number(r),isNaN(t)?(n.bot.emit("contextError",new Errors.NotParamNumber(n,e)),{break:!0,value:null}):{break:!1,value:Number(r)};if(e.type===discord_js_1.ApplicationCommandOptionType.Boolean)return null===(t="false"!==r&&("true"===r||null))?(n.bot.emit("contextError",new Errors.NotParamBoolean(n,e)),{break:!0,value:null}):{break:!1,value:t};if(e.type===discord_js_1.ApplicationCommandOptionType.User)return(t=await this.getMember(r,n.guild))?{break:!1,value:t}:(n.bot.emit("contextError",new Errors.InvalidParamMember(n,e)),{break:!0,value:null});if(e.type===discord_js_1.ApplicationCommandOptionType.Channel){if(t=await this.getChannel(r,n.guild))return e.channel_types&&!e.channel_types.includes(t.type)?(n.bot.emit("contextError",new Errors.InvalidChannelType(n,e,t.type,e.channel_types)),{break:!0,value:null}):{break:!1,value:t};n.bot.emit("contextError",new Errors.InvalidParamChannel(n,e))}else{if(e.type===discord_js_1.ApplicationCommandOptionType.Role)return(t=await this.getRole(r,n.guild))?{break:!1,value:t}:(n.bot.emit("contextError",new Errors.InvalidParamRole(n,e)),{break:!0,value:null});if(e.type===discord_js_1.ApplicationCommandOptionType.Attachment)return!(t=n.message?.attachments?.first())&&e.required?(n.bot.emit("contextError",new Errors.InvalidParamAttachment(n,e)),{break:!0,value:null}):{break:!1,value:t}}}return{break:!1,value:null}}}exports.Coreback=Coreback;const Plugins={async isGuild(e){return e.channel?.type!=discord_js_1.ChannelType.DM||(e.bot.emit("contextError",new Errors.GuildOnly(e)),!1)},async isInChannelType(...n){return async e=>{var r=e.channel;return!!n.includes(e.channel?.type)||(e.bot.emit("contextError",new Errors.NotInChannelType(e,n,r)),!1)}},async isNSFW(e){return!!e.channel.nsfw||(e.bot.emit("contextError",new Errors.NotNSFW(e)),!1)},async isOwner(e){return!!e.bot._options.owners?.includes(e.author.id)||(e.bot.emit("contextError",new Errors.NotOwner(e)),!1)},async hasAnyBotPerms(...e){return async r=>!!e.some(e=>(r.guild?.members.me).permissions.has(e))||(r.bot.emit("contextError",new Errors.MissingBotPermission(r,e)),!1)},async hasBotPerms(...e){return async r=>!!e.every(e=>(r.guild?.members.me).permissions.has(e))||(r.bot.emit("contextError",new Errors.MissingBotPermission(r,e)),!1)},async hasAnyPerms(...e){return async r=>!!e.some(e=>r.member.permissions.has(e))||(r.bot.emit("contextError",new Errors.MissingPermission(r,e)),!1)},async hasPerms(...e){return async r=>!!e.every(e=>r.member.permissions.has(e))||(r.bot.emit("contextError",new Errors.MissingPermission(r,e)),!1)},async hasAnyBotPermsInChannel(...s){return async e=>{var r=e.channel,n=e.guild?.members.me;let t=r.permissionsFor(n);return!!s.some(e=>t.has(e))||(e.bot.emit("contextError",new Errors.MissingBotChannelPermission(e,s,r)),!1)}},async hasBotPermsInChannel(...s){return async e=>{var r=e.channel,n=e.guild?.members.me;let t=r.permissionsFor(n);return!!s.every(e=>t.has(e))||(e.bot.emit("contextError",new Errors.MissingBotChannelPermission(e,s,r)),!1)}},async hasAnyPermsInChannel(...t){return async e=>{var r=e.channel;let n=r.permissionsFor(e.author.id);return!!t.some(e=>n.has(e))||(e.bot.emit("contextError",new Errors.MissingChannelPermission(e,t,r)),!1)}},async hasPermsInChannel(...t){return async e=>{var r=e.channel;let n=r.permissionsFor(e.author.id);return!!t.every(e=>n.has(e))||(e.bot.emit("contextError",new Errors.MissingChannelPermission(e,t,r)),!1)}},async onlyForIDs(...r){return async e=>!!r.includes(e.author.id)||(e.bot.emit("contextError",new Errors.OnlyForIDs(e,r)),!1)},async cooldown(t,s){return async e=>{var r="GUILD"==s?e.guild?.id||-1:"MEMBER"==s?e.member?.id||-1:"USER"==s?e.author.id:"CHANNEL"==s?e.channel?.id-1:-1,n=await e.bot.cooldowns.check(e.command?.data.name,r,1e3*t,s);return n?(e.bot.emit("contextError",new Errors.CommandInCooldown(e,n.left)),!1):(await e.bot.cooldowns.setCooldownSource(e.command?.data.name,r,s,1e3*t),!0)}}};exports.Plugins=Plugins;

@@ -1,186 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OnlyForIDs = exports.NotInChannelType = exports.NotNSFW = exports.InvalidChannelType = exports.InvalidParamRole = exports.InvalidParamChannel = exports.InvalidParamMember = exports.NotParamBoolean = exports.MissingBotChannelPermission = exports.MissingBotPermission = exports.MissingChannelPermission = exports.MissingPermission = exports.InvalidParamChoice = exports.NotParamNumber = exports.MissingRequiredParam = exports.UnknownCommandError = exports.CommandNotFound = exports.NotOwner = exports.GuildOnly = void 0;
class GuildOnly {
ctx;
constructor(context) {
this.ctx = context;
}
get user() {
return this.ctx.author;
}
}
exports.GuildOnly = GuildOnly;
class NotOwner {
ctx;
constructor(context) {
this.ctx = context;
}
get user() {
return this.ctx.author;
}
}
exports.NotOwner = NotOwner;
class CommandNotFound {
ctx;
provided;
constructor(context, provided) {
this.ctx = context;
this.provided = provided;
}
}
exports.CommandNotFound = CommandNotFound;
class UnknownCommandError {
ctx;
error;
constructor(context, error) {
this.ctx = context;
this.error = error;
}
}
exports.UnknownCommandError = UnknownCommandError;
class MissingRequiredParam {
ctx;
param;
constructor(context, param) {
this.ctx = context;
this.param = param;
}
}
exports.MissingRequiredParam = MissingRequiredParam;
class NotParamNumber {
ctx;
param;
constructor(context, param) {
this.ctx = context;
this.param = param;
}
}
exports.NotParamNumber = NotParamNumber;
class NotParamBoolean {
ctx;
param;
constructor(context, param) {
this.ctx = context;
this.param = param;
}
}
exports.NotParamBoolean = NotParamBoolean;
class InvalidParamChoice {
ctx;
param;
choices;
constructor(context, param, choices) {
this.ctx = context;
this.param = param;
this.choices = choices;
}
}
exports.InvalidParamChoice = InvalidParamChoice;
class InvalidParamMember {
ctx;
param;
constructor(context, param) {
this.ctx = context;
this.param = param;
}
}
exports.InvalidParamMember = InvalidParamMember;
class InvalidParamChannel {
ctx;
param;
constructor(context, param) {
this.ctx = context;
this.param = param;
}
}
exports.InvalidParamChannel = InvalidParamChannel;
class InvalidParamRole {
ctx;
param;
constructor(context, param) {
this.ctx = context;
this.param = param;
}
}
exports.InvalidParamRole = InvalidParamRole;
class InvalidChannelType {
ctx;
param;
provided;
expected;
constructor(context, param, provided, expected) {
this.ctx = context;
this.param = param;
this.provided = provided;
this.expected = expected;
}
}
exports.InvalidChannelType = InvalidChannelType;
class MissingPermission {
ctx;
permissions;
constructor(context, perm) {
this.ctx = context;
this.permissions = perm;
}
}
exports.MissingPermission = MissingPermission;
class MissingChannelPermission {
ctx;
permissions;
channel;
constructor(context, perm, channel) {
this.ctx = context;
this.permissions = perm;
this.channel = channel;
}
}
exports.MissingChannelPermission = MissingChannelPermission;
class MissingBotPermission {
ctx;
permissions;
constructor(context, perm) {
this.ctx = context;
this.permissions = perm;
}
}
exports.MissingBotPermission = MissingBotPermission;
class MissingBotChannelPermission {
ctx;
permissions;
channel;
constructor(context, perm, channel) {
this.ctx = context;
this.permissions = perm;
this.channel = channel;
}
}
exports.MissingBotChannelPermission = MissingBotChannelPermission;
class NotNSFW {
ctx;
constructor(context) {
this.ctx = context;
}
}
exports.NotNSFW = NotNSFW;
class NotInChannelType {
ctx;
types;
channel;
constructor(ctx, types, channel) {
this.ctx = ctx;
this.types = types;
this.channel = channel;
}
}
exports.NotInChannelType = NotInChannelType;
class OnlyForIDs {
ctx;
snowflakes;
constructor(context, snowflakes) {
this.ctx = context;
this.snowflakes = snowflakes;
}
}
exports.OnlyForIDs = OnlyForIDs;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommandInCooldown=exports.OnlyForIDs=exports.NotInChannelType=exports.NotNSFW=exports.InvalidParamAttachment=exports.InvalidChannelType=exports.InvalidParamRole=exports.InvalidParamChannel=exports.InvalidParamMember=exports.NotParamBoolean=exports.MissingBotChannelPermission=exports.MissingBotPermission=exports.MissingChannelPermission=exports.MissingPermission=exports.InvalidParamChoice=exports.NotParamNumber=exports.MissingRequiredParam=exports.UnknownCommandError=exports.CommandNotFound=exports.NotOwner=exports.GuildOnly=void 0;class GuildOnly{ctx;constructor(s){this.ctx=s}get user(){return this.ctx.author}}exports.GuildOnly=GuildOnly;class NotOwner{ctx;constructor(s){this.ctx=s}get user(){return this.ctx.author}}exports.NotOwner=NotOwner;class CommandNotFound{ctx;provided;constructor(s,t){this.ctx=s,this.provided=t}}exports.CommandNotFound=CommandNotFound;class UnknownCommandError{ctx;error;constructor(s,t){this.ctx=s,this.error=t}}exports.UnknownCommandError=UnknownCommandError;class MissingRequiredParam{ctx;param;constructor(s,t){this.ctx=s,this.param=t}}exports.MissingRequiredParam=MissingRequiredParam;class NotParamNumber{ctx;param;constructor(s,t){this.ctx=s,this.param=t}}exports.NotParamNumber=NotParamNumber;class NotParamBoolean{ctx;param;constructor(s,t){this.ctx=s,this.param=t}}exports.NotParamBoolean=NotParamBoolean;class InvalidParamChoice{ctx;param;choices;constructor(s,t,o){this.ctx=s,this.param=t,this.choices=o}}exports.InvalidParamChoice=InvalidParamChoice;class InvalidParamMember{ctx;param;constructor(s,t){this.ctx=s,this.param=t}}exports.InvalidParamMember=InvalidParamMember;class InvalidParamChannel{ctx;param;constructor(s,t){this.ctx=s,this.param=t}}exports.InvalidParamChannel=InvalidParamChannel;class InvalidParamRole{ctx;param;constructor(s,t){this.ctx=s,this.param=t}}exports.InvalidParamRole=InvalidParamRole;class InvalidChannelType{ctx;param;provided;expected;constructor(s,t,o,r){this.ctx=s,this.param=t,this.provided=o,this.expected=r}}exports.InvalidChannelType=InvalidChannelType;class InvalidParamAttachment{ctx;param;constructor(s,t){this.ctx=s,this.param=t}}exports.InvalidParamAttachment=InvalidParamAttachment;class MissingPermission{ctx;permissions;constructor(s,t){this.ctx=s,this.permissions=t}}exports.MissingPermission=MissingPermission;class MissingChannelPermission{ctx;permissions;channel;constructor(s,t,o){this.ctx=s,this.permissions=t,this.channel=o}}exports.MissingChannelPermission=MissingChannelPermission;class MissingBotPermission{ctx;permissions;constructor(s,t){this.ctx=s,this.permissions=t}}exports.MissingBotPermission=MissingBotPermission;class MissingBotChannelPermission{ctx;permissions;channel;constructor(s,t,o){this.ctx=s,this.permissions=t,this.channel=o}}exports.MissingBotChannelPermission=MissingBotChannelPermission;class NotNSFW{ctx;constructor(s){this.ctx=s}}exports.NotNSFW=NotNSFW;class NotInChannelType{ctx;types;channel;constructor(s,t,o){this.ctx=s,this.types=t,this.channel=o}}exports.NotInChannelType=NotInChannelType;class OnlyForIDs{ctx;snowflakes;constructor(s,t){this.ctx=s,this.snowflakes=t}}exports.OnlyForIDs=OnlyForIDs;class CommandInCooldown{ctx;timeLeft;constructor(s,t){this.ctx=s,this.timeLeft=t}}exports.CommandInCooldown=CommandInCooldown;

@@ -1,123 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Skyfold = void 0;
const discord_js_1 = require("discord.js");
const node_fs_1 = require("node:fs");
const path_1 = require("path");
const Base_1 = require("./Base");
const HybridBuilder_1 = require("./builders/HybridBuilder");
const HybridGroupBuilder_1 = require("./builders/HybridGroupBuilder");
const PrefixBuilder_1 = require("./builders/PrefixBuilder");
class Skyfold {
client;
commands;
interactions;
listeners;
constructor(options) {
if (!(options?.client instanceof Base_1.ErineClient))
throw new SyntaxError("Invalid client provided in options");
this.client = options.client;
this.commands = { PrefixType: null, HybridType: null, SlashType: null, HybridGroupType: null };
this.interactions = new discord_js_1.Collection();
this.listeners = null;
}
async load_commands(dir) {
if (!dir)
throw new SyntaxError("Missing directory to load commands");
const MODULES = (0, node_fs_1.readdirSync)((0, path_1.join)(process.cwd(), dir));
for (const file of MODULES) {
if ((0, node_fs_1.lstatSync)((0, path_1.join)(process.cwd(), dir, file)).isDirectory()) {
this.load_commands((0, path_1.join)(dir, file));
continue;
}
delete require.cache[(0, path_1.join)(process.cwd(), dir, file)];
let cmd = require((0, path_1.join)(process.cwd(), dir, file)).body;
if (!cmd)
continue;
if (this.client.coreback.isType(cmd, c => c.data instanceof PrefixBuilder_1.PrefixBuilder)) {
if (!this.commands.PrefixType)
this.commands.PrefixType = new discord_js_1.Collection();
this.commands.PrefixType.set(cmd.data.names[0], cmd);
}
else if (this.client.coreback.isType(cmd, c => c.data instanceof HybridBuilder_1.HybridBuilder)) {
if (!this.commands.HybridType)
this.commands.HybridType = new discord_js_1.Collection();
this.commands.HybridType.set(cmd.data instanceof PrefixBuilder_1.PrefixBuilder ? cmd.data.names[0] : cmd.data.name, cmd);
}
else if (this.client.coreback.isType(cmd, c => c.data instanceof discord_js_1.SlashCommandBuilder)) {
if (!this.commands.SlashType)
this.commands.SlashType = new discord_js_1.Collection();
this.commands.SlashType.set(cmd.data.name, cmd);
}
else if (this.client.coreback.isType(cmd, cmd => cmd.data instanceof HybridGroupBuilder_1.HybridGroup)) {
if (!this.commands.HybridGroupType)
this.commands.HybridGroupType = new discord_js_1.Collection();
this.commands.HybridGroupType.set(cmd.data.name, cmd);
}
}
}
async load_events(dir) {
if (!dir)
throw new SyntaxError("Missing directory to load events");
const MODULES = (0, node_fs_1.readdirSync)((0, path_1.join)(process.cwd(), dir));
for (const file of MODULES) {
if ((0, node_fs_1.lstatSync)((0, path_1.join)(process.cwd(), dir, file)).isDirectory()) {
this.load_events((0, path_1.join)(dir, file));
continue;
}
let event = require((0, path_1.join)(process.cwd(), dir, file)).event;
if (!event)
continue;
this.client.on(event.name, event.code);
}
}
async load_interactions(dir) {
if (!dir)
throw new SyntaxError("Missing directory to load interactions");
const MODULES = (0, node_fs_1.readdirSync)((0, path_1.join)(process.cwd(), dir));
for (const file of MODULES) {
if ((0, node_fs_1.lstatSync)((0, path_1.join)(process.cwd(), dir, file)).isDirectory()) {
this.load_interactions((0, path_1.join)(dir, file));
continue;
}
let interaction = require((0, path_1.join)(process.cwd(), dir, file)).interaction;
if (!interaction)
continue;
this.interactions?.set(interaction.name, interaction);
}
}
async sync(token, app_id) {
const rest = new discord_js_1.REST({ version: "10" }).setToken(token);
let slash = this.commands.SlashType?.map(s => s.data.toJSON());
let hybrid = this.commands.HybridType;
let hybrid_groups = this.commands.HybridGroupType;
let parsed = [];
if (hybrid) {
hybrid.forEach(x => {
let obj = x.data.toJSON();
obj.options = x.params?.params || [];
parsed.push(obj);
});
}
if (hybrid_groups) {
hybrid_groups.forEach(x => {
let obj = x.data.toJSON();
let subs = [];
for (const y of x.data.commands) {
let obj2 = y.data.toJSON();
obj2.options = y.params?.params || [];
obj2.type = 1;
subs.push(obj2);
}
obj.options = subs;
parsed.push(obj);
});
}
let f = (slash || []).concat(parsed);
let final = slash && hybrid ? slash.concat(parsed) : slash && !hybrid ? slash : parsed;
rest.put(discord_js_1.Routes.applicationCommands(app_id), {
body: f
});
}
}
exports.Skyfold = Skyfold;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Skyfold=void 0;const discord_js_1=require("discord.js"),node_fs_1=require("node:fs"),path_1=require("path"),Base_1=require("./Base"),HybridBuilder_1=require("./builders/HybridBuilder"),HybridGroupBuilder_1=require("./builders/HybridGroupBuilder"),PrefixBuilder_1=require("./builders/PrefixBuilder");class Skyfold{client;commands;interactions;listeners;constructor(e){if(!(e?.client instanceof Base_1.ErineClient))throw new SyntaxError("Invalid client provided in options");this.client=e.client,this.commands={PrefixType:null,HybridType:null,SlashType:null,HybridGroupType:null},this.interactions=new discord_js_1.Collection,this.listeners=null}async load_commands(e){if(!e)throw new SyntaxError("Missing directory to load commands");var i;for(const s of(0,node_fs_1.readdirSync)((0,path_1.join)(process.cwd(),e)))(0,node_fs_1.lstatSync)((0,path_1.join)(process.cwd(),e,s)).isDirectory()?this.load_commands((0,path_1.join)(e,s)):(delete require.cache[(0,path_1.join)(process.cwd(),e,s)],(i=require((0,path_1.join)(process.cwd(),e,s)).body)&&(this.client.coreback.isType(i,e=>e.data instanceof PrefixBuilder_1.PrefixBuilder)?(this.commands.PrefixType||(this.commands.PrefixType=new discord_js_1.Collection),this.commands.PrefixType.set(i.data.names[0],i)):this.client.coreback.isType(i,e=>e.data instanceof HybridBuilder_1.HybridBuilder)?(this.commands.HybridType||(this.commands.HybridType=new discord_js_1.Collection),this.commands.HybridType.set(i.data instanceof PrefixBuilder_1.PrefixBuilder?i.data.names[0]:i.data.name,i)):this.client.coreback.isType(i,e=>e.data instanceof discord_js_1.SlashCommandBuilder)?(this.commands.SlashType||(this.commands.SlashType=new discord_js_1.Collection),this.commands.SlashType.set(i.data.name,i)):this.client.coreback.isType(i,e=>e.data instanceof HybridGroupBuilder_1.HybridGroup)&&(this.commands.HybridGroupType||(this.commands.HybridGroupType=new discord_js_1.Collection),this.commands.HybridGroupType.set(i.data.name,i))))}async load_events(e){if(!e)throw new SyntaxError("Missing directory to load events");var i;for(const s of(0,node_fs_1.readdirSync)((0,path_1.join)(process.cwd(),e)))(0,node_fs_1.lstatSync)((0,path_1.join)(process.cwd(),e,s)).isDirectory()?this.load_events((0,path_1.join)(e,s)):(i=require((0,path_1.join)(process.cwd(),e,s)).event)&&this.client.on(i.name,i.code)}async load_interactions(e){if(!e)throw new SyntaxError("Missing directory to load interactions");var i;for(const s of(0,node_fs_1.readdirSync)((0,path_1.join)(process.cwd(),e)))(0,node_fs_1.lstatSync)((0,path_1.join)(process.cwd(),e,s)).isDirectory()?this.load_interactions((0,path_1.join)(e,s)):(i=require((0,path_1.join)(process.cwd(),e,s)).interaction)&&this.interactions?.set(i.name,i)}async sync(e,i){var e=new discord_js_1.REST({version:"10"}).setToken(e),s=this.commands.SlashType?.map(e=>e.data.toJSON()),o=this.commands.HybridType,r=this.commands.HybridGroupType;let t=[];o&&o.forEach(e=>{var i=e.data.toJSON();i.options=e.params?.params||[],t.push(i)}),r&&r.forEach(e=>{var i=e.data.toJSON(),s=[];for(const r of e.data.commands){var o=r.data.toJSON();o.options=r.params?.params||[],o.type=1,s.push(o)}i.options=s,t.push(i)}),r=(s||[]).concat(t),s&&o?s.concat(t):s&&!o||t,e.put(discord_js_1.Routes.applicationCommands(i),{body:r})}}exports.Skyfold=Skyfold;

@@ -1,84 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.event = void 0;
const tslib_1 = require("tslib");
const discord_js_1 = require("discord.js");
const Context_1 = require("../classes/Context");
const Errors = tslib_1.__importStar(require("../classes/Errors"));
const types_1 = require("util/types");
const event = {
name: 'interactionCreate',
async code(int, bot) {
if (int.type === discord_js_1.InteractionType.ApplicationCommand) {
let ctx = new Context_1.Context(int, bot);
if (bot._options.guildOnly && !int.guild)
return bot.emit('contextError', new Errors.GuildOnly(ctx));
let slash_command = bot.skyfold.commands.SlashType?.find(c => c.data.name === int.commandName);
let hybrid_command = bot.skyfold.commands.HybridType?.find(c => c.data.name === int.commandName);
if (slash_command && slash_command.plugins) {
for (const plugin of slash_command.plugins) {
if ((0, types_1.isPromise)(plugin)) {
if (!(await (await plugin)(ctx)))
return;
}
else {
if (!await plugin(ctx))
return;
}
}
}
if (hybrid_command && hybrid_command.plugins) {
for (const plugin of hybrid_command.plugins) {
if ((0, types_1.isPromise)(plugin)) {
if (!(await (await plugin)(ctx)))
return;
}
else {
if (!await plugin(ctx))
return;
}
}
}
let hybrid_group = bot.skyfold.commands.HybridGroupType?.find(c => c.data.name.toLocaleLowerCase() == int.commandName);
if (!slash_command && !hybrid_command && !hybrid_group)
return bot.emit('contextError', new Errors.CommandNotFound(ctx, int.commandName));
let sub = hybrid_group && int.options?.data?.[0]?.type == 1 ? hybrid_group.data.commands.find(c => c.data.name === int.options.data[0].name) : null;
if (sub && sub.plugins) {
for (const plugin of sub.plugins) {
if ((0, types_1.isPromise)(plugin)) {
if (!(await (await plugin)(ctx)))
return;
}
else {
if (!await plugin(ctx))
return;
}
}
}
try {
if (slash_command)
slash_command.code(ctx).catch(e => bot.emit('contextError', new Errors.UnknownCommandError(ctx, e)));
if (hybrid_command)
hybrid_command.code(ctx).catch(e => bot.emit('contextError', new Errors.UnknownCommandError(ctx, e)));
if (sub)
sub.code(ctx).catch(e => bot.emit('contextError', new Errors.UnknownCommandError(ctx, e)));
}
catch (e) {
bot.emit('contextError', new Errors.UnknownCommandError(ctx, e));
}
}
else {
let interaction = bot.skyfold.interactions?.get(int.customId);
if (!interaction)
return;
let ctx = new Context_1.Context(int, bot);
try {
interaction.code(ctx);
}
catch (e) {
bot.emit('contextError', new Errors.UnknownCommandError(ctx, e));
}
}
}
};
exports.event = event;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.event=void 0;const tslib_1=require("tslib"),discord_js_1=require("discord.js"),Context_1=require("../classes/Context"),Errors=tslib_1.__importStar(require("../classes/Errors")),types_1=require("util/types"),event={name:"interactionCreate",async code(t,o){if(t.type===discord_js_1.InteractionType.ApplicationCommand){let e=new Context_1.Context(t,o);if(o._options.guildOnly&&!t.guild)return o.emit("contextError",new Errors.GuildOnly(e));var r=o.skyfold.commands.SlashType?.find(r=>r.data.name===t.commandName),n=o.skyfold.commands.HybridType?.find(r=>r.data.name===t.commandName);if(r&&r.plugins)for(const a of r.plugins)if((0,types_1.isPromise)(a)){if(!await(await a)(e))return}else if(!await a(e))return;if(n&&n.plugins)for(const s of n.plugins)if((0,types_1.isPromise)(s)){if(!await(await s)(e))return}else if(!await s(e))return;var i=o.skyfold.commands.HybridGroupType?.find(r=>r.data.name.toLocaleLowerCase()==t.commandName);if(!r&&!n&&!i)return o.emit("contextError",new Errors.CommandNotFound(e,t.commandName));if((i=i&&1==t.options?.data?.[0]?.type?i.data.commands.find(r=>r.data.name===t.options.data[0].name):null)&&i.plugins)for(const m of i.plugins)if((0,types_1.isPromise)(m)){if(!await(await m)(e))return}else if(!await m(e))return;try{r&&r.code(e).catch(r=>o.emit("contextError",new Errors.UnknownCommandError(e,r))),n&&n.code(e).catch(r=>o.emit("contextError",new Errors.UnknownCommandError(e,r))),i&&i.code(e).catch(r=>o.emit("contextError",new Errors.UnknownCommandError(e,r)))}catch(r){o.emit("contextError",new Errors.UnknownCommandError(e,r))}}else if(r=o.skyfold.interactions?.get(t.customId)){n=new Context_1.Context(t,o);try{r.code(n)}catch(r){o.emit("contextError",new Errors.UnknownCommandError(n,r))}}}};exports.event=event;

@@ -1,142 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.event = void 0;
const tslib_1 = require("tslib");
const types_1 = require("util/types");
const Context_1 = require("../classes/Context");
const Errors = tslib_1.__importStar(require("../classes/Errors"));
async function LoadPrefixCommand(ctx, prefix_command, args) {
if (!prefix_command)
return;
ctx.command = prefix_command;
if (prefix_command.plugins) {
for (const plugin of prefix_command.plugins) {
if ((0, types_1.isPromise)(plugin)) {
if (!(await (await plugin)(ctx)))
return;
}
else {
if (!await plugin(ctx))
return;
}
}
}
if (prefix_command) {
if (prefix_command.params) {
let missing = prefix_command.params.params.find((x, i) => !args[i] && x.required);
if (missing)
return ctx.bot.emit('contextError', new Errors.MissingRequiredParam(ctx, missing));
let types = prefix_command.params.params.map(x => x.type);
for (let i = 0; i < types.length; i++) {
let parsed = await ctx.bot.coreback.convertParamType(args[i], prefix_command.params.params[i], ctx);
if (parsed?.break)
return;
if (prefix_command.params.params[i].long)
prefix_command.params.params[i].value = args.slice(i).join(' ');
else
prefix_command.params.params[i].value = parsed?.value;
}
ctx.params = prefix_command.params.params;
}
}
ctx.args = args;
try {
if (prefix_command)
prefix_command.code(ctx).catch(e => ctx.bot.emit('contextError', new Errors.UnknownCommandError(ctx, e)));
}
catch (e) {
ctx.bot.emit('contextError', new Errors.UnknownCommandError(ctx, e));
}
}
async function LoadHybridCommand(ctx, hybrid_command, args) {
if (!hybrid_command)
return;
ctx.command = hybrid_command;
if (hybrid_command.plugins) {
for (const plugin of hybrid_command.plugins) {
if ((0, types_1.isPromise)(plugin)) {
if (!(await (await plugin)(ctx)))
return;
}
else {
if (!await plugin(ctx))
return;
}
}
}
if (hybrid_command) {
if (hybrid_command.params) {
let missing = hybrid_command.params.params.find((x, i) => !args[i] && x.required);
if (missing)
return ctx.bot.emit('contextError', new Errors.MissingRequiredParam(ctx, missing));
let types = hybrid_command.params.params.map(x => x.type);
for (let i = 0; i < types.length; i++) {
let parsed = await ctx.bot.coreback.convertParamType(args[i], hybrid_command.params.params[i], ctx);
if (parsed?.break)
return;
if (hybrid_command.params.params[i].long)
hybrid_command.params.params[i].value = args.slice(i).join(' ');
else
hybrid_command.params.params[i].value = parsed?.value;
}
ctx.params = hybrid_command.params.params;
}
}
ctx.args = args;
try {
if (hybrid_command)
hybrid_command.code(ctx).catch(e => ctx.bot.emit('contextError', new Errors.UnknownCommandError(ctx, e)));
}
catch (e) {
ctx.bot.emit('contextError', new Errors.UnknownCommandError(ctx, e));
}
}
async function LoadHybridGroup(ctx, hybrid_group, args) {
if (!hybrid_group)
return;
let probably = args?.shift()?.toLowerCase();
if (!probably)
return;
let sub = hybrid_group.data.commands?.find(c => c.data.name.toLowerCase() == probably || c.data.aliases.includes(probably));
if (!sub)
return;
ctx.command = sub;
ctx.parent = hybrid_group;
LoadHybridCommand(ctx, sub, args).catch(e => ctx.bot.emit('contextError', new Errors.UnknownCommandError(new Context_1.Context(ctx.message, ctx.bot), e)));
}
const event = {
name: 'messageCreate',
async code(message, bot) {
if (message.author.bot)
return;
let ctx = new Context_1.Context(message, bot);
if (bot._options.guildOnly && !message.guild)
return bot.emit('contextError', new Errors.GuildOnly(ctx));
let prefix;
if (typeof bot._options.prefix === 'string')
prefix = bot._options.prefix;
else {
if ((0, types_1.isAsyncFunction)(bot._options.prefix))
prefix = await bot._options.prefix(ctx);
else
prefix = bot._options.prefix(ctx);
}
if (!prefix)
return;
if (!message.content.toLowerCase().startsWith(prefix.toLowerCase()))
return;
let args = message.content.slice(prefix.length).trim().split(/ +/);
let probably = args.shift()?.toLowerCase();
if (!probably)
return;
let prefix_command = bot.skyfold.commands.PrefixType?.find(c => c.data.names.includes(probably));
let hybrid_command = bot.skyfold.commands.HybridType?.find(c => c.data.name.toLowerCase() == probably || c.data.aliases.includes(probably));
let hybrid_group = bot.skyfold.commands.HybridGroupType?.find(c => c.data.name.toLocaleLowerCase() == probably);
if (!prefix_command && !hybrid_command && !hybrid_group)
return bot.emit('contextError', new Errors.CommandNotFound(ctx, probably));
LoadHybridGroup(ctx, hybrid_group, args).catch(e => bot.emit('contextError', new Errors.UnknownCommandError(ctx, e)));
LoadHybridCommand(new Context_1.Context(message, bot), hybrid_command, args).catch(e => bot.emit('contextError', new Errors.UnknownCommandError(ctx, e)));
LoadPrefixCommand(new Context_1.Context(message, bot), prefix_command, args).catch(e => bot.emit('contextError', new Errors.UnknownCommandError(ctx, e)));
}
};
exports.event = event;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.event=void 0;const tslib_1=require("tslib"),discord_js_1=require("discord.js"),types_1=require("util/types"),Context_1=require("../classes/Context"),Errors=tslib_1.__importStar(require("../classes/Errors"));async function LoadPrefixCommand(e,o,n){if(o){if((e.command=o).plugins)for(const a of o.plugins)if((0,types_1.isPromise)(a)){if(!await(await a)(e))return}else if(!await a(e))return;if(o&&o.params){var r=o.params.params?.filter(r=>r.type!=discord_js_1.ApplicationCommandOptionType.Attachment)?.find((r,a)=>!n[a]&&r.required);if(r)return e.bot.emit("contextError",new Errors.MissingRequiredParam(e,r));var s=o.params.params.map(r=>r.type);let t=0;for(let a=0;a<s.length;a++){let r;if(s[a]===discord_js_1.ApplicationCommandOptionType.Attachment?(r=await e.bot.coreback.convertParamType("",o.params.params[a],e,!1),t--):r=await e.bot.coreback.convertParamType(n[t],o.params.params[a],e),r?.break)return;o.params.params[a]?.long?o.params.params[a].value=n.slice(a).join(" "):o.params.params[a].value=r?.value,t++}e.params=o.params.params}e.args=n;try{o&&o.code(e).catch(r=>e.bot.emit("contextError",new Errors.UnknownCommandError(e,r)))}catch(r){e.bot.emit("contextError",new Errors.UnknownCommandError(e,r))}}}async function LoadHybridCommand(e,o,n){if(o){if((e.command=o).plugins)for(const a of o.plugins)if((0,types_1.isPromise)(a)){if(!await(await a)(e))return}else if(!await a(e))return;if(o&&o.params){var r=o.params.params?.filter(r=>r.type!=discord_js_1.ApplicationCommandOptionType.Attachment)?.find((r,a)=>!n[a]&&r.required);if(r)return e.bot.emit("contextError",new Errors.MissingRequiredParam(e,r));var s=o.params.params.map(r=>r.type);let t=0;for(let a=0;a<s.length;a++){let r;if(s[a]===discord_js_1.ApplicationCommandOptionType.Attachment?(r=await e.bot.coreback.convertParamType("",o.params.params[a],e,!1),t--):r=await e.bot.coreback.convertParamType(n[t],o.params.params[a],e),r?.break)return;o.params.params[a]?.long?o.params.params[a].value=n.slice(a).join(" "):o.params.params[a].value=r?.value,t++}e.params=o.params.params}e.args=n;try{o&&o.code(e).catch(r=>e.bot.emit("contextError",new Errors.UnknownCommandError(e,r)))}catch(r){e.bot.emit("contextError",new Errors.UnknownCommandError(e,r))}}}async function LoadHybridGroup(t,r,e){if(r){let a=e?.shift()?.toLowerCase();var o;a&&(o=r.data.commands?.find(r=>r.data.name.toLowerCase()==a||r.data.aliases.includes(a)))&&(t.command=o,t.parent=r,LoadHybridCommand(t,o,e).catch(r=>t.bot.emit("contextError",new Errors.UnknownCommandError(new Context_1.Context(t.message,t.bot),r))))}}const event={name:"messageCreate",async code(r,e){if(!r.author.bot){let t=new Context_1.Context(r,e);if(e._options.guildOnly&&!r.guild)return e.emit("contextError",new Errors.GuildOnly(t));if((o="string"==typeof e._options.prefix?e._options.prefix:(0,types_1.isAsyncFunction)(e._options.prefix)?await e._options.prefix(t):e._options.prefix(t))&&r.content.toLowerCase().startsWith(o.toLowerCase())){var o=r.content.slice(o.length).trim().split(/ +/);let a=o.shift()?.toLowerCase();if(a){var n=e.skyfold.commands.PrefixType?.find(r=>r.data.names.includes(a)),s=e.skyfold.commands.HybridType?.find(r=>r.data.name.toLowerCase()==a||r.data.aliases.includes(a)),i=e.skyfold.commands.HybridGroupType?.find(r=>r.data.name.toLocaleLowerCase()==a);if(!n&&!s&&!i)return e.emit("contextError",new Errors.CommandNotFound(t,a));LoadHybridGroup(t,i,o).catch(r=>e.emit("contextError",new Errors.UnknownCommandError(t,r))),LoadHybridCommand(new Context_1.Context(r,e),s,o).catch(r=>e.emit("contextError",new Errors.UnknownCommandError(t,r))),LoadPrefixCommand(new Context_1.Context(r,e),n,o).catch(r=>e.emit("contextError",new Errors.UnknownCommandError(t,r)))}}}}};exports.event=event;

@@ -1,20 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Context = exports.Plugins = exports.Errors = exports.ParamsBuilder = exports.HybridBuilder = exports.HybridGroup = exports.PrefixBuilder = exports.ErineClient = void 0;
const tslib_1 = require("tslib");
const Base_1 = require("./classes/Base");
Object.defineProperty(exports, "ErineClient", { enumerable: true, get: function () { return Base_1.ErineClient; } });
const PrefixBuilder_1 = require("./classes/builders/PrefixBuilder");
Object.defineProperty(exports, "PrefixBuilder", { enumerable: true, get: function () { return PrefixBuilder_1.PrefixBuilder; } });
const HybridBuilder_1 = require("./classes/builders/HybridBuilder");
Object.defineProperty(exports, "HybridBuilder", { enumerable: true, get: function () { return HybridBuilder_1.HybridBuilder; } });
const HybridGroupBuilder_1 = require("./classes/builders/HybridGroupBuilder");
Object.defineProperty(exports, "HybridGroup", { enumerable: true, get: function () { return HybridGroupBuilder_1.HybridGroup; } });
const ParamsBuilder_1 = require("./classes/builders/ParamsBuilder");
Object.defineProperty(exports, "ParamsBuilder", { enumerable: true, get: function () { return ParamsBuilder_1.ParamsBuilder; } });
const Context_1 = require("./classes/Context");
Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return Context_1.Context; } });
const Core_1 = require("./classes/Core");
Object.defineProperty(exports, "Plugins", { enumerable: true, get: function () { return Core_1.Plugins; } });
const Errors = tslib_1.__importStar(require("./classes/Errors"));
exports.Errors = Errors;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.version=exports.Bucket=exports.Context=exports.Plugins=exports.Errors=exports.ParamsBuilder=exports.HybridBuilder=exports.HybridGroup=exports.PrefixBuilder=exports.ErineClient=void 0;const tslib_1=require("tslib"),Base_1=require("./classes/Base"),PrefixBuilder_1=(Object.defineProperty(exports,"ErineClient",{enumerable:!0,get:function(){return Base_1.ErineClient}}),require("./classes/builders/PrefixBuilder")),HybridBuilder_1=(Object.defineProperty(exports,"PrefixBuilder",{enumerable:!0,get:function(){return PrefixBuilder_1.PrefixBuilder}}),require("./classes/builders/HybridBuilder")),HybridGroupBuilder_1=(Object.defineProperty(exports,"HybridBuilder",{enumerable:!0,get:function(){return HybridBuilder_1.HybridBuilder}}),require("./classes/builders/HybridGroupBuilder")),ParamsBuilder_1=(Object.defineProperty(exports,"HybridGroup",{enumerable:!0,get:function(){return HybridGroupBuilder_1.HybridGroup}}),require("./classes/builders/ParamsBuilder")),Context_1=(Object.defineProperty(exports,"ParamsBuilder",{enumerable:!0,get:function(){return ParamsBuilder_1.ParamsBuilder}}),require("./classes/Context")),Core_1=(Object.defineProperty(exports,"Context",{enumerable:!0,get:function(){return Context_1.Context}}),require("./classes/Core")),Errors=(Object.defineProperty(exports,"Plugins",{enumerable:!0,get:function(){return Core_1.Plugins}}),tslib_1.__importStar(require("./classes/Errors"))),version=(exports.Errors=Errors,require("../package.json").version),Bucket=(exports.version=version,{Member:"MEMBER",User:"USER",Guild:"GUILD",Channel:"CHANNEL"});exports.Bucket=Bucket;

@@ -111,2 +111,3 @@ import { Awaitable, BitFieldResolvable, ClientOptions, Snowflake, Client, ClientEvents, Message, User, TextChannel, GuildMember, Guild, CommandInteraction, Collection, SlashCommandBuilder, PermissionResolvable, Channel } from "discord.js";

}): Promise<void | InteractionResponse>;
deferEdit(options: string | MessagePayload | MessageCreateOptions | InteractionReplyOptions): Promise<Message | null>;
get<T>(param: string, defaultValue?: any): T | null;

@@ -128,2 +129,17 @@ }

class Cooldowns {
bot: ErineClient;
track: Collection<string, number>;
constructor(bot: ErineClient);
getCooldownSource(command: string, id: Snowflake, bucket: Bucket): Promise<any>;
setCooldownSource(command: string, id: Snowflake, bucket: Bucket, time: number): Promise<void>;
check(command: string, id: string, cooldown: number, bucket: Bucket): Promise<{
command: string;
id: string;
time: number;
bucket: Bucket;
left: number;
} | null>;
}
export interface DataHybridBuilder {

@@ -149,2 +165,3 @@ name: string

}
export interface DataPrefixBuilder {

@@ -154,3 +171,2 @@ names: string[]

usage?: string | null
cooldown?: number
category?: string | null

@@ -160,2 +176,9 @@ extra?: any

export enum Bucket {
Member = "MEMBER",
User = "USER",
Guild = "GUILD",
Channel = "CHANNEL"
}
class MissingPermission { ctx: Context; permission: PermissionResolvable; constructor(context: Context, perm: PermissionResolvable)}

@@ -172,2 +195,3 @@ class MissingChannelPermission { ctx: Context; permissions: PermissionResolvable; channel: Channel; constructor(context: Context, perm: PermissionResolvable, channel: Channel) }

class NotParamBoolean { ctx: Context; param: BaseParam; constructor(context: Context, param: BaseParam)}
class InvalidParamAttachment { ctx: Context; param: BaseParam; constructor(context: Context, param: baseParam) }
class InvalidParamChoice { ctx: Context; param: BaseParam; choices: { name: string; value: any}[]; constructor(context: Context, param: BaseParam, choices: { name: string; value: any}[])}

@@ -181,2 +205,3 @@ class InvalidParamMember { ctx: Context; param: BaseParam; constructor(context: Context, param: BaseParam)}

class OnlyForIDs { ctx: Context; snowflakes: Snowflake[]; constructor(context: Context, snowflakes: Snowflake[]) }
class CommandInCooldown { ctx: Context; timeLeft: number; constructor(context: Context, timeLeft: number) }

@@ -195,2 +220,3 @@ const Errors: {

NotParamBoolean: NotParamBoolean
InvalidParamAttachment
InvalidParamChoice: InvalidParamChoice

@@ -204,2 +230,3 @@ InvalidParamMember: InvalidParamMember

OnlyForIDs: OnlyForIDs
CommandInCooldown
}

@@ -221,2 +248,3 @@

onlyForIDs(...snowflakes: Snowflake[]): Promise<(ctx: Context) => Promise<boolean>>;
cooldown(seconds: number, bucket: Bucket): Promise<(ctx: Context) => Promise<boolean>>
}

@@ -264,2 +292,3 @@

addRole(param: BaseParam): ParamsBuilder;
addAttachment(param: BaseParam): ParamsBuilder;
}

@@ -271,3 +300,2 @@

usage: string | null;
cooldown?: number;
category: string | null;

@@ -279,3 +307,2 @@ extra: any;

setUsage(data: string): PrefixBuilder;
setCooldown(cooldown: number): PrefixBuilder;
setExtra(data: any): PrefixBuilder;

@@ -289,4 +316,6 @@ }

public coreback: Coreback
public cooldowns: Cooldowns
public load_events(dir: string): Promise<void>
public load_commands(dir: string): Promise<void>
public load_interactions(dir: string): Promise<void>
public on<K extends keyof ErineEvents>(event: K, listener: (...args: ErineEvents[K]) => Awaitable<void>): this;

@@ -312,2 +341,3 @@ public on<S extends string | symbol>(event: Exclude<S, keyof ErineEvents>, listener: (...args: any[]) => Awaitable<void>): this;

Skyfold,
Cooldowns,
Context,

@@ -319,4 +349,5 @@ Coreback,

PrefixBuilder,
Bucket,
Errors,
Plugins
}
{
"devDependencies": {
"@types/node": "^18.11.11",
"lodash": "^4.17.21",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.1",
"typescript": "^4.9.3"
"typescript": "^4.9.3",
"uglify-js": "^3.17.4"
},

@@ -15,7 +17,8 @@ "dependencies": {

"description": "A powerful discord.js framework to use in your bot!",
"version": "1.1.4",
"version": "1.1.41",
"main": "core/main.js",
"types": "main.d.ts",
"scripts": {
"test": "ts-node src/tests/index.ts"
"test": "ts-node src/tests/index.ts",
"ugly": "node core/util/uglifier.js"
},

@@ -26,3 +29,9 @@ "repository": {

},
"keywords": ["hybrid", "discord.js", "framework", "hybrid-commands", "discord.py"],
"keywords": [
"hybrid",
"discord.js",
"framework",
"hybrid-commands",
"discord.py"
],
"author": "",

@@ -29,0 +38,0 @@ "license": "ISC",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc