Skip to content

Commit

Permalink
Merge pull request #50 from alex-taxiera/release/3.0.0
Browse files Browse the repository at this point in the history
Release/3.0.0
  • Loading branch information
alex-taxiera authored Apr 12, 2020
2 parents b2f087b + 1d70e3a commit 2e10eb8
Show file tree
Hide file tree
Showing 62 changed files with 2,312 additions and 1,939 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
dist: trusty
language: node_js
node_js:
- "lts/erbium"
- lts/erbium
install:
- npm ci
cache:
directories:
- "$HOME/.npm"
- $HOME/.npm
jobs:
include:
-
Expand All @@ -29,7 +29,7 @@ jobs:
github_token: $GITHUB_TOKEN
skip_cleanup: true
keep_history: true
local_dir: './docs'
local_dir: ./docs/eris-boiler/$TRAVIS_TAG
committer_from_gh: true
on:
tags: true
Expand All @@ -42,7 +42,7 @@ jobs:
stages:
-
name: test
if: type = pull_request OR branch = master
if: type = pull_request OR branch =~ /^(master|dev)$/
-
name: publish
if: tag IS present
5 changes: 3 additions & 2 deletions bin/dev.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const nodemon = require('nodemon')
const { Utils: { logger } } = require('../')
const { logger } = require('../util')

nodemon({
script: 'demo/index.js',
ext: 'js',
watch: './'
watch: './',
nodeArgs: [ '--inspect=9999' ]
})

nodemon
Expand Down
2 changes: 1 addition & 1 deletion cli/index.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node
#!/usr/bin/env node

