Giter VIP home page Giter VIP logo

advanced-command-handler's Introduction

Advanced Command Handler

npm npm GitHub issues GitHub last commit (branch)

npm install

This is an Advanced Command Handler for Discord Bots, which uses classes for commands & events. You have a plethora of utils like functions that everyone uses, functions for errors, functions for tedious things that everyone needs for a Discord Bot, and some classes to simplify Logging things and manipulating embeds.

Version 3.0 uses Discord.js v12, use 3.1 to use Discord.js v13.

This library is here to simplify a lot developing Discord Bots and is far from being finished with every feature I want to add.
So feel free to watch this repo for futures releases! For now, it offers :

  • Command Handling
  • SubCommand Handling
  • Event Handling
  • Default message event & help command
  • A complete Logger
  • Some utilities function for errors, jsons and other
  • Typed arguments for commands

For more information on how to use it, see the Guide and the Documentation :

You can also see some examples that I've made here.
Feel free to PR to these to update these and add features that this handler can offer!

That's all for now :)

advanced-command-handler's People

Contributors

actions-user avatar ayfri avatar dependabot-preview[bot] avatar dependabot[bot] avatar dergash avatar fantomitechno avatar ghomkrosmonaute avatar loockeeer avatar xgraza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

advanced-command-handler's Issues

2021 Plan

This issue lists all the things I want to make before 2021 Q2.

Note: Bold things are things that I'm not sure to do before 2021 Q2 and at all.

Utils

  • Add a function to get all the missing properties from a message and a command.
  • Add a permissionError function.
  • Add some JSON I/O functions.
  • Add more miscellaneous functions.
  • Use the new Intl.DateTimeFormatter to format date into the Logger.
  • (V3) Save logger output into files.

Core

  • Add an Event class.
  • Add more methods to the classes.
  • (V3) Change system so commands (and events) will have to be subclasses from Command (and Event) class.
  • (V3) Add diverse command classes to make automated things like methods to react when something slow has to be made, to avoid repeating code.
  • Use typescript.

Examples

  • Move examples to separate repos.
  • Make more examples.

Other

  • Be more organized with the module's updates.
  • Make the wiki for GitHub.

There error is logger file

/app/utils/Logger.js:8
static logComments = true;
^
SyntaxError: Unexpected token =
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)

Error when loading commands.

[24 15:50:02.483][LOADING] Advanced Command Handler 2.2.2 by Ayfri.
[24 15:50:02.523][LOADING] Client initialized.
[24 15:50:02.526][LOADING] Loading commands.
[24 15:50:02.526][LOADING] Categories : (5)
[24 15:50:02.527][LOADING] Commands in the category 'economy' : (2)
[24 15:50:02.529][LOADING] TypeError: command.getInvalidPermissions is not a function
at loadCommand (/home/cristiioan/Desktop/mcdiscord/node_modules/advanced-command-handler/dist/classes/CommandHandler.js:121:44)
at async loadCommands (/home/cristiioan/Desktop/mcdiscord/node_modules/advanced-command-handler/dist/classes/CommandHandler.js:144:21)
at async Object.launch (/home/cristiioan/Desktop/mcdiscord/node_modules/advanced-command-handler/dist/classes/CommandHandler.js:90:13)
[24 15:50:04.167][ERROR] An error occurred.
TypeError: CommandHandler.prefixes.push is not a function
at Object.launch (/home/cristiioan/Desktop/mcdiscord/node_modules/advanced-command-handler/dist/classes/CommandHandler.js:102:33)
at processTicksAndRejections (node:internal/process/task_queues:94:5)

Version No 12

I had installed version 12 also but still it getting logger.js error kindly check....

Bot not responding to commands

Hello again, is there something wrong with the command that I don't understand. Because i tried using with prefix and it doesn't seem to respond.
Screenshot_7

Putting not existing permissions in commands throw an error

The command handler throws at runtime, in the event message, if a command uses permissions that dont exists. It would be better to check if permission exists and throw if an unknown permission is used in the loadCommand method in CommandHandler

[QUESTION] Configuration

Hello I have a question, where am I suppose to put the configuration, how do I name it or what am i suppose to do here about the configuration. And also I have install npm advanced-command-handler sooo is there a file that will create for me? if so then it doesn't
Screenshot_7

Disabled command

