-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { UserError } from "@/lib/discord/UserError" | ||
import { getGame } from "@/lib/game" | ||
import { scoreGame } from "@/lib/game/scoreGame" | ||
import { type ButtonInteraction } from "discord.js" | ||
|
||
export default { | ||
id: "confirmScore", | ||
async execute(interaction: ButtonInteraction) { | ||
await interaction.deferReply({ ephemeral: true }) | ||
|
||
const score1 = parseInt(interaction.args.shift()!) | ||
const score2 = parseInt(interaction.args.shift()!) | ||
|
||
const game = await getGame(interaction.channelId) | ||
if (!game) throw new UserError("This command can only be used in game channels!") | ||
|
||
const success = await scoreGame(game, score1, score2) | ||
if (!success) throw new UserError("This game has already been scored.") | ||
|
||
return "Game scored." | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters