From 451d5789652bdc834fe23771ca6ed129aa5cc1c3 Mon Sep 17 00:00:00 2001 From: Wessel T Date: Mon, 18 Mar 2019 16:09:18 +0100 Subject: [PATCH] Even more things! --- .github/CONTRIBUTING.md | 4 +- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 2 +- README.md | 5 +- TODO.md | 2 +- package.json | 8 +- src/_application.yml | 127 +++++++------------ src/assets/i18n/en_us/logs.yml | 8 +- src/assets/i18n/en_us/strings.yml | 10 +- src/assets/i18n/nl/logs.yml | 8 +- src/assets/i18n/nl/strings.yml | 10 +- src/commands/Discord/Core/locale.js | 2 + src/commands/Discord/Core/prefix.js | 1 + src/commands/Discord/Developer/echo.js | 2 + src/commands/Discord/Developer/eval.js | 5 +- src/commands/Discord/Developer/exec.js | 3 + src/commands/Discord/Games/splatoon.js | 2 + src/commands/Discord/Image/birb.js | 2 + src/commands/Discord/Information/avatar.js | 2 + src/commands/Discord/Information/commands.js | 41 +++--- src/commands/Discord/Information/commits.js | 4 +- src/commands/Discord/Information/guild.js | 2 + src/commands/Discord/Information/stats.js | 2 + src/commands/Discord/Information/user.js | 2 + src/commands/Discord/Tags/tag-add.js | 2 + src/commands/Discord/Tags/tag-del.js | 2 + src/commands/Discord/Tags/tag-info.js | 2 + src/commands/Discord/Tags/tag-source.js | 2 + src/commands/Discord/Tags/tag.js | 2 + src/commands/Discord/Tags/tags.js | 2 + src/commands/Discord/Utility/math.js | 2 + src/commands/Discord/Utility/ping.js | 2 + src/commands/Discord/Utility/snipe.js | 10 +- src/commands/Discord/_base.js | 40 ++++++ src/core/clients/Discord.js | 2 +- src/core/internal/Discord/Command.js | 41 +++--- src/core/internal/Discord/Context.js | 18 ++- src/core/internal/Discord/Event.js | 18 ++- src/core/internal/Discord/__baseCommand.js | 25 ---- src/core/internal/Discord/rest.js | 93 ++++++++++---- src/core/registry/Discord/Commands.js | 14 +- src/core/registry/Discord/Events.js | 2 +- src/events/Discord/_base.js | 24 ++++ src/events/Discord/guildMemberAdd.js | 5 +- src/events/Discord/ready.js | 2 +- src/main.js | 5 +- 47 files changed, 352 insertions(+), 221 deletions(-) create mode 100644 src/commands/Discord/_base.js delete mode 100644 src/core/internal/Discord/__baseCommand.js create mode 100644 src/events/Discord/_base.js diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index be232bd..02cec26 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,7 +2,7 @@ **The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the [Discord](https://discord.gg/SV7DAE9) instead of opening an issue – you will get redirected there anyway.** -If you wish to contribute to Wump, feel free to fork the repository and submit a pull request. +If you wish to contribute to Yorushika, feel free to fork the repository and submit a pull request. [ESLint](https://eslint.org/) is used to correct most typo's you make, so it would be helpful if you added [ESLint](https://eslint.org/) to your editor of choice) ## Setup @@ -11,4 +11,4 @@ To get ready to work on the codebase, please do the following: 1. Fork & clone the repository, and make sure you're on the **master** branch 2. Run `yarn --dev` or `npm install --dev` 4. Code your heart out and test using `yarn test` or `npm run test`! -6. [Submit a pull request](https://github.com/PassTheWessel/wump/compare) \ No newline at end of file +6. [Submit a pull request](https://github.com/PassTheWessel/yorushika/compare) \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 6ede35f..32591d3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,6 +1,6 @@ --- name: Bug Report -about: Report an issue with Wump +about: Report an issue with Yorushika title: "[BUG] Somenthing broke" labels: bug assignees: PassTheWessel diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 9fc05d7..0294930 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,6 +1,6 @@ --- name: Feature request -about: Request a feature for Wump +about: Request a feature for Yorushika title: "[ENHANCEMENT] This is an amazing new idea!" labels: enhancement assignees: PassTheWessel diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 97490f4..a9a9c7f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,6 +5,6 @@ - [ ] Code changes have been tested and there aren't any typos in it **Semantic versioning classification:** -- [ ] This PR changes wump's core codebase (methods or parameters added) +- [ ] This PR changes yorushika's core codebase (methods or parameters added) - [ ] This PR includes breaking changes (methods removed or renamed, parameters moved or removed) - [ ] This PR **only** includes non-code changes, like changes to documentation, README, etc. \ No newline at end of file diff --git a/README.md b/README.md index 50fa553..d378f78 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

- Wump + Yorushika


@@ -12,4 +12,7 @@ > A multi-platform bot written fully in Node.js +# Documentation +Yorushika's documentation can be found at [https://wumpusapp.gitbook.io](https://wumpusapp.gitbook.io) + You may use this project, but only **if** you follow the [licensing](./LICENSE) diff --git a/TODO.md b/TODO.md index d1a52e5..1f9dfe6 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,7 @@ - [x] = In progress - [ ] Global - - [ ] Clean locales + - [x] Clean locales - [ ] Information - [ ] Commands - [ ] Stats (rewrite) diff --git a/package.json b/package.json index b6c1fca..9b6ed3a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "wump", - "version": "1.5.3", - "displayName": "Wump", + "name": "yorushika", + "version": "1.5.5", + "displayName": "Yorushika", "description": "A multi-platform bot written in Node.js", "author": "Wessel \"wesselgame\" T ", "contributors": [], @@ -26,5 +26,5 @@ "eslint": "^5.6.0" }, "main": "src/main.js", - "repository": "https://github.com/PassTheWessel/wump" + "repository": "https://github.com/PassTheWessel/yorushika" } diff --git a/src/_application.yml b/src/_application.yml index 07ef37d..0be5107 100644 --- a/src/_application.yml +++ b/src/_application.yml @@ -1,91 +1,56 @@ -#-----------------[ Wump config ]-----------------# -# This is the configuration file of "Wump", all # -# your sensitive information is stored inside of # -# this file. Do **not** give this file or it's # -# contents to **anyone**, they can do a lot of # -# bad things with your tokens. Don't forget to # -# follow the licensing. - Wessel # -#-------------[ Configurable values ]-------------# -# db - : The db URI (Mongo) # -# debug - : The logging level # -# nightly - : Run inside of dev mode # -# discord: # -# enabled - : Enable/disable client # -# op - : The bot's OwnerIDs # -# token - : The bot's tokens # -# prefix - : The command prefix # -# events - Each: Enable/disable evts # -# playing - Each: The bot's status # -# commands - Each: Enable/disable cmds # -#-------------------------------------------------# - -db : 'mongodb://localhost:27017/Wump' -debug : 3 +#-----------------[ Yorushika config ]-----------------# +# This is the configuration file of "Wump", all your # +# sensitive information is stored inside of this file. # +# Do **not** give this file or it's contents to # +# **anyone**, they can do a lot of bad things with # +# your tokens. Please be kind and follow the license. # +# - Wessel # +#------------------------------------------------------# +debug: 4 nightly: true -discord : - enabled: true - token : '<--snip-->' - prefix : '!' - locale : 'en_us' +db: 'mongodb://localhost:27017/Wump' - op : +discord: + token: '<--snip-->' + prefix: '!' + locale: 'en_us' + enabled: true + + op: - '107130754189766656' - playing : - url : 'https://twitch.tv/wumpusapp' - name : 'type !help' - type : 1 # 0 - Playing / 1 - Streaming / 2 - Listening / 3 - Watching + + playing: + url: 'https://twitch.tv/wumpusapp' + name: 'type $help' + type: 1 # 0 - Playing / 1 - Streaming / 2 - Listening / 3 - Watching status: 'online' # online / idle / dnd / invisible webhook: - token : '<--snip-->' - channel: '<--snip-->' - events : - ready : true - shardready : true - shardresume : true - sharddisconnect: true - disconnect : true - messagecreate: true - messagedelete: true - commands : - # Category : CORE - locale : true - prefix : true - # Category : UTILITY - ping : true - math : true - snipe : true - # Category : INFORMATION - user : true - stats : true - guild : true - avatar : true - github : true - commits : true - commands : true - # Category : IMAGE - cat : true - dog : true - fox : true - duck : true - birb : true - lizard : true - penguin : true - # Category : TAGS - tag : true - tags : true - tag-add : true - tag-del : true - tag-info : true - tag-source : true - # Category : GAMES - splatoon : true - # Category : DEVELOPER - eval : true - echo : true - exec : true + token: false + channel: false -api : + events: + - ready + - shardReady + - shardResume + - disconnect + - messageCreate + - messageDelete + - guildMemberAdd + - shardDisconnect + + commands: + - yorushika.core.locale + - yorushika.core.prefix + - yorushika.utility.* + - yorushika.information.* + - yorushika.image.* + - yorushika.tags.* + - yorushika.games.* + - yorushika.developer.* + +api: lol: '<--snip-->' dbl: '<--snip-->' + ksoft: '<--snip-->' \ No newline at end of file diff --git a/src/assets/i18n/en_us/logs.yml b/src/assets/i18n/en_us/logs.yml index d3fbcb0..82beedf 100644 --- a/src/assets/i18n/en_us/logs.yml +++ b/src/assets/i18n/en_us/logs.yml @@ -14,9 +14,9 @@ member: - 'User is banned from ksoft.si ({e.ban.reason})' connection: - ready: '`[{date@now}] / {process.hash}]` {emoji} Master client on Wump (`v{global.version}`) connected' + ready: '`[{date@now}] / {process.hash}]` {emoji} Master client on Yorushika (`v{global.version}`) connected' shard : - ready : '`[{date@now}] / {process.hash}]` {emoji} Shard `#{e.shard.id}` connected to Wump (`v{global.version}`)' - resume : '`[{date@now}] / {process.hash}]` {emoji} Shard `#{e.shard.id}` resumed to Wump (`v{global.version}`)' - disconnect: '`[{date@now}] / {process.hash}]` {emoji} Shard `#{e.shard.id}` disconnected from Wump (`v{global.version}`)' \ No newline at end of file + ready : '`[{date@now}] / {process.hash}]` {emoji} Shard `#{e.shard.id}` connected to Yorushika (`v{global.version}`)' + resume : '`[{date@now}] / {process.hash}]` {emoji} Shard `#{e.shard.id}` resumed to Yorushika (`v{global.version}`)' + disconnect: '`[{date@now}] / {process.hash}]` {emoji} Shard `#{e.shard.id}` disconnected from Yorushika (`v{global.version}`)' \ No newline at end of file diff --git a/src/assets/i18n/en_us/strings.yml b/src/assets/i18n/en_us/strings.yml index 8da2f3a..e2fe2ed 100644 --- a/src/assets/i18n/en_us/strings.yml +++ b/src/assets/i18n/en_us/strings.yml @@ -21,9 +21,9 @@ error : cancelled: '$[emoji#0] This prompt has been cancelled' cooldown: '$[emoji#0] $[author:mention] **>** This command is on cooldown for **$[cooldown:left]**' votelock: - - '$[emoji#0] This command is **votelocked**, upvote [**`Wump`**](https://discordbots.org/bot/318057009188438016/vote) to unlock this command/parameters (It can take up to 10 minutes to register your vote)' + - '$[emoji#0] This command is **votelocked**, upvote [**`Yorushika`**](https://discordbots.org/bot/318057009188438016/vote) to unlock this command/parameters (It can take up to 10 minutes to register your vote)' - '' - - '$[emoji#1] If you still have issues after that, you can either create an [**`issue`**](https://github.com/PassTheWessel/wump/issues) on [**`GitHub`**](https://github.com/PassTheWessel/wump) or join my [**`Discord`**](https://discord.gg/SV7DAE9) and posting it there' + - '$[emoji#1] If you still have issues after that, you can either create an [**`issue`**](https://github.com/PassTheWessel/yorushika/issues) on [**`GitHub`**](https://github.com/PassTheWessel/yorushika) or join my [**`Discord`**](https://discord.gg/SV7DAE9) and posting it there' core: prefix: @@ -57,7 +57,7 @@ core: - '$[locale:map]' - '' - 'Type `$[locale:changeCmd]` to update your/the guild''s locale' - - 'If you want to help translate wump, you can join my [Discord](https://discord.gg/SV7DAE9) and create a pull request on my [GitHub](https://github.com/PassTheWessel/wump/compare)' + - 'If you want to help translate yorushika, you can join my [Discord](https://discord.gg/SV7DAE9) and create a pull request on my [GitHub](https://github.com/PassTheWessel/yorushika/compare)' util: ping: @@ -93,7 +93,7 @@ info: avatar: '$[emoji#0] Here''s **$[user:full]** avatar' - commits: '$[emoji#0] **10 most recent commits done on [`PassTheWessel/wump`](https://github.com/PassTheWessel/wump/)**: $[commits:list]' + commits: '$[emoji#0] **10 most recent commits done on [`PassTheWessel/yorushika`](https://github.com/PassTheWessel/yorushika/)**: $[commits:list]' commands: single: @@ -105,7 +105,7 @@ info: multi: - '$[emoji#0] The prefix for **$[guild:name]** is `$[guild:prefix]`' - '$[emoji#1] Type `$[guild:prefix]command ` for more information' - - '$[emoji#2] **Links**: [`Invite`]($[bot:invite]) **|** [`Support`](https://discord.gg/SV7DAE9) **|** [`GitHub`](https://github.com/PassTheWessel/wump) **|** [`Patreon`](https://patreon.com/wessel)' + - '$[emoji#2] **Links**: [`Invite`]($[bot:invite]) **|** [`Support`](https://discord.gg/SV7DAE9) **|** [`GitHub`](https://github.com/PassTheWessel/yorushika) **|** [`Patreon`](https://patreon.com/wessel)' fields: - 'Core' - 'Information' diff --git a/src/assets/i18n/nl/logs.yml b/src/assets/i18n/nl/logs.yml index 6eb7151..563a876 100644 --- a/src/assets/i18n/nl/logs.yml +++ b/src/assets/i18n/nl/logs.yml @@ -14,8 +14,8 @@ member: - 'Gebruiker is verbannen van ksoft.si ({e.ban.reason})' connection: - ready : '`[$[date:now] / $[process:hash]]` $[emoji#0] Meester client op Wump (`v$[wump:version]`) is verbonden' + ready : '`[$[date:now] / $[process:hash]]` $[emoji#0] Meester client op Yorushika (`v$[yorushika:version]`) is verbonden' shard : - ready : '`[$[date:now] / $[process:hash]]` $[emoji#0] Shard `#$[shard:id]` is verbonden naar Wump (`v$[wump:version]`)' - resume : '`[$[date:now] / $[process:hash]]` $[emoji#0] Shard `#$[shard:id]` is hervat naar Wump (`v$[wump:version]`)' - disconnect: '`[$[date:now] / $[process:hash]]` $[emoji#0] Shard `#$[shard:id]` is losgekoppeld van Wump (`v$[wump:version]`)' \ No newline at end of file + ready : '`[$[date:now] / $[process:hash]]` $[emoji#0] Shard `#$[shard:id]` is verbonden naar Yorushika (`v$[yorushika:version]`)' + resume : '`[$[date:now] / $[process:hash]]` $[emoji#0] Shard `#$[shard:id]` is hervat naar Yorushika (`v$[yorushika:version]`)' + disconnect: '`[$[date:now] / $[process:hash]]` $[emoji#0] Shard `#$[shard:id]` is losgekoppeld van Yorushika (`v$[yorushika:version]`)' \ No newline at end of file diff --git a/src/assets/i18n/nl/strings.yml b/src/assets/i18n/nl/strings.yml index d2f0cc2..31715d4 100644 --- a/src/assets/i18n/nl/strings.yml +++ b/src/assets/i18n/nl/strings.yml @@ -21,9 +21,9 @@ error : cancelled: '$[emoji#0] Dit prompt is geannuleerd' cooldown: '$[emoji#0] $[author:mention] **>** Dit commando is op cooldown voor **$[cooldown:left]**' votelock: - - '$[emoji#0] Dit commando is **votelocked**, stem voor [**`Wump`**](https://discordbots.org/bot/318057009188438016/vote) om dit commando/parameters te ontgrendelen (Het kan tot 10 minuten duren om uw stem te registreren)' + - '$[emoji#0] Dit commando is **votelocked**, stem voor [**`Yorushika`**](https://discordbots.org/bot/318057009188438016/vote) om dit commando/parameters te ontgrendelen (Het kan tot 10 minuten duren om uw stem te registreren)' - '' - - '$[emoji#1] Als u nogsteeds problemen hebt ná dat, kunt u een [**`issue`**](https://github.com/PassTheWessel/wump/issues) maken op [**`GitHub`**](https://github.com/PassTheWessel/wump) of mijn [**`Discord`**](https://discord.gg/SV7DAE9) joinen en het daar te plaatsen' + - '$[emoji#1] Als u nogsteeds problemen hebt ná dat, kunt u een [**`issue`**](https://github.com/PassTheWessel/yorushika/issues) maken op [**`GitHub`**](https://github.com/PassTheWessel/yorushika) of mijn [**`Discord`**](https://discord.gg/SV7DAE9) joinen en het daar te plaatsen' core : prefix : @@ -57,7 +57,7 @@ core : - '$[locale:map]' - '' - 'Typ `$[locale:changeCmd]` om de landinstelling van u/de gilde bij te werken' - - 'Als u wilt helpen met het vertalen van Wump, kunt u zij aansluiten bij mijn [Discord](https://discord.gg/SV7DAE9) en een pull request op [GitHub](https://github.com/PassTheWessel/wump/compare) te maken' + - 'Als u wilt helpen met het vertalen van Yorushika, kunt u zij aansluiten bij mijn [Discord](https://discord.gg/SV7DAE9) en een pull request op [GitHub](https://github.com/PassTheWessel/yorushika/compare) te maken' util : ping : @@ -87,13 +87,13 @@ info : avatar : '$[emoji#0] Hier is **$[user:full]** avatar' - commits : '$[emoji#0] **10 meest recente commits gedaan op [`PassTheWessel/wump`](https://github.com/PassTheWessel/wump/)**: $[commits:list]' + commits : '$[emoji#0] **10 meest recente commits gedaan op [`PassTheWessel/yorushika`](https://github.com/PassTheWessel/yorushika/)**: $[commits:list]' commands: multi : - '$[emoji#0] Het voorvoegsel voor **$[guild:name]** is `$[guild:prefix]`' - '$[emoji#1] typ `$[guild:prefix]command ` voor meer informatie' - - '$[emoji#2] **Links**: [`Uitnodiging`]($[bot:invite]) **|** [`Ondersteuning`](https://discord.gg/SV7DAE9) **|** [`GitHub`](https://github.com/PassTheWessel/wump) **|** [`Patreon`](https://patreon.com/wessel)' + - '$[emoji#2] **Links**: [`Uitnodiging`]($[bot:invite]) **|** [`Ondersteuning`](https://discord.gg/SV7DAE9) **|** [`GitHub`](https://github.com/PassTheWessel/yorushika) **|** [`Patreon`](https://patreon.com/wessel)' single: - '$[emoji#3] **Naam**: $[command:name]' - '$[emoji#4] **Syntaxis**: $[command:syntax]' diff --git a/src/commands/Discord/Core/locale.js b/src/commands/Discord/Core/locale.js index a41f6fd..91b367a 100644 --- a/src/commands/Discord/Core/locale.js +++ b/src/commands/Discord/Core/locale.js @@ -4,8 +4,10 @@ const { DiscordCommand } = require('../../../core'); module.exports = class Locale extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'locale', syntax : 'locale <-u|-g>', + bearer : 'yorushika', aliases : [], argument : [ '', '-' ], description: 'Change your locale', diff --git a/src/commands/Discord/Core/prefix.js b/src/commands/Discord/Core/prefix.js index a966721..62b77e9 100644 --- a/src/commands/Discord/Core/prefix.js +++ b/src/commands/Discord/Core/prefix.js @@ -5,6 +5,7 @@ module.exports = class Prefix extends DiscordCommand { super(bot, { name : 'prefix', syntax : 'prefix <...prefix:str> <-u|-g>', + bearer : 'yorushika', aliases : [], argument : [ '<...prefix:string>', '-<(u|g)>' ], description: 'Change your prefix', diff --git a/src/commands/Discord/Developer/echo.js b/src/commands/Discord/Developer/echo.js index 3a5a30b..41bf5fb 100644 --- a/src/commands/Discord/Developer/echo.js +++ b/src/commands/Discord/Developer/echo.js @@ -3,8 +3,10 @@ const { DiscordCommand } = require('../../../core'); module.exports = class Echo extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'echo', syntax : 'echo <...message:str>', + bearer : 'yorushika', aliases : [], argument : [ '<...message:str>' ], description: 'Repeat your input', diff --git a/src/commands/Discord/Developer/eval.js b/src/commands/Discord/Developer/eval.js index 69a81ea..d8f97e4 100644 --- a/src/commands/Discord/Developer/eval.js +++ b/src/commands/Discord/Developer/eval.js @@ -5,13 +5,14 @@ const { inspect } = require('util'); module.exports = class Eval extends DiscordCommand { constructor(bot) { super(bot, { - // Information + path : undefined, name : 'eval', syntax : 'eval <...code:str>', + bearer : 'yorushika', aliases : [], argument : [], description: 'Evaluate a snippet', - // Checks + hidden : false, enabled : true, cooldown : 0, diff --git a/src/commands/Discord/Developer/exec.js b/src/commands/Discord/Developer/exec.js index 3c3793a..1e11714 100644 --- a/src/commands/Discord/Developer/exec.js +++ b/src/commands/Discord/Developer/exec.js @@ -5,11 +5,14 @@ const { execSync } = require('child_process'); module.exports = class Exec extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'exec', syntax : 'exec <...cmd:str>', + bearer : 'yorushika', aliases : [], argument : [ '<...cmd:str>' ], description: 'Execute a command', + hidden : false, enabled : true, cooldown : 0, diff --git a/src/commands/Discord/Games/splatoon.js b/src/commands/Discord/Games/splatoon.js index f78d813..b6fbf5a 100644 --- a/src/commands/Discord/Games/splatoon.js +++ b/src/commands/Discord/Games/splatoon.js @@ -5,8 +5,10 @@ const w = require('wumpfetch'); module.exports = class Splatoon extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'splatoon', syntax : 'splatoon', + bearer : 'yorushika', aliases : [], argument : [], description: 'Get splatoon\'s current maps', diff --git a/src/commands/Discord/Image/birb.js b/src/commands/Discord/Image/birb.js index 8845f70..d27d1cf 100644 --- a/src/commands/Discord/Image/birb.js +++ b/src/commands/Discord/Image/birb.js @@ -5,8 +5,10 @@ const w = require('wumpfetch'); module.exports = class Birb extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'birb', syntax : 'birb', + bearer : 'yorushika', aliases : [ 'bird' ], argument : [], description: 'Get a random birb', diff --git a/src/commands/Discord/Information/avatar.js b/src/commands/Discord/Information/avatar.js index 5e461c0..deba369 100644 --- a/src/commands/Discord/Information/avatar.js +++ b/src/commands/Discord/Information/avatar.js @@ -15,8 +15,10 @@ try { module.exports = class Avatar extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'avatar', syntax : 'avatar [...user:string] [--large] [--(nearest|linear)] [--greyscale] [--jpeg] [--blur]', + bearer : 'yorushika', aliases : [ 'avt', 'pfp' ], argument : [ '[...user:string]', '[--large]', '[--(nearest|linear)]', '[--greyscale]', '[--jpeg]', '[--blur]' ], description: 'Get a user\'s avatar', diff --git a/src/commands/Discord/Information/commands.js b/src/commands/Discord/Information/commands.js index 39bc225..db5e0c6 100644 --- a/src/commands/Discord/Information/commands.js +++ b/src/commands/Discord/Information/commands.js @@ -6,8 +6,10 @@ const { readFileSync } = require('fs'); module.exports = class Commands extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'commands', syntax : 'commands [command:str]', + bearer : 'yorushika', aliases : [ 'command', 'cmds', 'cmd', 'help' ], argument : [ '[command:str]' ], description: 'Lists all commands', @@ -57,34 +59,43 @@ module.exports = class Commands extends DiscordCommand { description: this._localize(msg.author.locale.info.commands.multi.join('\n'), { msg: msg }), fields: [ this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'core' && !v.extData.hidden).length >= 1 ? { - name: msg.author.locale.info.commands.fields[0], - value: this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'core' && !v.extData.hidden).map((v) => `**•** [\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id}) ${v.extData.description ? `**-** ${v.extData.description}` : ''}`).join('\n'), + name: `${msg.author.locale.info.commands.fields[0]} (${this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'core' && !v.extData.hidden).length})`, + value: this.bot.cmds + .filter((v) => v.extData.category.toLowerCase() === 'core' && !v.extData.hidden) + .map((v) => `[\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id})`).join(', '), inline: this.static.inline } : undefined, this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'information' && !v.extData.hidden).length >= 1 ? { - name: msg.author.locale.info.commands.fields[1], - value: this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'information' && !v.extData.hidden).map((v) => `**•** [\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id}) ${v.extData.description ? `**-** ${v.extData.description}` : ''}`).join('\n'), + name: `${msg.author.locale.info.commands.fields[1]} (${this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'information' && !v.extData.hidden).length})`, + value: this.bot.cmds + .filter((v) => v.extData.category.toLowerCase() === 'information' && !v.extData.hidden) + .map((v) => `[\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id})`).join(', '), inline: this.static.inline } : undefined, this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'image' && !v.extData.hidden).length >= 1 ? { - name: msg.author.locale.info.commands.fields[2], - value: this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'image' && !v.extData.hidden).map((v) => `**•** [\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id}) ${v.extData.description ? `**-** ${v.extData.description}` : ''}`).join('\n'), + name: `${msg.author.locale.info.commands.fields[2]} (${this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'image' && !v.extData.hidden).length})`, + value: this.bot.cmds + .filter((v) => v.extData.category.toLowerCase() === 'image' && !v.extData.hidden) + .map((v) => `[\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id})`).join(', '), inline: this.static.inline } : undefined, this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'utility' && !v.extData.hidden).length >= 1 ? { - name: msg.author.locale.info.commands.fields[3], - value: this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'utility' && !v.extData.hidden).map((v) => `**•** [\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id}) ${v.extData.description ? `**-** ${v.extData.description}` : ''}`).join('\n'), - inline: this.static.inline + name: `${msg.author.locale.info.commands.fields[3]} (${this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'utility' && !v.extData.hidden).length})`, + value: this.bot.cmds + .filter((v) => v.extData.category.toLowerCase() === 'utility' && !v.extData.hidden) + .map((v) => `[\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id})`).join(', '), } : undefined, this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'developer' && !v.extData.hidden).length >= 1 ? { - name: msg.author.locale.info.commands.fields[4], - value: this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'developer' && !v.extData.hidden).map((v) => `**•** [\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id}) ${v.extData.description ? `**-** ${v.extData.description}` : ''}`).join('\n'), - inline: this.static.inline + name: `${msg.author.locale.info.commands.fields[4]} (${this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'developer' && !v.extData.hidden).length})`, + value: this.bot.cmds + .filter((v) => v.extData.category.toLowerCase() === 'developer' && !v.extData.hidden) + .map((v) => `[\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id})`).join(', '), } : undefined, this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'tags' && !v.extData.hidden).length >= 1 ? { - name: msg.author.locale.info.commands.fields[5], - value: this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'tags' && !v.extData.hidden).map((v) => `**•** [\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id}) ${v.extData.description ? `**-** ${v.extData.description}` : ''}`).join('\n'), - inline: this.static.inline + name: `${msg.author.locale.info.commands.fields[5]} (${this.bot.cmds.filter((v) => v.extData.category.toLowerCase() === 'tags' && !v.extData.hidden).length})`, + value: this.bot.cmds + .filter((v) => v.extData.category.toLowerCase() === 'tags' && !v.extData.hidden) + .map((v) => `[\`${msg.prefix}${v.extData.name}\`](https://discordapp.com/channels/${msg.channel.guild.id}/${msg.channel.id}/${msg.id})`).join(', '), } : undefined ] } diff --git a/src/commands/Discord/Information/commits.js b/src/commands/Discord/Information/commits.js index 32d2f56..a077530 100644 --- a/src/commands/Discord/Information/commits.js +++ b/src/commands/Discord/Information/commits.js @@ -6,8 +6,10 @@ const { table } = require('table'); module.exports = class Stats extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'commits', syntax : 'commits', + bearer : 'yorushika', aliases : [], argument : [], description: '10 most recent commits', @@ -61,7 +63,7 @@ module.exports = class Stats extends DiscordCommand { } async execute(msg, args) { - let res = await w(`${this.static.BASE_URL}/repos/PassTheWessel/wump/commits`, this.static.REQ_DATA).send(); + let res = await w(`${this.static.BASE_URL}/repos/PassTheWessel/yorushika/commits`, this.static.REQ_DATA).send(); res = res.json(); if (larg(args)['raw'] || larg(args)['r']) { diff --git a/src/commands/Discord/Information/guild.js b/src/commands/Discord/Information/guild.js index 31a1824..89f3d42 100644 --- a/src/commands/Discord/Information/guild.js +++ b/src/commands/Discord/Information/guild.js @@ -5,8 +5,10 @@ const moment = require('moment'); require('../../../util/moment/diff.js'); module.exports = class Guild extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'guild', syntax : 'guild <...guild:str>', + bearer : 'yorushika', aliases : [ '<...guild:str>' ], argument : [], description: 'Get a guild\'s information', diff --git a/src/commands/Discord/Information/stats.js b/src/commands/Discord/Information/stats.js index 8be3ca3..5c637a5 100644 --- a/src/commands/Discord/Information/stats.js +++ b/src/commands/Discord/Information/stats.js @@ -9,8 +9,10 @@ const { readFileSync } = require('fs'); module.exports = class Stats extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'stats', syntax : 'stats [--{no-deps|no-bot|no-sys|no-cpu|no-thumb}]', + bearer : 'yorushika', aliases : [ 'statistics' ], argument : [ '[--{no-deps|no-bot|no-sys|no-cpu|no-thumb}]' ], description: 'Some small statistics', diff --git a/src/commands/Discord/Information/user.js b/src/commands/Discord/Information/user.js index 03cd570..54bde4b 100644 --- a/src/commands/Discord/Information/user.js +++ b/src/commands/Discord/Information/user.js @@ -5,8 +5,10 @@ const moment = require('moment'); require('../../../util/moment/diff.js'); module.exports = class User extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'user', syntax : 'user <...user:string>', + bearer : 'yorushika', aliases : [ '<...user:string>' ], argument : [], description: 'Get a user\'s information', diff --git a/src/commands/Discord/Tags/tag-add.js b/src/commands/Discord/Tags/tag-add.js index 94e2451..5ba1393 100644 --- a/src/commands/Discord/Tags/tag-add.js +++ b/src/commands/Discord/Tags/tag-add.js @@ -4,8 +4,10 @@ const { DiscordCommand } = require('../../../core'); module.exports = class TagAdd extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'tag-add', syntax : 'tag-add <...name:str> | <..content:string>', + bearer : 'yorushika', aliases : [ 'tagadd', 'addtag', 'createtag', 'tagcreate', 'maketag', 'make-tag', 'tag-create' ], argument : [ '<...name:str>', '<..content:string>' ], description: 'Create a tag', diff --git a/src/commands/Discord/Tags/tag-del.js b/src/commands/Discord/Tags/tag-del.js index 539650b..969c854 100644 --- a/src/commands/Discord/Tags/tag-del.js +++ b/src/commands/Discord/Tags/tag-del.js @@ -3,8 +3,10 @@ const { DiscordCommand } = require('../../../core'); module.exports = class TagDel extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'tag-del', syntax : 'tag-del <...tag:str>', + bearer : 'yorushika', aliases : [ 'tagdel', 'deltag', 'tagdelete', 'deletetag', 'del-tag', 'tag-delete', 'delete-tag' ], argument : [ '<...tag:str>' ], description: 'Delete a tag', diff --git a/src/commands/Discord/Tags/tag-info.js b/src/commands/Discord/Tags/tag-info.js index 6d4e0ce..5b4250f 100644 --- a/src/commands/Discord/Tags/tag-info.js +++ b/src/commands/Discord/Tags/tag-info.js @@ -5,8 +5,10 @@ const moment = require('moment'); module.exports = class TagInfo extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'tag-info', syntax : 'tag-info <...tag:str>', + bearer : 'yorushika', aliases : [], argument : [ '<...tag:str>' ], description: 'Info about a tag', diff --git a/src/commands/Discord/Tags/tag-source.js b/src/commands/Discord/Tags/tag-source.js index 33e3b8d..374646e 100644 --- a/src/commands/Discord/Tags/tag-source.js +++ b/src/commands/Discord/Tags/tag-source.js @@ -3,8 +3,10 @@ const { DiscordCommand } = require('../../../core'); module.exports = class TagSource extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'tag-source', syntax : 'tag-source <...tag:str>', + bearer : 'yorushika', aliases : [ 'tagsource', 'tagsrc', 'tag-src' ], argument : [ '<...tag:str>' ], description: 'Source of a tag', diff --git a/src/commands/Discord/Tags/tag.js b/src/commands/Discord/Tags/tag.js index 583b756..e8e9c16 100644 --- a/src/commands/Discord/Tags/tag.js +++ b/src/commands/Discord/Tags/tag.js @@ -3,8 +3,10 @@ const { DiscordCommand } = require('../../../core'); module.exports = class Tag extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'tag', syntax : 'tag <...tag:str>', + bearer : 'yorushika', aliases : [ 'show-tag', 'disp-tag' ], argument : [ '<...tag:str>' ], description: 'Display a tag', diff --git a/src/commands/Discord/Tags/tags.js b/src/commands/Discord/Tags/tags.js index d588da9..dd8ff34 100644 --- a/src/commands/Discord/Tags/tags.js +++ b/src/commands/Discord/Tags/tags.js @@ -6,8 +6,10 @@ const { table } = require('table'); module.exports = class Tags extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'tags', syntax : 'tags', + bearer : 'yorushika', aliases : [], argument : [], description: 'A list of all tags', diff --git a/src/commands/Discord/Utility/math.js b/src/commands/Discord/Utility/math.js index ff0b510..3f89fa5 100644 --- a/src/commands/Discord/Utility/math.js +++ b/src/commands/Discord/Utility/math.js @@ -6,8 +6,10 @@ const { eval: mEval, config } = require('mathjs'); module.exports = class Math extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'math', syntax : 'math <...equation:str>', + bearer : 'yorushika', aliases : [], argument : [ '<...equation:str>' ], description: 'Evaluate an equation', diff --git a/src/commands/Discord/Utility/ping.js b/src/commands/Discord/Utility/ping.js index 682f402..f08dcde 100644 --- a/src/commands/Discord/Utility/ping.js +++ b/src/commands/Discord/Utility/ping.js @@ -3,8 +3,10 @@ const { DiscordCommand } = require('../../../core'); module.exports = class Ping extends DiscordCommand { constructor(bot) { super(bot, { + path : undefined, name : 'ping', syntax : 'ping', + bearer : 'yorushika', aliases : [ 'pong' ], argument : [], description: 'Lists latencies', diff --git a/src/commands/Discord/Utility/snipe.js b/src/commands/Discord/Utility/snipe.js index 0bd8807..8ce78b8 100644 --- a/src/commands/Discord/Utility/snipe.js +++ b/src/commands/Discord/Utility/snipe.js @@ -3,10 +3,12 @@ const { DiscordCommand } = require('../../../core/'); module.exports = class Snipe extends DiscordCommand { constructor(bot) { super(bot, { - name: 'snipe', - syntax: 'snipe', - aliases: [], - argument: [], + path : undefined, + name : 'snipe', + syntax : 'snipe', + bearer : 'yorushika', + aliases : [], + argument : [], description: 'Re-post a deleted message', hidden: false, diff --git a/src/commands/Discord/_base.js b/src/commands/Discord/_base.js new file mode 100644 index 0000000..c9bb58c --- /dev/null +++ b/src/commands/Discord/_base.js @@ -0,0 +1,40 @@ +const { DiscordCommand } = require('../../core'); + +module.exports = class name extends DiscordCommand { + constructor(bot) { + super(bot, { + path : undefined, + name : '', + syntax : '', + bearer : 'yorushika', + aliases : [], + argument : [], + description: '', + + hidden : false, + enabled : true, + cooldown : 1000, + category : 'Utility', + ownerOnly : false, + guildOnly : false, + permissions: [] + }); + + Object.freeze(this); + Object.freeze(this.static); + } + + async execute(msg, args, user, guild) { + // ... + } + + _localize(msg, extData = {}) { + try { + if (!msg) throw 'INVALID_STRING'; + + // ... + } catch (ex) { + return `LOCALIZE_ERROR:${ex.code}`; + } + } +}; \ No newline at end of file diff --git a/src/core/clients/Discord.js b/src/core/clients/Discord.js index 9fe7e96..1039e8b 100644 --- a/src/core/clients/Discord.js +++ b/src/core/clients/Discord.js @@ -48,7 +48,7 @@ module.exports = class WumpDiscord extends Eris { this.conf = options.config ? options.config : undefined; this.start = Date.now(); - this.requestHandler.userAgent = this.ua ? this.ua : `Wump (https://github.com/PassTheWessel/wump, ${this.pkg.version})`; + this.requestHandler.userAgent = this.ua ? this.ua : `Yorushika (https://github.com/PassTheWessel/yorushika, ${this.pkg.version})`; } async launch(events, commands, locales) { diff --git a/src/core/internal/Discord/Command.js b/src/core/internal/Discord/Command.js index 5b6c98a..79ae23a 100644 --- a/src/core/internal/Discord/Command.js +++ b/src/core/internal/Discord/Command.js @@ -3,27 +3,38 @@ module.exports = class WumpCommand { this.bot = bot; this.extData = Object.assign({ // Information - name : null, // Command name ( required ) - syntax : null, // Command syntax ( optional ) - aliases : [], // Command aliases ( optional ) - argument : [], // Command arguments ( optional ) + path : undefined, // The config path of the command [`yorushika.utility.ping` for example] ( optional ) + name : null, // Command name ( required ) + syntax : null, // Command syntax ( optional ) + bearer : 'yorushika', // Command bearer ( required ) + aliases : [], // Command aliases ( optional ) + argument : [], // Command arguments ( optional ) description: null, // Command description ( optional ) // Checks - hidden : false, // Hidden from view ( true / false ) - enabled : true, // Enabled or disabled ( true / false ) - cooldown : 1000, // Command cooldown ( optional ) - category : 'General', // Command category ( required ) - ownerOnly : false, // Owner only ( true / false ) - guildOnly : false, // Guild only ( true / false ) - permissions : [] // Bot permissions ( optional ) + hidden : false, // Hidden from view ( true / false ) + enabled : true, // Enabled or disabled ( true / false ) + cooldown : 1000, // Command cooldown ( optional ) + category : 'General', // Command category ( required ) + ownerOnly : false, // Owner only ( true / false ) + guildOnly : false, // Guild only ( true / false ) + permissions: [] // Bot permissions ( optional ) }, opts); - this.static = {}; + this.static = {}; this.mutable = {}; - Object.freeze(this.static); } - async execute(msg, args, user, guild) {} + async execute(msg, args, user, guild) { + // ... + } - _localize(msg) {} + _localize(msg, extData = {}) { + try { + if (!msg) throw 'INVALID_STRING'; + + // ... + } catch (ex) { + return `LOCALIZE_ERROR:${ex.code}`; + } + } }; \ No newline at end of file diff --git a/src/core/internal/Discord/Context.js b/src/core/internal/Discord/Context.js index 0096a41..ff8c165 100644 --- a/src/core/internal/Discord/Context.js +++ b/src/core/internal/Discord/Context.js @@ -1,18 +1,22 @@ module.exports = class WumpContext { constructor(bot, msg) { Object.assign(this, msg); + this.bot = bot; this.orig = msg; this.locale = null; this.prefix = null; } - get guild() { return this.channel.guild; } + get guild() { + return this.channel.guild; + } - getPrefix() { return this.prefix; } - getLocale() { return this.locale; } - getMember() { return this.member; } - - setPrefix(prefix) { this.prefix = prefix; } - setLocale(locale) { this.locale = locale; } + setPrefix(prefix) { + this.prefix = prefix; + } + + setLocale(locale) { + this.locale = locale; + } }; \ No newline at end of file diff --git a/src/core/internal/Discord/Event.js b/src/core/internal/Discord/Event.js index 9b112b1..038cdfa 100644 --- a/src/core/internal/Discord/Event.js +++ b/src/core/internal/Discord/Event.js @@ -1,13 +1,25 @@ module.exports = class WumpEvent { constructor(bot, opts = {}) { this.bot = bot; - this.extData = Object.assign({ name: null }, opts); + this.extData = Object.assign({ + name: null // Event name ( required ) + }, opts); this.static = {}; this.mutable = {}; } - emit(...args) {} + emit(...args) { + // ... + } - _localize(msg) {} + _localize(msg, extData = {}) { + try { + if (!msg) throw 'INVALID_STRING'; + + // ... + } catch (ex) { + return `LOCALIZE_ERROR:${ex.code}`; + } + } }; \ No newline at end of file diff --git a/src/core/internal/Discord/__baseCommand.js b/src/core/internal/Discord/__baseCommand.js deleted file mode 100644 index ecbacae..0000000 --- a/src/core/internal/Discord/__baseCommand.js +++ /dev/null @@ -1,25 +0,0 @@ -const { DiscordCommand } = require('../../../core'); - -module.exports = class name extends DiscordCommand { - constructor(bot) { - super(bot, { - name : '', - syntax : '', - aliases : [], - argument : [], - description: '', - - hidden : false, - enabled : true, - cooldown : 1000, - category : 'Utility', - ownerOnly : false, - guildOnly : false, - permissions : [ 'embedLinks' ] - }); - } - - async execute(msg, args, user, guild) {} - - _localize(msg) {} -}; \ No newline at end of file diff --git a/src/core/internal/Discord/rest.js b/src/core/internal/Discord/rest.js index fd347d2..d820818 100644 --- a/src/core/internal/Discord/rest.js +++ b/src/core/internal/Discord/rest.js @@ -4,41 +4,56 @@ module.exports = class RESTclient { } getRole($, g) { - if (/^\d+$/.test($) && g.roles.get($)) return $; - else if (/<@%(\d+)>$/.test($)) { - const m = $.match(/^<@&(\d+)>$/); - const r = g.roles.get(m[1]); - if (r) return $; + if (/^\d+$/.test($) && g.roles.get($)) { + return $; + } else if (/<@%(\d+)>$/.test($)) { + const m = $.match(/^<@&(\d+)>$/); + const r = g.roles.get(m[1]); + if (r) { + return $; + } } else { const r = g.roles.filter((v) => v.name.toLowerCase().includes($.toLowerCase())); - if (r.length > 0) return r[0]; + if (r.length >= 1) { + return r[0]; + } } return undefined; } getUser($) { - if (/^\d+$/.test($) && this.bot.users.get($)) return this.bot.users.get($); - else if (/^<@!?(\d+)>$/.test($)) { + if (/^\d+$/.test($) && this.bot.users.get($)) { + return this.bot.users.get($); + } else if (/^<@!?(\d+)>$/.test($)) { const u = this.bot.users.get($.match(/^<@!?(\d+)>$/)[1]); - if (u) return u; - }else if (/^(.+)#(\d{4})$/.test($)) { + if (u) { + return u; + } + } else if (/^(.+)#(\d{4})$/.test($)) { const m = $.match(/^(.+)#(\d{4})$/); - const u = this.bot.users.filter((u) => u.username === m[1] && Number(u.discriminator) === Number(m[2])); - if (u.length > 0) return u[0]; + const u = this.bot.users.filter((v) => v.username === m[1] && Number(v.discriminator) === Number(m[2])); + if (u.length >= 1) { + return u[0]; + } } else { - const u = this.bot.users.filter((u) => u.username.toLowerCase().includes($.toLowerCase())); - if (u.length > 0) return u[0]; + const u = this.bot.users.filter((v) => v.username.toLowerCase().includes($.toLowerCase())); + if (u.length >= 1) { + return u[0]; + } } return undefined; } getGuild($) { - if (/^\d+$/.test($) && this.bot.guilds.get($)) return this.bot.guilds.get($); - else { + if (/^\d+$/.test($) && this.bot.guilds.get($)) { + return this.bot.guilds.get($); + } else { const tmp = this.bot.guilds.filter((v) => v.name.toLowerCase().includes($.toLowerCase())); - if (tmp.length > 0) return tmp[0]; + if (tmp.length >= 1) { + return tmp[0]; + } } return undefined; @@ -49,43 +64,65 @@ module.exports = class RESTclient { if (/^\d+$/.test($)) { if (g) { - if (!g.channels.has($)) return undefined; + if (!g.channels.has($)) { + return undefined; + } + return g.channels.get($); } else { c = c in this.bot.channelGuildMap && this.bot.guilds.get(this.bot.channelGuildMap[$]).channels.get($); - if (c) return c; + if (c) { + return c; + } } } else if (/^<#(\d+)>$/.test(c)) { const m = $.match(/^<#(\d+)>$/); if ($) { - if (!g.channels.has(m[1])) return undefined; + if (!g.channels.has(m[1])) { + return undefined; + } + return g.channels.get(m[1]); } else { c = m[1] in this.bot.channelGuildMap && this.bot.guilds.get(this.bot.channelGuildMap[m[1]]).channels.get($); - if (c) return c; + if (c) { + return c; + } } } else if ($) { c = g.channels.filter((v) => v.name.toLowerCase().includes($.toLowerCase())); - if (c.length > 0) return c[0]; + if (c.length >= 1) { + return c[0]; + } } return undefined; } getMember($, g, n = false) { - if (!$ || !g) return undefined; - if (/^\d+$/.test($) && g.members.get($)) return g.members.get($); - else if (/^<@!?(\d+)>$/.test($)) { + if (!$ || !g) { + return undefined; + } + + if (/^\d+$/.test($) && g.members.get($)) { + return g.members.get($); + } else if (/^<@!?(\d+)>$/.test($)) { const m = $.match(/^<@!?(\d+)>$/); const u = g.members.get(m[1]); - if (u) return u; + if (u) { + return u; + } } else if (/^(.+)#(\d{4})$/.test($)) { const m = $.match(/^(.+)#(\d{4})$/); const u = g.members.filter((v) => v.user.username === m[1] && Number(v.user.discriminator) === Number(m[2])); - if (u.length > 0) return u[0]; + if (u.length >= 1) { + return u[0]; + } } else if (!n) { const u = g.members.filter((v) => v.user.username.toLowerCase().includes(v.toLowerCase())); - if (u.length > 0) return u[0]; + if (u.length >= 1) { + return u[0]; + } } return undefined; diff --git a/src/core/registry/Discord/Commands.js b/src/core/registry/Discord/Commands.js index 358d042..e089a9f 100644 --- a/src/core/registry/Discord/Commands.js +++ b/src/core/registry/Discord/Commands.js @@ -10,16 +10,24 @@ const startTimestamp = Date.now(); module.exports = class CommandRegistry { constructor(bot) { this.bot = bot; + this.ignored = [ 'js', 'md' ]; this.ratelimits = new Collection(); } start(directory, category, file) { try { const cmd = new(require(`${directory}/${category}/${file}`))(this.bot); - cmd.extData.location = `${directory}/${category}/${file}`; + cmd.extData.path = cmd.extData.path || [ cmd.extData.bearer || 'yorushika', cmd.extData.category || 'utility', cmd.extData.name || '*' ]; + cmd.extData.location = `${directory}/${category}/${file}`; + if (!cmd.extData.enabled) return; - if (!this.bot.conf['discord']['commands'][cmd.extData.name]) return; + if ( + !this.bot.conf.discord.commands.includes(cmd.extData.path.join('.').toLowerCase()) && + !this.bot.conf.discord.commands.includes(`${cmd.extData.path[0].toLowerCase()}.${cmd.extData.path[1].toLowerCase()}.*`) && + !this.bot.conf.discord.commands.includes(`${cmd.extData.path[0].toLowerCase()}.*`) && + !this.bot.conf.discord.commands.includes(`*`) + ) return; if (this.bot.cmds.has(cmd.extData.name)) return this.bot.print(1, `${cyan('Discord')} -- Duplicate command found - ${red(`${directory}/${category}/${file}`)}` ); this.bot.cmds.set(cmd.extData.name, cmd); @@ -31,7 +39,7 @@ module.exports = class CommandRegistry { const categories = await readdirSync(directory); for (let i = 0; i < categories.length; i++) { - if (categories[i].endsWith('md')) return; + if (this.ignored.some((v) => categories[i].endsWith(v))) return; readdir(`${directory}/${categories[i]}`, (err, cmds) => { if (err) process.handleError(err, 'LoadError', cyan('Discord')); this.bot.print(2, `${cyan('Discord')} >> Loading ${green(cmds.length)} commands from category ${yellow(categories[i])}` ); diff --git a/src/core/registry/Discord/Events.js b/src/core/registry/Discord/Events.js index 428555a..7c54478 100644 --- a/src/core/registry/Discord/Events.js +++ b/src/core/registry/Discord/Events.js @@ -25,7 +25,7 @@ module.exports = class EventStore { if (!e.endsWith('.js' )) return; const event = new(require(`${directory}/${e}`))(this.bot); - if (!this.bot.conf['discord']['events'][event.extData.name.toLowerCase()]) return false; + if (!this.bot.conf.discord.events.includes(event.extData.name)) return false; if (this.bot.events.has(event.extData.name)) return this.bot.print(1, `[${cyan('Discord')}] -- Duplicate event found - ${red(`${directory}/${event.extData.name}`)}`); this.bot.events.set(event.extData.name, event); diff --git a/src/events/Discord/_base.js b/src/events/Discord/_base.js new file mode 100644 index 0000000..3ba8e4f --- /dev/null +++ b/src/events/Discord/_base.js @@ -0,0 +1,24 @@ +const { DiscordEvent } = require('../../core'); + +module.exports = class name extends DiscordEvent { + constructor(bot) { + super(bot, { name: 'name' }); + + Object.freeze(this); + Object.freeze(this.static); + } + + emit(...args) { + // ... + } + + localize(msg, extData = {}) { + try { + if (!msg) throw 'INVALID_STRING'; + + // ... + } catch (ex) { + return `LOCALIZE_ERROR:${ex.code}`; + } + } +}; diff --git a/src/events/Discord/guildMemberAdd.js b/src/events/Discord/guildMemberAdd.js index 44a5bca..603fd9c 100644 --- a/src/events/Discord/guildMemberAdd.js +++ b/src/events/Discord/guildMemberAdd.js @@ -81,10 +81,11 @@ module.exports = class GuildMemberAdd extends DiscordEvent { const prohibited = new RegExp((this.bot.locales.get('badwords') || []).join('|'), 'gi'); member.bans = { - 'ksoft.si': this.bot.conf.api.ksoft ? await get(`${this.static.BASE_URL[0]}/bans/info/?user=${member.id}`, this.static.REQ_DATA[1]).send() : undefined, + 'ksoft.si': this.bot.conf.api.ksoft ? await get(`${this.static.BASE_URL[1]}/bans/info?user=${member.id}`, this.static.REQ_DATA[1]).send() : undefined, 'discord.services': await get(`${this.static.BASE_URL[0]}/api/ban/${member.id}`, this.static.REQ_DATA[0]).send() }; + member.c = moment.preciseDiff(new Date(), new Date(member.createdAt), true); let notes = []; @@ -104,7 +105,7 @@ module.exports = class GuildMemberAdd extends DiscordEvent { notes.push(`${this.bot.emote('logs', 'message_delete', '4')} ${strings.member.add.notes[3].replace(/{e\.ban\.reason}/, member.bans['discord.services'].body.reason || 'Unknown')}`); } if (member.bans['ksoft.si'] && !member.bans['ksoft.si'].body.code) { - notes.push(`${this.bot.emote('logs', 'message_delete', '5')} ${strings.member.add.notes[5].replace(/{e\.ban\.reason}/, member.bans['ksoft.si'].body.reason || 'Unknown')}`); + notes.push(`${this.bot.emote('logs', 'message_delete', '5')} ${strings.member.add.notes[4].replace(/{e\.ban\.reason}/, member.bans['ksoft.si'].body.reason || 'Unknown')}`); } this.bot.createMessage(entry.logger.channel, { diff --git a/src/events/Discord/ready.js b/src/events/Discord/ready.js index b4b62f2..48bf074 100644 --- a/src/events/Discord/ready.js +++ b/src/events/Discord/ready.js @@ -15,7 +15,7 @@ module.exports = class Ready extends DiscordEvent { this.bot.editStatus({ url : this.bot.conf.discord.playing.url || null, type : this.bot.conf.discord.playing.type || 3, - name : this.bot.conf.discord.playing.name || 'Wump', + name : this.bot.conf.discord.playing.name || 'Yorushika', status : this.bot.conf.discord.playing.status || 'online' }); } diff --git a/src/main.js b/src/main.js index 2814c13..4e59c00 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,7 @@ /** - * @name Wunp + * @name Yorushika * @author Wessel "wesselgame" T < discord@go2it.eu > * @license GPL-3.0 - * @version 0.1.1 * @description A multi-functional bot written in Node.js */ @@ -85,7 +84,7 @@ if (conf['discord']['enabled']) { autoreconnect: true }, - ua : `${pkg.displayName}/${conf['nightly'] ? 'nightly' : 'distribution'} (https://github.com/PassTheWessel/wump)`, + ua : `${pkg.displayName}/${conf['nightly'] ? 'nightly' : 'distribution'} (https://github.com/PassTheWessel/yorushika)`, db : mongoose, pkg : pkg, colors: col,