Skip to content

Commit 830278d

Browse files
authored
merge exp to master (#308)
* One get for guild data. * Rename permissions.js to database/controllers/permissions.js * I hate github * Update permissions.js * Whoops * So done. * Fix rule34, mention command bug, and spacing * Fixes an issue with prefix in DMs, not the right way but hot patch until proper rewrite. * closes #299 and a couple little things. * buffer ay yo * it picked on me for litle things! * now we got buffering and prefix fix yet again * wow * prefix was wrong in the "use [prefix]request to add more songs" * bye bye ytdl-core. * left in some console.logs * bad logic is bad * whoops forgot about them ECONNRESETS * You forced this on yourselves. * whoops ear rape * ugh this command is broken again * cucked by standard * whatever * memleaks * idk maybe get rid of the type error * welcomeChannel customize method * accommodate changes to rule34 api
1 parent f5ac516 commit 830278d

File tree

9 files changed

+470
-395
lines changed

9 files changed

+470
-395
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# 4.0.0
22
## Release phase
33

4+
### 4.5.0
5+
Improvements to command handler.
6+
Improvement to permissions database controller.
7+
Improvement to customize database controller.
8+
Improvement to join-voice command.
9+
Improvement to songs playing.
10+
411
### 4.4.0
512
Improvements to help handler.
613
Added aliases to `dogfact` and `catfact`.

DougBot.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,21 @@ bot.Dispatcher.on(Event.GUILD_MEMBER_ADD, function (s) {
257257
datacontrol.customize.isKnown(s.guild)
258258
datacontrol.customize.check(s.guild).then((r) => {
259259
if (r === 'on' || r === 'channel') {
260-
datacontrol.customize.reply(s, 'welcomeMessage').then((x) => {
261-
if (x === null || x === 'default') {
262-
s.guild.generalChannel.sendMessage(`Welcome ${s.member.username} to ${s.guild.name}!`)
263-
} else {
264-
s.guild.generalChannel.sendMessage(x.replace(/%user/g, s.member.mention).replace(/%server/g, s.guild.name))
265-
}
266-
}).catch((e) => {
267-
Logger.error(e)
260+
datacontrol.customize.reply(s, 'welcomeChannel').then(rep => {
261+
datacontrol.customize.reply(s, 'welcomeMessage').then((x) => {
262+
var channel = s.guild.channels.find(g => g.id === rep)
263+
if (!channel) return
264+
if (x === null || x === 'default') {
265+
channel.sendMessage(`Welcome ${s.member.username} to ${s.guild.name}!`)
266+
} else {
267+
channel.sendMessage(x.replace(/%user/g, s.member.mention).replace(/%server/g, s.guild.name))
268+
}
269+
}).catch((e) => {
270+
Logger.error(e)
271+
})
272+
}).catch(e => {
273+
if (e === 'Unsupported reply method') return // oh well
274+
else Logger.error(e)
268275
})
269276
} else if (r === 'private') {
270277
datacontrol.customize.reply(s, 'welcomeMessage').then((x) => {
@@ -333,7 +340,8 @@ bot.Dispatcher.onAny((type, data) => {
333340

334341
process.on('unhandledRejection', (reason, p) => {
335342
if (p !== null && reason !== null) {
336-
bugsnag.notify(new Error(`Unhandled promise: ${require('util').inspect(p, {depth: 3})}: ${reason}`))
343+
if (reason instanceof Error) bugsnag.notify(reason)
344+
else bugsnag.notify(new Error(`Unhandlled promise: ${require('util').inspect(p, {depth: 3})}: ${reason}`))
337345
}
338346
})
339347

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "WildBeast",
4-
"version": "4.4.0",
4+
"version": "4.5.0",
55
"description": "A Discord Bot",
66
"main": "DougBot.js",
77
"maintainers": [
@@ -37,7 +37,7 @@
3737
"dependencies": {
3838
"bugsnag": "^1.9.0",
3939
"cleverbot.io": "^1.0.4",
40-
"discordie": "qeled/discordie#dev",
40+
"discordie": "github:qeled/discordie#dev",
4141
"imgflipper": "^1.0.1",
4242
"leetspeak": "0.0.1",
4343
"minimist": "^1.2.0",
@@ -53,8 +53,7 @@
5353
"winston-elasticsearch": "^0.5.0",
5454
"xml2js": "^0.4.16",
5555
"youtube-api": "^2.0.2",
56-
"youtube-dl": "^1.11.1",
57-
"ytdl-core": "^0.17.0"
56+
"youtube-dl": "^1.11.1"
5857
},
5958
"devDependencies": {
6059
"eslint": "^4.1.0",

runtime/commands/default.js

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function getUptime () {
2525

2626
Commands.ping = {
2727
name: 'ping',
28-
help: "I'll reply to you with pong!",
28+
help: 'I\'ll reply to you with pong!',
2929
timeout: 10,
3030
level: 0,
3131
fn: function (msg) {
@@ -204,27 +204,27 @@ Commands.twitch = {
204204
}
205205
var url = 'https://api.twitch.tv/kraken/streams/' + suffix
206206
request.get(url)
207-
.set({'Accept': 'application/vnd.twitchtv.v3+json', 'Client-ID': config.api_keys.twitchId})
208-
.end((error, response) => {
209-
if (error) {
210-
bugsnag.notify(error)
211-
}
212-
if (!error && response.statusCode === 200) {
213-
var resp
214-
try {
215-
resp = response.body
216-
} catch (e) {
217-
msg.channel.sendMessage('The API returned an unconventional response.')
207+
.set({'Accept': 'application/vnd.twitchtv.v3+json', 'Client-ID': config.api_keys.twitchId})
208+
.end((error, response) => {
209+
if (error) {
210+
bugsnag.notify(error)
218211
}
219-
if (resp.stream !== null) {
220-
msg.channel.sendMessage(suffix + ' is currently live at https://www.twitch.tv/' + suffix)
221-
} else if (resp.stream === null) {
222-
msg.channel.sendMessage(suffix + ' is not currently streaming')
212+
if (!error && response.statusCode === 200) {
213+
var resp
214+
try {
215+
resp = response.body
216+
} catch (e) {
217+
msg.channel.sendMessage('The API returned an unconventional response.')
218+
}
219+
if (resp.stream !== null) {
220+
msg.channel.sendMessage(suffix + ' is currently live at https://www.twitch.tv/' + suffix)
221+
} else if (resp.stream === null) {
222+
msg.channel.sendMessage(suffix + ' is not currently streaming')
223+
}
224+
} else if (!error && response.statusCode === 404) {
225+
msg.channel.sendMessage('Channel does not exist!')
223226
}
224-
} else if (!error && response.statusCode === 404) {
225-
msg.channel.sendMessage('Channel does not exist!')
226-
}
227-
})
227+
})
228228
}
229229
}
230230

@@ -256,7 +256,7 @@ Commands.customize = {
256256

257257
Commands.info = {
258258
name: 'info',
259-
help: "I'll print some information about me.",
259+
help: 'I\'ll print some information about me.',
260260
timeout: 10,
261261
level: 0,
262262
fn: function (msg, suffix, bot) {
@@ -292,7 +292,7 @@ Commands.info = {
292292

293293
Commands['leave-server'] = {
294294
name: 'leave-server',
295-
help: "I'll leave this server if I am not welcome here.",
295+
help: 'I\'ll leave this server if I am not welcome here.',
296296
noDM: true,
297297
level: 3,
298298
fn: function (msg) {
@@ -350,9 +350,9 @@ Commands.setlevel = {
350350
} else if (msg.mentions.filter(m => m.id !== bot.User.id).length === 0 && msg.mention_roles.length === 0 && !msg.mention_everyone) {
351351
msg.reply('Please @mention the user(s)/role(s) you want to set the permission level of.')
352352
} else if (msg.mentions.filter(m => m.id !== bot.User.id).length === 1 && msg.mentions.filter(m => m.id !== bot.User.id)[0].id === msg.guild.owner.id) {
353-
msg.reply("You cannot set the server owner's level.")
353+
msg.reply('You cannot set the server owner\'s level.')
354354
} else if (msg.mentions.filter(m => m.id !== bot.User.id).length === 1 && msg.mentions.filter(m => m.id !== bot.User.id)[0].id === bot.User.id) {
355-
msg.reply("I don't need any level set, I can do anything regardless of access levels.")
355+
msg.reply('I don\'t need any level set, I can do anything regardless of access levels.')
356356
} else {
357357
Permissions.adjustLevel(msg, msg.mentions, parseFloat(suffix[0]), msg.mention_roles).then(function () {
358358
msg.channel.sendMessage('Alright! The permission levels have been set successfully!')
@@ -484,24 +484,24 @@ Commands.setnsfw = {
484484
msg.channel.sendMessage('NSFW commands are now disallowed for ' + msg.channel.mention)
485485
}
486486
}).catch(() => {
487-
msg.reply("I've failed to set NSFW flag!")
487+
msg.reply('I\'ve failed to set NSFW flag!')
488488
})
489489
} else {
490490
msg.channel.sendMessage('Use either `on` or `off` as suffix!')
491491
}
492492
} else {
493-
msg.channel.sendMessage("NSFW commands are always allowed in DM's.")
493+
msg.channel.sendMessage('NSFW commands are always allowed in DM\'s.')
494494
}
495495
}
496496
}
497497

498498
Commands.hello = {
499499
name: 'hello',
500-
help: "I'll respond to you with hello along with a GitHub link!",
500+
help: 'I\'ll respond to you with hello along with a GitHub link!',
501501
timeout: 20,
502502
level: 0,
503503
fn: function (msg, suffix, bot) {
504-
msg.channel.sendMessage('Hi ' + msg.author.username + ", I'm " + bot.User.username + ' and I was developed by the team over at TheSharks! Improve me by contributing to my source code on GitHub: https://github.com/TheSharks/WildBeast')
504+
msg.channel.sendMessage('Hi ' + msg.author.username + ', I\'m ' + bot.User.username + ' and I was developed by the team over at TheSharks! Improve me by contributing to my source code on GitHub: https://github.com/TheSharks/WildBeast')
505505
}
506506
}
507507

@@ -541,7 +541,7 @@ Commands.setstatus = {
541541

542542
Commands['server-info'] = {
543543
name: 'server-info',
544-
help: "I'll tell you some information about the server you're currently in.",
544+
help: 'I\'ll tell you some information about the server you\'re currently in.',
545545
aliases: ['serverinfo'],
546546
noDM: true,
547547
timeout: 20,
@@ -550,7 +550,11 @@ Commands['server-info'] = {
550550
// if we're not in a PM, return some info about the channel
551551
if (msg.guild) {
552552
var field = [{name: 'Server name', value: `${msg.guild.name} [${msg.guild.acronym}] (${msg.guild.id})`},
553-
{name: 'Owned by', value: '```\n' + `${msg.guild.owner.username}#${msg.guild.owner.discriminator} (${msg.guild.owner.id})` + '```', inline: true},
553+
{
554+
name: 'Owned by',
555+
value: '```\n' + `${msg.guild.owner.username}#${msg.guild.owner.discriminator} (${msg.guild.owner.id})` + '```',
556+
inline: true
557+
},
554558
{name: 'Current Region', value: '```\n' + msg.guild.region + '```', inline: true},
555559
{name: 'Members', value: '```\n' + msg.guild.members.length + '```', inline: true},
556560
{name: 'Text Channels', value: '```\n' + msg.guild.textChannels.length + '```', inline: true},
@@ -560,7 +564,10 @@ Commands['server-info'] = {
560564
if (msg.guild.afk_channel === null) {
561565
field.push({name: 'AFK-Channel', value: '```\nNone```'})
562566
} else {
563-
field.push({name: 'AFK-channel', value: '```\n' + `${msg.guild.afk_channel.name} (${msg.guild.afk_channel.id})` + '```'})
567+
field.push({
568+
name: 'AFK-channel',
569+
value: '```\n' + `${msg.guild.afk_channel.name} (${msg.guild.afk_channel.id})` + '```'
570+
})
564571
}
565572
var embed = {
566573
author: {name: `Information requested by ${msg.author.username}`},
@@ -575,24 +582,26 @@ Commands['server-info'] = {
575582
}
576583
msg.channel.sendMessage('', false, embed)
577584
} else {
578-
msg.channel.sendMessage("You can't do that in a DM, dummy!")
585+
msg.channel.sendMessage('You can\'t do that in a DM, dummy!')
579586
}
580587
}
581588
}
582589

583590
Commands.userinfo = {
584591
name: 'userinfo',
585-
help: "I'll get some information about the user you've mentioned.",
592+
help: 'I\'ll get some information about the user you\'ve mentioned.',
586593
noDM: true,
587594
level: 0,
588595
fn: function (msg, suffix, bot) {
589596
var Permissions = require('../databases/controllers/permissions.js')
590597
if (msg.isPrivate) {
591-
msg.channel.sendMessage("Sorry you can't use this in DMs")
598+
msg.channel.sendMessage('Sorry you can\'t use this in DMs')
592599
}
593600
if (msg.mentions.filter(m => m.id !== bot.User.id).length === 0) {
594601
Permissions.checkLevel(msg, msg.author.id, msg.member.roles).then((level) => {
595-
var tempRoles = msg.member.roles.sort(function (a, b) { return a.position - b.position }).reverse()
602+
var tempRoles = msg.member.roles.sort(function (a, b) {
603+
return a.position - b.position
604+
}).reverse()
596605
var roles = []
597606
for (var i in tempRoles) {
598607
roles.push(tempRoles[i].name)
@@ -628,7 +637,9 @@ Commands.userinfo = {
628637
Permissions.checkLevel(msg, user.id, user.memberOf(msg.guild).roles).then(function (level) {
629638
var guild = msg.guild
630639
var member = guild.members.find((m) => m.id === user.id)
631-
var tempRoles = member.roles.sort(function (a, b) { return a.position - b.position }).reverse()
640+
var tempRoles = member.roles.sort(function (a, b) {
641+
return a.position - b.position
642+
}).reverse()
632643
var roles = []
633644
for (var i in tempRoles) {
634645
roles.push(tempRoles[i].name)
@@ -664,13 +675,13 @@ Commands.userinfo = {
664675

665676
Commands['join-server'] = {
666677
name: 'join-server',
667-
help: "I'll join the server you've requested me to join, as long as the invite is valid and I'm not banned of already in the requested server.",
678+
help: 'I\'ll join the server you\'ve requested me to join, as long as the invite is valid and I\'m not banned of already in the requested server.',
668679
aliases: ['join', 'joinserver', 'invite'],
669680
usage: '<bot-mention> <instant-invite>',
670681
level: 0,
671682
fn: function (msg, suffix, bot) {
672683
if (bot.User.bot) {
673-
msg.channel.sendMessage("Sorry, bot accounts can't accept instant invites, instead, use my OAuth URL: <" + config.bot.oauth + '>')
684+
msg.channel.sendMessage('Sorry, bot accounts can\'t accept instant invites, instead, use my OAuth URL: <' + config.bot.oauth + '>')
674685
} else {
675686
Logger.warn('Using user accounts is deprecated!')
676687
}
@@ -844,7 +855,8 @@ Commands.softban = {
844855
let banMembers = {success: [], error: []}
845856
let reasonWords = []
846857
suffix.split(' ').map((id) => {
847-
if (id.startsWith('<@')) {} else {
858+
if (id.startsWith('<@')) {
859+
} else {
848860
reasonWords.push(id)
849861
}
850862
})
@@ -939,7 +951,7 @@ Commands.softban = {
939951

940952
Commands.prefix = {
941953
name: 'prefix',
942-
help: "If you, despite reading this have no clue what my prefix is, I'll tell you!",
954+
help: 'If you, despite reading this have no clue what my prefix is, I\'ll tell you!',
943955
timeout: 5,
944956
level: 0,
945957
fn: function (msg) {
@@ -986,7 +998,9 @@ Commands.colorrole = {
986998
msg.reply('I do not have Manage Roles permission here, sorry!')
987999
return
9881000
}
989-
var botRole = bot.User.memberOf(msg.guild).roles.sort(function (a, b) { return a.position < b.position })[0]
1001+
var botRole = bot.User.memberOf(msg.guild).roles.sort(function (a, b) {
1002+
return a.position < b.position
1003+
})[0]
9901004
if (role.position >= botRole.position) {
9911005
msg.reply('This role is higher or equal to my highest role, I cannot color it!')
9921006
return

0 commit comments

Comments
 (0)