Skip to content

Commit

Permalink
Merge branch 'dota' into dota-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
MeLlamoPablo committed Jan 11, 2017
2 parents cacfeb8 + 86629b0 commit 4b005fd
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 28 deletions.
20 changes: 8 additions & 12 deletions lib/commands/admin/add-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ module.exports = new Clapp.Command({
return new Promise((fulfill, reject) => {
let id = argv.args.user.match(/<@([0-9]+)>/)[1];
context.summaryHandler.bot.fetchUser(id).then(user => {
if (user !== null) {
db.admins.add(user).then(added => {
if (added) {
context.botAdmins.push(user.id);
fulfill("The user was added as an admin.", context);
} else {
fulfill("Error: the user is already in the admin list");
}
}).catch(reject);
} else {
fulfill("Error: the specified user doesn't exist.");
}
db.admins.add(user).then(added => {
if (added) {
context.botAdmins.push(user.id);
fulfill("The user was added as an admin.", context);
} else {
fulfill("Error: the user is already in the admin list");
}
}).catch(reject);
}).catch(err => {
if (err.status === 404) {
fulfill("Error: the specified user doesn't exist.");
Expand Down
36 changes: 23 additions & 13 deletions lib/commands/admin/kick.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,33 @@ module.exports = new Clapp.Command({
desc: "Kicks a player from an event.",
fn: (argv, context) => {
return new Promise((fulfill, reject) => {
let id = argv.args.user.match(/<@([0-9]+)>/)[1];

db.events.get(argv.args.id).then(event => {
if (event !== null) {
db.confirms.getByUser(event, context.msg.author).then(attends => {
if (attends) {
db.confirms.add(event, context.msg.author, false)
.then(() => context.summaryHandler.updateSummary(event))
.then(() => {
fulfill(context.msg.author + " has been successfully kicked from " +
"the event `" + argv.args.id + "`.\n" +
"Please note that they are able to rejoin it at any time. To " +
"prevent them from doing so, use the `blacklist-add` command.");
}).catch(reject);
context.summaryHandler.bot.fetchUser(id).then(user => {
db.confirms.getByUser(event, context.msg.author).then(attends => {
if (attends) {
db.confirms.add(event, user, false)
.then(() => context.summaryHandler.updateSummary(event))
.then(() => {
fulfill(user + " has been successfully kicked from " +
"the event `" + argv.args.id + "`.\n" +
"Please note that they are able to rejoin it at any time. To " +
"prevent them from doing so, use the `blacklist-add` command.");
}).catch(reject);
} else {
fulfill("Error: the specified user isn't attending the specified " +
"event.");
}
}).catch(reject);
}).catch(err => {
if (err.status === 404) {
fulfill("Error: the specified user doesn't exist.");
} else {
fulfill("Error: the specifier user isn't attending the specified " +
"event.");
reject(err);
}
}).catch(reject);
});
} else {
fulfill("Error: the specified event `" + argv.args.id + "` doesn't exist.");
}
Expand Down
5 changes: 3 additions & 2 deletions lib/commands/general/confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ module.exports = new Clapp.Command({
// Don't let people confirm yes if the event is full, but do let
// people confirm no even if the event is full.
if (
attendanceConfirms.length < event.limit
&& argv.args.attendance === "yes"
(argv.args.attendance === "yes" && attendanceConfirms.length < event.limit)
||
argv.args.attendance === "no"
) {
db.confirms.add(
event,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "schedulebot",
"version": "1.1.0",
"version": "1.1.1",
"description": "A Discord bot that makes scheduling easy",
"homepage": "https://github.com/mellamopablo/schedulebot#readme",
"author": "Pablo Rodríguez <pabloviolin8@gmail.com> (https://github.com/MeLlamoPablo)",
Expand Down
1 change: 1 addition & 0 deletions scripts/shared/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
"v1.1.1-dota",
"v1.1.0-dota",
"v1.0.6-dota",
"v1.0.5-dota",
Expand Down
1 change: 1 addition & 0 deletions scripts/sql/1.1.0-to-1.1.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--noop

0 comments on commit 4b005fd

Please sign in to comment.