Current section

Files

Jump to
discord_gleam src discord_gleam.erl
Raw

src/discord_gleam.erl

-module(discord_gleam).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([bot/1, run/2, send_message/4, reply/5, kick_member/4, ban_member/4, delete_message/4, wipe_global_commands/2, wipe_guild_commands/3, register_global_commands/3, register_guild_commands/4, interaction_reply_message/3]).
-spec bot(binary()) -> discord_gleam@types@bot:bot().
bot(Token) ->
{bot, Token}.
-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).
-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
).
-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).
-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
).
-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
).
-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
).
-spec wipe_global_commands(discord_gleam@types@bot:bot(), binary()) -> {binary(),
binary()}.
wipe_global_commands(Bot, Client_id) ->
discord_gleam@http@endpoints:wipe_global_commands(
erlang:element(2, Bot),
Client_id
).
-spec wipe_guild_commands(discord_gleam@types@bot:bot(), binary(), binary()) -> {binary(),
binary()}.
wipe_guild_commands(Bot, Client_id, Guild_id) ->
discord_gleam@http@endpoints:wipe_guild_commands(
erlang:element(2, Bot),
Client_id,
Guild_id
).
-spec register_global_commands(
discord_gleam@types@bot:bot(),
binary(),
list(discord_gleam@types@slash_command:slash_command())
) -> nil.
register_global_commands(Bot, Client_id, Commands) ->
gleam@list:each(
Commands,
fun(Command) ->
discord_gleam@http@endpoints:register_global_command(
erlang:element(2, Bot),
Client_id,
Command
)
end
).
-spec register_guild_commands(
discord_gleam@types@bot:bot(),
binary(),
binary(),
list(discord_gleam@types@slash_command:slash_command())
) -> nil.
register_guild_commands(Bot, Client_id, Guild_id, Commands) ->
gleam@list:each(
Commands,
fun(Command) ->
discord_gleam@http@endpoints:register_guild_command(
erlang:element(2, Bot),
Client_id,
Guild_id,
Command
)
end
).
-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
).