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)
|
||||
);
|
||||
|
||||
let teamStr = `${backticks}BLU:`;
|
||||
for (const player of bluPlayers) {
|
||||
teamStr += `\n${player.player.displayName}`;
|
||||
}
|
||||
teamStr += `\n\nRED:`;
|
||||
for (const player of redPlayers) {
|
||||
teamStr += `\n${player.player.displayName}`;
|
||||
}
|
||||
teamStr += backticks;
|
||||
try {
|
||||
let teamStr = `${backticks}BLU:`;
|
||||
for (const player of bluPlayers) {
|
||||
teamStr += `\n${player.player.displayName}`;
|
||||
}
|
||||
teamStr += `\n\nRED:`;
|
||||
for (const player of redPlayers) {
|
||||
teamStr += `\n${player.player.displayName}`;
|
||||
}
|
||||
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;
|
||||
|
||||
@ -978,6 +983,10 @@ client.on("messageCreate", async (message) => {
|
||||
for (const [playerId, rank] of Object.entries(rankings)) {
|
||||
if (rank > 0) {
|
||||
const player = await pickupGuild.members.fetch(playerId);
|
||||
if (!player) {
|
||||
console.error(`Could not find player ${playerId}`);
|
||||
continue;
|
||||
}
|
||||
const applicableName = getApplicableName(player);
|
||||
players.push({ name: applicableName, rank });
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user