Documentation ¶
Overview ¶
Package beelzebub implements a REST API client for Discord.
Index ¶
- Constants
- func HTTPClient(c *http.Client) defaultClientOption
- type ClientOption
- type CreateGuildOptions
- type Devil
- func (d *Devil) Application(id string) *application.Fly
- func (d *Devil) ApplicationWithToken(id, token string) *application.Fly
- func (d *Devil) Channel(id string) *channel.Fly
- func (d *Devil) ChannelWithToken(id, token string) *channel.Fly
- func (d *Devil) CreateGuild(ctx context.Context, opts *CreateGuildOptions) (*sigil.Guild, error)
- func (d *Devil) GetGateway(ctx context.Context) (*GetGatewayResponse, error)
- func (d *Devil) GetUser(ctx context.Context, id string) (*sigil.User, error)
- func (d *Devil) Guild(id string) *guild.Fly
- func (d *Devil) GuildWithToken(id, token string) *guild.Fly
- func (d *Devil) Invite(code string) *invite.Fly
- func (d *Devil) InviteWithToken(code, token string) *invite.Fly
- func (d *Devil) ListVoiceRegions(ctx context.Context) ([]*sigil.VoiceRegion, error)
- func (d *Devil) Stage(id string) *stage.Fly
- func (d *Devil) StageWithToken(id, token string) *stage.Fly
- func (d *Devil) TokenedWebhook(id, token string) *webhook.TokenFly
- func (d *Devil) User() *user.Fly
- func (d *Devil) UserWithToken(token string) *user.Fly
- func (d *Devil) Webhook(id string) *webhook.Fly
- func (d *Devil) WebhookWithToken(id, token string) *webhook.Fly
- type GetGatewayResponse
Constants ¶
const ( // BaseURL is the root of Discord's API, unversioned. BaseURL = "https://discord.com/api/v" // Version denotes what version of the API we're using. Version = "9" // RootURL is the root of Discord's API, versioned. RootURL = BaseURL + Version // ContentType is the default Content-Type header used by Beelzebub. ContentType = "application/json" // Accept is the default Accept header used by Beelzebub. Accept = "application/json" // UserAgent is the default User-Agent header used by Beelzebub. UserAgent = "DiscordBot (https://github.com/disaccord/beelzebub, %s)" )
Variables ¶
This section is empty.
Functions ¶
func HTTPClient ¶
HTTPClient sets the *http.Client on a DefaultClient.
Types ¶
type ClientOption ¶
type ClientOption func(*Devil)
ClientOption configures a Devil.
func WithRestClient ¶
func WithRestClient(rc flies.RestClient) ClientOption
WithRestClient sets the internal RestClient used by a Devil.
type CreateGuildOptions ¶
type CreateGuildOptions struct { Name string `json:"name"` Region null.String `json:"region,omitempty"` Icon string `json:"icon,omitempty"` VerificationLevel sigil.VerificationLevel `json:"verification_level,omitempty"` DefaultMessageNotifications sigil.DefaultMessageNotificationLevel `json:"default_message_notifications,omitempty"` ExplicitContentFilter sigil.ExplicitContentFilterLevel `json:"explicit_content_filter,omitempty"` Roles []*sigil.Role `json:"roles,omitempty"` Channels []*sigil.Channel `json:"channels,omitempty"` AFKChannelID null.String `json:"afk_channel_id,omitempty"` AFKTimeout int `json:"afk_timeout,omitempty"` SystemChannelID string `json:"system_channel_id,omitempty"` SystemChannelFlags sigil.SystemChannelFlag `json:"system_channel_flags,omitempty"` }
CreateGuildOptions contains parameters used to configure a Guild upon creation. The only required field is `Name`.
type Devil ¶
type Devil struct {
// contains filtered or unexported fields
}
Devil is an HTTP client responsible for interacting with Discord's API.
func New ¶
func New(defaultToken string, opts ...ClientOption) (*Devil, error)
New creates a new Devil with the given token and options. The token is used as a default for when a resource is not configured to use another.
func (*Devil) Application ¶
func (d *Devil) Application(id string) *application.Fly
Application is a shorthand for `*Devil.ApplicationWithToken(id, "")`.
func (*Devil) ApplicationWithToken ¶
func (d *Devil) ApplicationWithToken(id, token string) *application.Fly
ApplicationWithToken creates a new Fly to manage an Application. If omitted, `token` will be set to `*Devil.defaultToken`.
func (*Devil) ChannelWithToken ¶
ChannelWithToken creates a new Fly to manage a Channel. If omitted, `token` will be set to `*Devil.defaultToken`.
func (*Devil) CreateGuild ¶
CreateGuild creates a new Guild with the options. This can only be used by a bot in 10 guilds or less.
func (*Devil) GetGateway ¶
func (d *Devil) GetGateway(ctx context.Context) (*GetGatewayResponse, error)
GetGateway retreives a connection URL for Discord's Gateway. The return value should be cached, and this method should then only be called when connecting with the cached value fails.
func (*Devil) GuildWithToken ¶
GuildWithToken creates a new Fly to manage a Guild. If omitted, `token` will be set to `*Devil.defaultToken`.
func (*Devil) InviteWithToken ¶
InviteWithToken creates a new Fly to manage an Invite. If omitted, `token` will be set to `*Devil.defaultToken`.
func (*Devil) ListVoiceRegions ¶
ListVoiceRegions fetches the list of Voice Regions.
func (*Devil) StageWithToken ¶
StageWithToken creates a Fly to manage a Stage. If omitted, `token` is set to `*Devil.defaultToken`.
func (*Devil) TokenedWebhook ¶
TokenedWebhook creates a Fly to manage an unauthenticated Webhook.
func (*Devil) UserWithToken ¶
UserWithToken creates a new Fly to manage a User. If omitted, `token` will be set to `*Devil.defaultToken`.
type GetGatewayResponse ¶
type GetGatewayResponse struct {
URL string `json:"url"`
}
GetGatewayResponse is the response sent by Discord when requesting a URL to the gateway.