Adding in the CommandOptions a property disabled as Boolean, false by default.
It can be used to restrict a command (for example adding in the default message event that only the owner can use (yes it's look like ownerOnly but for a disable [command] command it look more logic to change a property like that)

CommandHandler.launch({}) returns an error

Describe the bug
Whenever I try to start the bot, it gives out an error from the CommandHandler.launch({}) part

This is the error I am getting:

CommandHandler.instance.client = new AdvancedClient_1.default(CommandHandler.instance, options.token, options.clientOptions ?? {});

				                                                                                            ^

SyntaxError: Unexpected token '?'

Can't launch in v3.0.0-beta.3

Describe the bug
All is in the title

Here is my code to launch the Commandhandler :

CommandHandler.create({
    prefixes: prefixes,
    commandsDir: 'bot/commands',
    eventsDir: 'bot/events',
    owners: owners
})

CommandHandler.launch({
    token: token,
    clientOptions: {
        ws: {
            intents: Intents.ALL
        },
        restTimeOffset: 100,
        disableMentions: "everyone",
        messageCacheMaxSize: 100
    }
})

And here is the error :

[2021/07/24 10:17:43.270][LOADING] Error: Cannot find module 'E:\Users\Simon\Documents\Simon\Discord\BOTS\base\out\E:\Users\Simon\Documents\Simon\Discord\BOTS\base\out\bot\commands\info\help.js'
Require stack:
- E:\Users\Simon\Documents\Simon\Discord\BOTS\base\node_modules\advanced-command-handler\dist\CommandHandler.js
- E:\Users\Simon\Documents\Simon\Discord\BOTS\base\node_modules\advanced-command-handler\dist\index.js
- E:\Users\Simon\Documents\Simon\Discord\BOTS\base\out\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
    at Function.Module._load (internal/modules/cjs/loader.js:730:27)
    at Module.require (internal/modules/cjs/loader.js:957:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at E:\Users\Simon\Documents\Simon\Discord\BOTS\base\node_modules\advanced-command-handler\dist\CommandHandler.js:238:71
    at async loadCommand (E:\Users\Simon\Documents\Simon\Discord\BOTS\base\node_modules\advanced-command-handler\dist\CommandHandler.js:238:23)     
    at async loadCommands (E:\Users\Simon\Documents\Simon\Discord\BOTS\base\node_modules\advanced-command-handler\dist\CommandHandler.js:279:21)    
    at async Object.launch (E:\Users\Simon\Documents\Simon\Discord\BOTS\base\node_modules\advanced-command-handler\dist\CommandHandler.js:194:13)

Specific NSFW

In short, I simply propose to be able to make an order only in NSFW channels ( -18 years old ).

The bot does not respond to commands - 2021

index.js

const { Client, Intents } = require('discord.js');
const Discord = require('discord.js')
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES] });
const fs = require('fs')

client.config = require('./config.json')

const {CommandHandler} = require('advanced-command-handler');

CommandHandler.create({
    commandsDir: 'commands',
    eventsDir: 'events',
    
    prefixes: ['m*', "!"],
    owners: [client.config.ownerid],
    saveLogsInFile: ['logs.txt'],
    useMentionAsPrefix: true,
}).launch({
    token: '',
    clientOptions: {
            intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_MEMBERS']
    }
});

client.login('');

commands/misc/ping.js

const {Command} = require('advanced-command-handler');

module.exports = class PingCommand extends Command {
    name = 'ping';
    aliases = ["latency"];
    category = 'misc';

    async run(ctx) {
        ctx.send("Ping!")
    }
}

When I do the m*ping command, nothing happens

no such file or directory, open './src/assets/presentation.txt

internal/fs/utils.js:298
throw err;
^

Error: ENOENT: no such file or directory, open './src/assets/presentation.txt' at Object. (C:\Users\champ\Desktop\GitHub\Bailey.js\index.js:53:16)
at Module._compile (internal/modules/cjs/loader.js:1236:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
at Module.load (internal/modules/cjs/loader.js:1085:32)
at Function.Module._load (internal/modules/cjs/loader.js:950:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47 {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: './src/assets/presentation.txt'
}

Le Savoir Faire

Bonjour , je voudrais savoir où définir les truc du genre "client.db = new db()" ou "this.db = new db()"

isOwner function is not a function

Hey so I am not using the last update because I don't have the function isOwner. So i am using 2.2.2 because after this update their is no handler.client.isOwner('id') function is it normal or just a bug ?

Wrong place for the dayjs export after compilation

Describe the bug
The Handler have a version of dayjs with a plugin (duration) wich is extended after being imported, but after compilation in Javascript (aka in the published version) the plugin is not present after looking in the code it's look like dayjs is exported before the plugin is added.

Here is a screenshot of the code where is the problem : image

(I forgot to screen the lines so je first line of the screen is the 26th)

Suggestion

Ajouter un prop nsfw : true/false pour dire que si c'est pas dans un salon nsfw il envoie une erreur

Owner bypass

Describe the solution you'd like
In the CommandHandler.create() method add a boolean for if the owners of the bot can bypass commands that require permission (or some tags as guildowneronly...)

Not working

Describe the bug
Bot isn't starting.

To Reproduce
Start the bot, Download Here

Expected behavior
No

'Channels' option in commands options

Describe the solution you'd like
Suggestion for Command Handler,
Current is

{
    name: '',
    description: '',
    // Optionnals :
    usage: '',
    category: '',
    nsfw: false,
    guildOnly: false,
    ownerOnly: false,
    aliases: [],
    userPermissions: [],
    clientPermissions: [],
    cooldown: 10
}

I would like if there would be an channel: (Channel-ID), For Channel only Specific commands

New Update getting error

/app/utils/Logger.js:8
static logComments = true;
^
SyntaxError: Unexpected token =
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
/app/utils/Logger.js:8
static logComments = true;
^
SyntaxError: Unexpected token =
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
/app/utils/Logger.js:8
static logComments = true;
^
SyntaxError: Unexpected token =
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)

guildCreate event is not sending messages

so I tried guildCreate event when a bot joins a server it should send a message. i tried it multiple times and it works once but when i tried another one it wont work anymore.

Screenshot_7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.