@gcommands/plugin-language

Extend default discord.js events for GCommands

Usage no npm install needed!

<script type="module">
  import gcommandsPluginLanguage from 'https://cdn.skypack.dev/@gcommands/plugin-language';
</script>

README

GCommands Plugin More Events

Official plugin for GCommands


NPM Banner


Installation

Install with npm / yarn / pnpm:

npm install @gcommands/plugin-language
yarn add @gcommands/plugin-language
pnpm add @gcommands/plugin-language
// index.js
const { Plugins } = require('gcommands');
const { readFileSync } = require('fs');

require('@gcommands/plugin-language').default({
  defaultLanguage: 'en-GB',
  languageText: JSON.parse(readFileSync(`${__dirname}/responses.json`, 'utf-8'))
});

Plugins.search(__dirname);

// ERROR, COOLDOWN, NOT_FOUND are default in GCommands (you can change it via plugin-language)

// responses.json
{
  "en-GB": {
    "hello": "Hello!",
    "ERROR": "Broken :(",
    "COOLDOWN": "You need wait {duration} for {name}",
    "NOT_FOUND": "Undefined command"
  },
  "en-US": {
    "hello": "Hello!",
    "ERROR": "Broken :(",
    "COOLDOWN": "You need wait {duration} for {name}",
    "NOT_FOUND": "Undefined command"
  },
  "da": {
    "hello": "Hej"
  },
  "de": {
    "hello": "Hallo"
  },
  "es-ES": {

  },
  "fr": {

  },
  "hr": {

  },
  "it": {
      
  },
  "lt": {

  },
  "hu": {

  },
  "nl": {

  },
  "no": {
      
  },
  "pl": {

  },
  "pt-BR": {

  },
  "ro": {
      
  },
  "fi": {

  },
  "sv-SE": {

  },
  "vi": {

  },
  "tr": {

  },
  "cs": {

  },
  "el": {

  },
  "bg": {

  },
  "ru": {
      
  },
  "uk": {

  },
  "hi": {

  },
  "th": {

  },
  "zh-CN": {

  },
  "ja": {

  },
  "zh-TW": {

  },
  "ko": {
      
  }
}
// ^ 

// command.js
const { Command } = require('gcommands');
const { LanguageManager } = require('@gcommands/plugin-language');

new Command({
  run: (ctx) => {
    const hello = LanguageManager.__(ctx.interaction, 'hello');

    ctx.reply({
      content: hello
    });
  }
})