discord_gleam
Values
pub fn ban_member(
bot: Bot,
guild_id: String,
user_id: String,
reason: String,
) -> #(String, String)
pub fn bot(
token: String,
client_id: String,
intents: Intents,
) -> Bot
Create a new bot instance.
Example:
import discord_gleam/discord/intents
pub fn main() {
let bot = discord_gleam.bot("TOKEN", "CLIENT_ID", intents.default())
}
pub fn delete_message(
bot: Bot,
channel_id: String,
message_id: String,
reason: String,
) -> #(String, String)
pub fn interaction_reply_message(
interaction: InteractionCreate,
message: String,
ephemeral: Bool,
) -> #(String, String)
pub fn kick_member(
bot: Bot,
guild_id: String,
user_id: String,
reason: String,
) -> #(String, String)
pub fn register_global_commands(
bot: Bot,
commands: List(SlashCommand),
) -> Nil
pub fn register_guild_commands(
bot: Bot,
guild_id: String,
commands: List(SlashCommand),
) -> Nil
pub fn reply(
bot: Bot,
channel_id: String,
message_id: String,
message: String,
embeds: List(Embed),
) -> Nil
pub fn run(
bot: Bot,
event_handlers: List(fn(Bot, Packet) -> Nil),
) -> Nil
Start the event loop, with a set of event handlers.
Example:
import discord_gleam/discord/intents
import discord_gleam/event_handler
pub fn main() {
let bot = discord_gleam.bot("TOKEN", "CLIENT_ID", intents.default())
let event_handlers = [handler]
}
fn handler(bot: bot.Bot, packet: event_handler.Packet) {
case packet {
event_handler.ReadyPacket(ready) -> {
logging.log(logging.Info, "Logged in as " <> ready.d.user.username)
}
_ -> Nil
}
}
pub fn send_direct_message(
bot: Bot,
user_id: String,
message: String,
embeds: List(Embed),
) -> Nil
Send a direct message to a user.
Same use as send_message
, but use user_id instead of channel_id.
discord_gleam.send_direct_message(bot, "USER_ID", "Hello world!", [])
pub fn send_message(
bot: Bot,
channel_id: String,
message: String,
embeds: List(Embed),
) -> Nil
Send a message to a channel.
Example:
import discord_gleam
pub fn main() {
...
let msg = discord_gleam.send_message(
bot,
"CHANNEL_ID",
"Hello world!",
[] // embeds
)
pub fn wipe_global_commands(bot: Bot) -> #(String, String)
pub fn wipe_guild_commands(
bot: Bot,
guild_id: String,
) -> #(String, String)