Skip to content

Commit

Permalink
fix: add game bet amount guess game (#1459)
Browse files Browse the repository at this point in the history
  • Loading branch information
namnhce authored Aug 21, 2023
1 parent 8f3cc30 commit 5dcf284
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions src/commands/guess/new/slash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,36 @@ import { SlashCommand } from "types/common"
import mochiGuess from "adapters/mochi-guess"
import { timeouts, timers } from ".."
import { truncate } from "lodash"
import { capitalizeFirst, equalIgnoreCase } from "utils/common"
import {
capitalizeFirst,
equalIgnoreCase,
getEmojiToken,
TokenEmojiKey,
} from "utils/common"
import { announceResult, cleanupAfterEndGame } from "../end/slash"
import { composeEmbedMessage } from "../../../ui/discord/embed"
function renderProgress(
referee: User,
question: string,
end: number,
code: string,
options: any[]
options: any[],
bet_default_value: number,
token_name: string
) {
const time = end <= Date.now() ? "0" : Math.round(end / 1000)
const msg1 = `:warning: The game will be closed <t:${time}:R>.\nPlease make sure you have submitted the answer and approved the mochi transaction.`
const msg2 = `**:hourglass:TIME'S UP**. We hope you enjoyed the game and learned something new. 🎉`

return [
`:video_game: **GUESS GAME**\n`,
`:game_die: \`ID. \` **${code}**`,
`:police_officer: \`Referee. \` <@${referee.id}>`,
`:question: \`Question. \` ${question}`,
`:game_die: \`ID. \` **${code}**`,
`:police_officer: \`Referee. \` <@${referee.id}>`,
`:moneybag: \`Bet Amount. \` ${bet_default_value} ${getEmojiToken(
token_name as TokenEmojiKey,
false
)} `,
`:question: \`Question. \` ${question}`,
"",
`${time === "0" ? msg2 : msg1}`,
"",
Expand Down Expand Up @@ -139,7 +150,15 @@ const slashCmd: SlashCommand = {

msg
.edit({
content: renderProgress(referee, question, end, data.code, options),
content: renderProgress(
referee,
question,
end,
data.code,
options,
data.bet_default_value,
data.token_name
),
})
.catch(() => null)
}
Expand Down Expand Up @@ -226,7 +245,15 @@ const slashCmd: SlashCommand = {
)

const msg = await thread.send({
content: renderProgress(referee, question, end, data.code, data.options),
content: renderProgress(
referee,
question,
end,
data.code,
data.options,
data.bet_default_value,
data.token_name
),
components: choices,
})

Expand Down

0 comments on commit 5dcf284

Please sign in to comment.