Compare commits

...

3 Commits

Author SHA1 Message Date
1ccc31d3d2 Update readme.md 2024-10-25 21:50:41 +02:00
7c4d8c246d Update README.md 2024-10-25 21:49:24 +02:00
43f0191752 Update readme.md 2024-10-25 21:47:54 +02:00
2 changed files with 37 additions and 67 deletions

View File

@@ -8,6 +8,26 @@ flowchart TD
PlayTrack --> NowPlayingEmbed PlayTrack --> NowPlayingEmbed
``` ```
```mermaid
sequenceDiagram
participant User as User
participant DiscordSocketClient as DiscordSocketClient
participant MessageReceivedHandler as MessageReceivedHandler
participant MessageReceivedNotification as MessageReceivedNotification
participant EmbedBuilder as EmbedBuilder
participant Channel as Channel
User->>DiscordSocketClient: Send message "!LunarisStats"
DiscordSocketClient->>MessageReceivedHandler: MessageReceivedNotification
MessageReceivedHandler->>MessageReceivedNotification: Handle(notification, cancellationToken)
MessageReceivedNotification->>MessageReceivedHandler: BotMentioned(notification, cancellationToken)
MessageReceivedHandler->>DiscordSocketClient: Get guilds and voice channels
DiscordSocketClient-->>MessageReceivedHandler: List of guilds and voice channels
MessageReceivedHandler->>EmbedBuilder: Create embed with statistics
EmbedBuilder-->>MessageReceivedHandler: Embed
MessageReceivedHandler->>Channel: Send embed message
```
## Steps in the code ## Steps in the code
| Name | Description | | Name | Description |
@@ -32,4 +52,4 @@ There is also OnTrackEnd, when it get called an attempt is made to play the next
| `player` | `LavaPlayer` | An instance of the `LavaPlayer` class, representing a music player connected to a specific voice channel. Used to play, pause, skip, and queue tracks. | | `player` | `LavaPlayer` | An instance of the `LavaPlayer` class, representing a music player connected to a specific voice channel. Used to play, pause, skip, and queue tracks. |
| `guildMessageIds` | `Dictionary<ulong, List<ulong>>` | A dictionary that maps guild IDs to lists of message IDs. Used to keep track of messages sent by the bot in each guild, allowing the bot to delete its old messages when it sends new ones. | | `guildMessageIds` | `Dictionary<ulong, List<ulong>>` | A dictionary that maps guild IDs to lists of message IDs. Used to keep track of messages sent by the bot in each guild, allowing the bot to delete its old messages when it sends new ones. |
| `songName` | `string` | A string that represents the name or URL of a song to play. Used to search for and queue tracks. | | `songName` | `string` | A string that represents the name or URL of a song to play. Used to search for and queue tracks. |
| `searchResponse` | `SearchResponse` | An instance of the `SearchResponse` class, representing the result of a search for tracks. Used to get the tracks that were found and queue them in the player. | | `searchResponse` | `SearchResponse` | An instance of the `SearchResponse` class, representing the result of a search for tracks. Used to get the tracks that were found and queue them in the player. |

View File

@@ -67,73 +67,23 @@ public class MessageReceivedHandler : INotificationHandler<MessageReceivedNotifi
### Class Diagram ### Class Diagram
```mermaid ```mermaid
classDiagram sequenceDiagram
class ClearQueueHandler { participant User as User
+Task Handle(ClearQueueCommand command, CancellationToken cancellationToken) participant DiscordSocketClient as DiscordSocketClient
} participant MessageReceivedHandler as MessageReceivedHandler
class DisconnectHandler { participant MessageReceivedNotification as MessageReceivedNotification
+Task Handle(DisconnectCommand command, CancellationToken cancellationToken) participant EmbedBuilder as EmbedBuilder
} participant Channel as Channel
class PauseHandler {
+Task Handle(PauseCommand command, CancellationToken cancellationToken)
}
class PlayHandler {
+Task Handle(PlayCommand command, CancellationToken cancellationToken)
}
class ResumeHandler {
+Task Handle(ResumeCommand command, CancellationToken cancellationToken)
}
class SkipHandler {
+Task Handle(SkipCommand command, CancellationToken cancellationToken)
}
class MessageReceivedHandler {
+Task Handle(MessageReceivedNotification notification, CancellationToken cancellationToken)
}
class IAudioService
class DiscordSocketClient
class SocketSlashCommand
class CancellationToken
class Task
class IRequestHandler
class INotificationHandler
ClearQueueHandler ..|> IRequestHandler User->>DiscordSocketClient: Send message "!LunarisStats"
DisconnectHandler ..|> IRequestHandler DiscordSocketClient->>MessageReceivedHandler: MessageReceivedNotification
PauseHandler ..|> IRequestHandler MessageReceivedHandler->>MessageReceivedNotification: Handle(notification, cancellationToken)
PlayHandler ..|> IRequestHandler MessageReceivedNotification->>MessageReceivedHandler: BotMentioned(notification, cancellationToken)
ResumeHandler ..|> IRequestHandler MessageReceivedHandler->>DiscordSocketClient: Get guilds and voice channels
SkipHandler ..|> IRequestHandler DiscordSocketClient-->>MessageReceivedHandler: List of guilds and voice channels
MessageReceivedHandler ..|> INotificationHandler MessageReceivedHandler->>EmbedBuilder: Create embed with statistics
ClearQueueHandler --> IAudioService EmbedBuilder-->>MessageReceivedHandler: Embed
DisconnectHandler --> IAudioService MessageReceivedHandler->>Channel: Send embed message
PauseHandler --> IAudioService
PlayHandler --> IAudioService
ResumeHandler --> IAudioService
SkipHandler --> IAudioService
ClearQueueHandler --> DiscordSocketClient
DisconnectHandler --> DiscordSocketClient
PauseHandler --> DiscordSocketClient
PlayHandler --> DiscordSocketClient
ResumeHandler --> DiscordSocketClient
SkipHandler --> DiscordSocketClient
ClearQueueHandler --> SocketSlashCommand
DisconnectHandler --> SocketSlashCommand
PauseHandler --> SocketSlashCommand
PlayHandler --> SocketSlashCommand
ResumeHandler --> SocketSlashCommand
SkipHandler --> SocketSlashCommand
ClearQueueHandler --> CancellationToken
DisconnectHandler --> CancellationToken
PauseHandler --> CancellationToken
PlayHandler --> CancellationToken
ResumeHandler --> CancellationToken
SkipHandler --> CancellationToken
ClearQueueHandler --> Task
DisconnectHandler --> Task
PauseHandler --> Task
PlayHandler --> Task
ResumeHandler --> Task
SkipHandler --> Task
``` ```
### Sequence Diagram for PlayHandler ### Sequence Diagram for PlayHandler