Skip to content

Commit 8fbe08f

Browse files
authored
Merge branch 'experimental' into master
2 parents cc42e7d + e2293e5 commit 8fbe08f

File tree

4 files changed

+89
-86
lines changed

4 files changed

+89
-86
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* @SteamingMutt
2+
*.js @TheSharks/development

runtime/commandcontrol.js

Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -45,90 +45,91 @@ if (cus !== null) {
4545
}
4646

4747
exports.helpHandle = function (msg, suffix) {
48-
var msgArray = []
49-
var msgArraytwo = []
50-
var cmdone = []
48+
var sorts = {
49+
0: [
50+
'[Available commands]\n'
51+
]
52+
}
53+
let counter = 0
5154
if (!suffix) {
5255
for (var index in commands) {
53-
if (commands[index].hidden || commands[index].level === 'master') {
54-
continue
55-
} else {
56-
cmdone.push(commands[index].name + ' = "' + commands[index].help + '"')
56+
if (!commands[index].hidden && commands[index].level !== 'master') {
57+
if (sorts[counter].join('\n').length > 1750) {
58+
counter++
59+
sorts[counter] = []
60+
}
61+
sorts[counter].push(index + ' = "' + commands[index].help + '"')
5762
}
5863
}
59-
var cmdtwo = cmdone.splice(0, cmdone.length / 2)
60-
msgArray.push('**Available commands:** \n')
61-
msgArray.push('```ini')
62-
msgArray.push(cmdone.sort().join('\n') + '\n')
63-
msgArray.push('```')
64-
msgArraytwo.push('```ini')
65-
msgArraytwo.push(cmdtwo.sort().join('\n') + '\n')
66-
msgArraytwo.push('```')
67-
msgArraytwo.push('If you want more information on the commands, check the command reference at http://docs.thesharks.xyz/commands.')
68-
msgArraytwo.push('For further questions, join our server: https://discord.gg/wildbot')
69-
msgArraytwo.push('Like what we do? Consider supporting my developer at Patreon! <https://www.patreon.com/Dougley>')
64+
var misc = [
65+
'If you want more information on the commands, check the command reference at http://docs.thesharks.xyz/commands.',
66+
'For further questions, join our server: discord.gg/wildbot',
67+
'Like what we do? Consider supporting my developer at Patreon! <https://www.patreon.com/Dougley>'
68+
]
7069
msg.author.openDM().then((y) => {
7170
if (!msg.isPrivate) {
7271
msg.channel.sendMessage('Help is underway ' + msg.author.mention + '!')
7372
}
74-
y.sendMessage(msgArray.join('\n'))
75-
y.sendMessage(msgArraytwo.join('\n'))
73+
for (var r in sorts) {
74+
y.sendMessage(`\`\`\`ini\n${sorts[r].sort().join('\n')}\n\`\`\``) // FIXME: The entire commands array should sort instead of the sorts one
75+
}
76+
y.sendMessage(misc.join('\n'))
7677
}).catch((e) => {
7778
Logger.error(e)
7879
msg.channel.sendMessage('Well, this is awkward, something went wrong while trying to PM you. Do you have them enabled on this server?')
7980
})
8081
} else if (suffix) {
8182
if (commands[suffix] || alias[suffix]) {
82-
var comad
83-
if (alias[suffix]) {
84-
comad = alias[suffix]
85-
} else {
86-
comad = commands[suffix]
87-
}
88-
if (comad.level === 'master' && require('../config.json').permissions.master.indexOf(msg.author.id) === -1) {
89-
msg.reply('this command is not for you to use, therefor I will not tell you how to use it.')
90-
} else {
91-
msgArray = []
92-
msgArray.push('Command name `' + comad.name + '`')
93-
msgArray.push('What this does: `' + comad.help + '`\n')
94-
msgArray.push('Example:')
95-
if (comad.hasOwnProperty('usage')) {
96-
msgArray.push('```' + `${require('../config.json').settings.prefix}${comad.name} ${comad.usage}` + '```')
97-
} else {
98-
msgArray.push('```' + `${require('../config.json').settings.prefix}${comad.name}` + '```')
99-
}
100-
msgArray.push(`**Required access level**: ${comad.level}`)
101-
if (comad.hasOwnProperty('aliases')) {
102-
msgArray.push(`**Aliases for this command**: ${comad.aliases.join(', ')}.`)
103-
}
104-
if (comad.hasOwnProperty('hidden')) {
105-
msgArray.push('*Shh, this is a secret command.*')
106-
}
107-
if (comad.hasOwnProperty('timeout')) {
108-
msgArray.push(`*This command has a timeout of ${comad.timeout} seconds.*`)
109-
}
110-
if (comad.hasOwnProperty('nsfw')) {
111-
msgArray.push('*This command is NSFW.*')
83+
var c = (commands[suffix]) ? commands[suffix] : alias[suffix]
84+
var attributes = []
85+
var name
86+
for (var x in commands) {
87+
if (commands[x] === c) {
88+
name = x
89+
break
11290
}
113-
if (comad.hasOwnProperty('noDM')) {
114-
msgArray.push('*This command cannot be used in DM.*')
115-
}
116-
if (comad.name === 'meme') {
117-
var str = '**Currently available memes:\n**'
118-
var meme = require('./commands/memes.json')
119-
for (var m in meme) {
120-
str += m + ', '
91+
}
92+
var def = [
93+
`Command name: \`${name}\``,
94+
`What this does: \`${c.help}\``,
95+
'Example:',
96+
'```',
97+
`${(c.usage) ? config.settings.prefix + name + ' ' + c.usage : config.settings.prefix + name}`,
98+
'```',
99+
`**Required access level**: ${c.level}`,
100+
`${(c.aliases) ? '**Aliases for this command**: ' + c.aliases.join(', ') + '\n' : ''}`
101+
]
102+
for (var attribute in c) {
103+
switch (attribute) {
104+
case 'noDM': {
105+
if (c[attribute] === true) attributes.push('*This command cannot be used in DMs.*')
106+
break
107+
}
108+
case 'hidden': {
109+
if (c[attribute] === true) attributes.push('*This is a hidden command.*')
110+
break
111+
}
112+
case 'nsfw': {
113+
if (c[attribute] === true) attributes.push('*This command is NSFW*')
114+
break
121115
}
122-
msgArray.push(str.substring(0, str.length - 2))
116+
case 'timeout': {
117+
attributes.push(`*This command has a timeout of ${c.timeout} seconds*`)
118+
break
119+
}
120+
}
121+
}
122+
if (name === 'meme') {
123+
var str = '\n**Currently available memes:\n**'
124+
var meme = require('./commands/memes.json')
125+
for (var m in meme) {
126+
str += m + ', '
123127
}
124-
msg.author.openDM().then((y) => {
125-
y.sendMessage(msgArray.join('\n'))
126-
}).catch((e) => {
127-
Logger.error(e)
128-
bugsnag.notify(e)
129-
msg.channel.sendMessage('Whoops, try again.')
130-
})
128+
attributes.push(str)
131129
}
130+
msg.author.openDM().then((y) => {
131+
y.sendMessage(def.join('\n') + attributes.join('\n'))
132+
})
132133
} else {
133134
msg.channel.sendMessage(`There is no **${suffix}** command!`)
134135
}

runtime/commands/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ Commands.softban = {
898898
m.edit('A provided ID isn\'t a member of this guild!')
899899
return
900900
}
901-
msg.guild.ban(member, 7, `${msg.author.username}#${msg.author.discriminator} used softban for: ${reason}`).then(() => {
901+
msg.guild.ban(member, 1, `${msg.author.username}#${msg.author.discriminator} used softban for: ${reason}`).then(() => {
902902
member.unban(msg.guild).then(() => {
903903
banMembers.success.push(`\`${member.username}#${member.discriminator}\``)
904904
if (banMembers.success.length + banMembers.error.length === idArray.length) {

runtime/commands/fun.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Commands.randomdog = {
116116
Commands.dogfact = {
117117
name: 'dogfact',
118118
help: "I'll give you some interesting dogfacts!",
119+
aliases: ['dogfacts'],
119120
timeout: 10,
120121
level: 0,
121122
fn: function (msg) {
@@ -130,6 +131,24 @@ Commands.dogfact = {
130131
}
131132
}
132133

134+
Commands.catfact = {
135+
name: 'catfact',
136+
help: "I'll give you some interesting catfacts!",
137+
aliases: ['catfacts'],
138+
timeout: 10,
139+
level: 0,
140+
fn: function (msg) {
141+
request.get('https://catfact.ninja/fact')
142+
.end((err, res) => {
143+
if (!err && res.status === 200) {
144+
msg.channel.sendMessage(res.body.fact)
145+
} else {
146+
Logger.error(`Got an error: ${err}, status code: ${res.status}`)
147+
}
148+
})
149+
}
150+
}
151+
133152
Commands.leetspeak = {
134153
name: 'leetspeak',
135154
help: "1'Ll 3nc0d3 Y0uR Me5s@g3 1Nt0 l337sp3@K!",
@@ -376,25 +395,6 @@ Commands.cleverbot = {
376395
}
377396
}
378397

379-
Commands.catfacts = {
380-
name: 'catfacts',
381-
help: "I'll give you some interesting catfacts",
382-
timeout: 10,
383-
level: 0,
384-
fn: function (msg) {
385-
request.get('http://catfacts-api.appspot.com/api/facts')
386-
.buffer()
387-
.end((err, res) => {
388-
if (err) {
389-
msg.channel.sendMessage('The API returned an unconventional response, please try again later.')
390-
} else {
391-
var fact = JSON.parse(res.text)
392-
msg.reply(fact.facts[0])
393-
}
394-
})
395-
}
396-
}
397-
398398
Commands.e621 = {
399399
name: 'e621',
400400
help: 'e621, the definition of *Stop taking the Internet so seriously.*',

0 commit comments

Comments
 (0)