require('./main')(process.argv)
2 changes: 1 addition & 1 deletion cli/main/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Action {
module.exports.Action = Action

module.exports.LoadActions = async () => {
let acts = []
const acts = []

const files = await fs.readdir(path.join(__dirname))

Expand Down
13 changes: 2 additions & 11 deletions cli/main/actions/init.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const { Action } = require('.')

const { exec } = require('child_process')
const { resolve } = require('path')
const { copyFiles } = require('../functions')

const { Action } = require('.')

const { print } = require('../functions')

Expand All @@ -11,13 +9,6 @@ class Initialize extends Action {
super({
name: 'init',
async run (params) {
print('Importing the template...')

const templateDir = resolve(__dirname, '..', 'migrations')
const userDir = resolve(process.cwd())

copyFiles(templateDir, userDir)

print('Loading package.json')
exec('npm init -y', (error, stdout, stderr) => {
if (error) {
Expand Down
25 changes: 23 additions & 2 deletions cli/main/actions/migrations.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const { Action } = require('.')

const { exec } = require('child_process')
const { resolve } = require('path')

const { Action } = require('.')

const { print } = require('../functions')
const { copyFiles } = require('../functions')

class Migrations extends Action {
constructor () {
Expand Down Expand Up @@ -88,9 +90,28 @@ class Migrations extends Action {
}
})
}
}),
new Action({
name: 'update',
async run () {
print('Importing the default migrations...')

const templateDir = resolve(__dirname, '..', 'migrations')
const userDir = resolve(process.cwd())

await copyFiles(templateDir, userDir)

print('Copied over all built in migrations')
}
})
],
async run () {
print('Importing the default migrations...')

const templateDir = resolve(__dirname, '..', 'migrations')
const userDir = resolve(process.cwd())

await copyFiles(templateDir, userDir)
print('Creating a knexfile...\n')

exec('npx knex init', (err, stdout, stderr) => {
Expand Down
42 changes: 0 additions & 42 deletions command-lib/settings/index.js

This file was deleted.

45 changes: 22 additions & 23 deletions command-lib/help.js → commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ const { Command } = require('../lib')
module.exports = new Command({
name: 'help',
description: 'Displays this message, duh!',
run: async (context) => {
run: async (bot, context) => {
const {
params,
bot
params
} = context

if (params[0]) {
return commandInfo(bot, params[0])
}

const { commands, longName } = filterCommands(bot.commands, context)
const { commands, longName } = await filterCommands(bot, context)

const content = commands.reduce(
(ax, { name, description, aliases }) => ax + `\n${name}` + (
Expand All @@ -29,25 +28,25 @@ module.exports = new Command({
}
})

function filterCommands (commands, context) {
return commands.reduce(
({ commands, longName }, command) => {
if (context.bot.ora.hasPermission({ ...context, command })) {
const {
name,
aliases,
description
} = command

longName = Math.max(
name.length + aliases.join('/').length + 3, longName
)
commands.push({ name, description, aliases })
}

return { commands, longName }
}, { commands: [], longName: 0 }
)
async function filterCommands (bot, context) {
const commands = []
let longName = 0
for (const command of bot.commands.values()) {
const { ok } = await bot.ora.hasPermission(bot, { ...context, command })
if (ok) {
const {
name,
aliases,
description
} = command

longName = Math.max(
name.length + aliases.join('/').length + 3, longName
)
commands.push({ name, description, aliases })
}
}
return { commands, longName }
}

function commandInfo (bot, cmd) {
Expand Down
1 change: 1 addition & 0 deletions command-lib/index.js → commands/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
isIndex: true,
settings: require('./settings'),
status: require('./status'),
help: require('./help'),
info: require('./info'),
process: require('./process')
Expand Down
2 changes: 1 addition & 1 deletion command-lib/info.js → commands/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = new Command({
options: {
deleteResponseDelay: 30000
},
run: async ({ bot }) => {
run: async (bot) => {
const owner = bot.users.get(bot.ownerID)
const ownerName = owner.username + '#' + owner.discriminator
const guilds = bot.guilds.size
Expand Down
4 changes: 2 additions & 2 deletions command-lib/process.js → commands/process.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const { Command } = require('../lib')
const { admin: permission } = require('../permission-lib')
const { admin: permission } = require('../permissions')

module.exports = new Command({
name: 'process',
description: 'Check process stats',
options: {
permission
},
run: async ({ bot }) => {
run: async (bot) => {
const seconds = process.uptime()
const uptime = getDuration(seconds)

Expand Down
36 changes: 36 additions & 0 deletions commands/settings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const { GuildCommand } = require('../../lib')
const { vip: permission } = require('../../permissions')

const prefix = require('./prefix')
const vip = require('./vip')

module.exports = new GuildCommand({
name: 'settings',
description: 'Change some settings for your server :)',
options: {
permission,
subCommands: [
prefix,
vip
]
},
run: async function (bot, context) {
return {
embed: {
description: ':gear: [**Settings**](https://github.com/alex-taxiera/eris-boiler)',
thumbnail: { url: bot.user.avatarURL },
timestamp: require('dateformat')(Date.now(), 'isoDateTime'),
color: 0x3498db,
footer: {
icon_url: bot.user.avatarURL,
text: 'eris-boiler'
},
fields: await Promise.all(this.subCommands.map(async (sub) => ({
name: sub.displayName,
value: await sub.getValue(bot, context),
inline: true
})))
}
}
}
})
11 changes: 8 additions & 3 deletions command-lib/settings/prefix.js → commands/settings/prefix.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
const { Command } = require('../../lib')
const { SettingCommand } = require('../../lib')

module.exports = new Command({
module.exports = new SettingCommand({
name: 'prefix',
description: 'set prefix for server',
options: {
parameters: [ 'desired prefix' ]
},
run: async ({ bot, msg, params }) => {
displayName: 'Prefix',
getValue: async (bot, { channel }) => {
const dbGuild = await bot.dbm.newQuery('guild').get(channel.guild.id)
return dbGuild.get('prefix') || bot.ora.defaultPrefix
},
run: async (bot, { msg, params }) => {
const fullParam = params.join(' ')
if (!fullParam) {
return 'Please provide a prefix!'
Expand Down
19 changes: 15 additions & 4 deletions command-lib/settings/vip.js → commands/settings/vip.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
const { Command } = require('../../lib')
const { owner: permission } = require('../../permission-lib')
const { SettingCommand } = require('../../lib')
const { owner: permission } = require('../../permissions')

module.exports = new Command({
module.exports = new SettingCommand({
name: 'vip',
description: 'set vip role for server',
options: {
parameters: [ 'vip role name/id/mention' ],
permission
},
run: async ({ bot, msg, params }) => {
displayName: 'VIP Role',
getValue: async (bot, { channel }) => {
const dbGuild = await bot.dbm.newQuery('guild').get(channel.guild.id)
const roleId = dbGuild.get('vip')

if (!roleId) {
return 'None'
}

return `<@&${roleId}>`
},
run: async (bot, { msg, params }) => {
const [ roleId ] = params
const fullParam = params.join(' ')

Expand Down
14 changes: 7 additions & 7 deletions command-lib/settings/status/add.js → commands/status/add.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const {
Command,
Utils: {
status: {
equalStatuses
}
Command
} = require('../../lib')
const {
status: {
equalStatuses
}
} = require('../../../lib')
} = require('../../util')

module.exports = new Command({
name: 'add',
Expand All @@ -16,7 +16,7 @@ module.exports = new Command({
(ex. \`Rocket League|0\`) where type is 0, 1, 2, or 3`
]
},
run: async ({ bot, params }) => {
run: async (bot, { params }) => {
const [ name, type ] = params.join(' ').split('|')
if (!name || !type) {
return 'Please format the status like name|type (ex. `Rocket League|0`)'
Expand Down
4 changes: 2 additions & 2 deletions command-lib/settings/status/del.js → commands/status/del.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Command } = require('../../../lib')
const { Command } = require('../../lib')

module.exports = new Command({
name: 'del',
Expand All @@ -9,7 +9,7 @@ module.exports = new Command({
where type is 0, 1, 2, or 3`
]
},
run: async ({ bot, params }) => {
run: async (bot, { params }) => {
const [ name, type ] = params.join(' ').split('|')
const [ toDelete ] = bot.dbm.newQuery('status')
.equalTo('name', name)
Expand Down
Loading

0 comments on commit 2e10eb8

Please sign in to comment.