Skip to content

Instantly share code, notes, and snippets.

@andrevdm
Created May 11, 2024 11:41
Show Gist options
  • Save andrevdm/fd109e04329366ed5ff1b6135d009790 to your computer and use it in GitHub Desktop.
Save andrevdm/fd109e04329366ed5ff1b6135d009790 to your computer and use it in GitHub Desktop.
F# discord bot
open System.Threading.Tasks
open DSharpPlus
let discord =
new DiscordClient(
new DiscordConfiguration(
Token = "xxxx", //Token goes here
TokenType = TokenType.Bot,
Intents = DiscordIntents.AllUnprivileged
)
)
discord.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
discord.add_MessageCreated (
fun _c e ->
task {
if e.Message.Content.StartsWith("!ping") then
do! e.Message.RespondAsync("Pong!") :> Task
}
)
Task.Delay(-1) |> Async.AwaitTask |> Async.RunSynchronously
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment