-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. -file("src/discord_gleam.gleam", 25). ?DOC( " Create a new bot instance.\n" " \n" " Example:\n" " ```gleam\n" " import discord_gleam/discord/intents\n" " \n" " pub 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", 64). ?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" " pub fn main() {\n" " let bot = discord_gleam.bot(\"TOKEN\", \"CLIENT_ID\", intents.default())\n" " \n" " let event_handlers = [handler]\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", 87). ?DOC( " Send a message to a channel.\n" " \n" " Example:\n" " ```gleam\n" " import discord_gleam\n" " \n" " pub 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", 101). ?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", 112). -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", 125). -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", 134). -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", 143). -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", 152). -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", 156). -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", 160). -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", 169). -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", 184). -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 ).