Skip to content

Commit

Permalink
0.3.0 Release (#126)
Browse files Browse the repository at this point in the history
* chore(deps-dev): bump @typescript-eslint/parser from 4.14.0 to 4.14.1 (#75)

Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.14.0 to 4.14.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.14.1/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @types/node from 14.14.21 to 14.14.22 (#70)

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.21 to 14.14.22.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump dayjs from 1.10.3 to 1.10.4 (#72)

Bumps [dayjs](https://github.com/iamkun/dayjs) from 1.10.3 to 1.10.4.
- [Release notes](https://github.com/iamkun/dayjs/releases)
- [Changelog](https://github.com/iamkun/dayjs/blob/v1.10.4/CHANGELOG.md)
- [Commits](iamkun/dayjs@v1.10.3...v1.10.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump eslint-plugin-jsdoc from 31.0.7 to 31.4.0 (#77)

Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 31.0.7 to 31.4.0.
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Commits](gajus/eslint-plugin-jsdoc@v31.0.7...v31.4.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @typescript-eslint/eslint-plugin (#76)

Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.14.0 to 4.14.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.14.1/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump eslint from 7.18.0 to 7.19.0 (#80)

Bumps [eslint](https://github.com/eslint/eslint) from 7.18.0 to 7.19.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v7.18.0...v7.19.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @typescript-eslint/parser from 4.14.1 to 4.15.0 (#84)

Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.14.1 to 4.15.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.15.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump eslint-plugin-jsdoc from 31.4.0 to 31.6.1 (#85)

Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 31.4.0 to 31.6.1.
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Commits](gajus/eslint-plugin-jsdoc@v31.4.0...v31.6.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @typescript-eslint/eslint-plugin (#86)

Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.14.1 to 4.15.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.15.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump eslint-plugin-promise from 4.2.1 to 4.3.1 (#88)

Bumps [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise) from 4.2.1 to 4.3.1.
- [Release notes](https://github.com/xjamundx/eslint-plugin-promise/releases)
- [Changelog](https://github.com/xjamundx/eslint-plugin-promise/blob/development/CHANGELOG.md)
- [Commits](eslint-community/eslint-plugin-promise@v4.2.1...v4.3.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump typescript from 4.1.3 to 4.1.5 (#89)

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.1.3 to 4.1.5.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v4.1.3...v4.1.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump mocha from 8.2.1 to 8.3.0 (#90)

Bumps [mocha](https://github.com/mochajs/mocha) from 8.2.1 to 8.3.0.
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)
- [Commits](mochajs/mocha@v8.2.1...v8.3.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @types/node from 14.14.22 to 14.14.27 (#91)

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.22 to 14.14.27.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @typescript-eslint/parser from 4.15.0 to 4.15.1 (#92)

Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.15.0 to 4.15.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.15.1/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump eslint-plugin-markdown from 1.0.2 to 2.0.0 (#93)

Bumps [eslint-plugin-markdown](https://github.com/eslint/eslint-plugin-markdown) from 1.0.2 to 2.0.0.
- [Release notes](https://github.com/eslint/eslint-plugin-markdown/releases)
- [Changelog](https://github.com/eslint/eslint-plugin-markdown/blob/main/CHANGELOG.md)
- [Commits](eslint/markdown@v1.0.2...v2.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump eslint-plugin-jsdoc from 31.6.1 to 32.1.0 (#101)

Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 31.6.1 to 32.1.0.
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Commits](gajus/eslint-plugin-jsdoc@v31.6.1...v32.1.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @types/node from 14.14.27 to 14.14.31 (#100)

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.27 to 14.14.31.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @typescript-eslint/eslint-plugin (#95)

Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.15.0 to 4.15.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.15.1/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump eslint from 7.19.0 to 7.20.0 (#94)

Bumps [eslint](https://github.com/eslint/eslint) from 7.19.0 to 7.20.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v7.19.0...v7.20.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: fetching before client ready

* style: code style

* chore: added command options

* fix: #46

* feat: added global variable

close: #14

* chore: update version

* chore: changed emoji order

* chore: prevent missing permission

* chore(deps-dev): bump typescript from 4.1.5 to 4.2.3 (#111)

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.1.5 to 4.2.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump mocha from 8.3.0 to 8.3.2 (#118)

Bumps [mocha](https://github.com/mochajs/mocha) from 8.3.0 to 8.3.2.
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)
- [Commits](mochajs/mocha@v8.3.0...v8.3.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump eslint-plugin-mocha from 8.0.0 to 8.1.0 (#112)

Bumps [eslint-plugin-mocha](https://github.com/lo1tuma/eslint-plugin-mocha) from 8.0.0 to 8.1.0.
- [Release notes](https://github.com/lo1tuma/eslint-plugin-mocha/releases)
- [Changelog](https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/CHANGELOG.md)
- [Commits](lo1tuma/eslint-plugin-mocha@8.0.0...8.1.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump eslint from 7.20.0 to 7.22.0 (#122)

Bumps [eslint](https://github.com/eslint/eslint) from 7.20.0 to 7.22.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v7.20.0...v7.22.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @types/node from 14.14.31 to 14.14.35 (#123)

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.31 to 14.14.35.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @typescript-eslint/parser from 4.15.1 to 4.18.0 (#121)

Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.15.1 to 4.18.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.18.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump eslint-plugin-jsdoc from 32.1.0 to 32.3.0 (#120)

Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 32.1.0 to 32.3.0.
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Commits](gajus/eslint-plugin-jsdoc@v32.1.0...v32.3.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @typescript-eslint/eslint-plugin (#124)

Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.15.1 to 4.18.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.18.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Create LICENSE (#127)

* Resolve generators (#125)

* feat: resolve generators

* fix: use async function

* fix: fix eslint errors

* chore: reorder emoji list

* types: added globalVariable

* feat: added some example code

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: zero734kr <zero734kr@gmail.com>
  • Loading branch information
3 people authored Mar 20, 2021
1 parent 5afb5cd commit feea5f4
Show file tree
Hide file tree
Showing 15 changed files with 352 additions and 352 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020-2021 Junseo Park

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 3 additions & 2 deletions examples/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ const config = require('./config')

const Dokdo = require('../src')

const DokdoHandler = new Dokdo(client, { aliases: ['dokdo', 'dok'], prefix: '!', noPerm: (message) => message.reply('No Permission') })
const DokdoHandler = new Dokdo(client, { aliases: ['dokdo', 'dok'], prefix: '!', noPerm: (message) => message.reply('🚫 You have no permission to use dokdo.'), globalVariable: { WONDER_IS_COOL: true } })
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`)
})

client.on('message', async message => {
DokdoHandler.run(message)
if (message.content === 'ping') return message.reply('pong')
await DokdoHandler.run(message)
})

client.login(config.token)
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dokdo",
"version": "0.2.0",
"version": "0.3.0",
"description": "Dokdo. Easy Discord bot debuging tool.",
"main": "./src/index.js",
"types": "./typings/index.d.ts",
Expand Down Expand Up @@ -36,8 +36,8 @@
"eslint": "^7.15.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^31.0.3",
"eslint-plugin-markdown": "^1.0.2",
"eslint-plugin-jsdoc": "^32.1.0",
"eslint-plugin-markdown": "^2.0.0",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ module.exports = async function curl (message, parent) {
if (err) msg = new ProcessManager(message, err.toString(), parent, { lang: 'js' })
else msg = new ProcessManager(message, data.toString(), parent, { lang: HLJS.getLang(filename.split('.').pop()) })
await msg.init()
await msg.addAction([{ emoji: '️', action: ({ manager }) => manager.destroy(), requirePage: true }, { emoji: '️', action: ({ manager }) => manager.previousPage(), requirePage: true }, { emoji: '▶️', action: ({ manager }) => manager.nextPage(), requirePage: true }])
await msg.addAction([{ emoji: '️', action: ({ manager }) => manager.previousPage(), requirePage: true }, { emoji: '️', action: ({ manager }) => manager.destroy(), requirePage: true }, { emoji: '▶️', action: ({ manager }) => manager.nextPage(), requirePage: true }])
})
}
2 changes: 1 addition & 1 deletion src/commands/curl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ module.exports = async function curl (message, parent) {
// console.log(res)
const msg = new ProcessManager(message, res || '', parent, { lang: type })
await msg.init()
await msg.addAction([{ emoji: '️', action: ({ manager }) => manager.destroy(), requirePage: true }, { emoji: '️', action: ({ manager }) => manager.previousPage(), requirePage: true }, { emoji: '▶️', action: ({ manager }) => manager.nextPage(), requirePage: true }])
await msg.addAction([{ emoji: '️', action: ({ manager }) => manager.previousPage(), requirePage: true }, { emoji: '️', action: ({ manager }) => manager.destroy(), requirePage: true }, { emoji: '▶️', action: ({ manager }) => manager.nextPage(), requirePage: true }])
}
41 changes: 21 additions & 20 deletions src/commands/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,27 @@ module.exports = async function Exec (message, parent) {
}, 180000)
console.log(res.pid)

await msg.addAction([{
emoji: '⏹️',
action: async ({ res, manager }) => {
res.stdin.pause()
const gg = await kill(res)
console.log(gg)
manager.destroy()
msg.add('^C')
}
},
{
emoji: '◀️',
action: ({ manager }) => manager.previousPage(),
requirePage: true
},
{
emoji: '▶️',
action: ({ manager }) => manager.nextPage(),
requirePage: true
}], { res })
await msg.addAction([
{
emoji: '◀️',
action: ({ manager }) => manager.previousPage(),
requirePage: true
},
{
emoji: '⏹️',
action: async ({ res, manager }) => {
res.stdin.pause()
const gg = await kill(res)
console.log(gg)
manager.destroy()
msg.add('^C')
}
},
{
emoji: '▶️',
action: ({ manager }) => manager.nextPage(),
requirePage: true
}], { res })

res.stdout.on('data', (data) => {
console.log(data.toString())
Expand Down
32 changes: 28 additions & 4 deletions src/commands/js.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ProcessManager, inspect, isinstance } = require('../utils')
const { ProcessManager, inspect, isinstance, isGenerator } = require('../utils')
const Discord = require('discord.js')

module.exports = async function js (message, parent) {
Expand All @@ -12,8 +12,28 @@ module.exports = async function js (message, parent) {
const result = await res
.then(async output => {
typeOf = typeof output
if (output instanceof Discord.MessageEmbed) await message.channel.send(output)
else if (isinstance(output, Discord.MessageAttachment)) await message.channel.send({ files: output instanceof Discord.Collection ? output.array() : [output] })

async function prettify (target) {
if (target instanceof Discord.MessageEmbed) await message.channel.send(target)
else if (isinstance(target, Discord.MessageAttachment)) {
await message.channel.send({
files: target instanceof Discord.Collection ? target.array() : [target]
})
}
}

if (isGenerator(output)) {
for (const value of output) {
prettify(value)

if (typeof value === 'function') await message.channel.send(value.toString())
else if (typeof value === 'string') await message.channel.send(value)
else await message.channel.send(inspect(value, { depth: 1, maxArrayLength: 200 }))
}
}

prettify(output)

if (typeof output === 'function') {
typeOf = 'object'
return output.toString()
Expand All @@ -31,5 +51,9 @@ module.exports = async function js (message, parent) {

const msg = new ProcessManager(message, result || '', parent, { lang: 'js', noCode: typeOf !== 'object' })
await msg.init()
await msg.addAction([{ emoji: '⏹️', action: ({ manager }) => manager.destroy(), requirePage: true }, { emoji: '◀️', action: ({ manager }) => manager.previousPage(), requirePage: true }, { emoji: '▶️', action: ({ manager }) => manager.nextPage(), requirePage: true }])
await msg.addAction([
{ emoji: '◀️', action: ({ manager }) => manager.previousPage(), requirePage: true },
{ emoji: '⏹️', action: ({ manager }) => manager.destroy(), requirePage: true },
{ emoji: '▶️', action: ({ manager }) => manager.nextPage(), requirePage: true }
])
}
2 changes: 1 addition & 1 deletion src/commands/jsi.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ module.exports = async function jsi (message, parent) {
})

await msg.init()
await msg.addAction([{ emoji: '️', action: ({ manager }) => manager.destroy() }, { emoji: '️', action: ({ manager }) => manager.previousPage(), requirePage: true }, { emoji: '▶️', action: ({ manager }) => manager.nextPage(), requirePage: true }])
await msg.addAction([{ emoji: '️', action: ({ manager }) => manager.previousPage(), requirePage: true }, { emoji: '️', action: ({ manager }) => manager.destroy() }, { emoji: '▶️', action: ({ manager }) => manager.nextPage(), requirePage: true }])
}
2 changes: 1 addition & 1 deletion src/commands/shard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ module.exports = async function shard (message, parent) {
}

await msg.init()
await msg.addAction([{ emoji: '️', action: ({ manager }) => manager.destroy(), requirePage: false }, { emoji: '️', action: ({ manager }) => manager.previousPage(), requirePage: true }, { emoji: '▶️', action: ({ manager }) => manager.nextPage(), requirePage: true }])
await msg.addAction([{ emoji: '️', action: ({ manager }) => manager.previousPage(), requirePage: true }, { emoji: '️', action: ({ manager }) => manager.destroy(), requirePage: false }, { emoji: '▶️', action: ({ manager }) => manager.nextPage(), requirePage: true }])
}
35 changes: 22 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Utils = require('./utils')
* @property {string[]} [owners] ID of owners
* @property {string} [prefix] Prefix of Bot
* @property {any[]} [secrets=[]] Secrets to hide
* @property {Record<string, any>} [globalVariable={}] Custom global Variable for eval
* @property {noPerm} [noPerm] Executed when command runned by not allowed user
* @property {boolean} [disableAttachmentExecution=false] Disable attachment execution.
*/
Expand All @@ -35,22 +36,30 @@ module.exports = class Dokdo {
* @param {Discord.Client} client Discord Client
* @param {DokdoOptions} options Dokdo Options
*/
constructor (client, { aliases = ['dokdo', 'dok'], owners = null, prefix, secrets = [], noPerm, disableAttachmentExecution = false } = {}) {
constructor (client, { aliases = ['dokdo', 'dok'], owners = null, prefix, secrets = [], noPerm, disableAttachmentExecution = false, globalVariable = {} } = {}) {
if (!(client instanceof Discord.Client)) throw new Error('Invalid `client`. `client` parameter is required.')
// if (!this.options || typeof options !== 'object') throw new Error('Invliad `options`. `options` parameter is required.')
if (noPerm && typeof noPerm !== 'function') throw new Error('`noPerm` parameter is must be Function.')
this.owners = owners
if (!this.owners) {
console.warn('[dokdo] Owners not given. Fetching from Application.')
if (noPerm && typeof noPerm !== 'function') throw new Error('`noPerm` parameter must be Function.')
if (globalVariable) {
if (typeof globalVariable !== 'object') throw new Error('`globalVariable` parameter must be Object.')
else {
Object.keys(globalVariable).forEach(el => {
global[el] = globalVariable[el]
})
}
}

client.fetchApplication().then(data => {
if (data.owner.members) this.owners = data.owner.members.map(el => el.id)
else if (data.owner.id) this.owners = [data.owner.id]
else this.owners = []
this.owners = owners

console.info(`[dokdo] Fetched ${this.owners.length} owner(s): ${this.owners.length > 3 ? this.owners.slice(0, 3).join(', ') + ` and ${this.owners.length - 3} more owners` : this.owners.join(', ')}`)
})
}
client.on('ready', () => {
if (!this.owners) {
console.warn('[dokdo] Owners not given. Fetching from Application.')
client.fetchApplication().then(data => {
this.owners = data.owner.members?.map(el => el.id) || [data.owner.id] || []
console.info(`[dokdo] Fetched ${this.owners.length} owner(s): ${this.owners.length > 3 ? this.owners.slice(0, 3).join(', ') + ` and ${this.owners.length - 3} more owners` : this.owners.join(', ')}`)
})
}
})

this.client = client
this.process = []
Expand Down Expand Up @@ -120,7 +129,7 @@ module.exports = class Dokdo {
Commands.cat(message, this)
break
default:
message.channel.send('Available Options: `sh`, `js`, `shard`')
message.channel.send('Available Options: `sh`, `js`, `shard`, `jsi`, `curl`, `cat`')
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/utils/ProcessManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ const codeBlock = require('./codeBlock')
*/
module.exports = class ProcessManager {
constructor (message, content, dokdo, options = {}) {
if (!content || typeof content !== 'string') throw new Error('Please pass valid content')
this.target = message.channel
this.dokdo = dokdo
this.content = content || ''
this.content = content || ''
this.messageContent = ''
this.options = options
this.limit = options.limit || 1900
Expand All @@ -53,6 +52,7 @@ module.exports = class ProcessManager {
this.wait = 1
this.message = null
this.argument = []
if (typeof this.content !== 'string') throw new Error('Please pass valid content')
}

async init () {
Expand Down Expand Up @@ -167,8 +167,8 @@ module.exports = class ProcessManager {
}

destroy () {
this.message.reactions.removeAll().catch(() => {})
this.reactCollector.stop()
this.message.reactions.removeAll()
}

genText () {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const inspect = require('./inspect')
const table = require('./table')
const type = require('./type')
const isinstance = require('./isinstance')
const isGenerator = require('./isGenerator')

module.exports = {
ProcessManager,
Expand All @@ -18,5 +19,6 @@ module.exports = {
table,
type,
inspect,
isinstance
isinstance,
isGenerator
}
7 changes: 7 additions & 0 deletions src/utils/isGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @param {any} target
* @returns {boolean}
*/
module.exports = target => target &&
typeof target.next === 'function' &&
typeof target.throw === 'function'
1 change: 1 addition & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare module 'dokdo' {
owners?: string[]
prefix?: string
secrets?: any[]
globalVariable?: Record<string, any>
noPerm(message: Discord.Message): any|Promise<any>
}

Expand Down
Loading

0 comments on commit feea5f4

Please sign in to comment.