guild

package
v0.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditLogOption

type AuditLogOption func(*auditLogQuery)

AuditLogOption allows to customize a query to the audit log.

func WithAuditLogBefore

func WithAuditLogBefore(before string) AuditLogOption

WithAuditLogBefore is used to paginate the audit log. The before parameter is the ID of the last audit log entry of our previous query.

func WithAuditLogEntryType

func WithAuditLogEntryType(typ audit.EntryType) AuditLogOption

WithAuditLogEntryType sets the entry type the query must return.

func WithAuditLogLimit

func WithAuditLogLimit(limit int) AuditLogOption

WithAuditLogLimit sets the limit the audit log query should return. It must be between 1 and 100 and defaults to 50 if not specified.

func WithAuditLogUserID

func WithAuditLogUserID(id string) AuditLogOption

WithAuditLogUserID sets the user ID of the audit log query. It make the query only return audit log entries that have been creating for actions performed by this user.

type ChannelPosition

type ChannelPosition struct {
	ID       string `json:"id"`
	Position int    `json:"position"`
}

ChannelPosition is a pair of channel ID with its position.

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

Resource is a resource that allows to perform various actions on a Discord guild. Create one with Client.Guild.

func NewResource

func NewResource(c resource.RestClient, id string) *Resource

func (*Resource) AddIntegration

func (r *Resource) AddIntegration(ctx context.Context, id, typ string) error

AddIntegration attaches an integration from the current user to the guild. Requires the 'MANAGE_GUILD' permission. Fires a Guild Integrations Update Gateway event.

func (*Resource) AddMember

func (r *Resource) AddMember(ctx context.Context, userID, token string, settings *discord.GuildMemberSettings) (*discord.GuildMember, error)

AddMember adds a user to the guild, provided you have a valid oauth2 access token for the user with the guilds.join scope. Fires a Guild Member Add Gateway event. Requires the bot to have the CREATE_INSTANT_INVITE permission.

func (*Resource) AddMemberRole

func (r *Resource) AddMemberRole(ctx context.Context, userID, roleID string) error

AddMemberRole is like AddMemberRoleWithReason but with no particular reason.

func (*Resource) AddMemberRoleWithReason

func (r *Resource) AddMemberRoleWithReason(ctx context.Context, userID, roleID, reason string) error

AddMemberRole adds a role to a guild member. Requires the 'MANAGE_ROLES' permission. Fires a Guild Member Update Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) AuditLog

func (r *Resource) AuditLog(ctx context.Context, opts ...AuditLogOption) (*audit.Log, error)

AuditLog returns the audit log of the given Guild. Requires the 'VIEW_AUDIT_LOG' permission.

func (*Resource) Ban

func (r *Resource) Ban(ctx context.Context, userID string) error

Ban is a shorthand to ban a user with no reason and without deleting his messages. Requires the 'BAN_MEMBERS' permission. For more control, use the BanWithReason method.

func (*Resource) BanWithReason

func (r *Resource) BanWithReason(ctx context.Context, userID string, delMsgDays int, reason string) error

BanWithReason creates a guild ban, and optionally delete previous messages sent by the banned user. Requires the 'BAN_MEMBERS' permission. Parameter delMsgDays is the number of days to delete messages for (0-7). Fires a Guild Ban Add Gateway event.

func (*Resource) Bans

func (r *Resource) Bans(ctx context.Context) ([]discord.Ban, error)

Bans returns a list of bans for the users banned from this guild. Requires the 'BAN_MEMBERS' permission.

func (*Resource) BeginPrune

func (r *Resource) BeginPrune(ctx context.Context, days int, computePruneCount bool) (pruneCount int, err error)

BeginPrune is like BeginPruneWithReason but with no particular reason.

func (*Resource) BeginPruneWithReason

func (r *Resource) BeginPruneWithReason(ctx context.Context, days int, computePruneCount bool, reason string) (pruneCount int, err error)

