goscord
1.0.0
Goscord 是 Golang 的一個包,提供與 Discord API 的高階綁定。
# Init the module:
go mod init < url >
# Install Goscord:
go get -u github.com/Goscord/goscord
建立一個新的 Discord 用戶端,可用於存取各種 Discord API 函數並為 Discord 事件設定回調函數。
package main
import (
"fmt"
"github.com/Goscord/goscord/goscord"
"github.com/Goscord/goscord/goscord/discord"
"github.com/Goscord/goscord/goscord/gateway"
"github.com/Goscord/goscord/goscord/gateway/event"
)
var client * gateway. Session
func main () {
fmt . Println ( "Starting..." )
client := goscord . New ( & gateway. Options {
Token : "token" ,
Intents : gateway . IntentGuildMessages ,
})
client . On ( event . EventReady , func () {
fmt . Println ( "Logged in as " + client . Me (). Tag ())
})
client . On ( event . EventMessageCreate , func ( msg * discord. Message ) {
if msg . Content == "ping" {
client . Channel . SendMessage ( msg . ChannelId , "Pong ! ?" )
}
})
client . Login ()
select {}
}
請參閱文件以取得更多詳細資訊。
歡迎請求請求。對於重大更改,請先開啟一個問題來討論您想要更改的內容。