Skip to content

Commit

Permalink
Merge branch 'experimental' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
zaza7 authored Jul 17, 2017
2 parents cc42e7d + e2293e5 commit 8fbe08f
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 86 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* @SteamingMutt
*.js @TheSharks/development
133 changes: 67 additions & 66 deletions runtime/commandcontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,90 +45,91 @@ if (cus !== null) {
}

exports.helpHandle = function (msg, suffix) {
var msgArray = []
var msgArraytwo = []
var cmdone = []
var sorts = {
0: [
'[Available commands]\n'
]
}
let counter = 0
if (!suffix) {
for (var index in commands) {
if (commands[index].hidden || commands[index].level === 'master') {
continue
} else {
cmdone.push(commands[index].name + ' = "' + commands[index].help + '"')
if (!commands[index].hidden && commands[index].level !== 'master') {
if (sorts[counter].join('\n').length > 1750) {
counter++
sorts[counter] = []
}
sorts[counter].push(index + ' = "' + commands[index].help + '"')
}
}
var cmdtwo = cmdone.splice(0, cmdone.length / 2)
msgArray.push('**Available commands:** \n')
msgArray.push('```ini')
msgArray.push(cmdone.sort().join('\n') + '\n')
msgArray.push('```')
msgArraytwo.push('```ini')
msgArraytwo.push(cmdtwo.sort().join('\n') + '\n')
msgArraytwo.push('```')
msgArraytwo.push('If you want more information on the commands, check the command reference at http://docs.thesharks.xyz/commands.')
msgArraytwo.push('For further questions, join our server: https://discord.gg/wildbot')
msgArraytwo.push('Like what we do? Consider supporting my developer at Patreon! <https://www.patreon.com/Dougley>')
var misc = [
'If you want more information on the commands, check the command reference at http://docs.thesharks.xyz/commands.',
'For further questions, join our server: discord.gg/wildbot',
'Like what we do? Consider supporting my developer at Patreon! <https://www.patreon.com/Dougley>'
]
msg.author.openDM().then((y) => {
if (!msg.isPrivate) {
msg.channel.sendMessage('Help is underway ' + msg.author.mention + '!')
}
y.sendMessage(msgArray.join('\n'))
y.sendMessage(msgArraytwo.join('\n'))
for (var r in sorts) {
y.sendMessage(`\`\`\`ini\n${sorts[r].sort().join('\n')}\n\`\`\``) // FIXME: The entire commands array should sort instead of the sorts one
}
y.sendMessage(misc.join('\n'))
}).catch((e) => {
Logger.error(e)
msg.channel.sendMessage('Well, this is awkward, something went wrong while trying to PM you. Do you have them enabled on this server?')
})
} else if (suffix) {
if (commands[suffix] || alias[suffix]) {
var comad
if (alias[suffix]) {
comad = alias[suffix]
} else {
comad = commands[suffix]
}
if (comad.level === 'master' && require('../config.json').permissions.master.indexOf(msg.author.id) === -1) {
msg.reply('this command is not for you to use, therefor I will not tell you how to use it.')
} else {
msgArray = []
msgArray.push('Command name `' + comad.name + '`')
msgArray.push('What this does: `' + comad.help + '`\n')
msgArray.push('Example:')
if (comad.hasOwnProperty('usage')) {
msgArray.push('```' + `${require('../config.json').settings.prefix}${comad.name} ${comad.usage}` + '```')
} else {
msgArray.push('```' + `${require('../config.json').settings.prefix}${comad.name}` + '```')
}
msgArray.push(`**Required access level**: ${comad.level}`)
if (comad.hasOwnProperty('aliases')) {
msgArray.push(`**Aliases for this command**: ${comad.aliases.join(', ')}.`)
}
if (comad.hasOwnProperty('hidden')) {
msgArray.push('*Shh, this is a secret command.*')
}
if (comad.hasOwnProperty('timeout')) {
msgArray.push(`*This command has a timeout of ${comad.timeout} seconds.*`)
}
if (comad.hasOwnProperty('nsfw')) {
msgArray.push('*This command is NSFW.*')
var c = (commands[suffix]) ? commands[suffix] : alias[suffix]
var attributes = []
var name
for (var x in commands) {
if (commands[x] === c) {
name = x
break
}
if (comad.hasOwnProperty('noDM')) {
msgArray.push('*This command cannot be used in DM.*')
}
if (comad.name === 'meme') {
var str = '**Currently available memes:\n**'
var meme = require('./commands/memes.json')
for (var m in meme) {
str += m + ', '
}
var def = [
`Command name: \`${name}\``,
`What this does: \`${c.help}\``,
'Example:',
'```',
`${(c.usage) ? config.settings.prefix + name + ' ' + c.usage : config.settings.prefix + name}`,
'```',
`**Required access level**: ${c.level}`,
`${(c.aliases) ? '**Aliases for this command**: ' + c.aliases.join(', ') + '\n' : ''}`
]
for (var attribute in c) {
switch (attribute) {
case 'noDM': {
if (c[attribute] === true) attributes.push('*This command cannot be used in DMs.*')
break
}
case 'hidden': {
if (c[attribute] === true) attributes.push('*This is a hidden command.*')
break
}
case 'nsfw': {
if (c[attribute] === true) attributes.push('*This command is NSFW*')
break
}
msgArray.push(str.substring(0, str.length - 2))
case 'timeout': {
attributes.push(`*This command has a timeout of ${c.timeout} seconds*`)
break
}
}
}
if (name === 'meme') {
var str = '\n**Currently available memes:\n**'
var meme = require('./commands/memes.json')
for (var m in meme) {
str += m + ', '
}
msg.author.openDM().then((y) => {
y.sendMessage(msgArray.join('\n'))
}).catch((e) => {
Logger.error(e)
bugsnag.notify(e)
msg.channel.sendMessage('Whoops, try again.')
})
attributes.push(str)
}
msg.author.openDM().then((y) => {
y.sendMessage(def.join('\n') + attributes.join('\n'))
})
} else {
msg.channel.sendMessage(`There is no **${suffix}** command!`)
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/commands/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ Commands.softban = {
m.edit('A provided ID isn\'t a member of this guild!')
return
}
msg.guild.ban(member, 7, `${msg.author.username}#${msg.author.discriminator} used softban for: ${reason}`).then(() => {
msg.guild.ban(member, 1, `${msg.author.username}#${msg.author.discriminator} used softban for: ${reason}`).then(() => {
member.unban(msg.guild).then(() => {
banMembers.success.push(`\`${member.username}#${member.discriminator}\``)
if (banMembers.success.length + banMembers.error.length === idArray.length) {
Expand Down
38 changes: 19 additions & 19 deletions runtime/commands/fun.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Commands.randomdog = {
Commands.dogfact = {
name: 'dogfact',
help: "I'll give you some interesting dogfacts!",
aliases: ['dogfacts'],
timeout: 10,
level: 0,
fn: function (msg) {
Expand All @@ -130,6 +131,24 @@ Commands.dogfact = {
}
}

Commands.catfact = {
name: 'catfact',
help: "I'll give you some interesting catfacts!",
aliases: ['catfacts'],
timeout: 10,
level: 0,
fn: function (msg) {
request.get('https://catfact.ninja/fact')
.end((err, res) => {
if (!err && res.status === 200) {
msg.channel.sendMessage(res.body.fact)
} else {
Logger.error(`Got an error: ${err}, status code: ${res.status}`)
}
})
}
}

Commands.leetspeak = {
name: 'leetspeak',
help: "1'Ll 3nc0d3 Y0uR Me5s@g3 1Nt0 l337sp3@K!",
Expand Down Expand Up @@ -376,25 +395,6 @@ Commands.cleverbot = {
}
}

Commands.catfacts = {
name: 'catfacts',
help: "I'll give you some interesting catfacts",
timeout: 10,
level: 0,
fn: function (msg) {
request.get('http://catfacts-api.appspot.com/api/facts')
.buffer()
.end((err, res) => {
if (err) {
msg.channel.sendMessage('The API returned an unconventional response, please try again later.')
} else {
var fact = JSON.parse(res.text)
msg.reply(fact.facts[0])
}
})
}
}

Commands.e621 = {
name: 'e621',
help: 'e621, the definition of *Stop taking the Internet so seriously.*',
Expand Down

0 comments on commit 8fbe08f

Please sign in to comment.