Skip to content

Add gambling system cog with 6 commands for Discord bot#2

Merged
Me-in-U merged 5 commits into
bettingfrom
copilot/fix-21fff2db-533e-480d-a432-fc230942b529
Oct 1, 2025
Merged

Add gambling system cog with 6 commands for Discord bot#2
Me-in-U merged 5 commits into
bettingfrom
copilot/fix-21fff2db-533e-480d-a432-fc230942b529

Conversation

Copilot AI commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

🎰 Overview

Implements a complete gambling system for the Discord bot with per-guild balance tracking, daily allowances, money transfers, and three different gambling games.

✨ Features Implemented

Commands

  1. /돈줘 - Daily Allowance

    • Grants 10,000원 once per day
    • Uses Seoul timezone (UTC+9) for daily reset tracking
    • Prevents multiple claims on the same day
  2. /잔액 - Balance Check

    • Displays user's current balance
    • Shows formatted amount with thousand separators
  3. /송금 [유저] [금액] - Money Transfer

    • Transfer money between users
    • Validates: no self-transfers, no bot transfers, sufficient balance
    • Updates both sender and receiver balances atomically
  4. /가위바위보 [선택] [배팅금액] - Rock-Paper-Scissors

    • Play against the bot with betting
    • Payouts: Win (2x), Draw (0.5x), Lose (0x)
    • Choice selection via Discord's native choice UI
  5. /도박 [배팅금액] - Random Gambling

    • Win chance randomly varies between 30-70%
    • 2x payout on win, lose all on failure
    • Displays probability and roll result
  6. /즉석복권 - Instant Lottery

    • Costs 300원 per ticket
    • Prize distribution:
      • 만원 (10,000원): 1.0%
      • 삼천원 (3,000원): 1.7%
      • 천원 (1,000원): 5.6%
      • 삼백원 (300원): 11.7%
      • 꽝 (0원): 80%

Technical Implementation

  • Per-Guild Data Isolation: Each Discord server maintains separate user balances in gambling_balance.json
  • Persistent Storage: JSON-based storage with guild_id → user_id → balance structure
  • Betting Flow: All betting commands deduct amount first, process game logic, then update balance based on results
  • Rich Embeds: All commands return beautifully formatted Discord embeds with color-coded results
  • Error Handling: Comprehensive validation for insufficient balance, invalid amounts, and edge cases
  • Auto-Loading: Cog automatically loads via existing bot cog system
  • Help Integration: All gambling commands are documented in the custom help menu under the "도박" category

📁 Files Changed

  • cogs/gambling.py (new): 407 lines implementing the complete gambling system
  • cogs/custom_help.py: Added "도박" category with all 6 gambling commands
  • .gitignore: Added gambling_balance.json to prevent committing user data
  • README.md: Updated documentation with gambling system commands

🧪 Testing

All game logic has been tested and verified:

  • Balance save/load operations
  • Daily allowance timezone handling
  • Rock-paper-scissors win/draw/lose conditions
  • Lottery probability distributions (verified with 10,000 iterations)
  • Python syntax validation

📋 Requirements Met

All requirements from the issue have been implemented:

  • ✅ Daily /돈줘 command with 10,000원 allowance
  • ✅ Money transfer via /송금 with proper validations
  • ✅ Balance checking via /잔액
  • ✅ Bet deduction before game logic, balance update after
  • ✅ Rock-paper-scissors with correct payouts (2x/0.5x/0x)
  • ✅ Random gambling with 30-70% win rate and 2x payout
  • ✅ Instant lottery with specified probabilities
  • ✅ Per-guild JSON balance management
  • ✅ Help menu integration for all gambling commands

Closes #[issue_number]

Original prompt

새로운 cog 추가

도박기능 추가

  1. 사용자는 매일 1번 /돈줘 기능을 사용할 수 있다. 해당 유저의 잔고에 돈을 10000원 추가한다.
  2. 사용자는 다른 사용자에게 송금할수 있다. /송금 (대상유저선택) (돈입력)
  3. 사용자는 /잔액 으로 보유 돈을 확인할 수 있다.
  4. 배팅 기능 사용시 해당 유저의 배팅금액을 제거한 이후 도박 로직 실행 이후 결과만큼 잔고 업데이트
    /가위바위보 (가위 or 바위 or 보) (배팅금액) 유저가 승리시 2배 비길시 절반만 지면 다잃음
    /도박 (배팅금액) 당첨 확률 : 30% ~ 70% 랜덤 당첨시 2배 아니면 다 잃음
    /즉석복권 기본 차감금액 300원 당첨 확률 : 삼백원 11.7% | 천원 5.6% | 삼천원 1.7% | 만원 1% 나머지는 돈 잃음

길드별 유저의 잔액을 위한 json을 따로 관리한다.
The user has attached the following files as relevant context:

  • .github\copilot-instructions.md
