language
stringclasses 6
values | original_string
stringlengths 25
887k
| text
stringlengths 25
887k
|
---|---|---|
JavaScript | static async checkChallengeIsNotVoided(challenge, member, channel) {
if (challenge.details.dateVoided) {
await Discord.queue(`Sorry, ${member}, but this match is voided.`, channel);
throw new Warning("Match was voided.");
}
} | static async checkChallengeIsNotVoided(challenge, member, channel) {
if (challenge.details.dateVoided) {
await Discord.queue(`Sorry, ${member}, but this match is voided.`, channel);
throw new Warning("Match was voided.");
}
} |
JavaScript | static async checkChallengeMapIsSet(challenge, member, channel) {
if (!challenge.details.map) {
await Discord.queue(`Sorry, ${member}, but the map for this match has not been set yet.`, channel);
throw new Warning("Map not set.");
}
} | static async checkChallengeMapIsSet(challenge, member, channel) {
if (!challenge.details.map) {
await Discord.queue(`Sorry, ${member}, but the map for this match has not been set yet.`, channel);
throw new Warning("Map not set.");
}
} |
JavaScript | static async checkChallengeMatchTimeIsSet(challenge, member, channel) {
if (!challenge.details.matchTime) {
await Discord.queue(`Sorry, ${member}, but the time for this match has not been set yet.`, channel);
throw new Warning("Match time not set.");
}
} | static async checkChallengeMatchTimeIsSet(challenge, member, channel) {
if (!challenge.details.matchTime) {
await Discord.queue(`Sorry, ${member}, but the time for this match has not been set yet.`, channel);
throw new Warning("Match time not set.");
}
} |
JavaScript | static async checkChallengeStatsComplete(challenge, member, channel) {
const stats = {};
try {
stats.challengingTeamStats = await challenge.getStatsForTeam(challenge.challengingTeam);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (stats.challengingTeamStats.length > 0 && stats.challengingTeamStats.length !== challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but **${challenge.challengingTeam.tag}** has **${stats.challengingTeamStats.length}** player stats and this match requires **${challenge.details.teamSize}**.`, channel);
throw new Warning("Insufficient number of stats.");
}
try {
stats.challengedTeamStats = await challenge.getStatsForTeam(challenge.challengedTeam);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (stats.challengedTeamStats.length > 0 && stats.challengedTeamStats.length !== challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but **${challenge.challengedTeam.tag}** has **${stats.challengedTeamStats.length}** player stats and this match requires **${challenge.details.teamSize}**.`, channel);
throw new Warning("Insufficient number of stats.");
}
if (stats.challengingTeamStats.length !== stats.challengedTeamStats.length) {
await Discord.queue(`Sorry, ${member}, but you must enter stats for either both teams or neither team.`, channel);
throw new Warning("Mismatched number of stats.");
}
return stats;
} | static async checkChallengeStatsComplete(challenge, member, channel) {
const stats = {};
try {
stats.challengingTeamStats = await challenge.getStatsForTeam(challenge.challengingTeam);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (stats.challengingTeamStats.length > 0 && stats.challengingTeamStats.length !== challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but **${challenge.challengingTeam.tag}** has **${stats.challengingTeamStats.length}** player stats and this match requires **${challenge.details.teamSize}**.`, channel);
throw new Warning("Insufficient number of stats.");
}
try {
stats.challengedTeamStats = await challenge.getStatsForTeam(challenge.challengedTeam);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (stats.challengedTeamStats.length > 0 && stats.challengedTeamStats.length !== challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but **${challenge.challengedTeam.tag}** has **${stats.challengedTeamStats.length}** player stats and this match requires **${challenge.details.teamSize}**.`, channel);
throw new Warning("Insufficient number of stats.");
}
if (stats.challengingTeamStats.length !== stats.challengedTeamStats.length) {
await Discord.queue(`Sorry, ${member}, but you must enter stats for either both teams or neither team.`, channel);
throw new Warning("Mismatched number of stats.");
}
return stats;
} |
JavaScript | static async checkChallengeTeamSizeIsSet(challenge, member, channel) {
if (!challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but the team size for this match has not been set yet.`, channel);
throw new Warning("Team size not set.");
}
} | static async checkChallengeTeamSizeIsSet(challenge, member, channel) {
if (!challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but the team size for this match has not been set yet.`, channel);
throw new Warning("Team size not set.");
}
} |
JavaScript | static async checkChallengeTeamStats(challenge, pilot, team, member, channel) {
const stats = await challenge.getStatsForTeam(team);
if (!stats.find((s) => s.pilot && s.pilot.id === pilot.id) && stats.length >= challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but you have already provided enough pilot stats for this match.`, channel);
throw new Warning("Too many stats for team.");
}
} | static async checkChallengeTeamStats(challenge, pilot, team, member, channel) {
const stats = await challenge.getStatsForTeam(team);
if (!stats.find((s) => s.pilot && s.pilot.id === pilot.id) && stats.length >= challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but you have already provided enough pilot stats for this match.`, channel);
throw new Warning("Too many stats for team.");
}
} |
JavaScript | static async checkChannelIsChallengeRoom(channel, member) {
try {
return await Challenge.getByChannel(channel);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
} | static async checkChannelIsChallengeRoom(channel, member) {
try {
return await Challenge.getByChannel(channel);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
} |
JavaScript | static async checkHasParameters(message, member, text, channel) {
if (!message) {
await Discord.queue(`Sorry, ${member}, but this command cannot be used by itself. ${text}`, channel);
return false;
}
return true;
} | static async checkHasParameters(message, member, text, channel) {
if (!message) {
await Discord.queue(`Sorry, ${member}, but this command cannot be used by itself. ${text}`, channel);
return false;
}
return true;
} |
JavaScript | static async checkMapIsValid(map, gameType, member, channel) {
let correctedMap;
try {
correctedMap = await Map.validate(map, gameType);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!correctedMap) {
await Discord.queue(`Sorry, ${member}, but that is not a map you can use. See https://otl.gg/maplist for a complete list of maps you can use.`, channel);
throw new Warning("Invalid map.");
}
return correctedMap;
} | static async checkMapIsValid(map, gameType, member, channel) {
let correctedMap;
try {
correctedMap = await Map.validate(map, gameType);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!correctedMap) {
await Discord.queue(`Sorry, ${member}, but that is not a map you can use. See https://otl.gg/maplist for a complete list of maps you can use.`, channel);
throw new Warning("Invalid map.");
}
return correctedMap;
} |
JavaScript | static async checkMemberCanBeCaptain(member, channel) {
let canBeCaptain;
try {
canBeCaptain = await member.canBeCaptain();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!canBeCaptain) {
await Discord.queue(`Sorry, ${member}, but you are penalized and cannot use this command. For details, talk to an admin.`, channel);
throw new Warning("Pilot is penalized from being captain.");
}
} | static async checkMemberCanBeCaptain(member, channel) {
let canBeCaptain;
try {
canBeCaptain = await member.canBeCaptain();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!canBeCaptain) {
await Discord.queue(`Sorry, ${member}, but you are penalized and cannot use this command. For details, talk to an admin.`, channel);
throw new Warning("Pilot is penalized from being captain.");
}
} |
JavaScript | static async checkMemberCanJoinATeam(member, channel) {
let deniedUntil;
try {
deniedUntil = await member.joinTeamDeniedUntil();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (deniedUntil) {
await Discord.queue(`Sorry, ${member}, but you have accepted an invitation in the past 28 days. You cannot use this command until ${deniedUntil.toLocaleString("en-US", {timeZone: await member.getTimezone(), month: "numeric", day: "numeric", year: "numeric", hour12: true, hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.`, channel);
throw new Warning("Pilot already accepted an invitation within 28 days.");
}
} | static async checkMemberCanJoinATeam(member, channel) {
let deniedUntil;
try {
deniedUntil = await member.joinTeamDeniedUntil();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (deniedUntil) {
await Discord.queue(`Sorry, ${member}, but you have accepted an invitation in the past 28 days. You cannot use this command until ${deniedUntil.toLocaleString("en-US", {timeZone: await member.getTimezone(), month: "numeric", day: "numeric", year: "numeric", hour12: true, hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.`, channel);
throw new Warning("Pilot already accepted an invitation within 28 days.");
}
} |
JavaScript | static async checkMemberHasTwitchName(member, channel) {
let twitchName;
try {
twitchName = await member.getTwitchName();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!twitchName) {
await Discord.queue(`Sorry, ${member}, but you haven't linked your Twitch channel yet! Use the \`!twitch\` command to link your Twitch channel.`, channel);
throw new Warning("Twitch channel not linked.");
}
return twitchName;
} | static async checkMemberHasTwitchName(member, channel) {
let twitchName;
try {
twitchName = await member.getTwitchName();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!twitchName) {
await Discord.queue(`Sorry, ${member}, but you haven't linked your Twitch channel yet! Use the \`!twitch\` command to link your Twitch channel.`, channel);
throw new Warning("Twitch channel not linked.");
}
return twitchName;
} |
JavaScript | static async checkMemberIsCaptainOrFounder(member, channel) {
const isCaptain = member.isCaptainOrFounder();
if (!isCaptain) {
await Discord.queue(`Sorry, ${member}, but you must be a team captain or founder to use this command.`, channel);
throw new Warning("Pilot is not a captain or founder.");
}
} | static async checkMemberIsCaptainOrFounder(member, channel) {
const isCaptain = member.isCaptainOrFounder();
if (!isCaptain) {
await Discord.queue(`Sorry, ${member}, but you must be a team captain or founder to use this command.`, channel);
throw new Warning("Pilot is not a captain or founder.");
}
} |
JavaScript | static async checkMemberIsFounder(member, channel) {
const isFounder = member.isFounder();
if (!isFounder) {
await Discord.queue(`Sorry, ${member}, but you must be a team founder to use this command.`, channel);
throw new Warning("Pilot is not a founder.");
}
} | static async checkMemberIsFounder(member, channel) {
const isFounder = member.isFounder();
if (!isFounder) {
await Discord.queue(`Sorry, ${member}, but you must be a team founder to use this command.`, channel);
throw new Warning("Pilot is not a founder.");
}
} |
JavaScript | static checkMemberIsOwner(member) {
if (!Discord.isOwner(member)) {
throw new Warning("Owner permission required to perform this command.");
}
} | static checkMemberIsOwner(member) {
if (!Discord.isOwner(member)) {
throw new Warning("Owner permission required to perform this command.");
}
} |
JavaScript | static async checkMemberNotBannedFromTeam(member, team, channel) {
let bannedUntil;
try {
bannedUntil = await member.bannedFromTeamUntil(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (bannedUntil) {
await Discord.queue(`Sorry, ${member}, but you have left this team within the past 28 days. You cannot use this command until ${bannedUntil.toLocaleString("en-US", {timeZone: await member.getTimezone(), month: "numeric", day: "numeric", year: "numeric", hour12: true, hour: "numeric", minute: "2-digit", timeZoneName: "short"})}`, channel);
throw new Warning("Pilot not allowed to accept an invite from this team.");
}
} | static async checkMemberNotBannedFromTeam(member, team, channel) {
let bannedUntil;
try {
bannedUntil = await member.bannedFromTeamUntil(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (bannedUntil) {
await Discord.queue(`Sorry, ${member}, but you have left this team within the past 28 days. You cannot use this command until ${bannedUntil.toLocaleString("en-US", {timeZone: await member.getTimezone(), month: "numeric", day: "numeric", year: "numeric", hour12: true, hour: "numeric", minute: "2-digit", timeZoneName: "short"})}`, channel);
throw new Warning("Pilot not allowed to accept an invite from this team.");
}
} |
JavaScript | static async checkMemberNotOnTeam(member, channel) {
let team;
try {
team = await member.getTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (team) {
await Discord.queue(`Sorry, ${member}, but you are already on **${team.name}**! Visit your team channel at ${team.teamChannel} to talk with your teammates, or use \`!leave\` to leave your current team.`, channel);
throw new Warning("Pilot is already on a team.");
}
} | static async checkMemberNotOnTeam(member, channel) {
let team;
try {
team = await member.getTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (team) {
await Discord.queue(`Sorry, ${member}, but you are already on **${team.name}**! Visit your team channel at ${team.teamChannel} to talk with your teammates, or use \`!leave\` to leave your current team.`, channel);
throw new Warning("Pilot is already on a team.");
}
} |
JavaScript | static async checkMemberNotStartingTeam(member, channel) {
let newTeam;
try {
newTeam = await member.getNewTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (newTeam) {
await Discord.queue(`Sorry, ${member}, but you are already in the process of starting a team! Visit ${newTeam.channel} to get started, or \`!cancel\` to cancel your new team creation.`, channel);
throw new Warning("Pilot is already in the process of starting a team.");
}
} | static async checkMemberNotStartingTeam(member, channel) {
let newTeam;
try {
newTeam = await member.getNewTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (newTeam) {
await Discord.queue(`Sorry, ${member}, but you are already in the process of starting a team! Visit ${newTeam.channel} to get started, or \`!cancel\` to cancel your new team creation.`, channel);
throw new Warning("Pilot is already in the process of starting a team.");
}
} |
JavaScript | static async checkMemberOnTeam(member, channel) {
let team;
try {
team = await member.getTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!team) {
await Discord.queue(`Sorry, ${member}, but you must be on a team to use this command.`, channel);
throw new Warning("Pilot not on a team.");
}
return team;
} | static async checkMemberOnTeam(member, channel) {
let team;
try {
team = await member.getTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!team) {
await Discord.queue(`Sorry, ${member}, but you must be on a team to use this command.`, channel);
throw new Warning("Pilot not on a team.");
}
return team;
} |
JavaScript | static async checkMemberStartingNewTeam(member, channel) {
let newTeam;
try {
newTeam = await member.getNewTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!newTeam) {
await Discord.queue(`Sorry, ${member}, but you can only use this command when you're in the process of creating a new team.`, channel);
throw new Warning("Pilot is not in the process of starting a team.");
}
return newTeam;
} | static async checkMemberStartingNewTeam(member, channel) {
let newTeam;
try {
newTeam = await member.getNewTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!newTeam) {
await Discord.queue(`Sorry, ${member}, but you can only use this command when you're in the process of creating a new team.`, channel);
throw new Warning("Pilot is not in the process of starting a team.");
}
return newTeam;
} |
JavaScript | static async checkNoParameters(message, member, text, channel) {
if (message) {
await Discord.queue(`Sorry, ${member ? `${member}, ` : ""}but this command does not take any parameters. ${text}`, channel);
return false;
}
return true;
} | static async checkNoParameters(message, member, text, channel) {
if (message) {
await Discord.queue(`Sorry, ${member ? `${member}, ` : ""}but this command does not take any parameters. ${text}`, channel);
return false;
}
return true;
} |
JavaScript | static async checkPilotCanBeCaptain(pilot, member, channel) {
let canBeCaptain;
try {
canBeCaptain = await pilot.canBeCaptain();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!canBeCaptain) {
await Discord.queue(`Sorry, ${member}, but due to past penalties, ${pilot.displayName} is unable to be a team captain or founder.`, channel);
throw new Warning("Pilot is penalized from being a team captain or founder.");
}
} | static async checkPilotCanBeCaptain(pilot, member, channel) {
let canBeCaptain;
try {
canBeCaptain = await pilot.canBeCaptain();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!canBeCaptain) {
await Discord.queue(`Sorry, ${member}, but due to past penalties, ${pilot.displayName} is unable to be a team captain or founder.`, channel);
throw new Warning("Pilot is penalized from being a team captain or founder.");
}
} |
JavaScript | static async checkPilotExists(message, member, channel) {
let pilot;
if (idParse.test(message)) {
const {groups: {id}} = idParse.exec(message);
pilot = Discord.findGuildMemberById(id);
} else {
pilot = Discord.findGuildMemberByDisplayName(message);
}
if (!pilot) {
await Discord.queue(`Sorry, ${member ? `${member}, ` : ""}but I can't find that pilot on this server. You must mention the pilot.`, channel);
throw new Warning("Pilot not found.");
}
return pilot;
} | static async checkPilotExists(message, member, channel) {
let pilot;
if (idParse.test(message)) {
const {groups: {id}} = idParse.exec(message);
pilot = Discord.findGuildMemberById(id);
} else {
pilot = Discord.findGuildMemberByDisplayName(message);
}
if (!pilot) {
await Discord.queue(`Sorry, ${member ? `${member}, ` : ""}but I can't find that pilot on this server. You must mention the pilot.`, channel);
throw new Warning("Pilot not found.");
}
return pilot;
} |
JavaScript | static async checkPilotExistsWithConfirmation(message, member, channel) {
let pilot, confirm;
if (idConfirmParse.test(message)) {
const {groups: {id, confirmed}} = idConfirmParse.exec(message);
pilot = Discord.findGuildMemberById(id);
confirm = confirmed;
} else if (nameConfirmParse.test(message)) {
const {groups: {name, confirmed}} = nameConfirmParse.exec(message);
pilot = Discord.findGuildMemberByDisplayName(name);
confirm = confirmed;
}
if (!pilot) {
await Discord.queue(`Sorry, ${member}, but I can't find that pilot on this server. You must mention the pilot you wish to make founder.`, channel);
throw new Warning("Pilot not found.");
}
return {pilot, confirm};
} | static async checkPilotExistsWithConfirmation(message, member, channel) {
let pilot, confirm;
if (idConfirmParse.test(message)) {
const {groups: {id, confirmed}} = idConfirmParse.exec(message);
pilot = Discord.findGuildMemberById(id);
confirm = confirmed;
} else if (nameConfirmParse.test(message)) {
const {groups: {name, confirmed}} = nameConfirmParse.exec(message);
pilot = Discord.findGuildMemberByDisplayName(name);
confirm = confirmed;
}
if (!pilot) {
await Discord.queue(`Sorry, ${member}, but I can't find that pilot on this server. You must mention the pilot you wish to make founder.`, channel);
throw new Warning("Pilot not found.");
}
return {pilot, confirm};
} |
JavaScript | static async checkPilotNotOnTeam(pilot, member, channel) {
const team = await pilot.getTeam();
if (team) {
await Discord.queue(`Sorry, ${member}, but this pilot is already on **${team.name}**.`, channel);
throw new Warning("Pilot is already on a team.");
}
} | static async checkPilotNotOnTeam(pilot, member, channel) {
const team = await pilot.getTeam();
if (team) {
await Discord.queue(`Sorry, ${member}, but this pilot is already on **${team.name}**.`, channel);
throw new Warning("Pilot is already on a team.");
}
} |
JavaScript | static async checkPilotOnTeam(team, pilot, member, channel) {
if (!team.role.members.find((m) => m.id === pilot.id)) {
await Discord.queue(`Sorry, ${member}, but this pilot is not on **${team.name}**.`, channel);
throw new Warning("Pilot is not on the correct team.");
}
} | static async checkPilotOnTeam(team, pilot, member, channel) {
if (!team.role.members.find((m) => m.id === pilot.id)) {
await Discord.queue(`Sorry, ${member}, but this pilot is not on **${team.name}**.`, channel);
throw new Warning("Pilot is not on the correct team.");
}
} |
JavaScript | static async checkTeamExists(message, member, channel) {
let team;
try {
team = await Team.getByNameOrTag(message);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!team) {
await Discord.queue(`Sorry, ${member}, but I can't find a team by the name of **${message}**.`, channel);
throw new Warning("Team does not exist.");
}
return team;
} | static async checkTeamExists(message, member, channel) {
let team;
try {
team = await Team.getByNameOrTag(message);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!team) {
await Discord.queue(`Sorry, ${member}, but I can't find a team by the name of **${message}**.`, channel);
throw new Warning("Team does not exist.");
}
return team;
} |
JavaScript | static async checkTeamExistsWithConfirmation(message, member, channel) {
const {groups: {name, confirmed}} = nameConfirmParse.exec(message);
let team;
try {
team = await Team.getByNameOrTag(name);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!team) {
await Discord.queue(`Sorry, ${member}, but I have no record of that team ever existing.`, channel);
throw new Warning("Team does not exist.");
}
return {team, confirm: confirmed};
} | static async checkTeamExistsWithConfirmation(message, member, channel) {
const {groups: {name, confirmed}} = nameConfirmParse.exec(message);
let team;
try {
team = await Team.getByNameOrTag(name);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!team) {
await Discord.queue(`Sorry, ${member}, but I have no record of that team ever existing.`, channel);
throw new Warning("Team does not exist.");
}
return {team, confirm: confirmed};
} |
JavaScript | static async checkTeamIsInChallenge(challenge, team, member, channel) {
if (challenge.challengingTeam.id !== team.id && challenge.challengedTeam.id !== team.id) {
await Discord.queue(`Sorry, ${member}, but **${team.name}** is not one of the teams in this challenge.`, channel);
throw new Warning("Pilot not on a team in the challenge.");
}
} | static async checkTeamIsInChallenge(challenge, team, member, channel) {
if (challenge.challengingTeam.id !== team.id && challenge.challengedTeam.id !== team.id) {
await Discord.queue(`Sorry, ${member}, but **${team.name}** is not one of the teams in this challenge.`, channel);
throw new Warning("Pilot not on a team in the challenge.");
}
} |
JavaScript | static async checkTimezoneIsValid(message, member, channel) {
if (!tzdata.zones[message]) {
await Discord.queue(`Sorry, ${member}, but that time zone is not recognized. Please note that this command is case sensitive. See #timezone-faq for a complete list of time zones.`, channel);
throw new Warning("Invalid time zone.");
}
let time;
try {
time = new Date().toLocaleString("en-US", {timeZone: message, hour12: true, hour: "numeric", minute: "2-digit", timeZoneName: "short"});
} catch (err) {
await Discord.queue(`Sorry, ${member}, but that time zone is not recognized. Please note that this command is case sensitive. See #timezone-faq for a complete list of time zones.`, channel);
throw new Warning("Invalid time zone.");
}
return time;
} | static async checkTimezoneIsValid(message, member, channel) {
if (!tzdata.zones[message]) {
await Discord.queue(`Sorry, ${member}, but that time zone is not recognized. Please note that this command is case sensitive. See #timezone-faq for a complete list of time zones.`, channel);
throw new Warning("Invalid time zone.");
}
let time;
try {
time = new Date().toLocaleString("en-US", {timeZone: message, hour12: true, hour: "numeric", minute: "2-digit", timeZoneName: "short"});
} catch (err) {
await Discord.queue(`Sorry, ${member}, but that time zone is not recognized. Please note that this command is case sensitive. See #timezone-faq for a complete list of time zones.`, channel);
throw new Warning("Invalid time zone.");
}
return time;
} |
JavaScript | static async checkUserExists(message, member, channel) {
/** @type {PlayerTypes.UserOrGuildMember} */
let pilot;
if (idParse.test(message)) {
const {groups: {id}} = idParse.exec(message);
pilot = Discord.findGuildMemberById(id);
if (!pilot) {
pilot = await Discord.findUserById(id);
}
} else {
pilot = Discord.findGuildMemberByDisplayName(message);
}
if (!pilot) {
await Discord.queue(`Sorry, ${member ? `${member}, ` : ""}but I can't find that user on Discord. You must mention the user.`, channel);
throw new Warning("User not found.");
}
return pilot;
} | static async checkUserExists(message, member, channel) {
/** @type {PlayerTypes.UserOrGuildMember} */
let pilot;
if (idParse.test(message)) {
const {groups: {id}} = idParse.exec(message);
pilot = Discord.findGuildMemberById(id);
if (!pilot) {
pilot = await Discord.findUserById(id);
}
} else {
pilot = Discord.findGuildMemberByDisplayName(message);
}
if (!pilot) {
await Discord.queue(`Sorry, ${member ? `${member}, ` : ""}but I can't find that user on Discord. You must mention the user.`, channel);
throw new Warning("User not found.");
}
return pilot;
} |
JavaScript | static async isDuplicateCommand(member, channel, message) {
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
return challenge.isDuplicateCommand(member, message);
} | static async isDuplicateCommand(member, channel, message) {
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
return challenge.isDuplicateCommand(member, message);
} |
JavaScript | async simulate(member, channel, message) {
await Commands.checkMemberIsOwner(member);
if (!idMessageParse.test(message)) {
return false;
}
const {groups: {id, command, newMessage}} = idMessageParse.exec(message);
if (Object.getOwnPropertyNames(Commands.prototype).filter((p) => typeof Commands.prototype[p] === "function" && p !== "constructor").indexOf(command) === -1) {
throw new Warning("Invalid command.");
}
const newMember = await Discord.findGuildMemberById(id);
if (!newMember) {
throw new Warning("User does not exist on the server.");
}
return await this[command](newMember, channel, newMessage) || void 0;
} | async simulate(member, channel, message) {
await Commands.checkMemberIsOwner(member);
if (!idMessageParse.test(message)) {
return false;
}
const {groups: {id, command, newMessage}} = idMessageParse.exec(message);
if (Object.getOwnPropertyNames(Commands.prototype).filter((p) => typeof Commands.prototype[p] === "function" && p !== "constructor").indexOf(command) === -1) {
throw new Warning("Invalid command.");
}
const newMember = await Discord.findGuildMemberById(id);
if (!newMember) {
throw new Warning("User does not exist on the server.");
}
return await this[command](newMember, channel, newMessage) || void 0;
} |
JavaScript | async help(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (message) {
return false;
}
await Discord.queue(`${member}, see the about page at https://otl.gg/about.`, channel);
return true;
} | async help(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (message) {
return false;
}
await Discord.queue(`${member}, see the about page at https://otl.gg/about.`, channel);
return true;
} |
JavaScript | async version(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (message) {
return false;
}
await Discord.queue(`We are The Fourth Sovereign, we are trillions. By roncli, Version ${pjson.version}. Project is open source, visit https://github.com/overload-development-community/otl-bot.`, channel);
return true;
} | async version(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (message) {
return false;
}
await Discord.queue(`We are The Fourth Sovereign, we are trillions. By roncli, Version ${pjson.version}. Project is open source, visit https://github.com/overload-development-community/otl-bot.`, channel);
return true;
} |
JavaScript | async website(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (message) {
return false;
}
await Discord.queue("Visit our website at https://otl.gg for league standings, matches, and stats!", channel);
return true;
} | async website(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (message) {
return false;
}
await Discord.queue("Visit our website at https://otl.gg for league standings, matches, and stats!", channel);
return true;
} |
JavaScript | async maplist(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (message) {
return false;
}
await Discord.queue("View the complete list of maps approved for play at https://otl.gg/maplist.", channel);
return true;
} | async maplist(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (message) {
return false;
}
await Discord.queue("View the complete list of maps approved for play at https://otl.gg/maplist.", channel);
return true;
} |
JavaScript | async createteam(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberNotStartingTeam(member, channel);
await Commands.checkMemberNotOnTeam(member, channel);
await Commands.checkMemberCanBeCaptain(member, channel);
await Commands.checkMemberCanJoinATeam(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!createteam` by itself to begin the process of creating a team.", channel)) {
return false;
}
let newTeam;
try {
newTeam = await member.createNewTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, you have begun the process of creating a team. Visit ${newTeam.channel} to set up your new team.`, channel);
return true;
} | async createteam(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberNotStartingTeam(member, channel);
await Commands.checkMemberNotOnTeam(member, channel);
await Commands.checkMemberCanBeCaptain(member, channel);
await Commands.checkMemberCanJoinATeam(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!createteam` by itself to begin the process of creating a team.", channel)) {
return false;
}
let newTeam;
try {
newTeam = await member.createNewTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, you have begun the process of creating a team. Visit ${newTeam.channel} to set up your new team.`, channel);
return true;
} |
JavaScript | async name(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const newTeam = await Commands.checkMemberStartingNewTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "To name your team, add the team name after the command, for example `!name Cronus Frontier`.", channel)) {
return false;
}
if (!teamNameParse.test(message)) {
if (teamTagParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but that is too short for a team name. Did you mean to use \`!tag ${message}\`?`, channel);
} else {
await Discord.queue(`Sorry, ${member}, but to prevent abuse, you can only use alphanumeric characters and spaces, and names must be between 6 and 25 characters. In the event you need to use other characters, please name your team within the rules for now, and then contact an admin after your team is created.`, channel);
}
throw new Warning("Invalid team name.");
}
if (Team.nameExists(message)) {
await Discord.queue(`Sorry, ${member}, but this team name already exists!`, channel);
throw new Warning("Team name already exists.");
}
try {
await newTeam.setName(message);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your team name is now set to ${message}. Note that proper casing may be applied to your name by an admin.`, channel);
return true;
} | async name(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const newTeam = await Commands.checkMemberStartingNewTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "To name your team, add the team name after the command, for example `!name Cronus Frontier`.", channel)) {
return false;
}
if (!teamNameParse.test(message)) {
if (teamTagParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but that is too short for a team name. Did you mean to use \`!tag ${message}\`?`, channel);
} else {
await Discord.queue(`Sorry, ${member}, but to prevent abuse, you can only use alphanumeric characters and spaces, and names must be between 6 and 25 characters. In the event you need to use other characters, please name your team within the rules for now, and then contact an admin after your team is created.`, channel);
}
throw new Warning("Invalid team name.");
}
if (Team.nameExists(message)) {
await Discord.queue(`Sorry, ${member}, but this team name already exists!`, channel);
throw new Warning("Team name already exists.");
}
try {
await newTeam.setName(message);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your team name is now set to ${message}. Note that proper casing may be applied to your name by an admin.`, channel);
return true;
} |
JavaScript | async tag(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const newTeam = await Commands.checkMemberStartingNewTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "To assign a tag to your team, add the tag after the command, for example `!tag CF` for a team named Cronus Frontier.", channel)) {
return false;
}
const tag = message.toUpperCase();
if (!teamTagParse.test(tag)) {
if (teamNameParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but that is too long for a tag name. Did you mean to use \`!name ${message}\`?`, channel);
} else {
await Discord.queue(`Sorry, ${member}, but you can only use alphanumeric characters, and are limited to 5 characters.`, channel);
}
throw new Warning("Invalid team tag.");
}
if (Team.tagExists(tag)) {
await Discord.queue(`Sorry, ${member}, but this team tag already exists!`, channel);
throw new Warning("Team tag already exists.");
}
try {
await newTeam.setTag(tag);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your team tag is now set to ${tag}.`, channel);
return true;
} | async tag(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const newTeam = await Commands.checkMemberStartingNewTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "To assign a tag to your team, add the tag after the command, for example `!tag CF` for a team named Cronus Frontier.", channel)) {
return false;
}
const tag = message.toUpperCase();
if (!teamTagParse.test(tag)) {
if (teamNameParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but that is too long for a tag name. Did you mean to use \`!name ${message}\`?`, channel);
} else {
await Discord.queue(`Sorry, ${member}, but you can only use alphanumeric characters, and are limited to 5 characters.`, channel);
}
throw new Warning("Invalid team tag.");
}
if (Team.tagExists(tag)) {
await Discord.queue(`Sorry, ${member}, but this team tag already exists!`, channel);
throw new Warning("Team tag already exists.");
}
try {
await newTeam.setTag(tag);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your team tag is now set to ${tag}.`, channel);
return true;
} |
JavaScript | async cancel(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const newTeam = await Commands.checkMemberStartingNewTeam(member, channel);
if (!message) {
await Discord.queue(`${member}, are you sure you want to cancel your new team request? There is no undoing this action! Type \`!cancel confirm\` to confirm.`, channel);
return true;
}
if (message !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!cancel confirm\` to confirm that you wish to cancel your request to create a team.`, channel);
return false;
}
try {
await newTeam.delete(`${member.displayName} cancelled team creation.`);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue("Your request to create a team has been cancelled.", member);
return true;
} | async cancel(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const newTeam = await Commands.checkMemberStartingNewTeam(member, channel);
if (!message) {
await Discord.queue(`${member}, are you sure you want to cancel your new team request? There is no undoing this action! Type \`!cancel confirm\` to confirm.`, channel);
return true;
}
if (message !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!cancel confirm\` to confirm that you wish to cancel your request to create a team.`, channel);
return false;
}
try {
await newTeam.delete(`${member.displayName} cancelled team creation.`);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue("Your request to create a team has been cancelled.", member);
return true;
} |
JavaScript | async complete(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const newTeam = await Commands.checkMemberStartingNewTeam(member, channel);
if (!newTeam.name) {
await Discord.queue(`Sorry, ${member}, but you must use the \`!name\` and \`!tag\` commands to give your team a name and a tag before completing your request to create a team.`, channel);
throw new Warning("Team not yet given a name.");
}
if (!newTeam.tag) {
await Discord.queue(`Sorry, ${member}, but you must use the \`!tag\` command to give your team a tag before completing your request to create a team.`, channel);
throw new Warning("Team not yet given a tag.");
}
if (Team.nameExists(newTeam.name)) {
await Discord.queue(`Sorry, ${member}, but this team name already exists! You'll need to use the \`!name\` command to try another.`, channel);
throw new Warning("Team name already exists.");
}
if (Team.tagExists(newTeam.tag)) {
await Discord.queue(`Sorry, ${member}, but this team tag already exists! You'll need to use the \`!tag\` command to try another.`, channel);
throw new Warning("Team tag already exists.");
}
if (!message) {
await Discord.queue(`${member}, are you sure you want to complete your request to create a team? There is no undoing this action! Type \`!complete confirm\` to confirm.`, channel);
return true;
}
if (message !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!complete confirm\` to confirm that you wish to complete your request to create a team.`, channel);
return false;
}
let team;
try {
team = await newTeam.createTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`Congratulations, ${member}! Your team has been created! You may now visit ${team.teamChannel} for team chat, and ${team.captainsChannel} for private chat with your team captains as well as system notifications for your team.`, member);
return true;
} | async complete(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const newTeam = await Commands.checkMemberStartingNewTeam(member, channel);
if (!newTeam.name) {
await Discord.queue(`Sorry, ${member}, but you must use the \`!name\` and \`!tag\` commands to give your team a name and a tag before completing your request to create a team.`, channel);
throw new Warning("Team not yet given a name.");
}
if (!newTeam.tag) {
await Discord.queue(`Sorry, ${member}, but you must use the \`!tag\` command to give your team a tag before completing your request to create a team.`, channel);
throw new Warning("Team not yet given a tag.");
}
if (Team.nameExists(newTeam.name)) {
await Discord.queue(`Sorry, ${member}, but this team name already exists! You'll need to use the \`!name\` command to try another.`, channel);
throw new Warning("Team name already exists.");
}
if (Team.tagExists(newTeam.tag)) {
await Discord.queue(`Sorry, ${member}, but this team tag already exists! You'll need to use the \`!tag\` command to try another.`, channel);
throw new Warning("Team tag already exists.");
}
if (!message) {
await Discord.queue(`${member}, are you sure you want to complete your request to create a team? There is no undoing this action! Type \`!complete confirm\` to confirm.`, channel);
return true;
}
if (message !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!complete confirm\` to confirm that you wish to complete your request to create a team.`, channel);
return false;
}
let team;
try {
team = await newTeam.createTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`Congratulations, ${member}! Your team has been created! You may now visit ${team.teamChannel} for team chat, and ${team.captainsChannel} for private chat with your team captains as well as system notifications for your team.`, member);
return true;
} |
JavaScript | async color(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "You can use the following colors: red, orange, yellow, green, aqua, blue, purple. You can also request a light or dark variant. For instance, if you want a dark green color for your team, enter `!color dark green`.", channel)) {
return false;
}
if (!colorParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you can only use the following colors: red, orange, yellow, green, aqua, blue, purple. You can also request a light or dark variant. For instance, if you want a dark green color for your team, enter \`!color dark green\`.`, channel);
throw new Warning("Invalid color.");
}
const team = await Commands.checkMemberOnTeam(member, channel),
colors = message.split(" ");
let color;
switch (colors[colors.length === 1 ? 0 : 1]) {
case "red":
switch (colors[0]) {
case "dark":
color = 0x800000;
break;
case "light":
color = 0xFF8080;
break;
default:
color = 0xFF0000;
break;
}
break;
case "orange":
switch (colors[0]) {
case "dark":
color = 0x804000;
break;
case "light":
color = 0xFFC080;
break;
default:
color = 0xFF8000;
break;
}
break;
case "yellow":
switch (colors[0]) {
case "dark":
color = 0x808000;
break;
case "light":
color = 0xFFFF80;
break;
default:
color = 0xFFFF00;
break;
}
break;
case "green":
switch (colors[0]) {
case "dark":
color = 0x008000;
break;
case "light":
color = 0x80FF80;
break;
default:
color = 0x00FF00;
break;
}
break;
case "aqua":
switch (colors[0]) {
case "dark":
color = 0x008080;
break;
case "light":
color = 0x80FFFF;
break;
default:
color = 0x00FFFF;
break;
}
break;
case "blue":
switch (colors[0]) {
case "dark":
color = 0x000080;
break;
case "light":
color = 0x8080FF;
break;
default:
color = 0x0000FF;
break;
}
break;
case "purple":
switch (colors[0]) {
case "dark":
color = 0x800080;
break;
case "light":
color = 0xFF80FF;
break;
default:
color = 0xFF00FF;
break;
}
break;
}
try {
await team.changeColor(member, color);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your team's color has been updated.`, channel);
return true;
} | async color(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "You can use the following colors: red, orange, yellow, green, aqua, blue, purple. You can also request a light or dark variant. For instance, if you want a dark green color for your team, enter `!color dark green`.", channel)) {
return false;
}
if (!colorParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you can only use the following colors: red, orange, yellow, green, aqua, blue, purple. You can also request a light or dark variant. For instance, if you want a dark green color for your team, enter \`!color dark green\`.`, channel);
throw new Warning("Invalid color.");
}
const team = await Commands.checkMemberOnTeam(member, channel),
colors = message.split(" ");
let color;
switch (colors[colors.length === 1 ? 0 : 1]) {
case "red":
switch (colors[0]) {
case "dark":
color = 0x800000;
break;
case "light":
color = 0xFF8080;
break;
default:
color = 0xFF0000;
break;
}
break;
case "orange":
switch (colors[0]) {
case "dark":
color = 0x804000;
break;
case "light":
color = 0xFFC080;
break;
default:
color = 0xFF8000;
break;
}
break;
case "yellow":
switch (colors[0]) {
case "dark":
color = 0x808000;
break;
case "light":
color = 0xFFFF80;
break;
default:
color = 0xFFFF00;
break;
}
break;
case "green":
switch (colors[0]) {
case "dark":
color = 0x008000;
break;
case "light":
color = 0x80FF80;
break;
default:
color = 0x00FF00;
break;
}
break;
case "aqua":
switch (colors[0]) {
case "dark":
color = 0x008080;
break;
case "light":
color = 0x80FFFF;
break;
default:
color = 0x00FFFF;
break;
}
break;
case "blue":
switch (colors[0]) {
case "dark":
color = 0x000080;
break;
case "light":
color = 0x8080FF;
break;
default:
color = 0x0000FF;
break;
}
break;
case "purple":
switch (colors[0]) {
case "dark":
color = 0x800080;
break;
case "light":
color = 0xFF80FF;
break;
default:
color = 0xFF00FF;
break;
}
break;
}
try {
await team.changeColor(member, color);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your team's color has been updated.`, channel);
return true;
} |
JavaScript | async addcaptain(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must mention the pilot on your team that you wish to add as a captain.", channel)) {
return false;
}
const captain = await Commands.checkPilotExists(message, member, channel);
if (captain.id === member.id) {
await Discord.queue(`Sorry, ${member}, but you can't promote yourself to captain!`, channel);
throw new Warning("Pilot can't promote themselves.");
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkPilotOnTeam(team, captain, member, channel);
const isCaptain = captain.isCaptainOrFounder();
if (isCaptain) {
await Discord.queue(`Sorry, ${member}, but ${captain.displayName} is already a captain!`, channel);
throw new Warning("Pilot is already a captain.");
}
await Commands.checkPilotCanBeCaptain(captain, member, channel);
try {
await team.addCaptain(member, captain);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id && channel.id !== team.captainsChannel.id) {
await Discord.queue(`${member}, ${captain.displayName} is now a team captain!`, channel);
}
return true;
} | async addcaptain(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must mention the pilot on your team that you wish to add as a captain.", channel)) {
return false;
}
const captain = await Commands.checkPilotExists(message, member, channel);
if (captain.id === member.id) {
await Discord.queue(`Sorry, ${member}, but you can't promote yourself to captain!`, channel);
throw new Warning("Pilot can't promote themselves.");
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkPilotOnTeam(team, captain, member, channel);
const isCaptain = captain.isCaptainOrFounder();
if (isCaptain) {
await Discord.queue(`Sorry, ${member}, but ${captain.displayName} is already a captain!`, channel);
throw new Warning("Pilot is already a captain.");
}
await Commands.checkPilotCanBeCaptain(captain, member, channel);
try {
await team.addCaptain(member, captain);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id && channel.id !== team.captainsChannel.id) {
await Discord.queue(`${member}, ${captain.displayName} is now a team captain!`, channel);
}
return true;
} |
JavaScript | async removecaptain(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must mention the pilot on your team that you wish to remove as a captain.", channel)) {
return false;
}
const captain = await Commands.checkPilotExists(message, member, channel);
if (captain.id === member.id) {
await Discord.queue(`Sorry, ${member}, but you can't remove yourself as captain!`, channel);
throw new Warning("Pilot can't remove themselves as captain.");
}
const team = await Commands.checkMemberOnTeam(member, channel);
if (!team.role.members.find((m) => m.id === captain.id)) {
await Discord.queue(`Sorry, ${member}, but you can only remove a captain if they are on your team.`, channel);
throw new Warning("Pilots are not on the same team.");
}
const isCaptain = captain.isCaptainOrFounder();
if (!isCaptain) {
await Discord.queue(`Sorry, ${member}, but ${captain.displayName} is not a captain!`, channel);
throw new Warning("Pilot is not a captain.");
}
try {
await team.removeCaptain(member, captain);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id && channel.id !== team.captainsChannel.id) {
await Discord.queue(`${member}, ${captain.displayName} is no longer a team captain.`, channel);
}
return true;
} | async removecaptain(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must mention the pilot on your team that you wish to remove as a captain.", channel)) {
return false;
}
const captain = await Commands.checkPilotExists(message, member, channel);
if (captain.id === member.id) {
await Discord.queue(`Sorry, ${member}, but you can't remove yourself as captain!`, channel);
throw new Warning("Pilot can't remove themselves as captain.");
}
const team = await Commands.checkMemberOnTeam(member, channel);
if (!team.role.members.find((m) => m.id === captain.id)) {
await Discord.queue(`Sorry, ${member}, but you can only remove a captain if they are on your team.`, channel);
throw new Warning("Pilots are not on the same team.");
}
const isCaptain = captain.isCaptainOrFounder();
if (!isCaptain) {
await Discord.queue(`Sorry, ${member}, but ${captain.displayName} is not a captain!`, channel);
throw new Warning("Pilot is not a captain.");
}
try {
await team.removeCaptain(member, captain);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id && channel.id !== team.captainsChannel.id) {
await Discord.queue(`${member}, ${captain.displayName} is no longer a team captain.`, channel);
}
return true;
} |
JavaScript | async disband(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
if (team.locked) {
await Discord.queue(`Sorry, ${member}, but your team's roster is locked for the playoffs. Roster changes will become available when your team is no longer participating.`, channel);
throw new Warning("Team rosters are locked.");
}
if (!message) {
await Discord.queue(`${member}, are you sure you want to disband your team? There is no undoing this action! Type \`!disband confirm\` to confirm.`, channel);
return true;
}
if (message !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!disband confirm\` to confirm that you wish to disband your team.`, channel);
return false;
}
try {
await team.disband(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue("You have successfully disbanded your team. Note that you or anyone else who has been founder or captain of your team in the past may `!reinstate` your team.", member);
return true;
} | async disband(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
if (team.locked) {
await Discord.queue(`Sorry, ${member}, but your team's roster is locked for the playoffs. Roster changes will become available when your team is no longer participating.`, channel);
throw new Warning("Team rosters are locked.");
}
if (!message) {
await Discord.queue(`${member}, are you sure you want to disband your team? There is no undoing this action! Type \`!disband confirm\` to confirm.`, channel);
return true;
}
if (message !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!disband confirm\` to confirm that you wish to disband your team.`, channel);
return false;
}
try {
await team.disband(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue("You have successfully disbanded your team. Note that you or anyone else who has been founder or captain of your team in the past may `!reinstate` your team.", member);
return true;
} |
JavaScript | async makefounder(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must mention the pilot you wish to make founder.", channel)) {
return false;
}
const {pilot, confirm} = await Commands.checkPilotExistsWithConfirmation(message, member, channel);
if (!pilot) {
await Discord.queue(`Sorry, ${member}, but I can't find that pilot on this server. You must mention the pilot you wish to make founder.`, channel);
throw new Warning("Pilot not found.");
}
if (pilot.id === member.id) {
await Discord.queue(`Sorry, ${member}, you can't make yourself the team's founder, you already *are* the founder!`, channel);
throw new Warning("Pilot is already the team's founder.");
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkPilotOnTeam(team, pilot, member, channel);
await Commands.checkPilotCanBeCaptain(pilot, member, channel);
if (!confirm) {
await Discord.queue(`${member}, are you sure you want to make ${pilot.displayName} your team's founder? Type \`!makefounder ${pilot.displayName} confirm\` to confirm.`, channel);
return true;
}
if (confirm !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!makefounder ${pilot.displayName} confirm\` to confirm that you wish to transfer team ownership.`, channel);
return false;
}
try {
await team.makeFounder(member, pilot);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, you have transferred team ownership to ${pilot.displayName}. You remain a team captain.`, member);
return true;
} | async makefounder(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must mention the pilot you wish to make founder.", channel)) {
return false;
}
const {pilot, confirm} = await Commands.checkPilotExistsWithConfirmation(message, member, channel);
if (!pilot) {
await Discord.queue(`Sorry, ${member}, but I can't find that pilot on this server. You must mention the pilot you wish to make founder.`, channel);
throw new Warning("Pilot not found.");
}
if (pilot.id === member.id) {
await Discord.queue(`Sorry, ${member}, you can't make yourself the team's founder, you already *are* the founder!`, channel);
throw new Warning("Pilot is already the team's founder.");
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkPilotOnTeam(team, pilot, member, channel);
await Commands.checkPilotCanBeCaptain(pilot, member, channel);
if (!confirm) {
await Discord.queue(`${member}, are you sure you want to make ${pilot.displayName} your team's founder? Type \`!makefounder ${pilot.displayName} confirm\` to confirm.`, channel);
return true;
}
if (confirm !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!makefounder ${pilot.displayName} confirm\` to confirm that you wish to transfer team ownership.`, channel);
return false;
}
try {
await team.makeFounder(member, pilot);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, you have transferred team ownership to ${pilot.displayName}. You remain a team captain.`, member);
return true;
} |
JavaScript | async reinstate(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberNotStartingTeam(member, channel);
await Commands.checkMemberNotOnTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must mention the pilot you wish to make founder.", channel)) {
return false;
}
const {team, confirm} = await Commands.checkTeamExistsWithConfirmation(message, member, channel);
if (!team.disbanded) {
await Discord.queue(`Sorry, ${member}, but you can't reinstate a team that isn't disbanded.`, channel);
throw new Warning("Team is not disbanded.");
}
let wasCaptain;
try {
wasCaptain = await member.wasPreviousCaptainOrFounderOfTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!wasCaptain) {
await Discord.queue(`Sorry, ${member}, but you must have been a captain or founder of the team you are trying to reinstate.`, channel);
throw new Warning("Team does not exist.");
}
await Commands.checkMemberCanBeCaptain(member, channel);
await Commands.checkMemberCanJoinATeam(member, channel);
await Commands.checkMemberNotBannedFromTeam(member, team, channel);
if (!confirm) {
await Discord.queue(`${member}, are you sure you wish to reinstate this team? Type \`!reinstate ${team.name} confirm\` to confirm that you wish to reinstate this team. Note that you will not be able to accept another invitation or create a team for 28 days.`, channel);
return true;
}
try {
await team.reinstate(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your team has been reinstated!`, channel);
await Discord.queue(`Congratulations, ${member}! Your team has been reinstated! You may now visit ${team.teamChannel} for team chat, and ${team.captainsChannel} for private chat with your team captains as well as system notifications for your team.`, member);
return true;
} | async reinstate(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberNotStartingTeam(member, channel);
await Commands.checkMemberNotOnTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must mention the pilot you wish to make founder.", channel)) {
return false;
}
const {team, confirm} = await Commands.checkTeamExistsWithConfirmation(message, member, channel);
if (!team.disbanded) {
await Discord.queue(`Sorry, ${member}, but you can't reinstate a team that isn't disbanded.`, channel);
throw new Warning("Team is not disbanded.");
}
let wasCaptain;
try {
wasCaptain = await member.wasPreviousCaptainOrFounderOfTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!wasCaptain) {
await Discord.queue(`Sorry, ${member}, but you must have been a captain or founder of the team you are trying to reinstate.`, channel);
throw new Warning("Team does not exist.");
}
await Commands.checkMemberCanBeCaptain(member, channel);
await Commands.checkMemberCanJoinATeam(member, channel);
await Commands.checkMemberNotBannedFromTeam(member, team, channel);
if (!confirm) {
await Discord.queue(`${member}, are you sure you wish to reinstate this team? Type \`!reinstate ${team.name} confirm\` to confirm that you wish to reinstate this team. Note that you will not be able to accept another invitation or create a team for 28 days.`, channel);
return true;
}
try {
await team.reinstate(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your team has been reinstated!`, channel);
await Discord.queue(`Congratulations, ${member}! Your team has been reinstated! You may now visit ${team.teamChannel} for team chat, and ${team.captainsChannel} for private chat with your team captains as well as system notifications for your team.`, member);
return true;
} |
JavaScript | async home(member, channel) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Discord.queue(`Sorry, ${member}, but this command has been retired. Please use \`!addhome\` or \`!removehome\``, channel);
return true;
} | async home(member, channel) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Discord.queue(`Sorry, ${member}, but this command has been retired. Please use \`!addhome\` or \`!removehome\``, channel);
return true;
} |
JavaScript | async addhome(member, channel, message) {
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To add a home map, you must include the game type followed by the name of the map. For instance, to add Vault as a 2v2 Team Anarchy home map, enter the following command: `!addhome 2v2 Vault`. To add Halcyon as a CTF home map, enter the following command: `!addhome CTF Halcyon`.", channel)) {
return false;
}
if (!mapParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must include the game type and the name of the map, such as \`!addhome 2v2 Vault\`, or \`!addhome CTF Halcyon\`.`, channel);
return false;
}
const {groups: {gameType, mapToCheck}} = mapParse.exec(message);
let gameTypeUpper = gameType.toUpperCase();
switch (gameTypeUpper) {
case "2":
case "2V2":
gameTypeUpper = "2v2";
break;
case "3":
case "3V3":
gameTypeUpper = "3v3";
break;
case "4":
case "4v4":
case "4V4":
case "4V4+":
gameTypeUpper = "4v4+";
break;
}
const map = await Commands.checkMapIsValid(mapToCheck, gameTypeUpper === "CTF" ? "CTF" : "TA", member, channel),
team = await Commands.checkMemberOnTeam(member, channel);
let homes;
try {
homes = await team.getHomeMaps(gameTypeUpper);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (homes.length >= 5) {
await Discord.queue(`Sorry, ${member}, but you already have 5 ${gameTypeUpper} home maps.`, channel);
throw new Warning("Team already has this home map set.");
}
if (homes.indexOf(map.map) !== -1) {
await Discord.queue(`Sorry, ${member}, but you already have this map set as your home.`, channel);
throw new Warning("Team already has this home map set.");
}
try {
await team.addHomeMap(member, gameTypeUpper, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id) {
await Discord.queue(`${member}, your home map has been set. Note this only applies to future challenges, any current challenges you have will use the home maps you had at the time of the challenge.`, channel);
}
return true;
} | async addhome(member, channel, message) {
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To add a home map, you must include the game type followed by the name of the map. For instance, to add Vault as a 2v2 Team Anarchy home map, enter the following command: `!addhome 2v2 Vault`. To add Halcyon as a CTF home map, enter the following command: `!addhome CTF Halcyon`.", channel)) {
return false;
}
if (!mapParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must include the game type and the name of the map, such as \`!addhome 2v2 Vault\`, or \`!addhome CTF Halcyon\`.`, channel);
return false;
}
const {groups: {gameType, mapToCheck}} = mapParse.exec(message);
let gameTypeUpper = gameType.toUpperCase();
switch (gameTypeUpper) {
case "2":
case "2V2":
gameTypeUpper = "2v2";
break;
case "3":
case "3V3":
gameTypeUpper = "3v3";
break;
case "4":
case "4v4":
case "4V4":
case "4V4+":
gameTypeUpper = "4v4+";
break;
}
const map = await Commands.checkMapIsValid(mapToCheck, gameTypeUpper === "CTF" ? "CTF" : "TA", member, channel),
team = await Commands.checkMemberOnTeam(member, channel);
let homes;
try {
homes = await team.getHomeMaps(gameTypeUpper);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (homes.length >= 5) {
await Discord.queue(`Sorry, ${member}, but you already have 5 ${gameTypeUpper} home maps.`, channel);
throw new Warning("Team already has this home map set.");
}
if (homes.indexOf(map.map) !== -1) {
await Discord.queue(`Sorry, ${member}, but you already have this map set as your home.`, channel);
throw new Warning("Team already has this home map set.");
}
try {
await team.addHomeMap(member, gameTypeUpper, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id) {
await Discord.queue(`${member}, your home map has been set. Note this only applies to future challenges, any current challenges you have will use the home maps you had at the time of the challenge.`, channel);
}
return true;
} |
JavaScript | async removehome(member, channel, message) {
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To remove a home map, you must include the game type followed by the name of the map. For instance, to remove Vault as a 2v2 Team Anarchy home map, enter the following command: `!removehome 2v2 Vault`. To remove Halcyon as a CTF home map, enter the following command: `!removehome CTF Halcyon`.", channel)) {
return false;
}
if (!mapParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must include the game type and the name of the map, such as \`!removehome 2v2 Vault\`, or \`!removehome CTF Halcyon\`.`, channel);
return false;
}
const {groups: {gameType, mapToCheck}} = mapParse.exec(message);
let gameTypeUpper = gameType.toUpperCase();
switch (gameTypeUpper) {
case "2":
case "2V2":
gameTypeUpper = "2v2";
break;
case "3":
case "3V3":
gameTypeUpper = "3v3";
break;
case "4":
case "4v4":
case "4V4":
case "4V4+":
gameTypeUpper = "4v4+";
break;
}
const map = await Commands.checkMapIsValid(mapToCheck, gameTypeUpper === "CTF" ? "CTF" : "TA", member, channel),
team = await Commands.checkMemberOnTeam(member, channel);
let homes;
try {
homes = await team.getHomeMaps(gameTypeUpper);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (homes.indexOf(map.map) === -1) {
await Discord.queue(`Sorry, ${member}, but you do not have this map set as your home.`, channel);
throw new Warning("Team does not have this home map set.");
}
try {
await team.removeHomeMap(member, gameTypeUpper, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id) {
await Discord.queue(`${member}, your home map has been removed. Note this only applies to future challenges, any current challenges you have will use the home maps you had at the time of the challenge. Also note that you will not be able to send or receive challenges until you once again have 5 maps in this category. Use the \`!addhome\` command to do this.`, channel);
}
return true;
} | async removehome(member, channel, message) {
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To remove a home map, you must include the game type followed by the name of the map. For instance, to remove Vault as a 2v2 Team Anarchy home map, enter the following command: `!removehome 2v2 Vault`. To remove Halcyon as a CTF home map, enter the following command: `!removehome CTF Halcyon`.", channel)) {
return false;
}
if (!mapParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must include the game type and the name of the map, such as \`!removehome 2v2 Vault\`, or \`!removehome CTF Halcyon\`.`, channel);
return false;
}
const {groups: {gameType, mapToCheck}} = mapParse.exec(message);
let gameTypeUpper = gameType.toUpperCase();
switch (gameTypeUpper) {
case "2":
case "2V2":
gameTypeUpper = "2v2";
break;
case "3":
case "3V3":
gameTypeUpper = "3v3";
break;
case "4":
case "4v4":
case "4V4":
case "4V4+":
gameTypeUpper = "4v4+";
break;
}
const map = await Commands.checkMapIsValid(mapToCheck, gameTypeUpper === "CTF" ? "CTF" : "TA", member, channel),
team = await Commands.checkMemberOnTeam(member, channel);
let homes;
try {
homes = await team.getHomeMaps(gameTypeUpper);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (homes.indexOf(map.map) === -1) {
await Discord.queue(`Sorry, ${member}, but you do not have this map set as your home.`, channel);
throw new Warning("Team does not have this home map set.");
}
try {
await team.removeHomeMap(member, gameTypeUpper, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id) {
await Discord.queue(`${member}, your home map has been removed. Note this only applies to future challenges, any current challenges you have will use the home maps you had at the time of the challenge. Also note that you will not be able to send or receive challenges until you once again have 5 maps in this category. Use the \`!addhome\` command to do this.`, channel);
}
return true;
} |
JavaScript | async homes(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const team = message ? await Commands.checkTeamExists(message, member, channel) : await Commands.checkMemberOnTeam(member, channel),
homes = await team.getHomeMapsByType();
const msg = Discord.messageEmbed({
title: `Home maps for **${team.name}**`,
fields: []
});
Object.keys(homes).sort().forEach((gameType) => {
msg.fields.push({
name: Challenge.getGameTypeName(gameType),
value: homes[gameType].join("\n"),
inline: true
});
});
await Discord.richQueue(msg, channel);
return true;
} | async homes(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const team = message ? await Commands.checkTeamExists(message, member, channel) : await Commands.checkMemberOnTeam(member, channel),
homes = await team.getHomeMapsByType();
const msg = Discord.messageEmbed({
title: `Home maps for **${team.name}**`,
fields: []
});
Object.keys(homes).sort().forEach((gameType) => {
msg.fields.push({
name: Challenge.getGameTypeName(gameType),
value: homes[gameType].join("\n"),
inline: true
});
});
await Discord.richQueue(msg, channel);
return true;
} |
JavaScript | async addneutral(member, channel, message) {
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To add a preferred neutral map, you must include the game type followed by the name of the map. For instance, to add Vault as a Team Anarchy neutral map, enter the following command: `!addneutral TA Vault`. To add Halcyon as a CTF neutral map, enter the following command: `!addneutral CTF Halcyon`.", channel)) {
return false;
}
if (!neutralMapParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must include the game type and the name of the map, such as \`!addneutral TA Vault\`, or \`!addneutral CTF Halcyon\`.`, channel);
return false;
}
const {groups: {gameType, mapToCheck}} = neutralMapParse.exec(message),
gameTypeUpper = gameType.toUpperCase(),
map = await Commands.checkMapIsValid(mapToCheck, gameTypeUpper === "CTF" ? "CTF" : "TA", member, channel),
team = await Commands.checkMemberOnTeam(member, channel);
let neutrals;
try {
neutrals = await team.getNeutralMaps(gameTypeUpper);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (neutrals.indexOf(map.map) !== -1) {
await Discord.queue(`Sorry, ${member}, but you already have this map set as a preferred neutral map.`, channel);
throw new Warning("Team already has this neutral map set.");
}
try {
await team.addNeutralMap(member, gameTypeUpper, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id) {
await Discord.queue(`${member}, your preferred neutral map has been set.`, channel);
}
return true;
} | async addneutral(member, channel, message) {
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To add a preferred neutral map, you must include the game type followed by the name of the map. For instance, to add Vault as a Team Anarchy neutral map, enter the following command: `!addneutral TA Vault`. To add Halcyon as a CTF neutral map, enter the following command: `!addneutral CTF Halcyon`.", channel)) {
return false;
}
if (!neutralMapParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must include the game type and the name of the map, such as \`!addneutral TA Vault\`, or \`!addneutral CTF Halcyon\`.`, channel);
return false;
}
const {groups: {gameType, mapToCheck}} = neutralMapParse.exec(message),
gameTypeUpper = gameType.toUpperCase(),
map = await Commands.checkMapIsValid(mapToCheck, gameTypeUpper === "CTF" ? "CTF" : "TA", member, channel),
team = await Commands.checkMemberOnTeam(member, channel);
let neutrals;
try {
neutrals = await team.getNeutralMaps(gameTypeUpper);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (neutrals.indexOf(map.map) !== -1) {
await Discord.queue(`Sorry, ${member}, but you already have this map set as a preferred neutral map.`, channel);
throw new Warning("Team already has this neutral map set.");
}
try {
await team.addNeutralMap(member, gameTypeUpper, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id) {
await Discord.queue(`${member}, your preferred neutral map has been set.`, channel);
}
return true;
} |
JavaScript | async removeneutral(member, channel, message) {
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To remove a preferred neutral map, you must include the game type followed by the name of the map. For instance, to remove Vault as a Team Anarchy neutral map, enter the following command: `!removeneutral TA Vault`. To remove Halcyon as a CTF neutral map, enter the following command: `!removeneutral CTF Halcyon`.", channel)) {
return false;
}
if (!neutralMapParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must include the game type and the name of the map, such as \`!removeneutral TA Vault\`, or \`!removeneutral CTF Halcyon\`.`, channel);
return false;
}
const {groups: {gameType, mapToCheck}} = neutralMapParse.exec(message),
gameTypeUpper = gameType.toUpperCase(),
map = await Commands.checkMapIsValid(mapToCheck, gameTypeUpper === "CTF" ? "CTF" : "TA", member, channel),
team = await Commands.checkMemberOnTeam(member, channel);
let neutrals;
try {
neutrals = await team.getNeutralMaps(gameTypeUpper);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (neutrals.indexOf(map.map) === -1) {
await Discord.queue(`Sorry, ${member}, but you do not have this map set as your preferred neutral map.`, channel);
throw new Warning("Team does not have this neutral map set.");
}
try {
await team.removeNeutralMap(member, gameTypeUpper, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id) {
await Discord.queue(`${member}, your preferred neutral map has been removed.`, channel);
}
return true;
} | async removeneutral(member, channel, message) {
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To remove a preferred neutral map, you must include the game type followed by the name of the map. For instance, to remove Vault as a Team Anarchy neutral map, enter the following command: `!removeneutral TA Vault`. To remove Halcyon as a CTF neutral map, enter the following command: `!removeneutral CTF Halcyon`.", channel)) {
return false;
}
if (!neutralMapParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must include the game type and the name of the map, such as \`!removeneutral TA Vault\`, or \`!removeneutral CTF Halcyon\`.`, channel);
return false;
}
const {groups: {gameType, mapToCheck}} = neutralMapParse.exec(message),
gameTypeUpper = gameType.toUpperCase(),
map = await Commands.checkMapIsValid(mapToCheck, gameTypeUpper === "CTF" ? "CTF" : "TA", member, channel),
team = await Commands.checkMemberOnTeam(member, channel);
let neutrals;
try {
neutrals = await team.getNeutralMaps(gameTypeUpper);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (neutrals.indexOf(map.map) === -1) {
await Discord.queue(`Sorry, ${member}, but you do not have this map set as your preferred neutral map.`, channel);
throw new Warning("Team does not have this neutral map set.");
}
try {
await team.removeNeutralMap(member, gameTypeUpper, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (channel.id !== team.teamChannel.id) {
await Discord.queue(`${member}, your preferred neutral map has been removed.`, channel);
}
return true;
} |
JavaScript | async neutrals(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const team = message ? await Commands.checkTeamExists(message, member, channel) : await Commands.checkMemberOnTeam(member, channel),
neutrals = await team.getNeutralMapsByType();
if (Object.keys(neutrals).length === 0) {
await Discord.queue(`**${team.name}** does not have any neutral maps specified yet.`, channel);
} else {
const msg = Discord.messageEmbed({
title: `Neutral maps for **${team.name}**`,
fields: []
});
Object.keys(neutrals).forEach((gameType) => {
msg.fields.push({
name: Challenge.getGameTypeName(gameType),
value: neutrals[gameType].join("\n"),
inline: false
});
});
await Discord.richQueue(msg, channel);
}
return true;
} | async neutrals(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const team = message ? await Commands.checkTeamExists(message, member, channel) : await Commands.checkMemberOnTeam(member, channel),
neutrals = await team.getNeutralMapsByType();
if (Object.keys(neutrals).length === 0) {
await Discord.queue(`**${team.name}** does not have any neutral maps specified yet.`, channel);
} else {
const msg = Discord.messageEmbed({
title: `Neutral maps for **${team.name}**`,
fields: []
});
Object.keys(neutrals).forEach((gameType) => {
msg.fields.push({
name: Challenge.getGameTypeName(gameType),
value: neutrals[gameType].join("\n"),
inline: false
});
});
await Discord.richQueue(msg, channel);
}
return true;
} |
JavaScript | async request(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberNotStartingTeam(member, channel);
await Commands.checkMemberNotOnTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must include the name of the team you want to send a join request to.", channel)) {
return false;
}
const team = await Commands.checkTeamExists(message, member, channel);
if (team.disbanded) {
await Discord.queue(`Sorry, ${member}, but that team has disbanded. A former captain or founder may reinstate the team with the \`!reinstate ${team.tag}\` command.`, channel);
throw new Warning("Team is disbanded.");
}
let hasRequested;
try {
hasRequested = await member.hasRequestedTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (hasRequested) {
await Discord.queue(`Sorry, ${member}, but to prevent abuse, you may only request to join a team once.`, channel);
throw new Warning("Request already exists.");
}
let hasBeenInvited;
try {
hasBeenInvited = await member.hasBeenInvitedToTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (hasBeenInvited) {
await Discord.queue(`Sorry, ${member}, but you have already been invited to this team. Type \`!accept ${team.tag.toLowerCase()}\` to join **${team.name}**.`, channel);
throw new Warning("Invitation exists, request not necessary.");
}
try {
await member.requestTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your request has been sent to join ${team.name}. The team's leadership has been notified of this request.`, channel);
return true;
} | async request(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberNotStartingTeam(member, channel);
await Commands.checkMemberNotOnTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must include the name of the team you want to send a join request to.", channel)) {
return false;
}
const team = await Commands.checkTeamExists(message, member, channel);
if (team.disbanded) {
await Discord.queue(`Sorry, ${member}, but that team has disbanded. A former captain or founder may reinstate the team with the \`!reinstate ${team.tag}\` command.`, channel);
throw new Warning("Team is disbanded.");
}
let hasRequested;
try {
hasRequested = await member.hasRequestedTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (hasRequested) {
await Discord.queue(`Sorry, ${member}, but to prevent abuse, you may only request to join a team once.`, channel);
throw new Warning("Request already exists.");
}
let hasBeenInvited;
try {
hasBeenInvited = await member.hasBeenInvitedToTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (hasBeenInvited) {
await Discord.queue(`Sorry, ${member}, but you have already been invited to this team. Type \`!accept ${team.tag.toLowerCase()}\` to join **${team.name}**.`, channel);
throw new Warning("Invitation exists, request not necessary.");
}
try {
await member.requestTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your request has been sent to join ${team.name}. The team's leadership has been notified of this request.`, channel);
return true;
} |
JavaScript | async invite(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must mention the pilot you wish to invite.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
let pilotCount;
try {
pilotCount = await team.getPilotAndInvitedCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (pilotCount >= 10) {
await Discord.queue(`Sorry, ${member}, but there is a maximum of 10 pilots per roster, and your team currently has ${pilotCount}, including invited pilots.`, channel);
throw new Warning("Roster is full.");
}
const pilot = await Commands.checkPilotExists(message, member, channel);
let existingNewTeam;
try {
existingNewTeam = await pilot.getNewTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (existingNewTeam) {
await Discord.queue(`Sorry, ${member}, but ${pilot.displayName} is currently in the process of starting a team.`, channel);
throw new Warning("Pilot is already in the process of starting a team.");
}
let invited;
try {
invited = await pilot.hasBeenInvitedToTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (invited) {
await Discord.queue(`Sorry, ${member}, but to prevent abuse you can only invite a pilot to your team once. If ${pilot.displayName} has not responded yet, ask them to \`!accept\` the invitation.`, channel);
throw new Warning("Pilot already invited.");
}
let currentTeam;
try {
currentTeam = await pilot.getTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (currentTeam) {
await Discord.queue(`Sorry, ${member}, but ${pilot.displayName} is already on another team!`, channel);
throw new Warning("Pilot already on another team.");
}
try {
await team.invitePilot(member, pilot);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, ${pilot.displayName} has been invited to your team.`, channel);
return true;
} | async invite(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must mention the pilot you wish to invite.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
let pilotCount;
try {
pilotCount = await team.getPilotAndInvitedCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (pilotCount >= 10) {
await Discord.queue(`Sorry, ${member}, but there is a maximum of 10 pilots per roster, and your team currently has ${pilotCount}, including invited pilots.`, channel);
throw new Warning("Roster is full.");
}
const pilot = await Commands.checkPilotExists(message, member, channel);
let existingNewTeam;
try {
existingNewTeam = await pilot.getNewTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (existingNewTeam) {
await Discord.queue(`Sorry, ${member}, but ${pilot.displayName} is currently in the process of starting a team.`, channel);
throw new Warning("Pilot is already in the process of starting a team.");
}
let invited;
try {
invited = await pilot.hasBeenInvitedToTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (invited) {
await Discord.queue(`Sorry, ${member}, but to prevent abuse you can only invite a pilot to your team once. If ${pilot.displayName} has not responded yet, ask them to \`!accept\` the invitation.`, channel);
throw new Warning("Pilot already invited.");
}
let currentTeam;
try {
currentTeam = await pilot.getTeam();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (currentTeam) {
await Discord.queue(`Sorry, ${member}, but ${pilot.displayName} is already on another team!`, channel);
throw new Warning("Pilot already on another team.");
}
try {
await team.invitePilot(member, pilot);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, ${pilot.displayName} has been invited to your team.`, channel);
return true;
} |
JavaScript | async capexempt(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!teamPilotParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must specify the team and mention the pilot, for example, \`!capexempt CF @roncli\`.`, channel);
throw new Warning("Invalid parameters.");
}
const {groups: {teamName, id}} = teamPilotParse.exec(message);
const team = await Commands.checkTeamExists(teamName, member, channel),
pilot = await Commands.checkPilotExists(id, member, channel);
await Commands.checkPilotNotOnTeam(pilot, member, channel);
const pilots = await team.getPilotCount();
if (pilots < 10) {
await Discord.queue(`Sorry, ${member}, but ${team.name} is not at the roster cap.`, channel);
throw new Warning("Team not at roster cap.");
}
team.addPilot(pilot);
pilot.roles.add(Discord.exemptRole);
return true;
} | async capexempt(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!teamPilotParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must specify the team and mention the pilot, for example, \`!capexempt CF @roncli\`.`, channel);
throw new Warning("Invalid parameters.");
}
const {groups: {teamName, id}} = teamPilotParse.exec(message);
const team = await Commands.checkTeamExists(teamName, member, channel),
pilot = await Commands.checkPilotExists(id, member, channel);
await Commands.checkPilotNotOnTeam(pilot, member, channel);
const pilots = await team.getPilotCount();
if (pilots < 10) {
await Discord.queue(`Sorry, ${member}, but ${team.name} is not at the roster cap.`, channel);
throw new Warning("Team not at roster cap.");
}
team.addPilot(pilot);
pilot.roles.add(Discord.exemptRole);
return true;
} |
JavaScript | async accept(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberNotStartingTeam(member, channel);
await Commands.checkMemberNotOnTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must include the name or tag of the team you wish to accept an invitation from. For example, if you wish to accept an invitation from Cronus Frontier, use either `!accept Cronus Frontier` or `!accept CF`.", channel)) {
return false;
}
if (!nameConfirmParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must include the name or tag of the team you wish to accept an invitation from. For example, if you wish to accept an invitation from Cronus Frontier, use either \`!accept Cronus Frontier\` or \`!accept CF\`.`, channel);
return false;
}
const {team, confirm} = await Commands.checkTeamExistsWithConfirmation(message, member, channel);
if (team.disbanded) {
await Discord.queue(`Sorry, ${member}, but that team has disbanded. A former captain or founder may reinstate the team with the \`!reinstate ${team.tag}\` command.`, channel);
throw new Warning("Team is disbanded.");
}
if (team.locked) {
await Discord.queue(`Sorry, ${member}, but that team's roster is locked for the playoffs. Roster changes will become available when that team is no longer participating.`, channel);
throw new Warning("Team rosters are locked.");
}
let isInvited;
try {
isInvited = await member.hasBeenInvitedToTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!isInvited) {
await Discord.queue(`Sorry, ${member}, but you don't have a pending invitation to ${team.name}.`, channel);
throw new Warning("Pilot does not have an invitation to accept.");
}
await Commands.checkMemberCanJoinATeam(member, channel);
await Commands.checkMemberNotBannedFromTeam(member, team, channel);
if (!confirm) {
await Discord.queue(`${member}, are you sure you want to join **${team.name}**? Type \`!accept ${team.tag.toUpperCase()} confirm\` to confirm. Note that you will not be able to accept another invitation or create a team for 28 days.`, channel);
return true;
}
if (confirm !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!accept ${team.tag.toUpperCase()} confirm\` to confirm that you wish to join this team.`, channel);
return false;
}
let requestedTeams;
try {
requestedTeams = await member.getRequestedOrInvitedTeams();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
try {
await team.addPilot(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
requestedTeams.forEach(async (requestedTeam) => {
await requestedTeam.updateChannels();
});
await Discord.queue(`${member}, you are now a member of **${team.name}**! Visit your team channel at ${team.teamChannel} to talk with your teammates. Best of luck flying in the OTL!`, channel);
return true;
} | async accept(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberNotStartingTeam(member, channel);
await Commands.checkMemberNotOnTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must include the name or tag of the team you wish to accept an invitation from. For example, if you wish to accept an invitation from Cronus Frontier, use either `!accept Cronus Frontier` or `!accept CF`.", channel)) {
return false;
}
if (!nameConfirmParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must include the name or tag of the team you wish to accept an invitation from. For example, if you wish to accept an invitation from Cronus Frontier, use either \`!accept Cronus Frontier\` or \`!accept CF\`.`, channel);
return false;
}
const {team, confirm} = await Commands.checkTeamExistsWithConfirmation(message, member, channel);
if (team.disbanded) {
await Discord.queue(`Sorry, ${member}, but that team has disbanded. A former captain or founder may reinstate the team with the \`!reinstate ${team.tag}\` command.`, channel);
throw new Warning("Team is disbanded.");
}
if (team.locked) {
await Discord.queue(`Sorry, ${member}, but that team's roster is locked for the playoffs. Roster changes will become available when that team is no longer participating.`, channel);
throw new Warning("Team rosters are locked.");
}
let isInvited;
try {
isInvited = await member.hasBeenInvitedToTeam(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!isInvited) {
await Discord.queue(`Sorry, ${member}, but you don't have a pending invitation to ${team.name}.`, channel);
throw new Warning("Pilot does not have an invitation to accept.");
}
await Commands.checkMemberCanJoinATeam(member, channel);
await Commands.checkMemberNotBannedFromTeam(member, team, channel);
if (!confirm) {
await Discord.queue(`${member}, are you sure you want to join **${team.name}**? Type \`!accept ${team.tag.toUpperCase()} confirm\` to confirm. Note that you will not be able to accept another invitation or create a team for 28 days.`, channel);
return true;
}
if (confirm !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!accept ${team.tag.toUpperCase()} confirm\` to confirm that you wish to join this team.`, channel);
return false;
}
let requestedTeams;
try {
requestedTeams = await member.getRequestedOrInvitedTeams();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
try {
await team.addPilot(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
requestedTeams.forEach(async (requestedTeam) => {
await requestedTeam.updateChannels();
});
await Discord.queue(`${member}, you are now a member of **${team.name}**! Visit your team channel at ${team.teamChannel} to talk with your teammates. Best of luck flying in the OTL!`, channel);
return true;
} |
JavaScript | async leave(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
if (team.locked) {
await Discord.queue(`Sorry, ${member}, but your team's roster is locked for the playoffs. Roster changes will become available when your team is no longer participating.`, channel);
throw new Warning("Team rosters are locked.");
}
const isFounder = member.isFounder();
if (isFounder) {
await Discord.queue(`Sorry, ${member}, but you are the team founder. You must either \`!disband\` the team or choose another teammate to \`!makefounder\`.`, channel);
throw new Warning("Pilot is the team founder.");
}
if (!message) {
await Discord.queue(`${member}, are you sure you want to leave **${team.name}**? Type \`!leave confirm\` to confirm. Note that you will not be able to rejoin this team for 28 days.`, channel);
return true;
}
if (message !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!leave confirm\` to confirm that you wish to leave **${team.name}**. Note that you will not be able to rejoin this team for 28 days.`, channel);
return false;
}
try {
await team.pilotLeft(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, you have left **${team.name}**.`, member);
return true;
} | async leave(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
if (team.locked) {
await Discord.queue(`Sorry, ${member}, but your team's roster is locked for the playoffs. Roster changes will become available when your team is no longer participating.`, channel);
throw new Warning("Team rosters are locked.");
}
const isFounder = member.isFounder();
if (isFounder) {
await Discord.queue(`Sorry, ${member}, but you are the team founder. You must either \`!disband\` the team or choose another teammate to \`!makefounder\`.`, channel);
throw new Warning("Pilot is the team founder.");
}
if (!message) {
await Discord.queue(`${member}, are you sure you want to leave **${team.name}**? Type \`!leave confirm\` to confirm. Note that you will not be able to rejoin this team for 28 days.`, channel);
return true;
}
if (message !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!leave confirm\` to confirm that you wish to leave **${team.name}**. Note that you will not be able to rejoin this team for 28 days.`, channel);
return false;
}
try {
await team.pilotLeft(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, you have left **${team.name}**.`, member);
return true;
} |
JavaScript | async remove(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
if (team.locked) {
await Discord.queue(`Sorry, ${member}, but your team's roster is locked for the playoffs. Roster changes will become available when your team is no longer participating.`, channel);
throw new Warning("Team rosters are locked.");
}
if (!await Commands.checkHasParameters(message, member, "To remove a pilot, you must mention them as part of the `!remove` command.", channel)) {
return false;
}
const {pilot, confirm} = await Commands.checkPilotExistsWithConfirmation(message, member, channel);
if (pilot.id === member.id) {
await Discord.queue(`Sorry, ${member}, you can't remove yourself with this command. If you wish to leave the team, use the \`!leave\` command.`, channel);
throw new Warning("Pilot cannot remove themselves.");
}
const isFounder = member.isFounder(),
pilotIsCaptain = pilot.isCaptainOrFounder();
if (!isFounder && pilotIsCaptain) {
await Discord.queue(`Sorry, ${member}, but you must be the founder to remove this pilot.`, channel);
throw new Warning("Pilot cannot remove a captain.");
}
let removable;
try {
removable = await member.canRemovePilot(pilot);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!removable) {
await Discord.queue(`Sorry, ${member}, but ${pilot.displayName} is not a pilot you can remove.`, channel);
throw new Warning("Pilot is not removable.");
}
if (!confirm) {
await Discord.queue(`${member}, are you sure you want to remove ${pilot.displayName}? Type \`!remove ${pilot.displayName} confirm\` to confirm.`, channel);
return true;
}
if (confirm !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!remove ${pilot.displayName} confirm\` to confirm that you wish to remove this pilot.`, channel);
return false;
}
try {
await team.removePilot(member, pilot);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, you have removed ${pilot.displayName}.`, channel);
return true;
} | async remove(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
if (team.locked) {
await Discord.queue(`Sorry, ${member}, but your team's roster is locked for the playoffs. Roster changes will become available when your team is no longer participating.`, channel);
throw new Warning("Team rosters are locked.");
}
if (!await Commands.checkHasParameters(message, member, "To remove a pilot, you must mention them as part of the `!remove` command.", channel)) {
return false;
}
const {pilot, confirm} = await Commands.checkPilotExistsWithConfirmation(message, member, channel);
if (pilot.id === member.id) {
await Discord.queue(`Sorry, ${member}, you can't remove yourself with this command. If you wish to leave the team, use the \`!leave\` command.`, channel);
throw new Warning("Pilot cannot remove themselves.");
}
const isFounder = member.isFounder(),
pilotIsCaptain = pilot.isCaptainOrFounder();
if (!isFounder && pilotIsCaptain) {
await Discord.queue(`Sorry, ${member}, but you must be the founder to remove this pilot.`, channel);
throw new Warning("Pilot cannot remove a captain.");
}
let removable;
try {
removable = await member.canRemovePilot(pilot);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!removable) {
await Discord.queue(`Sorry, ${member}, but ${pilot.displayName} is not a pilot you can remove.`, channel);
throw new Warning("Pilot is not removable.");
}
if (!confirm) {
await Discord.queue(`${member}, are you sure you want to remove ${pilot.displayName}? Type \`!remove ${pilot.displayName} confirm\` to confirm.`, channel);
return true;
}
if (confirm !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!remove ${pilot.displayName} confirm\` to confirm that you wish to remove this pilot.`, channel);
return false;
}
try {
await team.removePilot(member, pilot);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, you have removed ${pilot.displayName}.`, channel);
return true;
} |
JavaScript | async timezone(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (message) {
const time = await Commands.checkTimezoneIsValid(message, member, channel);
try {
await member.setTimezone(message);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your time zone has been set to ${message}, where the current local time is ${time}.`, channel);
return true;
}
try {
await member.clearTimezone();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your time zone has been cleared.`, channel);
return true;
} | async timezone(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (message) {
const time = await Commands.checkTimezoneIsValid(message, member, channel);
try {
await member.setTimezone(message);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your time zone has been set to ${message}, where the current local time is ${time}.`, channel);
return true;
}
try {
await member.clearTimezone();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your time zone has been cleared.`, channel);
return true;
} |
JavaScript | async challenge(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (!member.isCaptainOrFounder()) {
await Discord.queue(`Sorry, ${member}, but you must be a team captain or founder to use this command.`, channel);
throw new Warning("Pilot is not a founder or captain.");
}
if (!await Commands.checkHasParameters(message, member, "You must use `!challenge` along with the name or tag of the team that you wish to challenge, and optionally the game type you wish to challenge them to. For example `!challenge JOA`, or `!challenge JOA CTF`.", channel)) {
return false;
}
if (!challengeParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must use \`!challenge\` along with the name or tag of the team that you wish to challenge, and optionally the game type you wish to challenge them to. For example \`!challenge JOA\`, or \`!challenge JOA CTF\`.`, channel);
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
let pilotCount;
try {
pilotCount = await team.getPilotCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (pilotCount < 2) {
await Discord.queue(`Sorry, ${member}, but your team must have 2 or more pilots to challenge another team. \`!invite\` some pilots to your team!`, channel);
throw new Warning("Team only has one member.");
}
let homeMaps;
try {
homeMaps = await team.getHomeMapsByType();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!homeMaps.CTF || !homeMaps["2v2"] || pilotCount >= 3 && !homeMaps["3v3"] || pilotCount >= 4 && !homeMaps["4v4+"] || homeMaps.CTF.length !== 5 || homeMaps["2v2"].length !== 5 || pilotCount >= 3 && homeMaps["3v3"].length !== 5 || pilotCount >= 4 && homeMaps["4v4+"].length !== 5) {
await Discord.queue(`Sorry, ${member}, but your team must have 5 home maps set for each game type before you challenge another team. Use the \`!home <gameType> <number> <map>\` command to set your team's home maps.`, channel);
throw new Warning("Team does not have 5 home maps set for each game type.");
}
const {groups: {teamName, gameType}} = challengeParse.exec(message),
gameTypeUpper = gameType && gameType.toUpperCase() || void 0;
const opponent = await Commands.checkTeamExists(teamName, member, channel);
if (opponent.disbanded) {
await Discord.queue(`Sorry, ${member}, but that team is disbanded.`, channel);
throw new Warning("Team is disbanded.");
}
let opponentPilotCount;
try {
opponentPilotCount = await opponent.getPilotCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (opponentPilotCount < 2) {
await Discord.queue(`Sorry, ${member}, but your opponents must have 2 or more pilots to be challenged.`, channel);
throw new Warning("Opponent only has one member.");
}
let opponentHomeMaps;
try {
opponentHomeMaps = await opponent.getHomeMapsByType();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!opponentHomeMaps.CTF || !opponentHomeMaps["2v2"] || opponentPilotCount >= 3 && !opponentHomeMaps["3v3"] || opponentPilotCount >= 4 && !opponentHomeMaps["4v4+"] || opponentHomeMaps.CTF.length !== 5 || opponentHomeMaps["2v2"].length !== 5 || opponentPilotCount >= 3 && opponentHomeMaps["3v3"].length !== 5 || opponentPilotCount >= 4 && opponentHomeMaps["4v4+"].length !== 5) {
await Discord.queue(`Sorry, ${member}, but your opponents must have 5 home maps set for each game type before you can challenge them.`, channel);
throw new Warning("Opponent does not have 5 home maps set for each game type.");
}
let existingChallenge;
try {
existingChallenge = await Challenge.getByTeams(team, opponent);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (existingChallenge) {
await Discord.queue(`Sorry, ${member}, but there is already a pending challenge between these two teams! Visit ${existingChallenge.channel} for more information about this match.`, channel);
throw new Warning("Challenge already exists.");
}
if (team.id === opponent.id) {
await Discord.queue(`Sorry, ${member}, but this would cause shenanigans. Challenge some other team!`, channel);
throw new Warning("Attempted to challenge own team.");
}
let challenge;
try {
challenge = await Challenge.create(team, opponent, {gameType: gameTypeUpper});
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your challenge to **${opponent.name}** has been issued! Visit ${challenge.channel} for match discussion and to set the parameters for your match.`, channel);
return true;
} | async challenge(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (!member.isCaptainOrFounder()) {
await Discord.queue(`Sorry, ${member}, but you must be a team captain or founder to use this command.`, channel);
throw new Warning("Pilot is not a founder or captain.");
}
if (!await Commands.checkHasParameters(message, member, "You must use `!challenge` along with the name or tag of the team that you wish to challenge, and optionally the game type you wish to challenge them to. For example `!challenge JOA`, or `!challenge JOA CTF`.", channel)) {
return false;
}
if (!challengeParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must use \`!challenge\` along with the name or tag of the team that you wish to challenge, and optionally the game type you wish to challenge them to. For example \`!challenge JOA\`, or \`!challenge JOA CTF\`.`, channel);
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
let pilotCount;
try {
pilotCount = await team.getPilotCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (pilotCount < 2) {
await Discord.queue(`Sorry, ${member}, but your team must have 2 or more pilots to challenge another team. \`!invite\` some pilots to your team!`, channel);
throw new Warning("Team only has one member.");
}
let homeMaps;
try {
homeMaps = await team.getHomeMapsByType();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!homeMaps.CTF || !homeMaps["2v2"] || pilotCount >= 3 && !homeMaps["3v3"] || pilotCount >= 4 && !homeMaps["4v4+"] || homeMaps.CTF.length !== 5 || homeMaps["2v2"].length !== 5 || pilotCount >= 3 && homeMaps["3v3"].length !== 5 || pilotCount >= 4 && homeMaps["4v4+"].length !== 5) {
await Discord.queue(`Sorry, ${member}, but your team must have 5 home maps set for each game type before you challenge another team. Use the \`!home <gameType> <number> <map>\` command to set your team's home maps.`, channel);
throw new Warning("Team does not have 5 home maps set for each game type.");
}
const {groups: {teamName, gameType}} = challengeParse.exec(message),
gameTypeUpper = gameType && gameType.toUpperCase() || void 0;
const opponent = await Commands.checkTeamExists(teamName, member, channel);
if (opponent.disbanded) {
await Discord.queue(`Sorry, ${member}, but that team is disbanded.`, channel);
throw new Warning("Team is disbanded.");
}
let opponentPilotCount;
try {
opponentPilotCount = await opponent.getPilotCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (opponentPilotCount < 2) {
await Discord.queue(`Sorry, ${member}, but your opponents must have 2 or more pilots to be challenged.`, channel);
throw new Warning("Opponent only has one member.");
}
let opponentHomeMaps;
try {
opponentHomeMaps = await opponent.getHomeMapsByType();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (!opponentHomeMaps.CTF || !opponentHomeMaps["2v2"] || opponentPilotCount >= 3 && !opponentHomeMaps["3v3"] || opponentPilotCount >= 4 && !opponentHomeMaps["4v4+"] || opponentHomeMaps.CTF.length !== 5 || opponentHomeMaps["2v2"].length !== 5 || opponentPilotCount >= 3 && opponentHomeMaps["3v3"].length !== 5 || opponentPilotCount >= 4 && opponentHomeMaps["4v4+"].length !== 5) {
await Discord.queue(`Sorry, ${member}, but your opponents must have 5 home maps set for each game type before you can challenge them.`, channel);
throw new Warning("Opponent does not have 5 home maps set for each game type.");
}
let existingChallenge;
try {
existingChallenge = await Challenge.getByTeams(team, opponent);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (existingChallenge) {
await Discord.queue(`Sorry, ${member}, but there is already a pending challenge between these two teams! Visit ${existingChallenge.channel} for more information about this match.`, channel);
throw new Warning("Challenge already exists.");
}
if (team.id === opponent.id) {
await Discord.queue(`Sorry, ${member}, but this would cause shenanigans. Challenge some other team!`, channel);
throw new Warning("Attempted to challenge own team.");
}
let challenge;
try {
challenge = await Challenge.create(team, opponent, {gameType: gameTypeUpper});
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your challenge to **${opponent.name}** has been issued! Visit ${challenge.channel} for match discussion and to set the parameters for your match.`, channel);
return true;
} |
JavaScript | async pickmap(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (challenge.details.homeMapTeam.id === team.id) {
await Discord.queue(`Sorry, ${member}, but your team is the home team. Your opponents must pick the map from your list of home maps.`, channel);
throw new Warning("Wrong team.");
}
if (!message || ["a", "b", "c", "d", "e"].indexOf(message.toLowerCase()) === -1) {
await Discord.queue(`Sorry, ${member}, but this command cannot be used by itself. To pick from one of the five home maps, use \`!pickmap a\`, \`!pickmap b\`, \`!pickmap c\`, \`!pickmap d\`, or \`!pickmap e\`.`, channel);
throw new Warning("Missing map selection.");
}
if (challenge.details.gameType === "TA" && !challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but you must agree to a team size before selecting a map. Use \`!suggestteamsize\` to suggest a team size for this challenge.`, channel);
throw new Warning("Team size not set.");
}
try {
await challenge.pickMap(message.toLowerCase().charCodeAt(0) - 96);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async pickmap(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (challenge.details.homeMapTeam.id === team.id) {
await Discord.queue(`Sorry, ${member}, but your team is the home team. Your opponents must pick the map from your list of home maps.`, channel);
throw new Warning("Wrong team.");
}
if (!message || ["a", "b", "c", "d", "e"].indexOf(message.toLowerCase()) === -1) {
await Discord.queue(`Sorry, ${member}, but this command cannot be used by itself. To pick from one of the five home maps, use \`!pickmap a\`, \`!pickmap b\`, \`!pickmap c\`, \`!pickmap d\`, or \`!pickmap e\`.`, channel);
throw new Warning("Missing map selection.");
}
if (challenge.details.gameType === "TA" && !challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but you must agree to a team size before selecting a map. Use \`!suggestteamsize\` to suggest a team size for this challenge.`, channel);
throw new Warning("Team size not set.");
}
try {
await challenge.pickMap(message.toLowerCase().charCodeAt(0) - 96);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async suggestmap(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To suggest a neutral map, use the `!suggestmap` command with the map you want to suggest.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
await Commands.checkChallengeIsNotLocked(challenge, member, channel);
await Commands.checkChallengeIsNotPenalized(challenge, member, channel);
if (challenge.details.gameType === "TA" && !challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but you must agree to a team size before suggesting a map. Use \`!suggestteamsize\` to suggest a team size for this challenge.`, channel);
throw new Warning("Team size not set.");
}
const map = await Commands.checkMapIsValid(message, challenge.details.gameType, member, channel);
if (challenge.details.homeMaps.indexOf(map.map) !== -1) {
await Discord.queue(`Sorry, ${member}, but this is one of the home maps for the home map team, **${challenge.details.homeMapTeam.name}**, and cannot be used as a neutral map.`, channel);
throw new Warning("Pilot suggested one of the home options.");
}
try {
await challenge.suggestMap(team, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async suggestmap(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To suggest a neutral map, use the `!suggestmap` command with the map you want to suggest.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
await Commands.checkChallengeIsNotLocked(challenge, member, channel);
await Commands.checkChallengeIsNotPenalized(challenge, member, channel);
if (challenge.details.gameType === "TA" && !challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but you must agree to a team size before suggesting a map. Use \`!suggestteamsize\` to suggest a team size for this challenge.`, channel);
throw new Warning("Team size not set.");
}
const map = await Commands.checkMapIsValid(message, challenge.details.gameType, member, channel);
if (challenge.details.homeMaps.indexOf(map.map) !== -1) {
await Discord.queue(`Sorry, ${member}, but this is one of the home maps for the home map team, **${challenge.details.homeMapTeam.name}**, and cannot be used as a neutral map.`, channel);
throw new Warning("Pilot suggested one of the home options.");
}
try {
await challenge.suggestMap(team, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async suggestrandommap(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
await Commands.checkChallengeIsNotLocked(challenge, member, channel);
await Commands.checkChallengeIsNotPenalized(challenge, member, channel);
if (!suggestRandomMapParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but to suggest a random map, either use \`!suggestrandommap\` by itself to suggest a map from the full map pool, or \`suggestrandommap top 10\` or \`suggestrandommap bottom 20\` to pick from the most or least popular maps.`, channel);
throw new Warning("Invalid syntax.");
}
if (challenge.details.gameType === "TA" && !challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but you must agree to a team size before suggesting a map. Use \`!suggestteamsize\` to suggest a team size for this challenge.`, channel);
throw new Warning("Team size not set.");
}
const {groups: {direction, count}} = suggestRandomMapParse.exec(message);
const map = await challenge.getRandomMap(direction && direction.toLowerCase() || void 0, +count);
if (!map) {
await Discord.queue(`Sorry, ${member}, but I could not find a map to suggest.`, channel);
throw new Warning("No matching maps.");
}
try {
await challenge.suggestMap(team, map, true);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async suggestrandommap(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
await Commands.checkChallengeIsNotLocked(challenge, member, channel);
await Commands.checkChallengeIsNotPenalized(challenge, member, channel);
if (!suggestRandomMapParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but to suggest a random map, either use \`!suggestrandommap\` by itself to suggest a map from the full map pool, or \`suggestrandommap top 10\` or \`suggestrandommap bottom 20\` to pick from the most or least popular maps.`, channel);
throw new Warning("Invalid syntax.");
}
if (challenge.details.gameType === "TA" && !challenge.details.teamSize) {
await Discord.queue(`Sorry, ${member}, but you must agree to a team size before suggesting a map. Use \`!suggestteamsize\` to suggest a team size for this challenge.`, channel);
throw new Warning("Team size not set.");
}
const {groups: {direction, count}} = suggestRandomMapParse.exec(message);
const map = await challenge.getRandomMap(direction && direction.toLowerCase() || void 0, +count);
if (!map) {
await Discord.queue(`Sorry, ${member}, but I could not find a map to suggest.`, channel);
throw new Warning("No matching maps.");
}
try {
await challenge.suggestMap(team, map, true);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async confirmmap(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!confirmmap` by itself to confirm a suggested neutral map.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
await Commands.checkChallengeIsNotLocked(challenge, member, channel);
await Commands.checkChallengeIsNotPenalized(challenge, member, channel);
if (!challenge.details.suggestedMap || challenge.details.suggestedMap.length === 0) {
await Discord.queue(`Sorry, ${member}, but no one has suggested a neutral map for this match yet! Use the \`!suggestmap\` command to do so.`, channel);
throw new Warning("No map suggested yet.");
}
if (challenge.details.suggestedMapTeam.id === team.id) {
await Discord.queue(`Sorry, ${member}, but your team suggested this map, the other team must confirm.`, channel);
throw new Warning("Can't confirm own neutral map suggestion.");
}
try {
await challenge.confirmMap();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async confirmmap(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!confirmmap` by itself to confirm a suggested neutral map.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
await Commands.checkChallengeIsNotLocked(challenge, member, channel);
await Commands.checkChallengeIsNotPenalized(challenge, member, channel);
if (!challenge.details.suggestedMap || challenge.details.suggestedMap.length === 0) {
await Discord.queue(`Sorry, ${member}, but no one has suggested a neutral map for this match yet! Use the \`!suggestmap\` command to do so.`, channel);
throw new Warning("No map suggested yet.");
}
if (challenge.details.suggestedMapTeam.id === team.id) {
await Discord.queue(`Sorry, ${member}, but your team suggested this map, the other team must confirm.`, channel);
throw new Warning("Can't confirm own neutral map suggestion.");
}
try {
await challenge.confirmMap();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async suggestteamsize(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!message || ["2", "3", "4", "5", "6", "7", "8", "2v2", "3v3", "4v4", "5v5", "6v6", "7v7", "8v8"].indexOf(message.toLowerCase()) === -1) {
await Discord.queue(`Sorry, ${member}, but this command cannot be used by itself. To suggest a team size, use the \`!suggestteamsize <size>\` command, for example, \`!suggestteamsize 3\`.`, channel);
throw new Warning("Missing team size.");
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
try {
await challenge.suggestTeamSize(team, +message.charAt(0));
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async suggestteamsize(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!message || ["2", "3", "4", "5", "6", "7", "8", "2v2", "3v3", "4v4", "5v5", "6v6", "7v7", "8v8"].indexOf(message.toLowerCase()) === -1) {
await Discord.queue(`Sorry, ${member}, but this command cannot be used by itself. To suggest a team size, use the \`!suggestteamsize <size>\` command, for example, \`!suggestteamsize 3\`.`, channel);
throw new Warning("Missing team size.");
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
try {
await challenge.suggestTeamSize(team, +message.charAt(0));
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async confirmteamsize(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!confirmteamsize` by itself to confirm a suggested team size.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (!challenge.details.suggestedTeamSize) {
await Discord.queue(`Sorry, ${member}, but no one has suggested a team size for this match yet! Use the \`!suggestteamsize\` command to do so.`, channel);
throw new Warning("Team size not yet suggested.");
}
if (challenge.details.suggestedTeamSizeTeam.id === team.id) {
await Discord.queue(`Sorry, ${member}, but your team suggested this team size, the other team must confirm.`, channel);
throw new Warning("Can't confirm own team size suggestion.");
}
try {
await challenge.confirmTeamSize();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async confirmteamsize(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!confirmteamsize` by itself to confirm a suggested team size.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (!challenge.details.suggestedTeamSize) {
await Discord.queue(`Sorry, ${member}, but no one has suggested a team size for this match yet! Use the \`!suggestteamsize\` command to do so.`, channel);
throw new Warning("Team size not yet suggested.");
}
if (challenge.details.suggestedTeamSizeTeam.id === team.id) {
await Discord.queue(`Sorry, ${member}, but your team suggested this team size, the other team must confirm.`, channel);
throw new Warning("Can't confirm own team size suggestion.");
}
try {
await challenge.confirmTeamSize();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async suggesttype(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To suggest a game type, use `!suggesttype` along with either `TA` for Team Anarchy or `CTF` for Capture the Flag.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotLocked(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
const gameType = message.toUpperCase();
if (["TA", "CTF"].indexOf(gameType) === -1) {
await Discord.queue(`Sorry, ${member}, but to suggest a game type, use \`!suggesttype\` along with either \`TA\` for Team Anarchy or \`CTF\` for Capture the Flag.`, channel);
throw new Warning("Invalid game type.");
}
try {
await challenge.suggestGameType(team, gameType);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async suggesttype(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To suggest a game type, use `!suggesttype` along with either `TA` for Team Anarchy or `CTF` for Capture the Flag.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotLocked(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
const gameType = message.toUpperCase();
if (["TA", "CTF"].indexOf(gameType) === -1) {
await Discord.queue(`Sorry, ${member}, but to suggest a game type, use \`!suggesttype\` along with either \`TA\` for Team Anarchy or \`CTF\` for Capture the Flag.`, channel);
throw new Warning("Invalid game type.");
}
try {
await challenge.suggestGameType(team, gameType);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async confirmtype(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!confirmtype` by itself to confirm a suggested game type.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotLocked(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (!challenge.details.suggestedGameType) {
await Discord.queue(`Sorry, ${member}, but no one has suggested a game type for this match yet! Use the \`!suggesttype\` command to do so.`, channel);
throw new Warning("Game type not yet suggested.");
}
if (challenge.details.suggestedGameTypeTeam.id === team.id) {
await Discord.queue(`Sorry, ${member}, but your team suggested this game type, the other team must confirm.`, channel);
throw new Warning("Can't confirm own game type suggestion.");
}
try {
await challenge.confirmGameType();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async confirmtype(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!confirmtype` by itself to confirm a suggested game type.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotLocked(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (!challenge.details.suggestedGameType) {
await Discord.queue(`Sorry, ${member}, but no one has suggested a game type for this match yet! Use the \`!suggesttype\` command to do so.`, channel);
throw new Warning("Game type not yet suggested.");
}
if (challenge.details.suggestedGameTypeTeam.id === team.id) {
await Discord.queue(`Sorry, ${member}, but your team suggested this game type, the other team must confirm.`, channel);
throw new Warning("Can't confirm own game type suggestion.");
}
try {
await challenge.confirmGameType();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async suggesttime(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To suggest a time, use `!suggesttime` along with the date and time. If not set, time zone defaults to your team's selected time zone, or Pacific Time. Use the `!timezone` command to set your own time zone. Founders may use the `!teamtimezone` command to set the default time zone for their team.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
message = message.replace(/-/g, "/");
let date;
if (message.toLowerCase() === "now") {
date = new Date();
date = new Date(date.getTime() + (300000 - date.getTime() % 300000));
} else {
const tz = tc.TimeZone.zone(await member.getTimezone());
try {
date = new Date(new tc.DateTime(new Date(`${message} UTC`).toISOString(), tz).toIsoString());
} catch (_) {
try {
date = new Date(new tc.DateTime(new Date(`${new Date().toDateString()} ${message} UTC`).toISOString(), tz).toIsoString());
if (date < new Date()) {
date.setDate(date.getDate() + 1);
}
} catch (err) {
console.log(err);
await Discord.queue(`Sorry, ${member}, but I couldn't parse that date and time.`, channel);
throw new Warning("Invalid date.");
}
}
if (!date || isNaN(date.valueOf())) {
await Discord.queue(`Sorry, ${member}, but I couldn't parse that date and time.`, channel);
throw new Warning("Invalid date.");
}
if (date.getFullYear() === 2001 && message.indexOf("2001") === -1) {
date = new Date(`${message} UTC`);
date.setFullYear(new Date().getFullYear());
date = new Date(new tc.DateTime(date.toISOString(), tz).toIsoString());
if (date < new Date()) {
date.setFullYear(new Date().getFullYear() + 1);
}
}
if (!date || isNaN(date.valueOf())) {
await Discord.queue(`Sorry, ${member}, but I couldn't parse that date and time.`, channel);
throw new Warning("Invalid date.");
}
if (date < new Date()) {
await Discord.queue(`Sorry, ${member}, but that date is in the past.`, channel);
throw new Warning("Date is in the past.");
}
if (date.getTime() - new Date().getTime() > 28 * 24 * 60 * 60 * 1000) {
await Discord.queue(`Sorry, ${member}, but you cannot schedule a match that far into the future.`, channel);
throw new Warning("Date too far into the future.");
}
}
try {
await challenge.suggestTime(team, date);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async suggesttime(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To suggest a time, use `!suggesttime` along with the date and time. If not set, time zone defaults to your team's selected time zone, or Pacific Time. Use the `!timezone` command to set your own time zone. Founders may use the `!teamtimezone` command to set the default time zone for their team.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
message = message.replace(/-/g, "/");
let date;
if (message.toLowerCase() === "now") {
date = new Date();
date = new Date(date.getTime() + (300000 - date.getTime() % 300000));
} else {
const tz = tc.TimeZone.zone(await member.getTimezone());
try {
date = new Date(new tc.DateTime(new Date(`${message} UTC`).toISOString(), tz).toIsoString());
} catch (_) {
try {
date = new Date(new tc.DateTime(new Date(`${new Date().toDateString()} ${message} UTC`).toISOString(), tz).toIsoString());
if (date < new Date()) {
date.setDate(date.getDate() + 1);
}
} catch (err) {
console.log(err);
await Discord.queue(`Sorry, ${member}, but I couldn't parse that date and time.`, channel);
throw new Warning("Invalid date.");
}
}
if (!date || isNaN(date.valueOf())) {
await Discord.queue(`Sorry, ${member}, but I couldn't parse that date and time.`, channel);
throw new Warning("Invalid date.");
}
if (date.getFullYear() === 2001 && message.indexOf("2001") === -1) {
date = new Date(`${message} UTC`);
date.setFullYear(new Date().getFullYear());
date = new Date(new tc.DateTime(date.toISOString(), tz).toIsoString());
if (date < new Date()) {
date.setFullYear(new Date().getFullYear() + 1);
}
}
if (!date || isNaN(date.valueOf())) {
await Discord.queue(`Sorry, ${member}, but I couldn't parse that date and time.`, channel);
throw new Warning("Invalid date.");
}
if (date < new Date()) {
await Discord.queue(`Sorry, ${member}, but that date is in the past.`, channel);
throw new Warning("Date is in the past.");
}
if (date.getTime() - new Date().getTime() > 28 * 24 * 60 * 60 * 1000) {
await Discord.queue(`Sorry, ${member}, but you cannot schedule a match that far into the future.`, channel);
throw new Warning("Date too far into the future.");
}
}
try {
await challenge.suggestTime(team, date);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async confirmtime(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!confirmtime` by itself to confirm a suggested time.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (!challenge.details.suggestedTime) {
await Discord.queue(`Sorry, ${member}, but no one has suggested a time for this match yet! Use the \`!suggesttime\` command to do so.`, channel);
throw new Warning("Time not yet suggested.");
}
if (challenge.details.suggestedTimeTeam.id === team.id) {
await Discord.queue(`Sorry, ${member}, but your team suggested this time, the other team must confirm.`, channel);
throw new Warning("Can't confirm own time suggestion.");
}
try {
await challenge.confirmTime();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async confirmtime(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!confirmtime` by itself to confirm a suggested time.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (!challenge.details.suggestedTime) {
await Discord.queue(`Sorry, ${member}, but no one has suggested a time for this match yet! Use the \`!suggesttime\` command to do so.`, channel);
throw new Warning("Time not yet suggested.");
}
if (challenge.details.suggestedTimeTeam.id === team.id) {
await Discord.queue(`Sorry, ${member}, but your team suggested this time, the other team must confirm.`, channel);
throw new Warning("Can't confirm own time suggestion.");
}
try {
await challenge.confirmTime();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async clock(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (challenge.details.dateClocked) {
await Discord.queue(`Sorry, ${member}, but this challenge is already on the clock!`, channel);
throw new Warning("Match already clocked.");
}
if (challenge.details.matchTime) {
await Discord.queue(`Sorry, ${member}, but this challenge has already been scheduled and doesn't need to be clocked.`, channel);
throw new Warning("Match already scheduled.");
}
if (challenge.challengingTeam.locked || challenge.challengedTeam.locked) {
await Discord.queue(`Sorry, ${member}, but due to tournament participation, this match cannot be clocked.`, channel);
throw new Warning("A team is in a tournament.");
}
let nextClockDate;
try {
nextClockDate = await team.getNextClockDate();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (nextClockDate && nextClockDate > new Date()) {
await Discord.queue(`Sorry, ${member}, but your team cannot put another challenge on the clock until ${nextClockDate.toLocaleString("en-US", {timeZone: await member.getTimezone(), month: "numeric", day: "numeric", year: "numeric", hour12: true, hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.`, channel);
throw new Warning("Team has clocked a challenge in the last 28 days.");
}
let challengingTeamClockCount;
try {
challengingTeamClockCount = await challenge.challengingTeam.getClockedChallengeCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (challengingTeamClockCount >= 2) {
await Discord.queue(`Sorry, ${member}, but **${challenge.challengingTeam.name}** already has two challenges on the clock.`, channel);
throw new Warning("Challenging team has the maximum number of clocked challenges.");
}
let challengedTeamClockCount;
try {
challengedTeamClockCount = await challenge.challengedTeam.getClockedChallengeCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (challengedTeamClockCount >= 2) {
await Discord.queue(`Sorry, ${member}, but **${challenge.challengedTeam.name}** already has two challenges on the clock.`, channel);
throw new Warning("Challenged team has the maximum number of clocked challenges.");
}
let alreadyClocked;
try {
alreadyClocked = await team.hasClockedThisSeason(team.id === challenge.challengingTeam.id ? challenge.challengedTeam : challenge.challengingTeam);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (alreadyClocked) {
await Discord.queue(`Sorry, ${member}, but your team has already put **${(team.id === challenge.challengingTeam.id ? challenge.challengedTeam : challenge.challengingTeam).name}** on the clock this season.`, channel);
throw new Warning("Team already clocked this season.");
}
if (!message) {
await Discord.queue(`${member}, are you sure you wish to put this challenge on the clock? This command should only be used if the opposing team is not responding to your challenge. Note that you can only clock a challenge once every 28 days, you can only clock a team once every season, and you can have a maximum of two active challenges clocked at a time. Use \`!clock confirm\` to confirm.`, channel);
return true;
}
if (message !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!clock confirm\` to confirm that you wish to put this challenge on the clock.`, channel);
return false;
}
try {
await challenge.clock(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async clock(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (challenge.details.dateClocked) {
await Discord.queue(`Sorry, ${member}, but this challenge is already on the clock!`, channel);
throw new Warning("Match already clocked.");
}
if (challenge.details.matchTime) {
await Discord.queue(`Sorry, ${member}, but this challenge has already been scheduled and doesn't need to be clocked.`, channel);
throw new Warning("Match already scheduled.");
}
if (challenge.challengingTeam.locked || challenge.challengedTeam.locked) {
await Discord.queue(`Sorry, ${member}, but due to tournament participation, this match cannot be clocked.`, channel);
throw new Warning("A team is in a tournament.");
}
let nextClockDate;
try {
nextClockDate = await team.getNextClockDate();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (nextClockDate && nextClockDate > new Date()) {
await Discord.queue(`Sorry, ${member}, but your team cannot put another challenge on the clock until ${nextClockDate.toLocaleString("en-US", {timeZone: await member.getTimezone(), month: "numeric", day: "numeric", year: "numeric", hour12: true, hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.`, channel);
throw new Warning("Team has clocked a challenge in the last 28 days.");
}
let challengingTeamClockCount;
try {
challengingTeamClockCount = await challenge.challengingTeam.getClockedChallengeCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (challengingTeamClockCount >= 2) {
await Discord.queue(`Sorry, ${member}, but **${challenge.challengingTeam.name}** already has two challenges on the clock.`, channel);
throw new Warning("Challenging team has the maximum number of clocked challenges.");
}
let challengedTeamClockCount;
try {
challengedTeamClockCount = await challenge.challengedTeam.getClockedChallengeCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (challengedTeamClockCount >= 2) {
await Discord.queue(`Sorry, ${member}, but **${challenge.challengedTeam.name}** already has two challenges on the clock.`, channel);
throw new Warning("Challenged team has the maximum number of clocked challenges.");
}
let alreadyClocked;
try {
alreadyClocked = await team.hasClockedThisSeason(team.id === challenge.challengingTeam.id ? challenge.challengedTeam : challenge.challengingTeam);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (alreadyClocked) {
await Discord.queue(`Sorry, ${member}, but your team has already put **${(team.id === challenge.challengingTeam.id ? challenge.challengedTeam : challenge.challengingTeam).name}** on the clock this season.`, channel);
throw new Warning("Team already clocked this season.");
}
if (!message) {
await Discord.queue(`${member}, are you sure you wish to put this challenge on the clock? This command should only be used if the opposing team is not responding to your challenge. Note that you can only clock a challenge once every 28 days, you can only clock a team once every season, and you can have a maximum of two active challenges clocked at a time. Use \`!clock confirm\` to confirm.`, channel);
return true;
}
if (message !== "confirm") {
await Discord.queue(`Sorry, ${member}, but you must type \`!clock confirm\` to confirm that you wish to put this challenge on the clock.`, channel);
return false;
}
try {
await challenge.clock(team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async mynext(member, channel, message) {
if (message && message.toLowerCase() !== "time") {
await Discord.queue(`Sorry, ${member ? `${member}, ` : ""}but this command does not take any parameters. Use \`!mynext\` by itself to get the list of upcoming matches as a countdown, or use \`!mynext time\` to get the list with dates and times.`, channel);
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
const matches = (await Match.getUpcoming()).filter((m) => m.challengingTeamTag === team.tag || m.challengedTeamTag === team.tag);
if (matches.length === 0) {
await Discord.queue("There are no matches currently scheduled for your team.", channel);
return true;
}
const msg = Discord.messageEmbed({
title: "Overload Teams League Schedule",
fields: []
});
if (message === "time") {
for (const [index, match] of matches.entries()) {
msg.addField(`${index === 0 ? "Upcoming Matches:\n" : ""}${match.challengingTeamName} vs ${match.challengedTeamName}`, `**${Challenge.getGameTypeName(match.gameType)}**${match.map ? ` in **${match.map}**` : ""}\nBegins at ${match.matchTime.toLocaleString("en-US", {timeZone: await member.getTimezone(), weekday: "short", month: "short", day: "numeric", year: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.\n${match.twitchName ? `Watch online at https://twitch.tv/${match.twitchName}.` : Commands.checkChannelIsOnServer(channel) ? `Watch online at https://otl.gg/cast/${match.challengeId}, or use \`!cast ${match.challengeId}\` to cast this game.` : `Watch online at https://otl.gg/cast/${match.challengeId}.`}`);
}
} else {
matches.forEach((match, index) => {
const difference = match.matchTime.getTime() - new Date().getTime(),
days = Math.floor(Math.abs(difference) / (24 * 60 * 60 * 1000)),
hours = Math.floor(Math.abs(difference) / (60 * 60 * 1000) % 24),
minutes = Math.floor(Math.abs(difference) / (60 * 1000) % 60 % 60),
seconds = Math.floor(Math.abs(difference) / 1000 % 60);
if (difference > 0) {
msg.addField(`${index === 0 ? "Upcoming Matches:\n" : ""}${match.challengingTeamName} vs ${match.challengedTeamName}`, `**${Challenge.getGameTypeName(match.gameType)}**${match.map ? ` in **${match.map}**` : ""}\nBegins in ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"}`}.\n${match.twitchName ? `Watch online at https://twitch.tv/${match.twitchName}.` : Commands.checkChannelIsOnServer(channel) ? `Watch online at https://otl.gg/cast/${match.challengeId}, or use \`!cast ${match.challengeId}\` to cast this game.` : `Watch online at https://otl.gg/cast/${match.challengeId}.`}`);
} else {
msg.addField(`${index === 0 ? "Upcoming Matches:\n" : ""}${match.challengingTeamName} vs ${match.challengedTeamName}`, `**${Challenge.getGameTypeName(match.gameType)}**${match.map ? ` in **${match.map}**` : ""}\nBegan ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"}`} ago.\n${match.twitchName ? `Watch online at https://twitch.tv/${match.twitchName}.` : Commands.checkChannelIsOnServer(channel) ? `Watch online at https://otl.gg/cast/${match.challengeId}, or use \`!cast ${match.challengeId}\` to cast this game.` : `Watch online at https://otl.gg/cast/${match.challengeId}.`}`);
}
});
}
await Discord.richQueue(msg, channel);
return true;
} | async mynext(member, channel, message) {
if (message && message.toLowerCase() !== "time") {
await Discord.queue(`Sorry, ${member ? `${member}, ` : ""}but this command does not take any parameters. Use \`!mynext\` by itself to get the list of upcoming matches as a countdown, or use \`!mynext time\` to get the list with dates and times.`, channel);
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
const matches = (await Match.getUpcoming()).filter((m) => m.challengingTeamTag === team.tag || m.challengedTeamTag === team.tag);
if (matches.length === 0) {
await Discord.queue("There are no matches currently scheduled for your team.", channel);
return true;
}
const msg = Discord.messageEmbed({
title: "Overload Teams League Schedule",
fields: []
});
if (message === "time") {
for (const [index, match] of matches.entries()) {
msg.addField(`${index === 0 ? "Upcoming Matches:\n" : ""}${match.challengingTeamName} vs ${match.challengedTeamName}`, `**${Challenge.getGameTypeName(match.gameType)}**${match.map ? ` in **${match.map}**` : ""}\nBegins at ${match.matchTime.toLocaleString("en-US", {timeZone: await member.getTimezone(), weekday: "short", month: "short", day: "numeric", year: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.\n${match.twitchName ? `Watch online at https://twitch.tv/${match.twitchName}.` : Commands.checkChannelIsOnServer(channel) ? `Watch online at https://otl.gg/cast/${match.challengeId}, or use \`!cast ${match.challengeId}\` to cast this game.` : `Watch online at https://otl.gg/cast/${match.challengeId}.`}`);
}
} else {
matches.forEach((match, index) => {
const difference = match.matchTime.getTime() - new Date().getTime(),
days = Math.floor(Math.abs(difference) / (24 * 60 * 60 * 1000)),
hours = Math.floor(Math.abs(difference) / (60 * 60 * 1000) % 24),
minutes = Math.floor(Math.abs(difference) / (60 * 1000) % 60 % 60),
seconds = Math.floor(Math.abs(difference) / 1000 % 60);
if (difference > 0) {
msg.addField(`${index === 0 ? "Upcoming Matches:\n" : ""}${match.challengingTeamName} vs ${match.challengedTeamName}`, `**${Challenge.getGameTypeName(match.gameType)}**${match.map ? ` in **${match.map}**` : ""}\nBegins in ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"}`}.\n${match.twitchName ? `Watch online at https://twitch.tv/${match.twitchName}.` : Commands.checkChannelIsOnServer(channel) ? `Watch online at https://otl.gg/cast/${match.challengeId}, or use \`!cast ${match.challengeId}\` to cast this game.` : `Watch online at https://otl.gg/cast/${match.challengeId}.`}`);
} else {
msg.addField(`${index === 0 ? "Upcoming Matches:\n" : ""}${match.challengingTeamName} vs ${match.challengedTeamName}`, `**${Challenge.getGameTypeName(match.gameType)}**${match.map ? ` in **${match.map}**` : ""}\nBegan ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"}`} ago.\n${match.twitchName ? `Watch online at https://twitch.tv/${match.twitchName}.` : Commands.checkChannelIsOnServer(channel) ? `Watch online at https://otl.gg/cast/${match.challengeId}, or use \`!cast ${match.challengeId}\` to cast this game.` : `Watch online at https://otl.gg/cast/${match.challengeId}.`}`);
}
});
}
await Discord.richQueue(msg, channel);
return true;
} |
JavaScript | async matchtime(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
let challenge;
if (message) {
const challengeId = +message || 0;
challenge = await Commands.checkChallengeIdExists(challengeId, member, channel);
} else {
challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
}
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (challenge.details.matchTime) {
if (message) {
await Discord.queue(`${member}, the match between **${challenge.challengingTeam.name}** and **${challenge.challengedTeam.name}** ${challenge.details.matchTime > new Date() ? "is" : "was"} scheduled to take place ${challenge.details.matchTime.toLocaleString("en-US", {timeZone: await member.getTimezone(), weekday: "short", month: "short", day: "numeric", year: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.`, channel);
} else {
await Discord.queue(`${member}, this match ${challenge.details.matchTime > new Date() ? "is" : "was"} scheduled to take place ${challenge.details.matchTime.toLocaleString("en-US", {timeZone: await member.getTimezone(), weekday: "short", month: "short", day: "numeric", year: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.`, channel);
}
} else {
await Discord.queue(`${member}, this match has not yet been scheduled.`, channel);
}
return true;
} | async matchtime(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
let challenge;
if (message) {
const challengeId = +message || 0;
challenge = await Commands.checkChallengeIdExists(challengeId, member, channel);
} else {
challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
}
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (challenge.details.matchTime) {
if (message) {
await Discord.queue(`${member}, the match between **${challenge.challengingTeam.name}** and **${challenge.challengedTeam.name}** ${challenge.details.matchTime > new Date() ? "is" : "was"} scheduled to take place ${challenge.details.matchTime.toLocaleString("en-US", {timeZone: await member.getTimezone(), weekday: "short", month: "short", day: "numeric", year: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.`, channel);
} else {
await Discord.queue(`${member}, this match ${challenge.details.matchTime > new Date() ? "is" : "was"} scheduled to take place ${challenge.details.matchTime.toLocaleString("en-US", {timeZone: await member.getTimezone(), weekday: "short", month: "short", day: "numeric", year: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.`, channel);
}
} else {
await Discord.queue(`${member}, this match has not yet been scheduled.`, channel);
}
return true;
} |
JavaScript | async countdown(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
let challenge;
if (message) {
const challengeId = +message || 0;
challenge = await Commands.checkChallengeIdExists(challengeId, member, channel);
} else {
challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
}
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
if (challenge.details.matchTime) {
const difference = challenge.details.matchTime.getTime() - new Date().getTime(),
days = Math.floor(Math.abs(difference) / (24 * 60 * 60 * 1000)),
hours = Math.floor(Math.abs(difference) / (60 * 60 * 1000) % 24),
minutes = Math.floor(Math.abs(difference) / (60 * 1000) % 60 % 60),
seconds = Math.floor(Math.abs(difference) / 1000 % 60);
if (message) {
if (difference > 0) {
await Discord.queue(`${member}, the match between **${challenge.challengingTeam.name}** and **${challenge.challengedTeam.name}** is scheduled to begin in ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"}`}.`, channel);
} else {
await Discord.queue(`${member}, the match between **${challenge.challengingTeam.name}** and **${challenge.challengedTeam.name}** was scheduled to begin ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"} `} ago.`, channel);
}
} else if (difference > 0) {
await Discord.queue(`${member}, this match is scheduled to begin in ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"}`}.`, channel);
} else {
await Discord.queue(`${member}, this match was scheduled to begin ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"} `} ago.`, channel);
}
} else {
await Discord.queue(`${member}, this match has not yet been scheduled.`, channel);
}
return true;
} | async countdown(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
let challenge;
if (message) {
const challengeId = +message || 0;
challenge = await Commands.checkChallengeIdExists(challengeId, member, channel);
} else {
challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
}
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
if (challenge.details.matchTime) {
const difference = challenge.details.matchTime.getTime() - new Date().getTime(),
days = Math.floor(Math.abs(difference) / (24 * 60 * 60 * 1000)),
hours = Math.floor(Math.abs(difference) / (60 * 60 * 1000) % 24),
minutes = Math.floor(Math.abs(difference) / (60 * 1000) % 60 % 60),
seconds = Math.floor(Math.abs(difference) / 1000 % 60);
if (message) {
if (difference > 0) {
await Discord.queue(`${member}, the match between **${challenge.challengingTeam.name}** and **${challenge.challengedTeam.name}** is scheduled to begin in ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"}`}.`, channel);
} else {
await Discord.queue(`${member}, the match between **${challenge.challengingTeam.name}** and **${challenge.challengedTeam.name}** was scheduled to begin ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"} `} ago.`, channel);
}
} else if (difference > 0) {
await Discord.queue(`${member}, this match is scheduled to begin in ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"}`}.`, channel);
} else {
await Discord.queue(`${member}, this match was scheduled to begin ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"} `} ago.`, channel);
}
} else {
await Discord.queue(`${member}, this match has not yet been scheduled.`, channel);
}
return true;
} |
JavaScript | async deadline(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!deadline` by itself to get the match's clock deadline in your local time zone.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
if (challenge.details.dateClockDeadline) {
await Discord.queue(`${member}, the clock deadline ${challenge.details.dateClockDeadline > new Date() ? "expires" : "expired"} ${challenge.details.dateClockDeadline.toLocaleString("en-US", {timeZone: await member.getTimezone(), weekday: "short", month: "short", day: "numeric", year: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.`, channel);
} else {
await Discord.queue(`${member}, this match has not yet been put on the clock.`, channel);
}
return true;
} | async deadline(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!deadline` by itself to get the match's clock deadline in your local time zone.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
if (challenge.details.dateClockDeadline) {
await Discord.queue(`${member}, the clock deadline ${challenge.details.dateClockDeadline > new Date() ? "expires" : "expired"} ${challenge.details.dateClockDeadline.toLocaleString("en-US", {timeZone: await member.getTimezone(), weekday: "short", month: "short", day: "numeric", year: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "short"})}.`, channel);
} else {
await Discord.queue(`${member}, this match has not yet been put on the clock.`, channel);
}
return true;
} |
JavaScript | async deadlinecountdown(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!deadlinecountdown` by itself to get the time remaining until the match's clock deadline.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
if (challenge.details.dateClockDeadline) {
const difference = challenge.details.dateClockDeadline.getTime() - new Date().getTime(),
days = Math.floor(Math.abs(difference) / (24 * 60 * 60 * 1000)),
hours = Math.floor(Math.abs(difference) / (60 * 60 * 1000) % 24),
minutes = Math.floor(Math.abs(difference) / (60 * 1000) % 60 % 60),
seconds = Math.floor(Math.abs(difference) / 1000 % 60);
if (difference > 0) {
await Discord.queue(`${member}, this match's clock deadline expires in ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"},`}.`, channel);
} else {
await Discord.queue(`${member}, this match's clock deadline expired ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"}, `} ago.`, channel);
}
} else {
await Discord.queue(`${member}, this match has not yet been put on the clock.`, channel);
}
return true;
} | async deadlinecountdown(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!deadlinecountdown` by itself to get the time remaining until the match's clock deadline.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
if (challenge.details.dateClockDeadline) {
const difference = challenge.details.dateClockDeadline.getTime() - new Date().getTime(),
days = Math.floor(Math.abs(difference) / (24 * 60 * 60 * 1000)),
hours = Math.floor(Math.abs(difference) / (60 * 60 * 1000) % 24),
minutes = Math.floor(Math.abs(difference) / (60 * 1000) % 60 % 60),
seconds = Math.floor(Math.abs(difference) / 1000 % 60);
if (difference > 0) {
await Discord.queue(`${member}, this match's clock deadline expires in ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"},`}.`, channel);
} else {
await Discord.queue(`${member}, this match's clock deadline expired ${days > 0 ? `${days} day${days === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 ? `${hours} hour${hours === 1 ? "" : "s"}, ` : ""}${days > 0 || hours > 0 || minutes > 0 ? `${minutes} minute${minutes === 1 ? "" : "s"}, ` : ""}${`${seconds} second${seconds === 1 ? "" : "s"}, `} ago.`, channel);
}
} else {
await Discord.queue(`${member}, this match has not yet been put on the clock.`, channel);
}
return true;
} |
JavaScript | async twitch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (!await Commands.checkHasParameters(message, member, "To link your Twitch channel, add the name of your channel after the command, for example `!twitch roncli`.", channel)) {
return false;
}
try {
await member.addTwitchName(message);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your Twitch channel is now linked as https://twitch.tv/${message}. If you wish to unlink your channel, use the \`!removetwitch\` command.`, channel);
return true;
} | async twitch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (!await Commands.checkHasParameters(message, member, "To link your Twitch channel, add the name of your channel after the command, for example `!twitch roncli`.", channel)) {
return false;
}
try {
await member.addTwitchName(message);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your Twitch channel is now linked as https://twitch.tv/${message}. If you wish to unlink your channel, use the \`!removetwitch\` command.`, channel);
return true;
} |
JavaScript | async removetwitch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!removetwitch` by itself to unlink your Twitch channel.", channel)) {
return false;
}
try {
await member.removeTwitchName();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your Twitch channel is now unlinked.`, channel);
return true;
} | async removetwitch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!removetwitch` by itself to unlink your Twitch channel.", channel)) {
return false;
}
try {
await member.removeTwitchName();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your Twitch channel is now unlinked.`, channel);
return true;
} |
JavaScript | async streaming(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!streaming` by itself to indicate that you will be streaming this match.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
const twitchName = await Commands.checkMemberHasTwitchName(member, channel);
try {
await challenge.addStreamer(member, twitchName);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async streaming(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!streaming` by itself to indicate that you will be streaming this match.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
const twitchName = await Commands.checkMemberHasTwitchName(member, channel);
try {
await challenge.addStreamer(member, twitchName);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async notstreaming(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!notstreaming` by itself to indicate that you will not be streaming the match.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
try {
await challenge.removeStreamer(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async notstreaming(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!notstreaming` by itself to indicate that you will not be streaming the match.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
try {
await challenge.removeStreamer(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async cast(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (!await Commands.checkHasParameters(message, member, "To cast a match, use the command along with the challenge ID of the match you wish to cast, for example `!cast 1`.", channel)) {
return false;
}
await Commands.checkMemberHasTwitchName(member, channel);
if (message.toLowerCase() === "next") {
let matches;
try {
matches = await Match.getUpcoming();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
const uncastedMatches = matches.filter((m) => !m.twitchName);
if (uncastedMatches.length === 0) {
await Discord.queue("There are no matches without a caster currently scheduled.", channel);
} else {
await Discord.queue(`The next match is **${uncastedMatches[0].challengingTeamName}** vs **${uncastedMatches[0].challengedTeamName}** at ${uncastedMatches[0].matchTime.toLocaleString("en-US", {timeZone: await member.getTimezone(), month: "numeric", day: "numeric", year: "numeric", hour12: true, hour: "numeric", minute: "2-digit", timeZoneName: "short"})}. If you wish to cast this match, enter \`!cast ${uncastedMatches[0].challengeId}\`. To see other upcoming matches, enter \`!mynext\`.`, channel);
}
return true;
}
if (!numberParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must use \`!cast\` along with the challenge ID of the match you wish to cast, for example \`!cast 1\`.`, channel);
return false;
}
const challengeId = +message || 0,
challenge = await Commands.checkChallengeIdExists(challengeId, member, channel);
if (!challenge) {
await Discord.queue(`Sorry, ${member}, but I can't find an active challenge with that ID.`, channel);
throw new Warning("Invalid challenge.");
}
await Commands.checkChallengeDetails(challenge, member, channel);
if (challenge.details.caster) {
await Discord.queue(`Sorry, ${member}, but ${challenge.details.caster} is already scheduled to cast this match.`, channel);
throw new Warning("Caster is already set.");
}
if (!challenge.details.matchTime) {
await Discord.queue(`Sorry, ${member}, but this match has not been scheduled yet.`, channel);
throw new Warning("Match not scheduled.");
}
try {
await challenge.setCaster(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (challenge.channel) {
await Discord.queue(`${member}, you are now scheduled to cast the match between **${challenge.challengingTeam.name}** and **${challenge.challengedTeam.name}**! Use ${challenge.channel} to coordinate with the pilots who will be streaming the match. Be sure to use https://otl.gg/cast/${challenge.id} to help you cast this match. If you no longer wish to cast this match, use the \`!uncast\` command in ${challenge.channel}.`, member);
} else {
await Discord.queue(`${member}, you have been recorded as casting the match between **${challenge.challengingTeam.name}** and **${challenge.challengedTeam.name}**.`, member);
}
return true;
} | async cast(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
if (!await Commands.checkHasParameters(message, member, "To cast a match, use the command along with the challenge ID of the match you wish to cast, for example `!cast 1`.", channel)) {
return false;
}
await Commands.checkMemberHasTwitchName(member, channel);
if (message.toLowerCase() === "next") {
let matches;
try {
matches = await Match.getUpcoming();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
const uncastedMatches = matches.filter((m) => !m.twitchName);
if (uncastedMatches.length === 0) {
await Discord.queue("There are no matches without a caster currently scheduled.", channel);
} else {
await Discord.queue(`The next match is **${uncastedMatches[0].challengingTeamName}** vs **${uncastedMatches[0].challengedTeamName}** at ${uncastedMatches[0].matchTime.toLocaleString("en-US", {timeZone: await member.getTimezone(), month: "numeric", day: "numeric", year: "numeric", hour12: true, hour: "numeric", minute: "2-digit", timeZoneName: "short"})}. If you wish to cast this match, enter \`!cast ${uncastedMatches[0].challengeId}\`. To see other upcoming matches, enter \`!mynext\`.`, channel);
}
return true;
}
if (!numberParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must use \`!cast\` along with the challenge ID of the match you wish to cast, for example \`!cast 1\`.`, channel);
return false;
}
const challengeId = +message || 0,
challenge = await Commands.checkChallengeIdExists(challengeId, member, channel);
if (!challenge) {
await Discord.queue(`Sorry, ${member}, but I can't find an active challenge with that ID.`, channel);
throw new Warning("Invalid challenge.");
}
await Commands.checkChallengeDetails(challenge, member, channel);
if (challenge.details.caster) {
await Discord.queue(`Sorry, ${member}, but ${challenge.details.caster} is already scheduled to cast this match.`, channel);
throw new Warning("Caster is already set.");
}
if (!challenge.details.matchTime) {
await Discord.queue(`Sorry, ${member}, but this match has not been scheduled yet.`, channel);
throw new Warning("Match not scheduled.");
}
try {
await challenge.setCaster(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (challenge.channel) {
await Discord.queue(`${member}, you are now scheduled to cast the match between **${challenge.challengingTeam.name}** and **${challenge.challengedTeam.name}**! Use ${challenge.channel} to coordinate with the pilots who will be streaming the match. Be sure to use https://otl.gg/cast/${challenge.id} to help you cast this match. If you no longer wish to cast this match, use the \`!uncast\` command in ${challenge.channel}.`, member);
} else {
await Discord.queue(`${member}, you have been recorded as casting the match between **${challenge.challengingTeam.name}** and **${challenge.challengedTeam.name}**.`, member);
}
return true;
} |
JavaScript | async uncast(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!uncast` by itself to indicate that you will not be casting the match.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (!challenge.details.caster) {
await Discord.queue(`Sorry, ${member}, but no one is scheduled to cast this match yet. Did you mean to \`!cast ${challenge.id}\` instead?`, channel);
throw new Warning("Caster is not set.");
}
if (challenge.details.caster.id !== member.id) {
await Discord.queue(`Sorry, ${member}, but ${challenge.details.caster} is scheduled to cast this match, not you.`, channel);
throw new Warning("Caster is already set.");
}
try {
await challenge.unsetCaster(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (challenge.channel) {
await Discord.queue(`${member}, you are no longer scheduled to cast the match, and have been removed from ${challenge.channel}.`, member);
} else {
await Discord.queue(`${member}, you are no longer scheduled to cast the match.`, member);
}
return true;
} | async uncast(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
if (!await Commands.checkNoParameters(message, member, "Use `!uncast` by itself to indicate that you will not be casting the match.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (!challenge.details.caster) {
await Discord.queue(`Sorry, ${member}, but no one is scheduled to cast this match yet. Did you mean to \`!cast ${challenge.id}\` instead?`, channel);
throw new Warning("Caster is not set.");
}
if (challenge.details.caster.id !== member.id) {
await Discord.queue(`Sorry, ${member}, but ${challenge.details.caster} is scheduled to cast this match, not you.`, channel);
throw new Warning("Caster is already set.");
}
try {
await challenge.unsetCaster(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (challenge.channel) {
await Discord.queue(`${member}, you are no longer scheduled to cast the match, and have been removed from ${challenge.channel}.`, member);
} else {
await Discord.queue(`${member}, you are no longer scheduled to cast the match.`, member);
}
return true;
} |
JavaScript | async vod(member, channel, message) {
if (!await Commands.checkHasParameters(message, member, "To submit a VoD, enter the command followed by the challenge ID and the URL of the VoD, for example `!vod 125 https://twitch.tv/videos/12345`.", channel)) {
return false;
}
if (!vodParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but to submit a VoD, enter the command followed by the challenge ID and the URL of the VoD, for example \`!vod 125 https://twitch.tv/videos/12345\`.`, channel);
return false;
}
const {groups: {challengeId, vod}} = vodParse.exec(message);
const challenge = await Commands.checkChallengeIdExists(+challengeId, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsConfirmed(challenge, member, channel);
if (!challenge.details.caster) {
await Discord.queue(`Sorry, ${member}, but no one cast this match.`, channel);
throw new Warning("Caster is not set.");
}
if (challenge.details.caster.id !== member.id) {
await Discord.queue(`Sorry, ${member}, but ${challenge.details.caster} cast this match already.`, channel);
throw new Warning("Caster is already set.");
}
try {
await challenge.setVoD(vod);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (vod && vod.length > 0) {
await Discord.queue(`${member}, you have successfully added the VoD <${vod}> to challenge ${challenge.id} between **${challenge.challengingTeam.tag}** and **${challenge.challengedTeam.tag}**.`, member);
} else {
await Discord.queue(`${member}, you have cleared the VoD for challenge ${challenge.id} between **${challenge.challengingTeam.tag}** and **${challenge.challengedTeam.tag}**.`, member);
}
return true;
} | async vod(member, channel, message) {
if (!await Commands.checkHasParameters(message, member, "To submit a VoD, enter the command followed by the challenge ID and the URL of the VoD, for example `!vod 125 https://twitch.tv/videos/12345`.", channel)) {
return false;
}
if (!vodParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but to submit a VoD, enter the command followed by the challenge ID and the URL of the VoD, for example \`!vod 125 https://twitch.tv/videos/12345\`.`, channel);
return false;
}
const {groups: {challengeId, vod}} = vodParse.exec(message);
const challenge = await Commands.checkChallengeIdExists(+challengeId, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsConfirmed(challenge, member, channel);
if (!challenge.details.caster) {
await Discord.queue(`Sorry, ${member}, but no one cast this match.`, channel);
throw new Warning("Caster is not set.");
}
if (challenge.details.caster.id !== member.id) {
await Discord.queue(`Sorry, ${member}, but ${challenge.details.caster} cast this match already.`, channel);
throw new Warning("Caster is already set.");
}
try {
await challenge.setVoD(vod);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (vod && vod.length > 0) {
await Discord.queue(`${member}, you have successfully added the VoD <${vod}> to challenge ${challenge.id} between **${challenge.challengingTeam.tag}** and **${challenge.challengedTeam.tag}**.`, member);
} else {
await Discord.queue(`${member}, you have cleared the VoD for challenge ${challenge.id} between **${challenge.challengingTeam.tag}** and **${challenge.challengedTeam.tag}**.`, member);
}
return true;
} |
JavaScript | async report(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To report a completed match, enter the command followed by the score, using a space to separate the scores, for example `!report 49 27`. Note that only the losing team should report the score.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
await Commands.checkChallengeMapIsSet(challenge, member, channel);
await Commands.checkChallengeTeamSizeIsSet(challenge, member, channel);
await Commands.checkChallengeMatchTimeIsSet(challenge, member, channel);
if (!scoreParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but to report a completed match, enter the command followed by either the score using a space to separate the scores, for example \`!report 49 27\`, or with a URL to the tracker game played, for example \`report https://tracker.otl.gg/archive/12345\`. Note that only the losing team should report the score.`, channel);
return false;
}
const {groups: {scoreStr1, scoreStr2, gameId}} = scoreParse.exec(message);
let score1, score2;
if (gameId) {
try {
await challenge.addStats(+gameId, {}, true);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a problem with adding this match using the tracker URL. You can still report the score of this match using \`!report\` followed by the score using a space to separate the scores, for example \`!report 49 27\`.`, channel);
throw new Exception(err.message, err);
}
score1 = challenge.details.challengingTeamScore;
score2 = challenge.details.challengedTeamScore;
} else {
const details = await challenge.getTeamDetails();
if (details.stats.length > 0) {
await challenge.clearStats(member);
}
score1 = +scoreStr1;
score2 = +scoreStr2;
}
if (score2 > score1) {
[score1, score2] = [score2, score1];
}
try {
await challenge.reportMatch(team, score1, score2, !!gameId);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async report(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkHasParameters(message, member, "To report a completed match, enter the command followed by the score, using a space to separate the scores, for example `!report 49 27`. Note that only the losing team should report the score.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
await Commands.checkChallengeMapIsSet(challenge, member, channel);
await Commands.checkChallengeTeamSizeIsSet(challenge, member, channel);
await Commands.checkChallengeMatchTimeIsSet(challenge, member, channel);
if (!scoreParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but to report a completed match, enter the command followed by either the score using a space to separate the scores, for example \`!report 49 27\`, or with a URL to the tracker game played, for example \`report https://tracker.otl.gg/archive/12345\`. Note that only the losing team should report the score.`, channel);
return false;
}
const {groups: {scoreStr1, scoreStr2, gameId}} = scoreParse.exec(message);
let score1, score2;
if (gameId) {
try {
await challenge.addStats(+gameId, {}, true);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a problem with adding this match using the tracker URL. You can still report the score of this match using \`!report\` followed by the score using a space to separate the scores, for example \`!report 49 27\`.`, channel);
throw new Exception(err.message, err);
}
score1 = challenge.details.challengingTeamScore;
score2 = challenge.details.challengedTeamScore;
} else {
const details = await challenge.getTeamDetails();
if (details.stats.length > 0) {
await challenge.clearStats(member);
}
score1 = +scoreStr1;
score2 = +scoreStr2;
}
if (score2 > score1) {
[score1, score2] = [score2, score1];
}
try {
await challenge.reportMatch(team, score1, score2, !!gameId);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async confirm(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!confirm` by itself to confirm your opponent's match report.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (!challenge.details.dateReported) {
await Discord.queue(`Sorry, ${member}, but this match hasn't been reported yet. Use the \`!report\` command if you meant to report the score of the match.`, channel);
throw new Warning("Match not reported.");
}
if (!challenge.details.reportingTeam) {
if (!challenge.details.dateConfirmed) {
await Discord.queue(`Sorry, ${member}, but this match has already been confirmed.`, channel);
throw new Warning("Match was already confirmed.");
}
await Discord.queue(`Sorry, ${member}, but there was a conflict while reporting this match.`, channel);
throw new Warning("Conflict while reporting match.");
}
if (team.id === challenge.details.reportingTeam.id) {
await Discord.queue(`Sorry, ${member}, but you can't confirm your own team's report.`, channel);
throw new Warning("Can't confirm own report.");
}
await challenge.confirmMatch();
return true;
} | async confirm(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!confirm` by itself to confirm your opponent's match report.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsNotConfirmed(challenge, member, channel);
if (!challenge.details.dateReported) {
await Discord.queue(`Sorry, ${member}, but this match hasn't been reported yet. Use the \`!report\` command if you meant to report the score of the match.`, channel);
throw new Warning("Match not reported.");
}
if (!challenge.details.reportingTeam) {
if (!challenge.details.dateConfirmed) {
await Discord.queue(`Sorry, ${member}, but this match has already been confirmed.`, channel);
throw new Warning("Match was already confirmed.");
}
await Discord.queue(`Sorry, ${member}, but there was a conflict while reporting this match.`, channel);
throw new Warning("Conflict while reporting match.");
}
if (team.id === challenge.details.reportingTeam.id) {
await Discord.queue(`Sorry, ${member}, but you can't confirm your own team's report.`, channel);
throw new Warning("Can't confirm own report.");
}
await challenge.confirmMatch();
return true;
} |
JavaScript | async rematch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!rematch` by itself to request a rematch.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsConfirmed(challenge, member, channel);
if (challenge.details.dateRematched) {
await Discord.queue(`Sorry, ${member}, but a rematch for this challenge has already been created.`, channel);
throw new Warning("Already rematched.");
}
if (challenge.details.rematchTeam && team.id === challenge.details.rematchTeam.id) {
await Discord.queue(`Sorry, ${member}, but your team already requested a rematch, the other team must also request a \`!rematch\` for the new challenge to be created.`, channel);
throw new Warning("Can't confirm own report.");
}
if (challenge.details.dateRematchRequested) {
await challenge.createRematch(team);
} else {
await challenge.requestRematch(team);
}
return true;
} | async rematch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsCaptainOrFounder(member, channel);
if (!await Commands.checkNoParameters(message, member, "Use `!rematch` by itself to request a rematch.", channel)) {
return false;
}
const team = await Commands.checkMemberOnTeam(member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
await Commands.checkChallengeDetails(challenge, member, channel);
await Commands.checkChallengeIsNotVoided(challenge, member, channel);
await Commands.checkChallengeIsConfirmed(challenge, member, channel);
if (challenge.details.dateRematched) {
await Discord.queue(`Sorry, ${member}, but a rematch for this challenge has already been created.`, channel);
throw new Warning("Already rematched.");
}
if (challenge.details.rematchTeam && team.id === challenge.details.rematchTeam.id) {
await Discord.queue(`Sorry, ${member}, but your team already requested a rematch, the other team must also request a \`!rematch\` for the new challenge to be created.`, channel);
throw new Warning("Can't confirm own report.");
}
if (challenge.details.dateRematchRequested) {
await challenge.createRematch(team);
} else {
await challenge.requestRematch(team);
}
return true;
} |
JavaScript | async teamtimezone(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must specify a time zone with this command.", channel)) {
return false;
}
await Commands.checkTimezoneIsValid(message, member, channel);
try {
await team.setTimezone(message);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your team's time zone is now set.`, channel);
return true;
} | async teamtimezone(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsFounder(member, channel);
const team = await Commands.checkMemberOnTeam(member, channel);
if (!await Commands.checkHasParameters(message, member, "You must specify a time zone with this command.", channel)) {
return false;
}
await Commands.checkTimezoneIsValid(message, member, channel);
try {
await team.setTimezone(message);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, your team's time zone is now set.`, channel);
return true;
} |
JavaScript | async rename(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the team tag followed by the new team name to rename a team, for example `!rename CF Juno Offworld Automation`.", channel)) {
return false;
}
if (!teamTagteamNameParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must specify the team tag followed by the new team name to rename a team, for example \`!rename CF Juno Offworld Automation\`.`, channel);
throw new Warning("Invalid parameters.");
}
const {groups: {teamTag, teamName}} = teamTagteamNameParse.exec(message),
team = await Commands.checkTeamExists(teamTag, member, channel);
if (Team.nameExists(teamName)) {
await Discord.queue(`Sorry, ${member}, but there is already a team named ${teamName}.`, channel);
throw new Warning("Team name already exists.");
}
try {
await team.rename(teamName, member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error.`, channel);
throw err;
}
return true;
} | async rename(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the team tag followed by the new team name to rename a team, for example `!rename CF Juno Offworld Automation`.", channel)) {
return false;
}
if (!teamTagteamNameParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must specify the team tag followed by the new team name to rename a team, for example \`!rename CF Juno Offworld Automation\`.`, channel);
throw new Warning("Invalid parameters.");
}
const {groups: {teamTag, teamName}} = teamTagteamNameParse.exec(message),
team = await Commands.checkTeamExists(teamTag, member, channel);
if (Team.nameExists(teamName)) {
await Discord.queue(`Sorry, ${member}, but there is already a team named ${teamName}.`, channel);
throw new Warning("Team name already exists.");
}
try {
await team.rename(teamName, member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error.`, channel);
throw err;
}
return true;
} |
JavaScript | async retag(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the old team tag followed by the new team tag to rename a team tag, for example `!retag CF JOA`.", channel)) {
return false;
}
if (!twoTeamTagParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must specify the old team tag followed by the new team tag to rename a team tag, for example \`!rename CF JOA\`.`, channel);
throw new Warning("Invalid parameters.");
}
const {groups: {teamTag1, teamTag2}} = twoTeamTagParse.exec(message),
team = await Commands.checkTeamExists(teamTag1, member, channel);
const tag = teamTag2.toUpperCase();
if (Team.tagExists(tag)) {
await Discord.queue(`Sorry, ${member}, but there is already a team with a tag of ${tag}.`, channel);
throw new Warning("Team tag already exists.");
}
try {
await team.retag(tag, member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error.`, channel);
throw err;
}
return true;
} | async retag(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the old team tag followed by the new team tag to rename a team tag, for example `!retag CF JOA`.", channel)) {
return false;
}
if (!twoTeamTagParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must specify the old team tag followed by the new team tag to rename a team tag, for example \`!rename CF JOA\`.`, channel);
throw new Warning("Invalid parameters.");
}
const {groups: {teamTag1, teamTag2}} = twoTeamTagParse.exec(message),
team = await Commands.checkTeamExists(teamTag1, member, channel);
const tag = teamTag2.toUpperCase();
if (Team.tagExists(tag)) {
await Discord.queue(`Sorry, ${member}, but there is already a team with a tag of ${tag}.`, channel);
throw new Warning("Team tag already exists.");
}
try {
await team.retag(tag, member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error.`, channel);
throw err;
}
return true;
} |
JavaScript | async replacefounder(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the team and mention the pilot, for example, `!replacefounder CF @roncli`.", channel)) {
return false;
}
if (!teamPilotParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must specify the team and mention the pilot, for example, \`!replacefounder CF @roncli\`.`, channel);
throw new Warning("Invalid parameters.");
}
const {groups: {teamName, id}} = teamPilotParse.exec(message);
const team = await Commands.checkTeamExists(teamName, member, channel),
pilot = await Commands.checkPilotExists(id, member, channel);
await Commands.checkPilotOnTeam(team, pilot, member, channel);
await Commands.checkPilotCanBeCaptain(pilot, member, channel);
try {
await team.replaceFounder(pilot, member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error.`, channel);
throw err;
}
return true;
} | async replacefounder(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the team and mention the pilot, for example, `!replacefounder CF @roncli`.", channel)) {
return false;
}
if (!teamPilotParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must specify the team and mention the pilot, for example, \`!replacefounder CF @roncli\`.`, channel);
throw new Warning("Invalid parameters.");
}
const {groups: {teamName, id}} = teamPilotParse.exec(message);
const team = await Commands.checkTeamExists(teamName, member, channel),
pilot = await Commands.checkPilotExists(id, member, channel);
await Commands.checkPilotOnTeam(team, pilot, member, channel);
await Commands.checkPilotCanBeCaptain(pilot, member, channel);
try {
await team.replaceFounder(pilot, member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error.`, channel);
throw err;
}
return true;
} |
JavaScript | async ejectcaptain(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the captain to eject with this command.", channel)) {
return false;
}
const captain = await Commands.checkPilotExists(message, member, channel),
isCaptain = captain.isCaptainOrFounder(),
isFounder = captain.isFounder();
if (isFounder || !isCaptain) {
await Discord.queue(`Sorry, ${member}, but ${captain.displayName} is not a captain!`, channel);
throw new Warning("Pilot is not a captain.");
}
const team = await captain.getTeam();
try {
await team.removeCaptain(member, captain);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, ${captain.displayName} has been removed as a captain.`, channel);
return true;
} | async ejectcaptain(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the captain to eject with this command.", channel)) {
return false;
}
const captain = await Commands.checkPilotExists(message, member, channel),
isCaptain = captain.isCaptainOrFounder(),
isFounder = captain.isFounder();
if (isFounder || !isCaptain) {
await Discord.queue(`Sorry, ${member}, but ${captain.displayName} is not a captain!`, channel);
throw new Warning("Pilot is not a captain.");
}
const team = await captain.getTeam();
try {
await team.removeCaptain(member, captain);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, ${captain.displayName} has been removed as a captain.`, channel);
return true;
} |
JavaScript | async ejectpilot(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the pilot to eject with this command.", channel)) {
return false;
}
const pilot = await Commands.checkPilotExists(message, member, channel),
team = await pilot.getTeam();
if (!team) {
await Discord.queue(`Sorry, ${member}, but ${pilot.displayName} is not on a team!`, channel);
throw new Warning("Pilot is not on a team.");
}
const isFounder = pilot.isFounder();
if (isFounder) {
await Discord.queue(`Sorry, ${member}, but ${pilot.displayName} is the founder. Use the \`!replacefounder\` command for this team before ejecting this pilot.`, channel);
throw new Warning("Pilot is the team's founder.");
}
try {
await team.removePilot(member, pilot);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, ${pilot.displayName} has been removed from their team.`, channel);
return true;
} | async ejectpilot(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the pilot to eject with this command.", channel)) {
return false;
}
const pilot = await Commands.checkPilotExists(message, member, channel),
team = await pilot.getTeam();
if (!team) {
await Discord.queue(`Sorry, ${member}, but ${pilot.displayName} is not on a team!`, channel);
throw new Warning("Pilot is not on a team.");
}
const isFounder = pilot.isFounder();
if (isFounder) {
await Discord.queue(`Sorry, ${member}, but ${pilot.displayName} is the founder. Use the \`!replacefounder\` command for this team before ejecting this pilot.`, channel);
throw new Warning("Pilot is the team's founder.");
}
try {
await team.removePilot(member, pilot);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
await Discord.queue(`${member}, ${pilot.displayName} has been removed from their team.`, channel);
return true;
} |
JavaScript | async creatematch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the two teams to create a match for, along with the optional game type.", channel)) {
return false;
}
if (!createMatchParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must specify the two teams to create a match for, along with the optional game type.`, channel);
throw new Warning("Invalid parameters.");
}
const {groups: {teamTag1, teamTag2, gameType, number}} = createMatchParse.exec(message),
gameTypeUpper = gameType ? gameType.toUpperCase() : "TA";
const team1 = await Commands.checkTeamExists(teamTag1, member, channel);
if (team1.disbanded) {
await Discord.queue(`Sorry, ${member}, but **${team1.name}** is disbanded.`, channel);
throw new Warning("Team disbanded.");
}
let team1PilotCount;
try {
team1PilotCount = await team1.getPilotCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (team1PilotCount < 2) {
await Discord.queue(`Sorry, ${member}, but **${team1.name}** must have 2 or more pilots to be in a match.`, channel);
throw new Warning("Team only has one member.");
}
let team1HomeMaps;
try {
team1HomeMaps = await team1.getHomeMapsByType();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (gameTypeUpper === "TA") {
if (!team1HomeMaps.CTF || !team1HomeMaps["2v2"] || team1PilotCount >= 3 && !team1HomeMaps["3v3"] || team1PilotCount >= 4 && !team1HomeMaps["4v4+"] || team1HomeMaps["2v2"].length !== 5 || team1PilotCount >= 3 && team1HomeMaps["3v3"].length !== 5 || team1PilotCount >= 4 && team1HomeMaps["4v4+"].length !== 5) {
await Discord.queue(`Sorry, ${member}, but **${team1.name}** must have 5 home maps set for each category in the specified game type to be in a match.`, channel);
throw new Warning("Team does not have 5 home maps set for specified game type.");
}
} else if (!team1HomeMaps[gameTypeUpper] || team1HomeMaps[gameTypeUpper].length < 5) {
await Discord.queue(`Sorry, ${member}, but **${team1.name}** must have 5 home maps set for the specified game type to be in a match.`, channel);
throw new Warning("Team does not have 5 home maps set for specified game type.");
}
const team2 = await Commands.checkTeamExists(teamTag2, member, channel);
if (team2.disbanded) {
await Discord.queue(`Sorry, ${member}, but **${team2.name}** is disbanded.`, channel);
throw new Warning("Team disbanded.");
}
let team2PilotCount;
try {
team2PilotCount = await team2.getPilotCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (team2PilotCount < 2) {
await Discord.queue(`Sorry, ${member}, but **${team2.name}** must have 2 or more pilots to be in a match.`, channel);
throw new Warning("Team only has one member.");
}
let team2HomeMaps;
try {
team2HomeMaps = await team2.getHomeMapsByType();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (gameTypeUpper === "TA") {
if (!team2HomeMaps.CTF || !team2HomeMaps["2v2"] || team2PilotCount >= 3 && !team2HomeMaps["3v3"] || team2PilotCount >= 4 && !team2HomeMaps["4v4+"] || team2HomeMaps["2v2"].length !== 5 || team2PilotCount >= 3 && team2HomeMaps["3v3"].length !== 5 || team2PilotCount >= 4 && team2HomeMaps["4v4+"].length !== 5) {
await Discord.queue(`Sorry, ${member}, but **${team2.name}** must have 5 home maps set for each category in the specified game type to be in a match.`, channel);
throw new Warning("Team does not have 5 home maps set for specified game type.");
}
} else if (!team2HomeMaps[gameTypeUpper] || team2HomeMaps[gameTypeUpper].length < 5) {
await Discord.queue(`Sorry, ${member}, but **${team2.name}** must have 5 home maps set for the specified game type to be in a match.`, channel);
throw new Warning("Team does not have 5 home maps set for specified game type.");
}
try {
await Challenge.create(team1, team2, {gameType: gameTypeUpper, adminCreated: true, number: number ? +number : 1});
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async creatematch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "You must specify the two teams to create a match for, along with the optional game type.", channel)) {
return false;
}
if (!createMatchParse.test(message)) {
await Discord.queue(`Sorry, ${member}, but you must specify the two teams to create a match for, along with the optional game type.`, channel);
throw new Warning("Invalid parameters.");
}
const {groups: {teamTag1, teamTag2, gameType, number}} = createMatchParse.exec(message),
gameTypeUpper = gameType ? gameType.toUpperCase() : "TA";
const team1 = await Commands.checkTeamExists(teamTag1, member, channel);
if (team1.disbanded) {
await Discord.queue(`Sorry, ${member}, but **${team1.name}** is disbanded.`, channel);
throw new Warning("Team disbanded.");
}
let team1PilotCount;
try {
team1PilotCount = await team1.getPilotCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (team1PilotCount < 2) {
await Discord.queue(`Sorry, ${member}, but **${team1.name}** must have 2 or more pilots to be in a match.`, channel);
throw new Warning("Team only has one member.");
}
let team1HomeMaps;
try {
team1HomeMaps = await team1.getHomeMapsByType();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (gameTypeUpper === "TA") {
if (!team1HomeMaps.CTF || !team1HomeMaps["2v2"] || team1PilotCount >= 3 && !team1HomeMaps["3v3"] || team1PilotCount >= 4 && !team1HomeMaps["4v4+"] || team1HomeMaps["2v2"].length !== 5 || team1PilotCount >= 3 && team1HomeMaps["3v3"].length !== 5 || team1PilotCount >= 4 && team1HomeMaps["4v4+"].length !== 5) {
await Discord.queue(`Sorry, ${member}, but **${team1.name}** must have 5 home maps set for each category in the specified game type to be in a match.`, channel);
throw new Warning("Team does not have 5 home maps set for specified game type.");
}
} else if (!team1HomeMaps[gameTypeUpper] || team1HomeMaps[gameTypeUpper].length < 5) {
await Discord.queue(`Sorry, ${member}, but **${team1.name}** must have 5 home maps set for the specified game type to be in a match.`, channel);
throw new Warning("Team does not have 5 home maps set for specified game type.");
}
const team2 = await Commands.checkTeamExists(teamTag2, member, channel);
if (team2.disbanded) {
await Discord.queue(`Sorry, ${member}, but **${team2.name}** is disbanded.`, channel);
throw new Warning("Team disbanded.");
}
let team2PilotCount;
try {
team2PilotCount = await team2.getPilotCount();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (team2PilotCount < 2) {
await Discord.queue(`Sorry, ${member}, but **${team2.name}** must have 2 or more pilots to be in a match.`, channel);
throw new Warning("Team only has one member.");
}
let team2HomeMaps;
try {
team2HomeMaps = await team2.getHomeMapsByType();
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
if (gameTypeUpper === "TA") {
if (!team2HomeMaps.CTF || !team2HomeMaps["2v2"] || team2PilotCount >= 3 && !team2HomeMaps["3v3"] || team2PilotCount >= 4 && !team2HomeMaps["4v4+"] || team2HomeMaps["2v2"].length !== 5 || team2PilotCount >= 3 && team2HomeMaps["3v3"].length !== 5 || team2PilotCount >= 4 && team2HomeMaps["4v4+"].length !== 5) {
await Discord.queue(`Sorry, ${member}, but **${team2.name}** must have 5 home maps set for each category in the specified game type to be in a match.`, channel);
throw new Warning("Team does not have 5 home maps set for specified game type.");
}
} else if (!team2HomeMaps[gameTypeUpper] || team2HomeMaps[gameTypeUpper].length < 5) {
await Discord.queue(`Sorry, ${member}, but **${team2.name}** must have 5 home maps set for the specified game type to be in a match.`, channel);
throw new Warning("Team does not have 5 home maps set for specified game type.");
}
try {
await Challenge.create(team1, team2, {gameType: gameTypeUpper, adminCreated: true, number: number ? +number : 1});
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async lockmatch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkNoParameters(message, member, "Use `!lockmatch` by itself to lock a challenge.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
if (challenge.details.adminCreated) {
await Discord.queue(`Sorry, ${member}, but this match is already locked.`, channel);
throw new Warning("Match already locked.");
}
try {
await challenge.lock(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async lockmatch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkNoParameters(message, member, "Use `!lockmatch` by itself to lock a challenge.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
if (challenge.details.adminCreated) {
await Discord.queue(`Sorry, ${member}, but this match is already locked.`, channel);
throw new Warning("Match already locked.");
}
try {
await challenge.lock(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async unlockmatch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkNoParameters(message, member, "Use `!unlockmatch` by itself to lock a challenge.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
if (!challenge.details.adminCreated) {
await Discord.queue(`Sorry, ${member}, but this match is already unlocked.`, channel);
throw new Warning("Match already unlocked.");
}
try {
await challenge.unlock(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async unlockmatch(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkNoParameters(message, member, "Use `!unlockmatch` by itself to lock a challenge.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
if (!challenge.details.adminCreated) {
await Discord.queue(`Sorry, ${member}, but this match is already unlocked.`, channel);
throw new Warning("Match already unlocked.");
}
try {
await challenge.unlock(member);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async forcehomemapteam(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "Use `!forcehomemapteam` along with the team you want to be the home map team.", channel)) {
return false;
}
const team = await Commands.checkTeamExists(message, member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
try {
await challenge.setHomeMapTeam(member, team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async forcehomemapteam(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "Use `!forcehomemapteam` along with the team you want to be the home map team.", channel)) {
return false;
}
const team = await Commands.checkTeamExists(message, member, channel);
await Commands.checkTeamIsInChallenge(challenge, team, member, channel);
try {
await challenge.setHomeMapTeam(member, team);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
JavaScript | async forcemap(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "Use `!forcemap` with either the letter of the home map to use or with a neutral home map.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
if (["a", "b", "c", "d", "e"].indexOf(message.toLowerCase()) !== -1) {
try {
await challenge.pickMap(message.toLowerCase().charCodeAt(0) - 96);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
}
const map = await Commands.checkMapIsValid(message, challenge.details.gameType, member, channel);
try {
await challenge.setMap(member, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} | async forcemap(member, channel, message) {
if (!Commands.checkChannelIsOnServer(channel)) {
return false;
}
const challenge = await Commands.checkChannelIsChallengeRoom(channel, member);
if (!challenge) {
return false;
}
await Commands.checkMemberIsOwner(member);
if (!await Commands.checkHasParameters(message, member, "Use `!forcemap` with either the letter of the home map to use or with a neutral home map.", channel)) {
return false;
}
await Commands.checkChallengeDetails(challenge, member, channel);
if (["a", "b", "c", "d", "e"].indexOf(message.toLowerCase()) !== -1) {
try {
await challenge.pickMap(message.toLowerCase().charCodeAt(0) - 96);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
}
const map = await Commands.checkMapIsValid(message, challenge.details.gameType, member, channel);
try {
await challenge.setMap(member, map.map);
} catch (err) {
await Discord.queue(`Sorry, ${member}, but there was a server error. An admin will be notified about this.`, channel);
throw err;
}
return true;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.