Projects and Diseases placeholder application commands (#17)

* fix module name in backup

* save projects to persistent_term

* retrieve projects on bot startup

* remove commented out code

* register project autocomplete

* placeholder text for project

* placeholder disease command
This commit is contained in:
2025-12-08 08:53:48 +01:00
committed by GitHub
parent 02372f2076
commit 0eddf04678
11 changed files with 182 additions and 27 deletions
+19 -7
View File
@@ -9,10 +9,26 @@ defmodule PlantIdDiscordBot.Consumer do
@global_application_commands Consumer.Commands.global_application_commands()
def handle_event({:READY, _data, _ws_state}) do
Api.create_global_application_command(@global_application_commands)
Projects.fetch_projects()
guild_id = Application.get_env(:plantid_discord_bot, :dev_guild_id)
# Register commands instantly in your test server
Enum.each(@global_application_commands, fn cmd ->
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)
end
Api.update_status(:online, "Guess the Plant | /help")
end
def handle_event({:INTERACTION_CREATE, %{type: 4} = interaction, _ws_state}) do
PlantIdDiscordBot.Cog.Projects.autocomplete(interaction)
end
def handle_event({:INTERACTION_CREATE, %{data: %{name: command}} = interaction, _ws_state}) do
case command do
"source" -> Cog.Info.source(interaction)
@@ -22,6 +38,8 @@ defmodule PlantIdDiscordBot.Consumer do
"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
end
@@ -30,11 +48,5 @@ defmodule PlantIdDiscordBot.Consumer do
Api.start_typing!(message.channel_id)
Cog.PlantNetMessage.id(message)
end
# if length(attachments) > 0 do
# # deprecated -> Nostrum.Api.Channel.start_typing/1 in v1.0
# Api.start_typing!(message.channel_id)
# Cog.PlantNetMessage.id(message)
# end
end
end