-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cyteon
committed
Jul 17, 2024
1 parent
db2558a
commit f7e09c4
Showing
9 changed files
with
103 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
import discord_gleam/event_handler | ||
import discord_gleam/http/endpoints | ||
import discord_gleam/types/bot | ||
import discord_gleam/types/message | ||
import discord_gleam/ws/event_loop | ||
|
||
pub fn bot(token: String) -> bot.Bot { | ||
bot.Bot(token: token) | ||
} | ||
|
||
pub fn run( | ||
token: String, | ||
bot: bot.Bot, | ||
event_handlers: List(event_handler.EventHandler), | ||
) -> Nil { | ||
event_loop.main(token, event_handlers) | ||
event_loop.main(bot, event_handlers) | ||
} | ||
|
||
pub fn send_message(bot: bot.Bot, message: String, channel_id: String) -> Nil { | ||
let msg = message.Message(content: message) | ||
|
||
endpoints.send_message(bot.token, msg, channel_id) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub type Bot { | ||
Bot(token: String) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import gleam/json | ||
|
||
pub type Message { | ||
Message(content: String) | ||
} | ||
|
||
pub fn to_string(msg: Message) -> String { | ||
json.object([#("content", json.string(msg.content))]) | ||
|> json.to_string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters