-
Notifications
You must be signed in to change notification settings - Fork 0
Rock paper Scissors with bot command Elias Cueto #4
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||
| import discord | ||||||
| import logging | ||||||
| from discord.ext import commands | ||||||
| from discord import app_commands | ||||||
|
|
||||||
| from frontend import config_colors as colors | ||||||
| from config import settings | ||||||
|
|
||||||
|
|
||||||
| class EliasCog(commands.Cog): | ||||||
| def __init__(self, bot: commands.Bot): | ||||||
| self.bot = bot | ||||||
| self.logger = logging.getLogger( | ||||||
| f"discord.cog.{self.__class__.__name__.lower()}" | ||||||
| ) | ||||||
| self.status_emojis = { | ||||||
| "🪨": "Rock", | ||||||
| "": "Paper", | ||||||
|
||||||
| "✂️": "Scissors", | ||||||
| "⭐": "Won", | ||||||
| "❌": "Lost", | ||||||
| } | ||||||
| @app_commands.guilds(discord.Object(id=settings.DEBUG_GUILD_ID)) | ||||||
| @app_commands.command(name="RPS", description="Plays Rock Paper Scissors with the bot!", ) | ||||||
| async def ping(self, interaction: discord.Interaction, arg1): | ||||||
|
||||||
| for emoji in self.status_emojis.keys(): | ||||||
| await message.add_reaction(emoji) | ||||||
|
||||||
| message = f"Choose your reaction" | ||||||
|
||||||
| message = f"Choose your reaction" | |
| message = "Choose your reaction" |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Using PING color for RPS embed
Consider adding a specific RPS color to config_colors for clarity instead of reusing colors.PING.
Suggested implementation:
embed = discord.Embed(
title="Ping",
description=message,
color=colors.RPS,
)You must also add a new color constant for RPS in your colors or config_colors module, for example:
RPS = 0x3498db # Choose an appropriate hex color codeand ensure it is imported where this file uses colors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider refactoring the command into a standalone function without a Cog, custom logger, or unused mappings to simplify the implementation.
Steps to apply:
EliasCogclass andsetupfunction entirely.commands/rps.py) with the above code.commands/rps.py(e.g. viabot.tree.copy_global_to(guild=...)or your existing command loader).status_emojisdict and custom logger import.This keeps the slash-command, the embed, and the reactions, with far less indirection.