Skip to content

Commit

Permalink
Allow setting of home.
Browse files Browse the repository at this point in the history
  • Loading branch information
roncli committed Jan 9, 2017
1 parent eabd09f commit 0c8a92e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions fusion.js
Expand Up @@ -11,6 +11,7 @@ var glicko2 = require("glicko2"),
messageParse = /^!([^\ ]+)(?:\ +(.+[^\ ]))?\ *$/,
idParse = /^<@([0-9]+)>$/,
twoIdParse = /^<@([0-9]+)>\ <@([0-9]+)>$/,
setHomeParse = /^<@([0-9]+)> (.*)$/,
forceMatchReportParse = /^<@([0-9]+)>\ <@([0-9]+)>\ (-?[0-9]+)\ (-?[0-9]+)$/,
reportParse = /^(-?[0-9]+)\ (-?[0-9]+)$/,
noPermissions = {
Expand Down Expand Up @@ -865,6 +866,32 @@ Fusion.discordMessages = {
});
},

sethome: (from, user, channel, message) => {
"use strict";

if (!Fusion.isAdmin(user) || !message) {
return;
}

if (!event) {
Fusion.discordQueue("Sorry, " + user + ", but there is no event currently running.", channel);
return;
}

matches = forceMatchReportParse.exec(message);
if (!matches) {
Fusion.discordQueue("Sorry, " + user + ", but you must mention the user to set their home level. Try this command in a public channel instead.", channel);
return;
}

player = obsDiscord.members.get(matches[1]);

event.players[player.id].home = matches[2];
Fusion.discordQueue("You have successfully set the home level of " + player.displayName + " to `" + event.players[player.id].home + "`.", user);
Fusion.discordQueue(from + " has changed your home level to `" + event.players[player.id].home + "`.", player);
Fusion.discordQueue(obsDiscord.members.get(user.id).displayName + " has had their home level set to `" + message + "`.", generalChannel);
},

cancelmatch: (from, user, channel, message) => {
"use strict";

Expand Down

0 comments on commit 0c8a92e

Please sign in to comment.