slash improvements

master
Kit Kasune 3 years ago
parent 4e35a7fdb6
commit b4b06961fe
  1. 16
      .idea/workspace.xml
  2. 21
      bot.js
  3. 3
      events/ready.js
  4. 2
      slash/fun/8ball.js
  5. 2
      util/slashmanager.d.ts
  6. 19
      util/slashmanager.js
  7. 19
      util/ts/slashmanager.ts

@ -5,7 +5,13 @@
</component>
<component name="ChangeListManager">
<list default="true" id="826c705b-a7fa-4ece-b82a-e278fca7d494" name="Changes" comment="more generous daily windows">
<change beforePath="$PROJECT_DIR$/commands/anime/haswatched.js" beforeDir="false" afterPath="$PROJECT_DIR$/commands/anime/haswatched.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bot.js" beforeDir="false" afterPath="$PROJECT_DIR$/bot.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/events/ready.js" beforeDir="false" afterPath="$PROJECT_DIR$/events/ready.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/slash/8ball.js" beforeDir="false" afterPath="$PROJECT_DIR$/slash/fun/8ball.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/slashmanager.d.ts" beforeDir="false" afterPath="$PROJECT_DIR$/util/slashmanager.d.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/slashmanager.js" beforeDir="false" afterPath="$PROJECT_DIR$/util/slashmanager.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/ts/slashmanager.ts" beforeDir="false" afterPath="$PROJECT_DIR$/util/ts/slashmanager.ts" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -43,14 +49,14 @@
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/util/ts" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="settings.editor.selected.configurable" value="MTConfigurable" />
<property name="ts.external.directory.path" value="C:\Users\clarkjr1836\Downloads\WebStorm-2021.2.2.win\plugins\JavaScriptLanguage\jsLanguageServicesImpl\external" />
<property name="ts.external.directory.path" value="C:\Program Files\JetBrains\WebStorm 2021.2\plugins\JavaScriptLanguage\jsLanguageServicesImpl\external" />
<property name="ts.rename.search.for.dynamic.occurrences" value="true" />
<property name="vue.rearranger.settings.migration" value="true" />
</component>
@ -58,6 +64,9 @@
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\clarkjr1836\Desktop\bot\Natsuki\util\ts" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\wubzy\Desktop\bot\Natsuki\slash\fun" />
</key>
</component>
<component name="RunAnythingCache">
<option name="myCommands">
@ -90,6 +99,7 @@
<workItem from="1642537991410" duration="3454000" />
<workItem from="1642638383959" duration="700000" />
<workItem from="1642707112676" duration="1337000" />
<workItem from="1644446122031" duration="2837000" />
</task>
<task id="LOCAL-00001" summary="not even gonna explain">
<created>1640148826800</created>