BeginPruneWithReason begins a prune operation. Requires the 'KICK_MEMBERS' permission. Returns the number of members that were removed in the prune operation if computePruneCount is set to true (not recommended for large guilds). Fires multiple Guild Member Remove Gateway events. The given reason will be set in the audit log entry for this action.

func (*Resource) ChangeNick

func (r *Resource) ChangeNick(ctx context.Context, name string) (string, error)

ChangeNick modifies the nickname of the current user (i.e.: the bot) for this guild. It returns the nickname on success. Requires the 'CHANGE_NICKNAME' permission. Fires a Guild Member Update Gateway event.

func (*Resource) Channels

func (r *Resource) Channels(ctx context.Context) ([]discord.Channel, error)

Channels returns the list of channels in the guild.

func (*Resource) Delete

func (r *Resource) Delete(ctx context.Context) error

Delete deletes the guild permanently. Current user must be owner. Fires a Guild Delete Gateway event.

func (*Resource) DeleteEmoji

func (r *Resource) DeleteEmoji(ctx context.Context, emojiID string) error

DeleteEmoji is like DeleteEmojiWithReason but with no particular reason.

func (*Resource) DeleteEmojiWithReason

func (r *Resource) DeleteEmojiWithReason(ctx context.Context, emojiID, reason string) error

DeleteEmojiWithReason deletes the given emoji. Requires the 'MANAGE_EMOJIS' permission. Fires a Guild Emojis Update Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) DeleteRole

func (r *Resource) DeleteRole(ctx context.Context, id string) error

DeleteRole is like DeleteRoleWithReason but with no particular reason.

func (*Resource) DeleteRoleWithReason

func (r *Resource) DeleteRoleWithReason(ctx context.Context, id, reason string) error

DeleteRole deletes a guild role. Requires the 'MANAGE_ROLES' permission. Fires a Guild Role Delete Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) Emoji

func (r *Resource) Emoji(ctx context.Context, emojiID string) (*discord.Emoji, error)

Emoji returns an emoji from the guild.

func (*Resource) Emojis

func (r *Resource) Emojis(ctx context.Context) ([]discord.Emoji, error)

Emojis returns the list of emojis of the guild. Requires the MANAGE_EMOJIS permission.

func (*Resource) Get

func (r *Resource) Get(ctx context.Context) (*discord.Guild, error)

Get returns the guild.

func (*Resource) Integrations

func (r *Resource) Integrations(ctx context.Context) ([]discord.GuildIntegration, error)

Integrations returns the list of integrations for the guild. Requires the 'MANAGE_GUILD' permission.

func (*Resource) Invites

func (r *Resource) Invites(ctx context.Context) ([]discord.Invite, error)

Invites returns the list of invites (with invite metadata) for the guild. Requires the 'MANAGE_GUILD' permission.

func (*Resource) Kick

func (r *Resource) Kick(ctx context.Context, userID string) error

Kick is like KickWithReason but with no particular reason.

func (*Resource) KickWithReason

func (r *Resource) KickWithReason(ctx context.Context, userID, reason string) error

Kick removes the given user from the guild. Requires 'KICK_MEMBERS' permission. Fires a Guild Member Remove Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) Member

func (r *Resource) Member(ctx context.Context, userID string) (*discord.GuildMember, error)

Member returns a single guild member given its user ID.

func (*Resource) Members

func (r *Resource) Members(ctx context.Context, limit int, after string) ([]discord.GuildMember, error)

Members returns a list of at most limit guild members, starting at after. limit must be between 1 and 1000 and will be set to those values if higher/lower. after is the ID of the guild member you want to get the list from, leave it empty to start from the beginning.

func (*Resource) Modify

func (r *Resource) Modify(ctx context.Context, settings *discord.GuildSettings) (*discord.Guild, error)

Modify is like ModifyWithReason but with no particular reason.

