mirror of
https://github.com/TheRealOwenRees/plantid-discord-bot.git
synced 2026-07-23 04:26:57 +00:00
Feature/projects (#18)
* add up to 5 attachments * multiclause function event handler * fix incorrect Cog calls * add default param as "all" so we can start differentiating the types of identifications in the future - projects / diseases * abstract message sending * overwrite global application commands * pass message from projects to message sending and id functions
This commit is contained in:
+14
-13
@@ -5,6 +5,7 @@ defmodule PlantIdDiscordBot.Consumer do
|
||||
use Nostrum.Consumer
|
||||
alias Nostrum.Api
|
||||
alias PlantIdDiscordBot.{Cog, Consumer}
|
||||
alias PlantIdDiscordBot.PlantNet.Projects
|
||||
|
||||
@global_application_commands Consumer.Commands.global_application_commands()
|
||||
|
||||
@@ -17,9 +18,9 @@ defmodule PlantIdDiscordBot.Consumer do
|
||||
Api.create_guild_application_command(guild_id, cmd)
|
||||
end)
|
||||
|
||||
# Only register global commands in production
|
||||
if Mix.env() == :prod do
|
||||
Api.create_global_application_command(@global_application_commands)
|
||||
# Api.create_global_application_command(@global_application_commands)
|
||||
Api.bulk_overwrite_global_application_commands(@global_application_commands)
|
||||
end
|
||||
|
||||
Api.update_status(:online, "Guess the Plant | /help")
|
||||
@@ -30,17 +31,7 @@ defmodule PlantIdDiscordBot.Consumer do
|
||||
end
|
||||
|
||||
def handle_event({:INTERACTION_CREATE, %{data: %{name: command}} = interaction, _ws_state}) do
|
||||
case command do
|
||||
"source" -> Cog.Info.source(interaction)
|
||||
"invite" -> Cog.Info.invite(interaction)
|
||||
"help" -> Cog.Info.help(interaction)
|
||||
"info" -> Cog.Info.info(interaction)
|
||||
"stats" -> Cog.Info.stats(interaction)
|
||||
"status" -> Cog.Info.status(interaction)
|
||||
"servers" -> Cog.Info.servers(interaction)
|
||||
"diseases" -> Cog.Diseases.diseases(interaction)
|
||||
"projects" -> Cog.Projects.projects(interaction)
|
||||
end
|
||||
handle_interaction(command, interaction)
|
||||
end
|
||||
|
||||
def handle_event({:MESSAGE_CREATE, %{attachments: attachments} = message, _ws_state}) do
|
||||
@@ -49,4 +40,14 @@ defmodule PlantIdDiscordBot.Consumer do
|
||||
Cog.PlantNetMessage.id(message)
|
||||
end
|
||||
end
|
||||
|
||||
defp handle_interaction("source", interaction), do: Cog.Info.source(interaction)
|
||||
defp handle_interaction("invite", interaction), do: Cog.Info.invite(interaction)
|
||||
defp handle_interaction("help", interaction), do: Cog.Info.help(interaction)
|
||||
defp handle_interaction("info", interaction), do: Cog.Info.info(interaction)
|
||||
defp handle_interaction("stats", interaction), do: Cog.Info.stats(interaction)
|
||||
defp handle_interaction("status", interaction), do: Cog.Info.status(interaction)
|
||||
defp handle_interaction("servers", interaction), do: Cog.Info.servers(interaction)
|
||||
defp handle_interaction("diseases", interaction), do: Cog.Diseases.diseases(interaction)
|
||||
defp handle_interaction("projects", interaction), do: Cog.Projects.projects(interaction)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user