change applciation commands structure

This commit is contained in:
Owen
2024-12-22 11:53:54 +01:00
committed by Owen Rees
parent 891966f217
commit 9b59fff176
3 changed files with 77 additions and 48 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ import Config
config :plantid_discord_bot, config :plantid_discord_bot,
start_time: DateTime.utc_now(), start_time: DateTime.utc_now(),
guild_ids: [1_002_507_312_159_797_318], guild_ids: [],
api: Nostrum.Api, api: Nostrum.Api,
max_results: 5, max_results: 5,
score_threshold: 0.3, score_threshold: 0.3,
+73 -41
View File
@@ -1,46 +1,78 @@
defmodule PlantIdDiscordBot.Consumer.Commands do defmodule PlantIdDiscordBot.Consumer.Commands do
def global_application_commands() do def global_application_commands do
[ [
{"source", "Link to the source code for this bot", []}, %{
{"invite", "Invite link for this bot", []}, name: "source",
{"help", "Help information for this bot", []}, description: "Link to the source code for this bot",
{"info", "Information about this bot", []}, options: []
{"stats", "Statistics about this bot", []}, },
{"status", "API Status", []}, %{
{"servers", "All servers that this bot belongs to", []}, name: "invite",
{"id", "ID a plant from up to 5 images", description: "Invite link for this bot",
[ options: []
%{ },
type: 11, %{
name: "image1", name: "help",
description: "The image to identify", description: "Help information for this bot",
required: true options: []
}, },
%{ %{
type: 11, name: "info",
name: "image2", description: "Information about this bot",
description: "The image to identify", options: []
required: false },
}, %{
%{ name: "stats",
type: 11, description: "Statistics about this bot",
name: "image3", options: []
description: "The image to identify", },
required: false %{
}, name: "status",
%{ description: "API Status",
type: 11, options: []
name: "image4", },
description: "The image to identify", %{
required: false name: "servers",
}, description: "All servers that this bot belongs to",
%{ options: []
type: 11, },
name: "image5", %{
description: "The image to identify", name: "id",
required: false description: "ID a plant from up to 5 images",
} options: [
]} %{
# Attachment type
type: 11,
name: "image1",
description: "The image to identify",
required: true
},
%{
type: 11,
name: "image2",
description: "The image to identify",
required: false
},
%{
type: 11,
name: "image3",
description: "The image to identify",
required: false
},
%{
type: 11,
name: "image4",
description: "The image to identify",
required: false
},
%{
type: 11,
name: "image5",
description: "The image to identify",
required: false
}
]
}
] ]
end end
end end
+3 -6
View File
@@ -9,13 +9,10 @@ defmodule PlantIdDiscordBot.Consumer do
@global_application_commands Commands.global_application_commands() @global_application_commands Commands.global_application_commands()
def handle_event({:READY}) do def handle_event({:READY, _data, _ws_state}) do
# mock function depending on the environment Api.create_global_application_command(@global_application_commands)
# Api.create_global_application_command(@global_application_commands)
# TODO fix, not working # TODO fix, not working
Api.update_status(:online, "Guess the Plant|/help") Api.update_status(:online, %{name: "Guess the Plant | /help", type: 0})
# TODO remove in prod
Api.create_guild_application_command(1_002_507_312_159_797_318, @global_application_commands)
end end
def handle_event({:INTERACTION_CREATE, %{data: %{name: command}} = interaction, _ws_state}) do def handle_event({:INTERACTION_CREATE, %{data: %{name: command}} = interaction, _ws_state}) do