func (*Resource) ModifyChannelPosition

func (r *Resource) ModifyChannelPosition(ctx context.Context, pos []ChannelPosition) error

ModifyChannelPosition modifies the positions of a set of channel for the guild. Requires 'MANAGE_CHANNELS' permission. Fires multiple Channel Update Gateway events.

Only channels to be modified are required, with the minimum being a swap between at least two channels.

func (*Resource) ModifyEmoji

func (r *Resource) ModifyEmoji(ctx context.Context, emojiID, name string, roles []string) (*discord.Emoji, error)

ModifyEmoji is like ModifyEmojiWithReason but with no particular reason.

func (*Resource) ModifyEmojiWithReason

func (r *Resource) ModifyEmojiWithReason(ctx context.Context, emojiID, name string, roles []string, reason string) (*discord.Emoji, error)

ModifyEmojiWithReason modifies the given emoji for the guild. Requires the 'MANAGE_EMOJIS' permission. Fires a Guild Emojis Update Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) ModifyIntegration

func (r *Resource) ModifyIntegration(ctx context.Context, id string, settings *discord.GuildIntegrationSettings) error

ModifyIntegration modifies the behavior and settings of a guild integration. Requires the 'MANAGE_GUILD' permission. Fires a Guild Integrations Update Gateway event.

func (*Resource) ModifyMember

func (r *Resource) ModifyMember(ctx context.Context, userID string, settings *discord.GuildMemberSettings) error

ModifyMember is like ModifyMemberWithReason but with no particular reason.

func (*Resource) ModifyMemberWithReason

func (r *Resource) ModifyMemberWithReason(ctx context.Context, userID string, settings *discord.GuildMemberSettings, reason string) error

ModifyMember modifies attributes of a guild member. Fires a Guild Member Update Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) ModifyRole

func (r *Resource) ModifyRole(ctx context.Context, id string, settings *discord.RoleSettings) (*discord.Role, error)

ModifyRole is like ModifyRoleWithReason but with no particular reason.

func (*Resource) ModifyRolePositions

func (r *Resource) ModifyRolePositions(ctx context.Context, pos []RolePosition) ([]discord.Role, error)

ModifyRolePositions modifies the positions of a set of roles for the guild. Requires 'MANAGE_ROLES' permission. Fires multiple Guild Role Update Gateway events.

func (*Resource) ModifyRoleWithReason

func (r *Resource) ModifyRoleWithReason(ctx context.Context, id string, settings *discord.RoleSettings, reason string) (*discord.Role, error)

ModifyRole modifies a guild role. Requires the 'MANAGE_ROLES' permission. Fires a Guild Role Update Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) ModifyWidget

func (r *Resource) ModifyWidget(ctx context.Context, embed *discord.GuildWidget) (*discord.GuildWidget, error)

ModifyWidget modifies the widget of the guild. Requires the 'MANAGE_GUILD' permission.

func (*Resource) ModifyWithReason

func (r *Resource) ModifyWithReason(ctx context.Context, settings *discord.GuildSettings, reason string) (*discord.Guild, error)

ModifyWithReason modifies the guild's settings. Requires the 'MANAGE_GUILD' permission. Returns the updated guild on success. Fires a Guild Update Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) NewChannel

func (r *Resource) NewChannel(ctx context.Context, settings *discord.ChannelSettings) (*discord.Channel, error)

NewChannel is like NewChannelWithReason but with no particular reason.

func (*Resource) NewChannelWithReason

func (r *Resource) NewChannelWithReason(ctx context.Context, settings *discord.ChannelSettings, reason string) (*discord.Channel, error)

NewChannelWithReason creates a new channel in the guild. Requires the MANAGE_CHANNELS permission. Fires a Channel Create Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) NewEmoji

func (r *Resource) NewEmoji(ctx context.Context, name, image string, roles []string) (*discord.Emoji, error)

