v0.5.1

Discord API

最終更新


github.com/bwmarrin/discordgo v0.29.0 を土台にした github.com/pardnchiu/go-bot/core/discord のすべての exported シンボルです。

型


シンボル定義備考
Botstruct(非公開フィールド)New で作成する。メソッドは並行利用しても安全
Statusstruct { Running bool; Username string; UserID string }Status() が返す
Inputstructフィールド: ChannelID、ChannelName、GuildID、MessageID、UserID、Username、Text(すべて string)、Attachments []*discordgo.MessageAttachment、CallbackPicks []string、Raw *discordgo.MessageCreate。Discord の設定 を参照
ReplyHandlerfunc(ctx context.Context, input Input) string
ChannelStatusstruct(非公開フィールド)SendStatus が管理するチャンネルごとのステータス項目。呼び出し側では作成しない
StatusOptionfunc(*statusOptions)SendStatus のオプション

コンストラクタとオプション


関数効果
New(token string) (*Bot, error)token が空の場合、または discordgo が拒否した場合にエラー
WithStatusEmoji(emoji string) StatusOptionリアクションの絵文字。デフォルトは 🤔

メソッド


メソッド戻り値エラーと制限
Start(ctx context.Context)errorUser("@me") または Session.Open の失敗
Close()errorSession.Close の失敗
Status()Status
Reply(handler ReplyHandler)—以前の handler を置き換える
Send(ctx, channelID, replyTo, text string)(*discordgo.Message, error)空のチャンネル ID、API のエラー
Delete(ctx, channelID, messageID string)error空の ID、API のエラー
SendFiles(ctx, channelID, replyTo string, paths []string, caption ...string)(*discordgo.Message, error)空のチャンネル ID、パスが 0 個または 10 個超、空のパス、os.Open の失敗
SendVoice(ctx, channelID, replyTo, path string, caption ...string)(*discordgo.Message, error)空のチャンネル ID またはパス、os.Open の失敗
SendInput(ctx, channelID, replyTo, prompt string)(*discordgo.Message, error)空のチャンネル ID またはプロンプト、UUID の失敗
SendSelect(ctx, channelID, replyTo, text string, items []string)(*discordgo.Message, error)空のチャンネル ID またはテキスト、空でない項目が 0 個または 25 個超、UUID の失敗
SendMultiSelect(ctx, channelID, replyTo, text string, items []string)(*discordgo.Message, error)SendSelect と同じ
SendStatus(ctx, channelID, replyTo, text string, opts ...StatusOption)error即座に flush した場合の送信 / 編集エラー
FinishStatus(ctx, channelID string)error削除のエラー、または処理中の編集を待つ間の ctx.Err()
Save(ctx, att *discordgo.MessageAttachment, dir string)(string, error)nil の添付ファイル、空の URL または dir、25 MiB を超えるファイル、200 以外の HTTP ステータス、ファイルシステムのエラー

関連ページ


Discord の設定 · Discord メッセージ · Discord インタラクション · ステータスメッセージ · メディアの保存