Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #22 from pyraxo/dev
Browse files Browse the repository at this point in the history
0.4.1
  • Loading branch information
ærion authored Aug 8, 2017
2 parents a3b59c4 + 1b4d9d9 commit c9793ad
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sylphy",
"version": "0.4.0",
"version": "0.4.1",
"description": "The better Discord bot framework",
"main": "index.js",
"scripts": {
Expand Down
35 changes: 34 additions & 1 deletion res/i18n/en/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,40 @@
"ON_COOLDOWN": "please cool down! ({{time}} seconds left)",
"NO_PERMS": "you need the permissions {{perms}} to run this command!",
"NO_PERMS_BOT": "I need the permissions {{perms}} to run this command!",
"NO_PMS": "this command can't be run in PMs."
"NO_PMS": "this command can't be run in PMs.",
"member": {
"NOT_FOUND": "the member could not be found"
},
"channel": {
"NOT_FOUND": "the channel could not be found"
},
"command": {
"NOT_FOUND": "the command could not be found"
},
"group": {
"NOT_FOUND": "the command group could not be found"
},
"role": {
"NOT_FOUND": "the role could not be found"
},
"string": {
"NOT_STRING": "{{arg}} must be a string",
"MAX": "{{arg}} length cannot be more than {{max}}",
"MIN": "{{arg}} length cannot be less than {{min}}",
"ONE_OF": "{{arg}} must be one of the following"
},
"list": {
"MAX": "{{arg}} length cannot contain more than {{max}} items",
"MIN": "{{arg}} length cannot contain less than {{min}} items",
"MAX_LENGTH": "{{arg}} cannot contain items longer than {{maxLength}}",
"MIN_LENGTH": "{{arg}} cannot contain items shorter than {{minLength}}",
"DUPES": "{{arg}} cannot contain duplicate values"
},
"int": {
"NOT_INT": "{{arg}} is not an integer",
"MAX": "{{arg}} must be less than or equals to {{max}}",
"MIN": "{{arg}} must be more than or equals to {{min}}"
}
},
"menus": {
"EXIT": "Enter {{cancel}} to exit the menu.",
Expand Down
2 changes: 1 addition & 1 deletion src/core/Interpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Interpreter extends Collection {
*/
parse (string, group = 'default', locale = 'en', options = {}) {
if (!string) return string
return string.split(' ').map(str => (
return String(string).split(' ').map(str => (
str.replace(/\{\{(.+)\}\}/gi, (matched, key) => {
const g = key.startsWith('%') ? 'default.' : group + '.'
key = key.startsWith('%') ? key.substr(1) : key
Expand Down
2 changes: 1 addition & 1 deletion src/managers/Resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class Resolver extends Collection {
if (err instanceof Error) {
return Promise.reject({ message: 'PARSING_ERROR', err: err })
}
return Promise.reject({ message: `{{${err}}}` })
return Promise.reject({ message: err, arg: `**\`${arg.name || 'argument'}\`**` })
})
}

Expand Down
5 changes: 3 additions & 2 deletions src/managers/Responder.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ class Responder {
try {
return await input.resolve(ans, [ans.cleanContent], data, dialog.input)
} catch (err) {
const p2 = await this.format('emoji:error').send(
`${err.err || err.message || err || '{{%menus.ERROR}}'}\n\n{{%menus.EXIT}}`,
const display = err.err || err.message || err
const p2 = await this.error(
`{{%${display ? 'errors.' + display : 'menus.ERROR'}}}\n\n{{%menus.EXIT}}`,
Object.assign(err, { cancel: `\`${cancel}\`` })
)
return awaitMessage(p2)
Expand Down
9 changes: 4 additions & 5 deletions src/resolvers/channel.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
module.exports = {
type: 'channel',
resolve: (content, { text = true, voice = true } = {}, msg) => {
resolve: (content, { text, voice } = {}, msg) => {
const guild = msg.channel.guild
content = String(content).toLowerCase()
let channel = content.match(/^<#?(\d{17,18})>$/)
if (!channel) {
if (!msg.channelMentions.length) {
content = String(content).toLowerCase()
let channels = guild.channels.filter(c => {
if (text && c.type !== 0) return
if (voice && c.type !== 2) return
Expand All @@ -17,7 +16,7 @@ module.exports = {
return Promise.reject('channel.NOT_FOUND')
}
} else {
let chan = guild.channels.get(channel[1])
let chan = guild.channels.get(msg.channelMentions[0])
if (!chan) return Promise.reject('channel.NOT_FOUND')
return Promise.resolve([chan])
}
Expand Down
7 changes: 3 additions & 4 deletions src/resolvers/member.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ module.exports = {
type: 'member',
resolve: (content, { bot = false }, msg) => {
const guild = msg.channel.guild
content = String(content).toLowerCase()
let user = content.match(/^<@!?(\d{17,18})>$/) || content.match(/^(\d{17,18})$/)
if (!user) {
if (!msg.mentions.length) {
content = String(content).toLowerCase()
let members = guild.members.filter(m => {
if (!bot && m.user.bot) return
const name = m.user.username.toLowerCase()
Expand All @@ -22,7 +21,7 @@ module.exports = {
return Promise.reject('member.NOT_FOUND')
}
} else {
let member = guild.members.get(user[1])
let member = guild.members.get(msg.mentions[0])
if (!member) return Promise.reject('member.NOT_FOUND')
return Promise.resolve([member])
}
Expand Down
2 changes: 2 additions & 0 deletions src/structures/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Command extends Base {
set _options (args = {}) {
const {
name,
description,
group = 'none',
aliases = [],
cooldown = 5,
Expand All @@ -65,6 +66,7 @@ class Command extends Base {
throw new Error(`${this.constructor.name} command is not named`)
}

this.description = description
this.cooldown = cooldown
this.options = options
if (this.options.modOnly) {
Expand Down
1 change: 1 addition & 0 deletions src/util/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = Object.assign(require('./Utils'), {
utils: require('./Utils'),
Collection: require('./Collection'),
Permitter: require('./Permitter'),
Terminal: require('./Terminal')
Expand Down

0 comments on commit c9793ad

Please sign in to comment.