NewEmoji is like NewEmojiWithReason but with no particular reason.

func (*Resource) NewEmojiWithReason

func (r *Resource) NewEmojiWithReason(ctx context.Context, name, image string, roles []string, reason string) (*discord.Emoji, error)

NewEmojiWithReason creates a new emoji for the guild. image is the base64 encoded data of a 128*128 image. Requires the 'MANAGE_EMOJIS' permission. Fires a Guild Emojis Update Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) NewRole

func (r *Resource) NewRole(ctx context.Context, settings *discord.RoleSettings) (*discord.Role, error)

NewRole is like NewRoleWithReason but with no particular reason.

func (*Resource) NewRoleWithReason

func (r *Resource) NewRoleWithReason(ctx context.Context, settings *discord.RoleSettings, reason string) (*discord.Role, error)

NewRole creates a new role for the guild. Requires the 'MANAGE_ROLES' permission. Fires a Guild Role Create Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) PruneCount

func (r *Resource) PruneCount(ctx context.Context, days int) (int, error)

PruneCount returns the number of members that would be removed in a prune operation. Requires the 'KICK_MEMBERS' permission.

func (*Resource) RemoveIntegration

func (r *Resource) RemoveIntegration(ctx context.Context, id string) error

RemoveIntegration removes the attached integration for the guild. Requires the 'MANAGE_GUILD' permission. Fires a Guild Integrations Update Gateway event.

func (*Resource) RemoveMemberRole

func (r *Resource) RemoveMemberRole(ctx context.Context, userID, roleID string) error

RemoveMemberRole is like RemoveMemberRoleWithReason but with no particular reason.

func (*Resource) RemoveMemberRoleWithReason

func (r *Resource) RemoveMemberRoleWithReason(ctx context.Context, userID, roleID, reason string) error

RemoveMemberRoleWithReason removes a role from a guild member. Requires the 'MANAGE_ROLES' permission. Fires a Guild Member Update Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) Roles

func (r *Resource) Roles(ctx context.Context) ([]discord.Role, error)

Roles returns a list of roles for the guild. Requires the 'MANAGE_ROLES' permission.

func (*Resource) SyncIntegration

func (r *Resource) SyncIntegration(ctx context.Context, id string) error

SyncIntegration syncs a guild integration. Requires the 'MANAGE_GUILD' permission.

func (*Resource) Unban

func (r *Resource) Unban(ctx context.Context, userID string) error

Unban is like UnbanWithReason but with no particular reason.

func (*Resource) UnbanWithReason

func (r *Resource) UnbanWithReason(ctx context.Context, userID, reason string) error

Unban removes the ban for a user. Requires the 'BAN_MEMBERS' permissions. Fires a Guild Ban Remove Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) VanityURL

func (r *Resource) VanityURL(ctx context.Context) (*discord.Invite, error)

VanityURL returns a partial invite for the guild if that feature is enabled. Requires the 'MANAGE_GUILD' permission.

func (*Resource) VoiceRegions

func (r *Resource) VoiceRegions(ctx context.Context) ([]discord.VoiceRegion, error)

VoiceRegions returns a list of available voice regions for the guild. Unlike the similar VoiceRegions method of the Client, this returns VIP servers when the guild is VIP-enabled.

func (*Resource) Webhooks

func (r *Resource) Webhooks(ctx context.Context) ([]discord.Webhook, error)

Webhooks returns the list of webhooks in the guild. Requires the 'MANAGE_WEBHOOKS' permission.

func (*Resource) Widget

func (r *Resource) Widget(ctx context.Context) (*discord.GuildWidget, error)

Widget returns the guild's widget. Requires the 'MANAGE_GUILD' permission.

type RolePosition

type RolePosition struct {
	ID       string `json:"id"`
	Position int    `json:"position"`
}

RolePosition is a pair of role ID with its position. A higher position means it will appear before in the list.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL