-
Notifications
You must be signed in to change notification settings - Fork 0
initial commit for thomas #2
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
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideIntroduces a new ThomasCog for onboarding in the Discord bot, defining random text and image responses and exposing a slash command to send a styled embed. Sequence Diagram for the /thomas CommandsequenceDiagram
actor User
participant DiscordClient as Discord Client
participant DiscordBot as Discord Bot
participant ThomasCog
User->>DiscordClient: Executes /thomas command
DiscordClient->>DiscordBot: Forwards command /thomas
DiscordBot->>ThomasCog: Thomas(interaction)
activate ThomasCog
ThomasCog->>ThomasCog: line = random.choice(random_lines)
ThomasCog->>ThomasCog: image = random.choice(random_images)
ThomasCog->>ThomasCog: Create discord.Embed(title, description, color)
ThomasCog->>ThomasCog: embed.set_image(url=image)
ThomasCog->>DiscordBot: interaction.response.send_message(embed)
deactivate ThomasCog
DiscordBot->>DiscordClient: Sends message with embed
DiscordClient->>User: Displays message
Class Diagram for the new ThomasCogclassDiagram
class ThomasCog {
+bot: commands.Bot
+logger: logging.Logger
+random_lines: list~str~
+random_images: list~str~
+__init__(bot: commands.Bot)
+Thomas(interaction: discord.Interaction) async
}
ThomasCog --|> commands.Cog
ThomasCog ..> discord.Bot : uses
ThomasCog ..> logging.Logger : uses
ThomasCog ..> discord.Interaction : uses
ThomasCog ..> discord.Embed : creates
class commands.Cog {<<Interface/Base>>}
class discord.Bot {<<Framework>>}
class discord.Interaction {<<Framework>>}
class discord.Embed {<<Data>>}
class logging.Logger {<<Utility>>}
class Global {
<<Module>>
+setup(bot: commands.Bot) async
}
Global ..> ThomasCog : instantiates
Global ..> discord.Bot : registers cog
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @Jest-a - I've reviewed your changes - here's some feedback:
- Add missing commas between strings in the random_lines and random_images lists so each entry is a separate list item instead of getting concatenated.
- Rename the command method from
Thomasto lowercase (e.g.thomas) to follow PEP8 naming conventions for function/method names. - Update the embed title (currently "Tom") to match the command/cog name for consistency (e.g. use "Thomas").
Here's what I looked at during the review
- 🟡 General issues: 4 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| self.random_lines = [ | ||
| "Every good thing that happens to you in this game is preplanned like a show. There's an audience waiting for your downfall." | ||
| "...I should buy a boat." | ||
| "So... come here often?" | ||
| "Wanna hear a joke?" | ||
| "Im out of funny ideas, come back later" | ||
| "Check out this cool gif" | ||
| "I'm hungry. Like, I really could go for some rigatoni right now." | ||
| "I've been thinking of starting a band recently. Might call it [adjective] [noun]. What do you think?" | ||
| ] |
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 (bug_risk): Missing commas between string literals in random_lines list
Without commas, these strings are combined into a single list element. Please add commas to separate each string as an individual item.
| "Check out this cool gif" | ||
| "I'm hungry. Like, I really could go for some rigatoni right now." | ||
| "I've been thinking of starting a band recently. Might call it [adjective] [noun]. What do you think?" | ||
| ] |
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 (bug_risk): Missing commas between string literals in random_images list
Without commas, all URLs are combined into one string. Add commas so each URL is a separate list element for random.choice().
|
|
||
| @app_commands.guilds(discord.Object(id=settings.DEBUG_GUILD_ID)) | ||
| @app_commands.command(name="thomas", description="Does Something") | ||
| async def Thomas(self, interaction: discord.Interaction): |
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: Method name should follow snake_case naming
Rename Thomas to thomas to comply with PEP8 naming conventions.
| ) | ||
| embed.set_image(url=image) | ||
|
|
||
| self.logger.info(f"Selected line: {line}, image: {image}") |
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: Use debug level for verbose selection logs
Switch to self.logger.debug for these detailed randomization messages to reduce noise in production logs.
| self.logger.info(f"Selected line: {line}, image: {image}") | |
| self.logger.debug(f"Selected line: {line}, image: {image}") |
|
new name, who dis? |
Summary by Sourcery
New Features: