Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add game bet amount guess game #1459

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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