From 3235944d836dd88ed003f8bfd2486fb21710359f Mon Sep 17 00:00:00 2001 From: 1computer1 Date: Thu, 16 May 2019 20:51:46 -0400 Subject: [PATCH] Add user-friendly names and show enabled languages --- src/commands/help.js | 19 ++++--------------- src/languages/bash.js | 1 + src/languages/c.js | 1 + src/languages/clojure.js | 1 + src/languages/cpp.js | 1 + src/languages/csharp.js | 1 + src/languages/elixir.js | 1 + src/languages/fsharp.js | 1 + src/languages/go.js | 1 + src/languages/haskell.js | 1 + src/languages/java.js | 1 + src/languages/javascript.js | 1 + src/languages/julia.js | 1 + src/languages/lua.js | 1 + src/languages/ocaml.js | 1 + src/languages/pascal.js | 1 + src/languages/perl.js | 1 + src/languages/php.js | 1 + src/languages/prolog.js | 1 + src/languages/python.js | 1 + src/languages/racket.js | 1 + src/languages/ruby.js | 1 + src/languages/rust.js | 1 + src/struct/Language.js | 2 ++ 24 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/commands/help.js b/src/commands/help.js index 1ca2688..56d9792 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -11,24 +11,13 @@ class HelpCommand extends Command { exec(message) { return message.util.send([ '**Usage:**', - 'Put a `>` before a code block with a language or an inline code block that has a language to execute it.', + 'Put a `>` before a code block or inline codeblock that starts with a language code to execute it.', 'You can add options, separated by semicolons, after the `>`.', '', - '**Examples:**', - '```', - '>`\u200B``py', - 'print(\'Hello world!\');', - '`\u200B``', + '**Enabled Languages (Name: Language Codes):**', + ...this.client.languageHandler.modules.map(lang => `${lang.name}: \`${lang.aliases.join('`, `')}\``), '', - '>`hs main = print (1 + 1)`', - '', - '>e; harmony`\u200B``js', - 'class Foo { bar = 1; }', - 'new Foo().bar;', - '`\u200B``', - '```', - '', - 'Read the readme for supported languages and options: ' + 'See the readme for usage examples, supported languages, and options: ' ]); } } diff --git a/src/languages/bash.js b/src/languages/bash.js index d9cfffd..65b5671 100644 --- a/src/languages/bash.js +++ b/src/languages/bash.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Bash extends Language { constructor() { super('bash', { + name: 'Bash', aliases: ['bash', 'sh'] }); } diff --git a/src/languages/c.js b/src/languages/c.js index c33c2bc..a773bd5 100644 --- a/src/languages/c.js +++ b/src/languages/c.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class C extends Language { constructor() { super('c', { + name: 'C', aliases: ['c'] }); } diff --git a/src/languages/clojure.js b/src/languages/clojure.js index d05ceeb..4fd13c7 100644 --- a/src/languages/clojure.js +++ b/src/languages/clojure.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Clojure extends Language { constructor() { super('clojure', { + name: 'Clojure', aliases: ['clojure', 'clj'] }); } diff --git a/src/languages/cpp.js b/src/languages/cpp.js index a7a2053..b11cda6 100644 --- a/src/languages/cpp.js +++ b/src/languages/cpp.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class CPP extends Language { constructor() { super('cpp', { + name: 'C++', aliases: ['cpp', 'c++'] }); } diff --git a/src/languages/csharp.js b/src/languages/csharp.js index 070e245..0ca2c24 100644 --- a/src/languages/csharp.js +++ b/src/languages/csharp.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class CSharp extends Language { constructor() { super('csharp', { + name: 'C#', aliases: ['csharp', 'cs'], options: { e: () => '' diff --git a/src/languages/elixir.js b/src/languages/elixir.js index d7c6dd3..e0b1cb1 100644 --- a/src/languages/elixir.js +++ b/src/languages/elixir.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Elixir extends Language { constructor() { super('elixir', { + name: 'Elixir', aliases: ['elixir'] }); } diff --git a/src/languages/fsharp.js b/src/languages/fsharp.js index cc3ccc2..89b939f 100644 --- a/src/languages/fsharp.js +++ b/src/languages/fsharp.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class FSharp extends Language { constructor() { super('fsharp', { + name: 'F#', aliases: ['fsharp', 'fs'] }); } diff --git a/src/languages/go.js b/src/languages/go.js index 34427bf..9a487a3 100644 --- a/src/languages/go.js +++ b/src/languages/go.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Go extends Language { constructor() { super('go', { + name: 'Go', aliases: ['golang', 'go'] }); } diff --git a/src/languages/haskell.js b/src/languages/haskell.js index 7e86266..193c311 100644 --- a/src/languages/haskell.js +++ b/src/languages/haskell.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Haskell extends Language { constructor() { super('haskell', { + name: 'Haskell', aliases: ['haskell', 'hs'], options: { e: () => '' diff --git a/src/languages/java.js b/src/languages/java.js index 2c4ce4e..27848e3 100644 --- a/src/languages/java.js +++ b/src/languages/java.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Java extends Language { constructor() { super('java', { + name: 'Java', aliases: ['java'] }); } diff --git a/src/languages/javascript.js b/src/languages/javascript.js index a88558d..1ee6974 100644 --- a/src/languages/javascript.js +++ b/src/languages/javascript.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class JavaScript extends Language { constructor() { super('javascript', { + name: 'JavaScript', aliases: ['javascript', 'js'], options: { harmony: () => '', diff --git a/src/languages/julia.js b/src/languages/julia.js index 09b6e27..bbc20e0 100644 --- a/src/languages/julia.js +++ b/src/languages/julia.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Julia extends Language { constructor() { super('julia', { + name: 'Julia', aliases: ['julia'], options: { e: () => '' diff --git a/src/languages/lua.js b/src/languages/lua.js index f630ece..62eae16 100644 --- a/src/languages/lua.js +++ b/src/languages/lua.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Lua extends Language { constructor() { super('lua', { + name: 'Lua', aliases: ['lua'] }); } diff --git a/src/languages/ocaml.js b/src/languages/ocaml.js index a66b4e1..01adf12 100644 --- a/src/languages/ocaml.js +++ b/src/languages/ocaml.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class OCaml extends Language { constructor() { super('ocaml', { + name: 'OCaml', aliases: ['ocaml'] }); } diff --git a/src/languages/pascal.js b/src/languages/pascal.js index f4969c4..6ac387c 100644 --- a/src/languages/pascal.js +++ b/src/languages/pascal.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Pascal extends Language { constructor() { super('pascal', { + name: 'Pascal', aliases: ['pascal', 'pas', 'freepascal'] }); } diff --git a/src/languages/perl.js b/src/languages/perl.js index ac6c7d9..ad25559 100644 --- a/src/languages/perl.js +++ b/src/languages/perl.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Perl extends Language { constructor() { super('perl', { + name: 'Perl', aliases: ['perl', 'pl'] }); } diff --git a/src/languages/php.js b/src/languages/php.js index 70628a8..f1c446f 100644 --- a/src/languages/php.js +++ b/src/languages/php.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class PHP extends Language { constructor() { super('php', { + name: 'PHP', aliases: ['php'] }); } diff --git a/src/languages/prolog.js b/src/languages/prolog.js index b5b97d4..6858e3e 100644 --- a/src/languages/prolog.js +++ b/src/languages/prolog.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Prolog extends Language { constructor() { super('prolog', { + name: 'Prolog', aliases: ['prolog'] }); } diff --git a/src/languages/python.js b/src/languages/python.js index d2d91f2..3ad3d56 100644 --- a/src/languages/python.js +++ b/src/languages/python.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Python extends Language { constructor() { super('python', { + name: 'Python', aliases: ['python', 'py'], loads: ['python3', 'python2'], options: { diff --git a/src/languages/racket.js b/src/languages/racket.js index be8f64a..2394c54 100644 --- a/src/languages/racket.js +++ b/src/languages/racket.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Racket extends Language { constructor() { super('racket', { + name: 'Racket', aliases: ['lisp'] }); } diff --git a/src/languages/ruby.js b/src/languages/ruby.js index f04f894..5a879a2 100644 --- a/src/languages/ruby.js +++ b/src/languages/ruby.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Ruby extends Language { constructor() { super('ruby', { + name: 'Ruby', aliases: ['ruby', 'rb'] }); } diff --git a/src/languages/rust.js b/src/languages/rust.js index b4f036a..3a88418 100644 --- a/src/languages/rust.js +++ b/src/languages/rust.js @@ -3,6 +3,7 @@ const Language = require('../struct/Language'); class Rust extends Language { constructor() { super('rust', { + name: 'Rust', aliases: ['rust', 'rs'] }); } diff --git a/src/struct/Language.js b/src/struct/Language.js index f3b1441..f33c819 100644 --- a/src/struct/Language.js +++ b/src/struct/Language.js @@ -3,12 +3,14 @@ const { AkairoModule } = require('discord-akairo'); class Language extends AkairoModule { constructor(id, { category, + name, aliases, loads = [id], options = {} } = {}) { super(id, { category }); + this.name = name; this.aliases = aliases; this.loads = loads; this.options = options;