-
Notifications
You must be signed in to change notification settings - Fork 0
Abstract plugins from main codebase #4
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
Open
motorlatitude
wants to merge
16
commits into
develop
Choose a base branch
from
feature/plugin-abstraction
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4c9a44a
🎨 Abstracted plugins
motorlatitude cace398
🐛 Better error handling in jokes plugin
motorlatitude dc1f951
🐛 Fixed`/points` user command to correctly get supplied user
motorlatitude 6ee7455
🎨 Update reaction handling in PointsPlugin to use EmojiId for upvote/…
motorlatitude 9738f19
🐛 Add InvalidInternalState error to handle plugin context issues and …
motorlatitude b3b6263
🔥 Remove OPENAI_API_KEY from environment variables in README and dock…
motorlatitude 7fdd3f1
🎨 Check for message author id checks against actual bot ID rather tha…
motorlatitude b71368b
Merge remote-tracking branch 'origin/develop' into feature/plugin-abs…
motorlatitude f76eaaf
🚨 Fix some lint errors
motorlatitude 3bd82cc
🎨 Clamping dice sides
motorlatitude 3db51f9
🎨 Add InvalidInternalAPIResponse error variant and handle empty joke …
motorlatitude 1fca50a
🎨 Update sleep durations in Jokes and Patches plugins; fix some lint …
motorlatitude 42136f3
🎨 Enhance error handling and plugin event sending. Additionally, ensu…
motorlatitude 216a5c0
🚨 Fix clippy warnings
motorlatitude 057892a
🐛 Fix iteration over game IDs in PatchesPlugin
motorlatitude 1d5eca4
🎨 Introduce PatchesError enum for improved error handling in Patches …
motorlatitude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| use derive_more::{Display, From}; | ||
|
|
||
| use crate::{plugin, storage}; | ||
|
|
||
| pub type Result<T, E = Error> = std::result::Result<T, E>; | ||
|
|
||
| #[derive(Debug, From, Display)] | ||
| #[non_exhaustive] | ||
| pub enum Error { | ||
| /// An error indicating that a plugin failed to send an event due to an | ||
| /// issue with the Serenity context or API. | ||
| #[display("Failed to send event: {}", err)] | ||
| FailedToSendEvent { | ||
| /// The error that occurred during sending the event | ||
| err: serenity::Error, | ||
| }, | ||
|
|
||
| // -- Internal | ||
| /// An error related to storage operations, such as database interactions. | ||
| #[from] | ||
| Storage(storage::StorageError), | ||
| /// An error related to plugin operations. | ||
| #[from] | ||
| Plugin(plugin::PluginError), | ||
|
|
||
| // -- Plugin errors | ||
| /// A plugin encountered an error that doesn't fit into any of the other | ||
| /// predefined categories, allowing plugins to return custom error messages | ||
| /// or types that can be displayed or logged without needing to define a new | ||
| /// variant in the main `Error` enum for every possible plugin error | ||
| /// scenario. | ||
| Custom(Box<dyn std::error::Error + Send + Sync>), | ||
|
|
||
| // -- External | ||
| /// An error related to the Serenity library, such as issues with the | ||
| /// Discord API. | ||
| #[from] | ||
| Serenity(serenity::Error), | ||
|
|
||
| /// An error related to the reqwest library, such as issues with making | ||
| /// HTTP requests. | ||
| #[from] | ||
| Reqwest(reqwest::Error), | ||
| } | ||
|
|
||
| impl From<rusqlite::Error> for Error { | ||
| fn from(e: rusqlite::Error) -> Self { | ||
| Self::Storage(storage::StorageError::from(e)) | ||
| } | ||
| } | ||
|
|
||
| impl std::error::Error for Error {} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Already defined in Storage Error enum, unecessary duplication