Created
May 11, 2024 11:41
-
-
Save andrevdm/fd109e04329366ed5ff1b6135d009790 to your computer and use it in GitHub Desktop.
F# discord bot
This file contains hidden or 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
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