Skip to content

Commit 86629b0

Browse files
committed
v1.1.1 - Closes #9 and #10
1 parent d30d919 commit 86629b0

File tree

6 files changed

+37
-28
lines changed

6 files changed

+37
-28
lines changed

lib/commands/admin/add-admin.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,14 @@ module.exports = new Clapp.Command({
1111
return new Promise((fulfill, reject) => {
1212
let id = argv.args.user.match(/<@([0-9]+)>/)[1];
1313
context.summaryHandler.bot.fetchUser(id).then(user => {
14-
if (user !== null) {
15-
db.admins.add(user).then(added => {
16-
if (added) {
17-
context.botAdmins.push(user.id);
18-
fulfill("The user was added as an admin.", context);
19-
} else {
20-
fulfill("Error: the user is already in the admin list");
21-
}
22-
}).catch(reject);
23-
} else {
24-
fulfill("Error: the specified user doesn't exist.");
25-
}
14+
db.admins.add(user).then(added => {
15+
if (added) {
16+
context.botAdmins.push(user.id);
17+
fulfill("The user was added as an admin.", context);
18+
} else {
19+
fulfill("Error: the user is already in the admin list");
20+
}
21+
}).catch(reject);
2622
}).catch(err => {
2723
if (err.status === 404) {
2824
fulfill("Error: the specified user doesn't exist.");

lib/commands/admin/kick.js

+23-13
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,33 @@ module.exports = new Clapp.Command({
88
desc: "Kicks a player from an event.",
99
fn: (argv, context) => {
1010
return new Promise((fulfill, reject) => {
11+
let id = argv.args.user.match(/<@([0-9]+)>/)[1];
12+
1113
db.events.get(argv.args.id).then(event => {
1214
if (event !== null) {
13-
db.confirms.getByUser(event, context.msg.author).then(attends => {
14-
if (attends) {
15-
db.confirms.add(event, context.msg.author, false)
16-
.then(() => context.summaryHandler.updateSummary(event))
17-
.then(() => {
18-
fulfill(context.msg.author + " has been successfully kicked from " +
19-
"the event `" + argv.args.id + "`.\n" +
20-
"Please note that they are able to rejoin it at any time. To " +
21-
"prevent them from doing so, use the `blacklist-add` command.");
22-
}).catch(reject);
15+
context.summaryHandler.bot.fetchUser(id).then(user => {
16+
db.confirms.getByUser(event, context.msg.author).then(attends => {
17+
if (attends) {
18+
db.confirms.add(event, user, false)
19+
.then(() => context.summaryHandler.updateSummary(event))
20+
.then(() => {
21+
fulfill(user + " has been successfully kicked from " +
22+
"the event `" + argv.args.id + "`.\n" +
23+
"Please note that they are able to rejoin it at any time. To " +
24+
"prevent them from doing so, use the `blacklist-add` command.");
25+
}).catch(reject);
26+
} else {
27+
fulfill("Error: the specified user isn't attending the specified " +
28+
"event.");
29+
}
30+
}).catch(reject);
31+
}).catch(err => {
32+
if (err.status === 404) {
33+
fulfill("Error: the specified user doesn't exist.");
2334
} else {
24-
fulfill("Error: the specifier user isn't attending the specified " +
25-
"event.");
35+
reject(err);
2636
}
27-
}).catch(reject);
37+
});
2838
} else {
2939
fulfill("Error: the specified event `" + argv.args.id + "` doesn't exist.");
3040
}

lib/commands/general/confirm.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ module.exports = new Clapp.Command({
4141
// Don't let people confirm yes if the event is full, but do let
4242
// people confirm no even if the event is full.
4343
if (
44-
attendanceConfirms.length < event.limit
45-
&& argv.args.attendance === "yes"
44+
(argv.args.attendance === "yes" && attendanceConfirms.length < event.limit)
45+
||
46+
argv.args.attendance === "no"
4647
) {
4748
db.confirms.add(
4849
event,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "schedulebot",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "A Discord bot that makes scheduling easy",
55
"homepage": "https://github.com/mellamopablo/schedulebot#readme",
66
"author": "Pablo Rodríguez <[email protected]> (https://github.com/MeLlamoPablo)",

scripts/shared/versions.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[
2+
"v1.1.1-dota",
23
"v1.1.0-dota",
34
"v1.0.6-dota",
45
"v1.0.5-dota",

scripts/sql/1.1.0-to-1.1.1.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--noop

0 commit comments

Comments
 (0)