Current section
Files
Jump to
Current section
Files
src/discord_gleam.erl
-module(discord_gleam).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([bot/3, run/2, send_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]).
-file("src/discord_gleam.gleam", 15).
-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", 31).
-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", 38).
-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", 49).
-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", 62).
-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", 71).
-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", 80).
-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", 89).
-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", 93).
-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", 97).
-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", 106).
-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", 121).
-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
).