Advertisement
Ayan143

Match System

May 4th, 2025
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 22.39 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands, tasks
  3. from datetime import datetime, timedelta
  4. import asyncio
  5. import random
  6. import json
  7. import os
  8. from typing import Optional, Union, List, Dict
  9.  
  10. # Initialize bot with all required intents
  11. intents = discord.Intents.default()
  12. intents.members = True
  13. intents.message_content = True
  14.  
  15. bot = commands.Bot(command_prefix=".", intents=intents, case_insensitive=True)
  16.  
  17. # File to store data
  18. DATA_FILE = "relationships.json"
  19.  
  20. # Relationship types
  21. RELATIONSHIP_TYPES = {
  22.     "dating": "Dating",
  23.     "married": "Married",
  24.     "engaged": "Engaged",
  25.     "friends": "Friends with Benefits",
  26.     "complicated": "It's Complicated"
  27. }
  28.  
  29. # Load data from file
  30. def load_data():
  31.     if os.path.exists(DATA_FILE):
  32.         with open(DATA_FILE, 'r') as f:
  33.             return json.load(f)
  34.     return {"relationships": [], "proposals": [], "cooldowns": {}}
  35.  
  36. # Save data to file
  37. def save_data(data):
  38.     with open(DATA_FILE, 'w') as f:
  39.         json.dump(data, f, indent=4)
  40.  
  41. # Relationship class
  42. class Relationship:
  43.     def __init__(self, user1: int, user2: int, rel_type: str, since: str):
  44.         self.user1 = user1
  45.         self.user2 = user2
  46.         self.type = rel_type
  47.         self.since = since
  48.    
  49.     def to_dict(self):
  50.         return {
  51.             "user1": self.user1,
  52.             "user2": self.user2,
  53.             "type": self.type,
  54.             "since": self.since
  55.         }
  56.    
  57.     @classmethod
  58.     def from_dict(cls, data: dict):
  59.         return cls(data["user1"], data["user2"], data["type"], data["since"])
  60.    
  61.     def involves(self, user_id: int) -> bool:
  62.         return self.user1 == user_id or self.user2 == user_id
  63.    
  64.     def get_partner(self, user_id: int) -> int:
  65.         if self.user1 == user_id:
  66.             return self.user2
  67.         return self.user1
  68.    
  69.     def __contains__(self, user_id: int) -> bool:
  70.         return self.involves(user_id)
  71.  
  72. # Proposal class
  73. class Proposal:
  74.     def __init__(self, from_user: int, to_user: int, rel_type: str, expires: str):
  75.         self.from_user = from_user
  76.         self.to_user = to_user
  77.         self.type = rel_type
  78.         self.expires = expires
  79.    
  80.     def to_dict(self):
  81.         return {
  82.             "from_user": self.from_user,
  83.             "to_user": self.to_user,
  84.             "type": self.type,
  85.             "expires": self.expires
  86.         }
  87.    
  88.     @classmethod
  89.     def from_dict(cls, data: dict):
  90.         return cls(data["from_user"], data["to_user"], data["type"], data["expires"])
  91.    
  92.     def is_expired(self) -> bool:
  93.         return datetime.fromisoformat(self.expires) < datetime.utcnow()
  94.  
  95. # Cooldown tracker
  96. class CooldownTracker:
  97.     def __init__(self, user_id: int, command: str, expires: str):
  98.         self.user_id = user_id
  99.         self.command = command
  100.         self.expires = expires
  101.    
  102.     def to_dict(self):
  103.         return {
  104.             "user_id": self.user_id,
  105.             "command": self.command,
  106.             "expires": self.expires
  107.         }
  108.    
  109.     @classmethod
  110.     def from_dict(cls, data: dict):
  111.         return cls(data["user_id"], data["command"], data["expires"])
  112.    
  113.     def is_expired(self) -> bool:
  114.         return datetime.fromisoformat(self.expires) < datetime.utcnow()
  115.  
  116. # Initialize data
  117. bot.relationships = []
  118. bot.proposals = []
  119. bot.cooldowns = {}
  120.  
  121. # Load data on startup
  122. @bot.event
  123. async def on_ready():
  124.     print(f'Logged in as {bot.user.name} ({bot.user.id})')
  125.    
  126.     data = load_data()
  127.     bot.relationships = [Relationship.from_dict(r) for r in data.get("relationships", [])]
  128.     bot.proposals = [Proposal.from_dict(p) for p in data.get("proposals", [])]
  129.     bot.cooldowns = {k: CooldownTracker.from_dict(v) for k, v in data.get("cooldowns", {}).items()}
  130.    
  131.     # Start background tasks
  132.     cleanup_expired_data.start()
  133.     print('Bot is ready!')
  134.  
  135. # Background task to clean up expired data
  136. @tasks.loop(minutes=5)
  137. async def cleanup_expired_data():
  138.     # Clean expired proposals
  139.     bot.proposals = [p for p in bot.proposals if not p.is_expired()]
  140.    
  141.     # Clean expired cooldowns
  142.     bot.cooldowns = {k: v for k, v in bot.cooldowns.items() if not v.is_expired()}
  143.    
  144.     save_data({
  145.         "relationships": [r.to_dict() for r in bot.relationships],
  146.         "proposals": [p.to_dict() for p in bot.proposals],
  147.         "cooldowns": {k: v.to_dict() for k, v in bot.cooldowns.items()}
  148.     })
  149.  
  150. # Check if user is on cooldown for a command
  151. def check_cooldown(user_id: int, command: str, cooldown_seconds: int) -> Optional[str]:
  152.     key = f"{user_id}_{command}"
  153.     if key in bot.cooldowns and not bot.cooldowns[key].is_expired():
  154.         remaining = (datetime.fromisoformat(bot.cooldowns[key].expires) - datetime.utcnow()).total_seconds()
  155.         return f"You're on cooldown for this command. Try again in {int(remaining)} seconds."
  156.    
  157.     # Set new cooldown
  158.     expires = (datetime.utcnow() + timedelta(seconds=cooldown_seconds)).isoformat()
  159.     bot.cooldowns[key] = CooldownTracker(user_id, command, expires)
  160.     return None
  161.  
  162. # Get user's current relationship
  163. def get_relationship(user_id: int) -> Optional[Relationship]:
  164.     for rel in bot.relationships:
  165.         if rel.involves(user_id):
  166.             return rel
  167.     return None
  168.  
  169. # Check if proposal exists between users
  170. def get_proposal(from_user: int, to_user: int) -> Optional[Proposal]:
  171.     for prop in bot.proposals:
  172.         if prop.from_user == from_user and prop.to_user == to_user:
  173.             return prop
  174.     return None
  175.  
  176. # Relationship command group
  177. @bot.group(name="relationship", aliases=["rel", "r"], invoke_without_command=True)
  178. async def relationship(ctx):
  179.     """Main relationship command group"""
  180.     await ctx.send_help(ctx.command)
  181.  
  182. @relationship.command(name="status", aliases=["info", "check"])
  183. async def relationship_status(ctx, user: Optional[discord.Member] = None):
  184.     """Check your or someone else's relationship status"""
  185.     target = user or ctx.author
  186.     rel = get_relationship(target.id)
  187.    
  188.     if rel:
  189.         partner = await bot.fetch_user(rel.get_partner(target.id))
  190.         rel_type = RELATIONSHIP_TYPES.get(rel.type, rel.type.capitalize())
  191.         embed = discord.Embed(
  192.             title=f"{target.display_name}'s Relationship Status",
  193.             description=f"❤️ {target.display_name} is {rel_type.lower()} with {partner.mention} since {rel.since}",
  194.             color=discord.Color.pink()
  195.         )
  196.         await ctx.send(embed=embed)
  197.     else:
  198.         embed = discord.Embed(
  199.             title=f"{target.display_name}'s Relationship Status",
  200.             description="💔 Currently single",
  201.             color=discord.Color.light_grey()
  202.         )
  203.         await ctx.send(embed=embed)
  204.  
  205. @relationship.command(name="propose", aliases=["ask", "request"])
  206. async def relationship_propose(ctx, user: discord.Member, rel_type: str = "dating"):
  207.     """Propose a relationship to someone"""
  208.     # Validation checks
  209.     if user == ctx.author:
  210.         return await ctx.send("You can't propose to yourself!")
  211.    
  212.     if user.bot:
  213.         return await ctx.send("You can't propose to a bot!")
  214.    
  215.     if rel_type.lower() not in RELATIONSHIP_TYPES:
  216.         valid_types = ", ".join(RELATIONSHIP_TYPES.keys())
  217.         return await ctx.send(f"Invalid relationship type. Valid types are: {valid_types}")
  218.    
  219.     # Check existing relationships
  220.     if get_relationship(ctx.author.id):
  221.         return await ctx.send("You're already in a relationship!")
  222.    
  223.     if get_relationship(user.id):
  224.         return await ctx.send(f"{user.display_name} is already in a relationship!")
  225.    
  226.     # Check cooldown
  227.     cooldown_msg = check_cooldown(ctx.author.id, "propose", 3600)  # 1 hour cooldown
  228.     if cooldown_msg:
  229.         return await ctx.send(cooldown_msg)
  230.    
  231.     # Check for existing proposal
  232.     if get_proposal(ctx.author.id, user.id):
  233.         return await ctx.send("You already have a pending proposal with this user!")
  234.    
  235.     # Create proposal
  236.     expires = (datetime.utcnow() + timedelta(days=7)).isoformat()  # 7 days to respond
  237.     proposal = Proposal(ctx.author.id, user.id, rel_type.lower(), expires)
  238.     bot.proposals.append(proposal)
  239.    
  240.     save_data({
  241.         "relationships": [r.to_dict() for r in bot.relationships],
  242.         "proposals": [p.to_dict() for p in bot.proposals],
  243.         "cooldowns": {k: v.to_dict() for k, v in bot.cooldowns.items()}
  244.     })
  245.    
  246.     # Send proposal message
  247.     rel_type_display = RELATIONSHIP_TYPES.get(rel_type.lower(), rel_type.capitalize())
  248.     embed = discord.Embed(
  249.         title="💌 Relationship Proposal",
  250.         description=f"{ctx.author.mention} has proposed to {user.mention} to be {rel_type_display.lower()}!",
  251.         color=discord.Color.pink()
  252.     )
  253.     embed.add_field(name="To accept", value=f"Type `-relationship/rel/r accept {ctx.author.name}`")
  254.     embed.add_field(name="To reject", value=f"Type `-relationship/rel/r reject {ctx.author.name}`")
  255.     embed.set_footer(text="This proposal expires in 7 days")
  256.     await ctx.send(embed=embed)
  257.  
  258. @relationship.command(name="accept", aliases=["yes"])
  259. async def relationship_accept(ctx, user: discord.Member):
  260.     """Accept a relationship proposal"""
  261.     proposal = get_proposal(user.id, ctx.author.id)
  262.    
  263.     if not proposal:
  264.         return await ctx.send(f"No pending proposal from {user.display_name}!")
  265.    
  266.     # Remove the proposal
  267.     bot.proposals.remove(proposal)
  268.    
  269.     # Create the relationship
  270.     since = datetime.utcnow().isoformat()
  271.     relationship = Relationship(proposal.from_user, proposal.to_user, proposal.type, since)
  272.     bot.relationships.append(relationship)
  273.    
  274.     save_data({
  275.         "relationships": [r.to_dict() for r in bot.relationships],
  276.         "proposals": [p.to_dict() for p in bot.proposals],
  277.         "cooldowns": {k: v.to_dict() for k, v in bot.cooldowns.items()}
  278.     })
  279.    
  280.     # Send acceptance message
  281.     rel_type_display = RELATIONSHIP_TYPES.get(proposal.type, proposal.type.capitalize())
  282.     embed = discord.Embed(
  283.         title="💖 Relationship Formed",
  284.         description=f"{ctx.author.mention} has accepted {user.mention}'s proposal!",
  285.         color=discord.Color.green()
  286.     )
  287.     embed.add_field(name="Relationship Type", value=rel_type_display)
  288.     embed.add_field(name="Since", value=since)
  289.     await ctx.send(embed=embed)
  290.  
  291. @relationship.command(name="reject", aliases=["no", "decline"])
  292. async def relationship_reject(ctx, user: discord.Member):
  293.     """Reject a relationship proposal"""
  294.     proposal = get_proposal(user.id, ctx.author.id)
  295.    
  296.     if not proposal:
  297.         return await ctx.send(f"No pending proposal from {user.display_name}!")
  298.    
  299.     # Remove the proposal
  300.     bot.proposals.remove(proposal)
  301.    
  302.     save_data({
  303.         "relationships": [r.to_dict() for r in bot.relationships],
  304.         "proposals": [p.to_dict() for p in bot.proposals],
  305.         "cooldowns": {k: v.to_dict() for k, v in bot.cooldowns.items()}
  306.     })
  307.    
  308.     # Send rejection message
  309.     embed = discord.Embed(
  310.         title="💔 Proposal Rejected",
  311.         description=f"{ctx.author.mention} has rejected {user.mention}'s proposal.",
  312.         color=discord.Color.red()
  313.     )
  314.     await ctx.send(embed=embed)
  315.  
  316. @relationship.command(name="breakup", aliases=["divorce", "end"])
  317. async def relationship_breakup(ctx):
  318.     """End your current relationship"""
  319.     rel = get_relationship(ctx.author.id)
  320.    
  321.     if not rel:
  322.         return await ctx.send("You're not in a relationship!")
  323.    
  324.     # Get partner
  325.     partner_id = rel.get_partner(ctx.author.id)
  326.     partner = await bot.fetch_user(partner_id)
  327.    
  328.     # Remove relationship
  329.     bot.relationships.remove(rel)
  330.    
  331.     save_data({
  332.         "relationships": [r.to_dict() for r in bot.relationships],
  333.         "proposals": [p.to_dict() for p in bot.proposals],
  334.         "cooldowns": {k: v.to_dict() for k, v in bot.cooldowns.items()}
  335.     })
  336.    
  337.     # Send breakup message
  338.     embed = discord.Embed(
  339.         title="💔 Relationship Ended",
  340.         description=f"{ctx.author.mention} has ended their relationship with {partner.mention}.",
  341.         color=discord.Color.dark_red()
  342.     )
  343.     await ctx.send(embed=embed)
  344.  
  345. @relationship.command(name="upgrade", aliases=["promote"])
  346. async def relationship_upgrade(ctx, new_type: str):
  347.     """Upgrade your relationship type (e.g., from dating to married)"""
  348.     rel = get_relationship(ctx.author.id)
  349.    
  350.     if not rel:
  351.         return await ctx.send("You're not in a relationship!")
  352.    
  353.     if new_type.lower() not in RELATIONSHIP_TYPES:
  354.         valid_types = ", ".join(RELATIONSHIP_TYPES.keys())
  355.         return await ctx.send(f"Invalid relationship type. Valid types are: {valid_types}")
  356.    
  357.     # Check cooldown
  358.     cooldown_msg = check_cooldown(ctx.author.id, "upgrade", 86400)  # 24 hour cooldown
  359.     if cooldown_msg:
  360.         return await ctx.send(cooldown_msg)
  361.    
  362.     # Get partner
  363.     partner_id = rel.get_partner(ctx.author.id)
  364.    
  365.     # Create upgrade proposal
  366.     expires = (datetime.utcnow() + timedelta(days=7)).isoformat()  # 7 days to respond
  367.     proposal = Proposal(ctx.author.id, partner_id, new_type.lower(), expires)
  368.     bot.proposals.append(proposal)
  369.    
  370.     save_data({
  371.         "relationships": [r.to_dict() for r in bot.relationships],
  372.         "proposals": [p.to_dict() for p in bot.proposals],
  373.         "cooldowns": {k: v.to_dict() for k, v in bot.cooldowns.items()}
  374.     })
  375.    
  376.     # Send upgrade proposal
  377.     partner = await bot.fetch_user(partner_id)
  378.     new_type_display = RELATIONSHIP_TYPES.get(new_type.lower(), new_type.capitalize())
  379.     current_type_display = RELATIONSHIP_TYPES.get(rel.type, rel.type.capitalize())
  380.    
  381.     embed = discord.Embed(
  382.         title="💍 Relationship Upgrade Proposal",
  383.         description=f"{ctx.author.mention} wants to upgrade their relationship with {partner.mention} from {current_type_display} to {new_type_display}!",
  384.         color=discord.Color.gold()
  385.     )
  386.     embed.add_field(name="To accept", value=f"Type `-relationship/rel/r accept_upgrade {ctx.author.name}`")
  387.     embed.add_field(name="To reject", value=f"Type `-relationship/rel/r reject_upgrade {ctx.author.name}`")
  388.     embed.set_footer(text="This proposal expires in 7 days")
  389.     await ctx.send(embed=embed)
  390.  
  391. @relationship.command(name="accept_upgrade")
  392. async def relationship_accept_upgrade(ctx, user: discord.Member):
  393.     """Accept a relationship upgrade proposal"""
  394.     proposal = get_proposal(user.id, ctx.author.id)
  395.    
  396.     if not proposal:
  397.         return await ctx.send(f"No pending upgrade proposal from {user.display_name}!")
  398.    
  399.     # Find and update the existing relationship
  400.     rel = get_relationship(ctx.author.id)
  401.     if not rel:
  402.         return await ctx.send("You're not in a relationship!")
  403.    
  404.     rel.type = proposal.type
  405.     bot.proposals.remove(proposal)
  406.    
  407.     save_data({
  408.         "relationships": [r.to_dict() for r in bot.relationships],
  409.         "proposals": [p.to_dict() for p in bot.proposals],
  410.         "cooldowns": {k: v.to_dict() for k, v in bot.cooldowns.items()}
  411.     })
  412.    
  413.     # Send acceptance message
  414.     new_type_display = RELATIONSHIP_TYPES.get(proposal.type, proposal.type.capitalize())
  415.     embed = discord.Embed(
  416.         title="💖 Relationship Upgraded",
  417.         description=f"{ctx.author.mention} has accepted {user.mention}'s relationship upgrade proposal!",
  418.         color=discord.Color.green()
  419.     )
  420.     embed.add_field(name="New Relationship Type", value=new_type_display)
  421.     await ctx.send(embed=embed)
  422.  
  423. @relationship.command(name="reject_upgrade")
  424. async def relationship_reject_upgrade(ctx, user: discord.Member):
  425.     """Reject a relationship upgrade proposal"""
  426.     proposal = get_proposal(user.id, ctx.author.id)
  427.    
  428.     if not proposal:
  429.         return await ctx.send(f"No pending upgrade proposal from {user.display_name}!")
  430.    
  431.     # Remove the proposal
  432.     bot.proposals.remove(proposal)
  433.    
  434.     save_data({
  435.         "relationships": [r.to_dict() for r in bot.relationships],
  436.         "proposals": [p.to_dict() for p in bot.proposals],
  437.         "cooldowns": {k: v.to_dict() for k, v in bot.cooldowns.items()}
  438.     })
  439.    
  440.     # Send rejection message
  441.     embed = discord.Embed(
  442.         title="💔 Upgrade Rejected",
  443.         description=f"{ctx.author.mention} has rejected {user.mention}'s relationship upgrade proposal.",
  444.         color=discord.Color.red()
  445.     )
  446.     await ctx.send(embed=embed)
  447.  
  448. @relationship.command(name="list", aliases=["all"])
  449. async def relationship_list(ctx):
  450.     """List all current relationships in the server"""
  451.     # Get all relationships involving server members
  452.     server_member_ids = {m.id for m in ctx.guild.members}
  453.     server_relationships = []
  454.    
  455.     for rel in bot.relationships:
  456.         if rel.user1 in server_member_ids and rel.user2 in server_member_ids:
  457.             server_relationships.append(rel)
  458.    
  459.     if not server_relationships:
  460.         return await ctx.send("No relationships in this server yet!")
  461.    
  462.     # Create paginated embed
  463.     rel_type_counts = {}
  464.     for rel in server_relationships:
  465.         rel_type_counts[rel.type] = rel_type_counts.get(rel.type, 0) + 1
  466.    
  467.     embed = discord.Embed(
  468.         title=f"💑 Relationships in {ctx.guild.name}",
  469.         color=discord.Color.pink()
  470.     )
  471.    
  472.     # Add relationship type counts
  473.     type_lines = []
  474.     for rel_type, count in rel_type_counts.items():
  475.         type_display = RELATIONSHIP_TYPES.get(rel_type, rel_type.capitalize())
  476.         type_lines.append(f"{type_display}: {count}")
  477.    
  478.     embed.add_field(name="Relationship Types", value="\n".join(type_lines), inline=False)
  479.    
  480.     # Add some sample relationships (first 5)
  481.     sample_lines = []
  482.     for rel in server_relationships[:5]:
  483.         user1 = await bot.fetch_user(rel.user1)
  484.         user2 = await bot.fetch_user(rel.user2)
  485.         type_display = RELATIONSHIP_TYPES.get(rel.type, rel.type.capitalize())
  486.         sample_lines.append(f"{user1.name} ❤️ {user2.name} ({type_display})")
  487.    
  488.     if len(server_relationships) > 5:
  489.         sample_lines.append(f"...and {len(server_relationships) - 5} more")
  490.    
  491.     embed.add_field(name="Sample Relationships", value="\n".join(sample_lines), inline=False)
  492.     embed.set_footer(text=f"Total relationships: {len(server_relationships)}")
  493.     await ctx.send(embed=embed)
  494.  
  495. @relationship.command(name="stats", aliases=["leaderboard"])
  496. async def relationship_stats(ctx):
  497.     """Show relationship statistics and leaderboard"""
  498.     # Get all relationships involving server members
  499.     server_member_ids = {m.id for m in ctx.guild.members}
  500.     server_relationships = []
  501.    
  502.     for rel in bot.relationships:
  503.         if rel.user1 in server_member_ids and rel.user2 in server_member_ids:
  504.             server_relationships.append(rel)
  505.    
  506.     if not server_relationships:
  507.         return await ctx.send("No relationships in this server yet!")
  508.    
  509.     # Count relationships per user
  510.     relationship_counts = {}
  511.     for rel in server_relationships:
  512.         relationship_counts[rel.user1] = relationship_counts.get(rel.user1, 0) + 1
  513.         relationship_counts[rel.user2] = relationship_counts.get(rel.user2, 0) + 1
  514.    
  515.     # Sort by count (descending)
  516.     sorted_users = sorted(relationship_counts.items(), key=lambda x: x[1], reverse=True)
  517.    
  518.     # Create embed
  519.     embed = discord.Embed(
  520.         title=f"💑 Relationship Statistics for {ctx.guild.name}",
  521.         color=discord.Color.pink()
  522.     )
  523.    
  524.     # Add total count
  525.     embed.add_field(
  526.         name="Total Relationships",
  527.         value=str(len(server_relationships)),
  528.         inline=False
  529.     )
  530.    
  531.     # Add leaderboard (top 5)
  532.     leaderboard_lines = []
  533.     for i, (user_id, count) in enumerate(sorted_users[:5], 1):
  534.         user = await bot.fetch_user(user_id)
  535.         leaderboard_lines.append(f"{i}. {user.name}: {count} relationship{'s' if count > 1 else ''}")
  536.    
  537.     embed.add_field(
  538.         name="Relationship Leaderboard",
  539.         value="\n".join(leaderboard_lines),
  540.         inline=False
  541.     )
  542.    
  543.     # Add relationship type distribution
  544.     type_counts = {}
  545.     for rel in server_relationships:
  546.         type_counts[rel.type] = type_counts.get(rel.type, 0) + 1
  547.    
  548.     type_lines = []
  549.     for rel_type, count in type_counts.items():
  550.         type_display = RELATIONSHIP_TYPES.get(rel_type, rel_type.capitalize())
  551.         type_lines.append(f"{type_display}: {count}")
  552.    
  553.     embed.add_field(
  554.         name="Relationship Types",
  555.         value="\n".join(type_lines),
  556.         inline=False
  557.     )
  558.    
  559.     await ctx.send(embed=embed)
  560.  
  561. @relationship.command(name="random", aliases=["matchmake"])
  562. async def relationship_random(ctx):
  563.     """Get a random match suggestion"""
  564.     # Check cooldown
  565.     cooldown_msg = check_cooldown(ctx.author.id, "random", 1200)  # 24 hour cooldown
  566.     if cooldown_msg:
  567.         return await ctx.send(cooldown_msg)
  568.    
  569.     # Get all single members in the server
  570.     single_members = []
  571.     for member in ctx.guild.members:
  572.         if member.bot or member == ctx.author:
  573.             continue
  574.        
  575.         if not get_relationship(member.id):
  576.             single_members.append(member)
  577.    
  578.     if not single_members:
  579.         return await ctx.send("No available singles in this server!")
  580.    
  581.     # Select a random match
  582.     match = random.choice(single_members)
  583.    
  584.     # Calculate compatibility score (just for fun)
  585.     compatibility = random.randint(50, 100)
  586.    
  587.     # Send match suggestion
  588.     embed = discord.Embed(
  589.         title="💘 Random Match Suggestion",
  590.         description=f"Your random match is {match.mention}!",
  591.         color=discord.Color.pink()
  592.     )
  593.     embed.add_field(name="Compatibility", value=f"{compatibility}%")
  594.     embed.add_field(name="Next Steps", value=f"Type `-relationship/rel/r propose {match.name}` to start a relationship!")
  595.     embed.set_footer(text="You can get another suggestion in 20 minutes")
  596.     await ctx.send(embed=embed)
  597.  
  598. # Error handling
  599. @relationship.error
  600. async def relationship_error(ctx, error):
  601.     if isinstance(error, commands.MissingRequiredArgument):
  602.         await ctx.send("Missing required argument! Please check the command usage.")
  603.     elif isinstance(error, commands.BadArgument):
  604.         await ctx.send("Invalid argument! Please check the command usage.")
  605.     elif isinstance(error, commands.CommandInvokeError):
  606.         await ctx.send(f"An error occurred: {str(error.original)}")
  607.     else:
  608.         await ctx.send("An unknown error occurred!")
  609.  
  610. # Run the bot
  611. if __name__ == "__main__":
  612.     bot.run("bot token")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement