Files
Lunaris2.0/Bot
SocksOnHead 8dcd4b334d Fix deadlock and auto leave voice channel after 3 min (#4)
* Fix for thread being busy handling discord commands blocking audioplayer to timeout
* Auto leave if alone in voice channel after 3 min

Co-authored-by: Myx <info@azaaxin.com>
2024-08-12 02:02:10 +02:00
..
2024-08-11 16:06:52 +02:00
2024-08-11 16:06:52 +02:00
2024-08-11 16:06:52 +02:00
2024-06-01 23:53:15 +02:00

How commands from Discord gets executed

flowchart TD
    Program[Program] -->|Register| EventListener
    EventListener[DiscordEventListener] --> A[MessageReceivedHandler]

    EventListener[DiscordEventListener] --> A2[SlashCommandReceivedHandler]

    A --> |Message| f{If bot is mentioned}
    f --> |ChatCommand| v[ChatHandler]

    A2[SlashCommandReceivedHandler] -->|Message| C{Send to correct command by 
            looking at commandName}

    C -->|JoinCommand| D[JoinHandler]
    C -->|PlayCommand| E[PlayHandler]
    C -->|HelloCommand| F[HelloHandler]
    C -->|GoodbyeCommand| G[GoodbyeHandler]

Program registers an event listener DiscordEventListener which publish a message :

await Mediator.Publish(new MessageReceivedNotification(arg), _cancellationToken);
Name Description
SlashCommandReceivedHandler Handles commands using / from any Discord Guild/Server.
MessageReceivedHandler Listens to all messages.

Handler integrations

flowchart TD
    D[JoinHandler] --> Disc[Discord Api]
    E[PlayHandler] --> Disc[Discord Api]
    F[HelloHandler] --> Disc[Discord Api]
    G[GoodbyeHandler] --> Disc[Discord Api]
    v[ChatHandler] --> Disc[Discord Api]
    v --> o[Ollama Server]
    o --> v
    E --> Lava[Lavalink]
Name Description
JoinHandler Handles the logic for just joining a voice channel.
PlayHandler Handles the logic for joining and playing music in a voice channel.
HelloHandler Responds with Hello. (Dummy handler, will be removed)
GoodbyeHandler Responds with Goodbye. (Dummy handler, will be removed)
ChatHandler Handles the logic for LLM chat with user.