Almost like a daughter, it's a general purpose bot, called Yui I'm developing for discord with discord.js library, the name is inspired by the character Yui from the anime Sword Art Online, which at first is an A.I.
- Add the bot, just click in this LINK
- You must be an administrator on some server
- Read the Docs of commands HERE
- Enjoy 😁
Before all you must to be added the bot in your server, to do this follow the link
// Clone de repository
$ git clone https://github.com/miguelrisquelme/yui.git
// Install the dependencies
$ npm i
// Create and configure the file .env, follow the example on .env.example
~/.env
// Start the aplication
$ npm run dev
For the error consoles to work, the folder structure has to be standardized, just follow these instructions:
-
The command name must be the same as its folder name.
/commands/${nameCommand}
module.exports = { name: `${nameCommand}`, description: "Description Command", execute, };
-
The name of the functions must be the same as the arguments passed after the command
> time ${args}
/commands/time/functions/${args}.js
Example Output:
❌ TypeError: message.channel.sen is not a function
🦊 Input: '> time hours'
✨ Command: time
🔥 Function: hours
🧅 Possible Path: /commands/time/hours.js
The code of catch Error:
const error = require("../utils/handlers/errors/errors.handler");
...
catch (err) {
const args = message.content.slice(prefix.length).trim().split(/ +/);
console.error(`
❌ ${err.toString()}
🦊 Input: '${message.content}'
✨ Command: ${args[0]}
🔥 Function: ${args[1]}
🧅 Possible Path: /commands/${args[0]}/${args[1]}.js
`);
console.error(err);
error.handler(err, message);
}
- Directory where all bot commands are found
- Each command is in a folder with its name
- Inside each folder has
- main.js - Command settings
- /functions - Inside this folder are the subcommands so to speak
Code example
// Imports
const execute = (message, args) => {
try {
// The code to execute
} catch (error) {
console.error(error);
}
};
module.exports = {
name: "Command's name",
description: "Description's command",
execute,
};
- Directory where all bot events are found
- Everything that will be executed as an action is here
- Where will the data be manipulated
- Handlers are created to manipulate data types
- Events
- Errors
- Commands
- Anonymous function
- List the commands
- Execute the handlers by sending the events directory
- List the commands
- Add them to the client which is the BOT instance
- Handle the events
- Speak when the bot has fully started
- Listen to the event message
- Handle errors
- Say the types of errors
- Check who is calling the command, if it is the OWNER_ID it will assign the name defined in the
.env
file - Handles the triggered event
- Do the checks
- Execute the command
- Shows how many servers the bot is connected to
- Says the application is already running