Merge pull request #114 from VashSoftware/invites_catch
.catch() for dm in invites.ts
This commit is contained in:
@@ -14,6 +14,8 @@ import { notifyMatchCreated, notifyMatchFinished } from '$lib/server/discord/cli
|
|||||||
import { updateElo } from './rating';
|
import { updateElo } from './rating';
|
||||||
import { getExpectedPicker, getMatchOrThrow, assertState, getMatchFull } from './helpers';
|
import { getExpectedPicker, getMatchOrThrow, assertState, getMatchFull } from './helpers';
|
||||||
|
|
||||||
|
export { getMatchFull, getMatchOrThrow };
|
||||||
|
|
||||||
// ── Create Match ────────────────────────────────────────────────────────
|
// ── Create Match ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export async function createMatch(opts: {
|
export async function createMatch(opts: {
|
||||||
|
|||||||
@@ -68,18 +68,14 @@ export async function createInvite(opts: {
|
|||||||
|
|
||||||
// Send Bancho DMs (best-effort)
|
// Send Bancho DMs (best-effort)
|
||||||
for (const member of invitedMembers) {
|
for (const member of invitedMembers) {
|
||||||
try {
|
const u = await db.query.user.findFirst({
|
||||||
const u = await db.query.user.findFirst({
|
where: eq(user.id, member.userId)
|
||||||
where: eq(user.id, member.userId)
|
});
|
||||||
});
|
if (u?.name) {
|
||||||
if (u?.name) {
|
sendDM(
|
||||||
await sendDM(
|
u.name,
|
||||||
u.name,
|
`Match invite: ${title}. Accept/decline at https://esports.vash.software/matches or reply !accept ${invite.id.slice(0, 8)}`
|
||||||
`Match invite: ${title}. Accept/decline at https://esports.vash.software/matches or reply !accept ${invite.id.slice(0, 8)}`
|
).catch(() => {}); // Silent best-effort
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// DM sending is best-effort
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user