chore: some error protection
This commit is contained in:
parent
1c0144b076
commit
2034c56208
29
index.js
29
index.js
@ -766,17 +766,22 @@ client.on("interactionCreate", async (interaction) => {
|
|||||||
a.player.displayName.localeCompare(b.player.displayName)
|
a.player.displayName.localeCompare(b.player.displayName)
|
||||||
);
|
);
|
||||||
|
|
||||||
let teamStr = `${backticks}BLU:`;
|
try {
|
||||||
for (const player of bluPlayers) {
|
let teamStr = `${backticks}BLU:`;
|
||||||
teamStr += `\n${player.player.displayName}`;
|
for (const player of bluPlayers) {
|
||||||
}
|
teamStr += `\n${player.player.displayName}`;
|
||||||
teamStr += `\n\nRED:`;
|
}
|
||||||
for (const player of redPlayers) {
|
teamStr += `\n\nRED:`;
|
||||||
teamStr += `\n${player.player.displayName}`;
|
for (const player of redPlayers) {
|
||||||
}
|
teamStr += `\n${player.player.displayName}`;
|
||||||
teamStr += backticks;
|
}
|
||||||
|
teamStr += backticks;
|
||||||
|
|
||||||
await interaction.followUp(teamStr);
|
await interaction.followUp(teamStr);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
await interaction.followUp("Couldn't print teams before moving players");
|
||||||
|
}
|
||||||
|
|
||||||
let moveErr = 0;
|
let moveErr = 0;
|
||||||
|
|
||||||
@ -978,6 +983,10 @@ client.on("messageCreate", async (message) => {
|
|||||||
for (const [playerId, rank] of Object.entries(rankings)) {
|
for (const [playerId, rank] of Object.entries(rankings)) {
|
||||||
if (rank > 0) {
|
if (rank > 0) {
|
||||||
const player = await pickupGuild.members.fetch(playerId);
|
const player = await pickupGuild.members.fetch(playerId);
|
||||||
|
if (!player) {
|
||||||
|
console.error(`Could not find player ${playerId}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const applicableName = getApplicableName(player);
|
const applicableName = getApplicableName(player);
|
||||||
players.push({ name: applicableName, rank });
|
players.push({ name: applicableName, rank });
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user