Giter Site home page Giter Site logo

ninja-5000 / elysium-fork Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 2.0 213 KB

Open-Source code of Elysium bot.

Home Page: https://canary.discord.com/api/oauth2/authorize?client_id=786480896928645131&permissions=268504080&scope=applications.commands%20bot

License: Other

JavaScript 100.00%

elysium-fork's Introduction

discord.js Bot Template

This is a template for a Discord bot. It is written in JavaScript and uses the discord.js library. It is designed to be easy to use and easy to modify.

Features

Feature
✅ Very easy and simple
✅ Supports most modern features such as slash commands, message components, modals...
✅ Localization
✅ Command Handler
✅ Built-in commands
✅ Error handler
✅ Custom logger
✅ Custom embeds

Setup

  1. Clone this repository.
  2. Run npm install to install dependencies.
  3. Rename the .env.example file to .env and fill in the values.
  4. Fill in the values in config.json.
  5. Run npm start to start the bot.

Commands

Setting Up Commands

  1. Create a new file in the src/commands directory.
  2. Copy the following code into the file:
const { SlashCommandBuilder, ChatInputCommandInteraction } = require("discord.js");

module.exports = {
    category: 'General', // The category the command belongs to. "Owner" and "Developer" are special categories. You can use anything as a category.
    data: new SlashCommandBuilder() // The command data
        .setName('command') // The name of the command
        .setDescription('Command description'), // The description of the command
    /**
     * @param {ChatInputCommandInteraction} interaction 
     */
    async execute(interaction) {
        interaction.reply('Hello, world!');
    }
};
  1. Fill in the values in the code.

Built-in Commands

  • ping: Replies with the bot's ping.
  • help: Replies with the help menu.
  • eval: Evaluates JavaScript code.

Embeds

We use a custom embed class to make it easier to create embeds. It is similar to discord.js's EmbedBuilder but with default values. You can find the class in src/modules/embed.js.

Creating an Embed

const EmbedMaker = require('../modules/embed.js');

const embed = new EmbedMaker(client) // You can use interaction.client in command files
    .setTitle('Title')
    .setDescription('Description')

Localization

Adding a localization

  1. Find your language file in src/i18n and open it. If it doesn't exist, create it.
  2. Copy the following code into the file:
module.exports = {
    MY_LOCALIZED_TEXT: 'My localized text',
    // ...
};
  1. Fill in the values in the code.
  2. Add your language to the locales object in src/modules/localization.js.

Using a localization

const { localize } = require('../modules/localization.js');

console.log(localize('en-US', 'MY_LOCALIZED_TEXT')); // Replace 'en-US' with the language code of your language file.

Logger

We use a custom logger class to make it easier to log messages. You can find the class in src/modules/logger.js.

Logging a message

Method Usage: logger(type, title, ...messages)

const logger = require('../modules/logger.js');

logger('warning', 'COMMAND', 'Command', 'eval', 'blocked for', 'tolgchu', 'because it is developer only');

According to the above code, the logger will highlight "eval" and "tolgchu" parts.

Logger example

elysium-fork's People

Contributors

tolga1452 avatar taynotfound avatar

Forkers

sidd-underscore

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.