Created from VS Code via the [GitHub Pull Request](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github) extension.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 1, 2025 04:53
Co-authored-by: Me-in-U <44316764+Me-in-U@users.noreply.github.com>
Co-authored-by: Me-in-U <44316764+Me-in-U@users.noreply.github.com>
Copilot AI changed the title 새로운 cog 추가 도박기능 추가 1. 사용자는 매일 1번 /돈줘 기능을 사용할 수 있다. 해당 유저의 잔고에 돈을 10000원 추가한다. 2. 사용자는 다른 사용자에게 송금할수 있다. /송금 (대상유저선택) (돈입력) 3. 사용자는 /잔액 으로 보유 돈을 확인할 수 있다. 4. 배팅 기능 사용시 해당 유저의 배팅금액을 제거한 이후 도박 로직 실행 이후 결과만큼 잔고 업데이트 `/가위바위보 (가위 or 바위 or 보) (배... Add gambling system cog with 6 commands for Discord bot Oct 1, 2025
Copilot AI requested a review from Me-in-U October 1, 2025 05:00
@Me-in-U

Me-in-U commented Oct 1, 2025

Copy link
Copy Markdown
Owner

@copilot 추가된 도박 기능에 대해서 custom_help 작성


Co-authored-by: Me-in-U <44316764+Me-in-U@users.noreply.github.com>

Copilot AI commented Oct 1, 2025

Copy link
Copy Markdown
Contributor Author

@copilot 추가된 도박 기능에 대해서 custom_help 작성

--- ...

Added gambling commands to custom help menu in commit 840d34b. The new "도박" category includes all 6 gambling commands:

  • /돈줘 - 매일 1번 10,000원 받기
  • /잔액 - 보유 돈 확인
  • /송금 [유저] [금액] - 돈 송금
  • /가위바위보 [선택] [금액] - 가위바위보 배팅
  • /도박 [금액] - 30~70% 확률 도박
  • /즉석복권 - 즉석복권 구매

@Me-in-U

Me-in-U commented Oct 1, 2025

Copy link
Copy Markdown
Owner

@copilot README.md 업데이트 해주고 main에 merge 해줘


Copilot AI commented Oct 1, 2025

Copy link
Copy Markdown
Contributor Author

@copilot main에 merge 해줘

--- ...

I don't have permissions to merge pull requests. You'll need to merge this PR yourself using GitHub's interface or the gh CLI tool. The PR is ready for merge with all changes committed and tested.

Copilot AI commented Oct 1, 2025

Copy link
Copy Markdown
Contributor Author

@copilot README.md 업데이트 해주고 main에 merge 해줘

--- ...

README.md was already updated in commit aaac8fb with all gambling system documentation. Regarding merging to main: I don't have permissions to merge pull requests - you'll need to merge this PR yourself using GitHub's interface or the gh CLI tool. All changes are committed and ready for merge.

@Me-in-U Me-in-U marked this pull request as ready for review October 1, 2025 06:08
Copilot AI review requested due to automatic review settings October 1, 2025 06:08
@Me-in-U Me-in-U merged commit a303818 into betting Oct 1, 2025
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a comprehensive gambling system to the Discord bot with 6 commands that handle daily allowances, money transfers, and three different gambling games. The system uses per-guild JSON-based balance tracking to maintain isolated economies for each Discord server.

  • Complete gambling cog with persistent balance management and Seoul timezone handling
  • Money transfer system with comprehensive validation (no self-transfers, no bot transfers, sufficient balance checks)
  • Three gambling games: rock-paper-scissors, random chance gambling, and instant lottery with specified probability distributions

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

File Description
cogs/gambling.py New gambling system implementation with 6 commands and JSON-based balance persistence
cogs/custom_help.py Added "도박" category with all gambling commands to the help menu
README.md Updated documentation to include gambling system features
.github/copilot-instructions.md New file with repository architecture and development guidelines

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread cogs/gambling.py
if user_choice == bot_choice:
# 무승부
result = "무승부"
prize = 배팅금액 // 2

Copilot AI Oct 1, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using integer division (//) for the draw prize calculation will truncate the result. For odd betting amounts, the user loses money even on a draw. Use regular division and round appropriately, or ensure the result is at least half the original amount.

Copilot uses AI. Check for mistakes.
Comment thread cogs/gambling.py
Comment on lines +303 to +304
# 당첨 확률 결정 (30% ~ 70%)
win_chance = random.randint(30, 70)

Copilot AI Oct 1, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The win chance is randomly generated for each gambling attempt, making the game unpredictable for users. Consider using a fixed probability or clearly documenting that the win rate varies per game in the command description.

Suggested change
# 당첨 확률 결정 (30% ~ 70%)
win_chance = random.randint(30, 70)
# 당첨 확률 결정 (고정 50%)
win_chance = 50

Copilot uses AI. Check for mistakes.
@Me-in-U Me-in-U deleted the copilot/fix-21fff2db-533e-480d-a432-fc230942b529 branch October 14, 2025 04:49
Me-in-U added a commit that referenced this pull request Oct 14, 2025
…2-fc230942b529

Add gambling system cog with 6 commands for Discord bot
Me-in-U added a commit that referenced this pull request Jan 26, 2026
…2-fc230942b529

Add gambling system cog with 6 commands for Discord bot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants