/source application command with test

This commit is contained in:
Owen
2024-12-13 23:02:23 +01:00
parent 1c4d0fb8af
commit 5975458407
12 changed files with 233 additions and 162 deletions
+28 -9
View File
@@ -1,18 +1,37 @@
defmodule PlantIdDiscordBot do
@moduledoc """
Documentation for `PlantidDiscordBot`.
A Discord bot that identifies plants from photos of their organs.
"""
@doc """
Hello world.
use Nostrum.Consumer
alias Nostrum.Api
alias PlantIdDiscordBot.Cog
## Examples
IO.inspect("Starting PlantIdDiscordBot")
iex> PlantidDiscordBot.hello()
:world
@global_application_commands [
{"servers", "All servers that this bot belongs to, []"},
{"invite", "Invite link for this bot, []"},
{"source", "Link to the source code for this bot, []"},
{"info", "Information about this bot, []"},
{"stats", "Statistics about this bot, []"},
{"help", "Help information for this bot, []"},
{"status", "API Status, []"},
{"id", "ID a plant from up to 5 images, []"}
]
"""
def hello do
:world
# Starts the bot
def handle_event({:READY}) do
# mock function depending on the environment
Api.create_global_application_command(@global_application_commands)
# TODO fix, not working
Api.update_status(:online, "Guess the Plant|/help")
# TODO remove in prod
Api.create_guild_application_command(1_002_507_312_159_797_318, @global_application_commands)
end
# Handle /source command
def handle_event({:INTERACTION_CREATE, %{data: %{name: "source"}} = interaction, _ws_state}) do
Cog.Info.source(interaction)
end
end