-module(discord_gleam). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([bot/3, run/2, send_message/4, send_direct_message/4, reply/5, kick_member/4, ban_member/4, delete_message/4, wipe_global_commands/1, wipe_guild_commands/2, register_global_commands/2, register_guild_commands/3, interaction_reply_message/3]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " The primary module of discord_gleam. \\\n" " This module contains high-level functions to interact with the Discord API. \\\n" " But you can always implement stuff yourself using the low-level functions from the rest of the library. \\\n" ). -file("src/discord_gleam.gleam", 29). ?DOC( " Create a new bot instance.\n" " \n" " Example:\n" " ```gleam\n" " import discord_gleam/discord/intents\n" " \n" " fn main() {\n" " let bot = discord_gleam.bot(\"TOKEN\", \"CLIENT_ID\", intents.default()))\n" " }\n" " ```\n" ). -spec bot(binary(), binary(), discord_gleam@discord@intents:intents()) -> discord_gleam@types@bot:bot(). bot(Token, Client_id, Intents) -> {bot, Token, Client_id, Intents, {cache, case bravo@uset:new(<<"MessagesCache"/utf8>>, 1, public) of {ok, Cache} -> {some, Cache}; {error, _} -> none end}}. -file("src/discord_gleam.gleam", 70). ?DOC( " Start the event loop, with a set of event handlers.\n" "\n" " Example:\n" " ```gleam\n" " import discord_gleam/discord/intents\n" " import discord_gleam/event_handler\n" " \n" " fn main() {\n" " let bot = discord_gleam.bot(\"TOKEN\", \"CLIENT_ID\", intents.default())\n" " \n" " let event_handlers = [handler]\n" " \n" " discord_gleam.run(bot, event_handlers)\n" " }\n" " \n" " fn handler(bot: bot.Bot, packet: event_handler.Packet) {\n" " case packet {\n" " event_handler.ReadyPacket(ready) -> {\n" " logging.log(logging.Info, \"Logged in as \" <> ready.d.user.username)\n" " }\n" " \n" " _ -> Nil\n" " }\n" " }\n" ). -spec run( discord_gleam@types@bot:bot(), list(fun((discord_gleam@types@bot:bot(), discord_gleam@event_handler:packet()) -> nil)) ) -> nil. run(Bot, Event_handlers) -> discord_gleam@ws@event_loop:main(Bot, Event_handlers). -file("src/discord_gleam.gleam", 93). ?DOC( " Send a message to a channel.\n" " \n" " Example:\n" " ```gleam\n" " import discord_gleam\n" " \n" " fn main() {\n" " ...\n" " \n" " let msg = discord_gleam.send_message(\n" " bot, \n" " \"CHANNEL_ID\",\n" " \"Hello world!\",\n" " [] // embeds\n" " )\n" " }\n" ). -spec send_message( discord_gleam@types@bot:bot(), binary(), binary(), list(discord_gleam@types@message:embed()) ) -> nil. send_message(Bot, Channel_id, Message, Embeds) -> Msg = {message, Message, Embeds}, discord_gleam@http@endpoints:send_message( erlang:element(2, Bot), Channel_id, Msg ). -file("src/discord_gleam.gleam", 107). ?DOC( " Send a direct message to a user. \\\n" " Same use as `send_message`, but use user_id instead of channel_id. \\\n" " `discord_gleam.send_direct_message(bot, \"USER_ID\", \"Hello world!\", [])`\n" ). -spec send_direct_message( discord_gleam@types@bot:bot(), binary(), binary(), list(discord_gleam@types@message:embed()) ) -> nil. send_direct_message(Bot, User_id, Message, Embeds) -> Msg = {message, Message, Embeds}, discord_gleam@http@endpoints:send_direct_message( erlang:element(2, Bot), User_id, Msg ). -file("src/discord_gleam.gleam", 131). ?DOC( " Reply to a message in a channel.\n" " \n" " Example:\n" " \n" " ```gleam\n" " import discord_gleam\n" " \n" " fn main() {\n" " ...\n" " \n" " discord_gleam.reply(bot, \"CHANNEL_ID\", \"MESSAGE_ID\", \"Hello world!\", [])\n" " }\n" " ```\n" ). -spec reply( discord_gleam@types@bot:bot(), binary(), binary(), binary(), list(discord_gleam@types@message:embed()) ) -> nil. reply(Bot, Channel_id, Message_id, Message, Embeds) -> Msg = {reply, Message, Message_id, Embeds}, discord_gleam@http@endpoints:reply(erlang:element(2, Bot), Channel_id, Msg). -file("src/discord_gleam.gleam", 157). ?DOC( " Kicks an member from an server. \\\n" " The reason will be what is shown in the audit log.\n" " \n" " Example:\n" " \n" " ```gleam\n" " import discord_gleam\n" " \n" " fn main() {\n" " ...\n" " \n" " discord_gleam.kick_member(bot, \"GUILD_ID\", \"USER_ID\", \"REASON\")\n" " }\n" ). -spec kick_member(discord_gleam@types@bot:bot(), binary(), binary(), binary()) -> {binary(), binary()}. kick_member(Bot, Guild_id, User_id, Reason) -> discord_gleam@http@endpoints:kick_member( erlang:element(2, Bot), Guild_id, User_id, Reason ). -file("src/discord_gleam.gleam", 166). -spec ban_member(discord_gleam@types@bot:bot(), binary(), binary(), binary()) -> {binary(), binary()}. ban_member(Bot, Guild_id, User_id, Reason) -> discord_gleam@http@endpoints:ban_member( erlang:element(2, Bot), Guild_id, User_id, Reason ). -file("src/discord_gleam.gleam", 175). -spec delete_message( discord_gleam@types@bot:bot(), binary(), binary(), binary() ) -> {binary(), binary()}. delete_message(Bot, Channel_id, Message_id, Reason) -> discord_gleam@http@endpoints:delete_message( erlang:element(2, Bot), Channel_id, Message_id, Reason ). -file("src/discord_gleam.gleam", 186). ?DOC( " Wipes all the global slash commands for the bot. \\\n" " Restarting your client might be required to see the changes. \\\n" ). -spec wipe_global_commands(discord_gleam@types@bot:bot()) -> {binary(), binary()}. wipe_global_commands(Bot) -> discord_gleam@http@endpoints:wipe_global_commands( erlang:element(2, Bot), erlang:element(3, Bot) ). -file("src/discord_gleam.gleam", 192). ?DOC( " Wipes all the guild slash commands for the bot. \\\n" " Restarting your client might be required to see the changes. \\\n" ). -spec wipe_guild_commands(discord_gleam@types@bot:bot(), binary()) -> {binary(), binary()}. wipe_guild_commands(Bot, Guild_id) -> discord_gleam@http@endpoints:wipe_guild_commands( erlang:element(2, Bot), erlang:element(3, Bot), Guild_id ). -file("src/discord_gleam.gleam", 198). ?DOC( " Registers a global slash command. \\\n" " Restarting your client might be required to see the changes. \\\n" ). -spec register_global_commands( discord_gleam@types@bot:bot(), list(discord_gleam@types@slash_command:slash_command()) ) -> nil. register_global_commands(Bot, Commands) -> gleam@list:each( Commands, fun(Command) -> discord_gleam@http@endpoints:register_global_command( erlang:element(2, Bot), erlang:element(3, Bot), Command ) end ). -file("src/discord_gleam.gleam", 209). ?DOC( " Registers a guild-specific slash command. \\\n" " Restarting your client might be required to see the changes. \\\n" ). -spec register_guild_commands( discord_gleam@types@bot:bot(), binary(), list(discord_gleam@types@slash_command:slash_command()) ) -> nil. register_guild_commands(Bot, Guild_id, Commands) -> gleam@list:each( Commands, fun(Command) -> discord_gleam@http@endpoints:register_guild_command( erlang:element(2, Bot), erlang:element(3, Bot), Guild_id, Command ) end ). -file("src/discord_gleam.gleam", 225). ?DOC(" Make a basic text reply to an interaction.\n"). -spec interaction_reply_message( discord_gleam@ws@packets@interaction_create:interaction_create(), binary(), boolean() ) -> {binary(), binary()}. interaction_reply_message(Interaction, Message, Ephemeral) -> discord_gleam@http@endpoints:interaction_send_text( Interaction, Message, Ephemeral ).