Giter Site home page Giter Site logo

yui-discord / yui Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 0.0 3.47 MB

πŸ‘Ύ 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.

Home Page: https://bit.ly/yui-bot

JavaScript 99.90% Procfile 0.10%
discord discord-bot discord-js bot javascript yui sword-art-online sao

yui's Introduction

Yui

VersΓ£o em portuguΓͺs

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.


πŸ€” How to use in my server?

  • Add the bot, just click in this LINK
    • You must be an administrator on some server
  • Read the Docs of commands HERE
  • Enjoy 😁

🧩 Running locally

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

❌ Error Handling

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);
}

🧬 Application flow

Directories

/commands

  • 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,
};

/events

  • Directory where all bot events are found
  • Everything that will be executed as an action is here

/handlers

  • Where will the data be manipulated
  • Handlers are created to manipulate data types
    • Events
    • Errors
    • Commands

Important Files

index.js

  • Anonymous function
  • List the commands
  • Execute the handlers by sending the events directory

commands.handler.js

  • List the commands
  • Add them to the client which is the BOT instance

events.handler.js

  • Handle the events
  • Speak when the bot has fully started
  • Listen to the event message

error.handler.js

  • Handle errors
  • Say the types of errors

message.js

  • 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

ready.js

  • Shows how many servers the bot is connected to
  • Says the application is already running




πŸ“š References

yui's People

Contributors

miguelitodev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.