docs(globally): Add docstrings and refactor various code by kzndotsh · Pull Request #194 · allthingslinux/tux

added 12 commits

April 28, 2024 20:48
… functions for datetime conversion

feat(functions.py): add compare_guild_channel_changes and compare_member_changes functions for comparing changes in GuildChannel and Member instances respectively
…ganize the file for better readability

refactor(pyproject.toml): reorder dependencies and add new ones for better project management
feat(tux/utils/constants.py): add new constants for gate logging and tux logs to improve logging capabilities
…rnary expressions for cleaner code and improved readability
This commit introduces a new file, audit.py, which contains a class for audit logging. This class includes listeners for various events such as channel creation/deletion/update, guild update, emoji and sticker updates, integration creation/update/deletion, role creation/deletion/update, scheduled event creation/deletion/update, stage instance creation/deletion/update, and thread creation/deletion/update. Each listener sends an embed message to the audit log channel detailing the event.

feat(logging): add new logging cog 'gate.py' for gate logging
refactor(logging): update 'member.py' to use DatabaseController and simplify member update logging
feat(logging): add new logging cog 'message.py' for guild logging
refactor(logging): update 'mod.py' to improve ban/unban logging and remove duplicate code
…ry condition checks

refactor(users.py): rename variable 'existing_user' to 'user' for better readability
fix(users.py): ensure update_user method updates all fields regardless of changes
feat(users.py): import UsersUpdateInput from prisma.types to use as data type for update_user method
feat(embeds.py): add default return values for avatar and username when user and interaction are None to prevent null values
…sistency

feat(cog_loader.py): add exception handling to provide more robust error handling
style(main.py): add comments to improve code readability
refactor(console.py): update comments for better understanding of the code

feat(functions.py): add convert_to_seconds function to convert formatted time string to seconds
docs(functions.py): update docstrings to numpy style for better readability and consistency
refactor(functions.py): improve is_integer and is_float functions by using is_convertible_to_type function for DRY code
refactor(error_handler.py): update error handling logic to improve error messages and logging
fix(error_handler.py): handle app command errors separately to avoid conflicts
style(error_handler.py): improve code readability and maintainability by simplifying error handling logic

feat(test_error_handler.py): add new file for testing error handling in discord.py
This new file contains a Cog class with commands to raise every type of discord.py error for testing purposes.

feat: add error handling commands to ErrorTests cog in discord bot

This commit adds a series of commands to the ErrorTests cog in the discord bot. Each command raises a specific exception when invoked, allowing for testing and debugging of error handling mechanisms. The exceptions covered include DisabledCommand, CommandInvokeError, CommandOnCooldown, MaxConcurrencyReached, various ExtensionErrors, ClientException, and CommandRegistrationError.

refactor(error_handler.py): rename ErrorHandler to UnifiedErrorHandler for clarity
feat(error_handler.py): add support for traditional command errors and app command errors
fix(error_handler.py): improve error message for better user experience
style(error_handler.py): refactor code for better readability and maintainability
…ring and guild check

refactor(admin/load.py): rename 'cog' to 'ext', add detailed docstring and error handling
refactor(admin/reload.py): rename 'cog' to 'ext', add detailed docstring and error handling
refactor(admin/sync.py): add detailed docstring, guild check and change ctx.send to ctx.reply
refactor(admin/unload.py): rename 'cog' to 'ext', add detailed docstring and error handling

The refactor was done to improve the readability and maintainability of the code. The renaming of 'cog' to 'ext' was done to better reflect the nature of the variable. The addition of detailed docstrings provides a clear understanding of the purpose and usage of the commands. The enhanced error handling provides more specific feedback to the user. The guild check ensures that the commands are only used in a server context.
… for better code understanding

refactor(purge.py): remove unused imports and methods, use EmbedCreator for creating embeds
refactor(report.py): rename ConfirmModal to ReportModal for better semantics
feat(purge.py): add error handling for non-text channels and invalid number of messages
feat(report.py): add docstring to report method, improve report submission process

docs(slowmode.py, timeout.py, unban.py): add docstrings to methods for better code readability and understanding
refactor(slowmode.py): change default slowmode delay from 5 to 4 seconds for better user experience
style(slowmode.py, timeout.py, unban.py): add line breaks for better code readability
fix(unban.py): remove redundant logging of unban command usage, logging is now handled after successful unbanning

docs(warn.py): add docstrings to methods for better code readability and understanding
refactor(warn.py): remove error handling from create_infraction method to improve separation of concerns
…usability

docs(archwiki.py): add docstrings to query_archwiki and archwiki methods for better code understanding
style(archwiki.py): improve code readability by using self.base_url instead of base_url

docs(avatar.py): add docstrings to avatar method for better code understanding
refactor(avatar.py): improve code readability by assigning avatar url to a variable

feat(guide.py): add meta_fields, support_fields, resources_fields for better code organization
docs(guide.py): add docstrings to guide method for better code understanding
refactor(guide.py): improve code readability by using fields variables in embed.add_field

feat(info.py): add logger to log command usage
docs(info.py): add docstrings to server, tux, member, irc methods for better code understanding
refactor(info.py): improve code readability by reordering code blocks and assigning values to variables

refactor(membercount.py, ping.py, poll.py, remindme.py): add docstrings for better code readability
feat(membercount.py, ping.py, poll.py, remindme.py): add logging for user command usage for better tracking
fix(remindme.py): handle exceptions when getting and creating reminders to prevent app crash
refactor(remindme.py): move convert_to_seconds function to utils/functions.py for better code organization
style(remindme.py): improve code comments for better understanding

docs(rolecount.py, tldr.py): add docstrings to methods for better code understanding
refactor(rolecount.py, tldr.py): improve variable typing for better type checking
refactor(tldr.py): modify subprocess handling for better error management and readability
style(tldr.py): improve error messages for user clarity
… understanding

refactor(database/controllers): change docstring format for better readability and consistency
feat(database/controllers): add channel_id and guild_id parameters to create_reminder method in RemindersController to associate reminders with specific channels and guilds

docs(roles.py, snippets.py): update docstrings to numpy style for better readability and consistency
refactor(roles.py): modify default values in update_role method to handle None values correctly
feat(roles.py): add docstrings to sync_role and delete_role methods for better understanding of their functionality
feat(snippets.py): add docstrings to __init__, get_all_snippets, get_all_snippets_sorted, get_snippet_by_name, create_snippet, delete_snippet, and update_snippet methods for better understanding of their functionality

docs(database/controllers): update docstrings in user_roles.py and users.py for better clarity and consistency
refactor(users.py): optimize sync_user method to only update fields that have changed to improve performance

sourcery-ai[bot]