@ -74,11 +74,8 @@ client.misc = {
fullyReady: false
};
//const config = require('./config.js');
const auth = require('./auth.json');
//client.config = config;
async function init() {
const cliargs = new TagFilter([
new Tag(['cli', 'c', 'nc', 'nocli'], 'nocli', 'toggle'),
@ -108,10 +105,6 @@ async function init() {
client.misc.startupNoConnect = new Date();
client.config = auth;
client.slash = new SlashManager(client).setTestServer('691122844339404800').importCommands().init();
client.slash.register();
client = client.slash.client;
let mloginsp = ora(chalk.magentaBright('Connecting to Mongo client...')).start();
let pmcc = new Date().getTime();
const config = client.config;
@ -140,6 +133,8 @@ async function init() {
client.utils.c = (text, a=true) => `${text.slice(0, 1).toUpperCase()}${a ? text.slice(1).toLowerCase() : text.slice(1)}`;
client.utils.ca = (text, a=true) => text.split(/\s+/gm).map(t => client.utils.c(t, a)).join(" ");
client.utils.sm = (mpr, ago=true) => `${mpr.years ? `${mpr.years} year${client.utils.s(mpr.years)} ` : ''}${mpr.months ? `${mpr.months} month${client.utils.s(mpr.months)} ` : ''}${mpr.days} day${client.utils.s(mpr.days)}${ago ? ' ago' : ''}`;
client.utils.p = (text) => text.endsWith('s') ? "'" : "'s";
client.utils.ps = (text) => `${text}${client.utils.p(text)}`;
['commands', 'aliases', 'executables'].forEach(x => client[x] = new Discord.Collection());
client.responses = {triggers: [], commands: new Discord.Collection()};
@ -151,7 +146,19 @@ async function init() {
.map(i => client.misc.config.gradients ? gs.instagram(i) : chalk.blue(i))
.forEach((i, ind) => client.misc.cache.spin.add(iters[ind], {text: i}));
}
for (let i = 0; i < iters.length; i++) {let x = iters[i]; await require(`./handle/${x}`)(client);}
const spl = client.misc.config.spinners ? (i) => client.misc.cache.spinLog.push(i) : (i) => console.log(i);
spl(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Getting Slash Commands...')}\n`);
client.slash = new SlashManager(client)
.setTestServer('691122844339404800')
.importCommands(false, undefined, (cmd) => spl(`${chalk.gray('[LOAD]')} >> ${chalk.blueBright('Loaded Slash Command')} ${chalk.white(cmd.name)}`))
.init();
if (client.misc.config.dev) {await client.slash.devRegister();}
else {await client.slash.register();}
client = client.slash.client;
spl(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Loaded all Slash Commands')}`);
if (client.misc.config.spinners) {
client.misc.cache.spinLog.forEach(log => console.log(log));
}

@ -21,9 +21,6 @@ module.exports = async client => {
const config = client.config;
/*let db = mongoose.connection;
await db.guild.update({}, {"$set": {'prefix': ''}}, false, true);*/
console.log(`\n${chalk.green('[BOOT]')} >> [${moment().format('L LTS')}] -> ${chalk.greenBright("Connected to Discord")}.`);
let date = new Date; date = date.toString().slice(date.toString().search(":") - 2, date.toString().search(":") + 6);
console.log(`\n${chalk.gray('[INFO]')} >> ${chalk.white(`Logged in at ${date}.`)}`);

@ -1,4 +1,4 @@
const {SlashCommand} = require('../util/slash');
const {SlashCommand} = require('../../util/slash');
const {SlashCommandBuilder} = require('@discordjs/builders');
const Discord = require('discord.js');

@ -21,7 +21,7 @@ export declare class SlashManager {
setAfterHandle(execute: (client: Discord.Client, interaction: Discord.CommandInteraction, success: Boolean) => any): SlashManager;
setTestServer(id: string): SlashManager;
private handle;
importCommands(dir?: string): SlashManager;
importCommands(register?: boolean | RegisterMode, dir?: string, log?: (command: SlashCommand, manager: SlashManager) => void): SlashManager;
}
declare type CommandLookup = SlashCommand[] | SlashCommand | string | string[];
export {};

@ -123,12 +123,19 @@ class SlashManager {
this.afterHandle(this.client, interaction, success);
}
;
importCommands(dir) {
dir = dir || './slash';
const commands = fs.readdirSync(dir).filter(file => file.endsWith('.js'));
for (const command of commands) {
this.add(require(`../${dir}/${command}`)(this.client));
}
importCommands(register = false, dir = './slash', log = () => { }) {
const search = (toSearch) => {
let cdir = fs.readdirSync(toSearch);
const commands = cdir.filter(file => file.endsWith('.js'));
for (const command of commands) {
const slashCommand = require(`../${toSearch}/${command}`)(this.client);
this.add(slashCommand, register);
log(slashCommand, this);
}
const subdirs = cdir.filter(file => fs.lstatSync(`${toSearch}/${file}`).isDirectory());
subdirs.forEach(subdir => search(`${toSearch}/${subdir}`));
};
search(dir);
return this;
}
;

@ -115,12 +115,19 @@ export class SlashManager {
public importCommands(dir?: string): SlashManager {
dir = dir || './slash';
const commands = fs.readdirSync(dir).filter(file => file.endsWith('.js'));
for (const command of commands) {
this.add(require(`../${dir}/${command}`)(this.client));
}
public importCommands(register: boolean | RegisterMode = false, dir: string = './slash', log: (command: SlashCommand, manager: SlashManager) => void = () => {}): SlashManager {
const search = (toSearch: string): void => {
let cdir = fs.readdirSync(toSearch);
const commands = cdir.filter(file => file.endsWith('.js'));
for (const command of commands) {
const slashCommand = require(`../${toSearch}/${command}`)(this.client);
this.add(slashCommand, register);
log(slashCommand, this);
}
const subdirs = cdir.filter(file => fs.lstatSync(`${toSearch}/${file}`).isDirectory());
subdirs.forEach(subdir => search(`${toSearch}/${subdir}`));
};
search(dir);
return this;
};

Loading…
Cancel
Save