Documentation ¶
Index ¶
- type AuditLogOption
- type ChannelPosition
- type Resource
- func (r *Resource) AddIntegration(ctx context.Context, id, typ string) error
- func (r *Resource) AddMember(ctx context.Context, userID, token string, ...) (*discord.GuildMember, error)
- func (r *Resource) AddMemberRole(ctx context.Context, userID, roleID string) error
- func (r *Resource) AddMemberRoleWithReason(ctx context.Context, userID, roleID, reason string) error
- func (r *Resource) AuditLog(ctx context.Context, opts ...AuditLogOption) (*audit.Log, error)
- func (r *Resource) Ban(ctx context.Context, userID string) error
- func (r *Resource) BanWithReason(ctx context.Context, userID string, delMsgDays int, reason string) error
- func (r *Resource) Bans(ctx context.Context) ([]discord.Ban, error)
- func (r *Resource) BeginPrune(ctx context.Context, days int, computePruneCount bool) (pruneCount int, err error)
- func (r *Resource) BeginPruneWithReason(ctx context.Context, days int, computePruneCount bool, reason string) (pruneCount int, err error)
- func (r *Resource) ChangeNick(ctx context.Context, name string) (string, error)
- func (r *Resource) Channels(ctx context.Context) ([]discord.Channel, error)
- func (r *Resource) Delete(ctx context.Context) error
- func (r *Resource) DeleteEmoji(ctx context.Context, emojiID string) error
- func (r *Resource) DeleteEmojiWithReason(ctx context.Context, emojiID, reason string) error
- func (r *Resource) DeleteRole(ctx context.Context, id string) error
- func (r *Resource) DeleteRoleWithReason(ctx context.Context, id, reason string) error
- func (r *Resource) Emoji(ctx context.Context, emojiID string) (*discord.Emoji, error)
- func (r *Resource) Emojis(ctx context.Context) ([]discord.Emoji, error)
- func (r *Resource) Get(ctx context.Context) (*discord.Guild, error)
- func (r *Resource) Integrations(ctx context.Context) ([]discord.GuildIntegration, error)
- func (r *Resource) Invites(ctx context.Context) ([]discord.Invite, error)
- func (r *Resource) Kick(ctx context.Context, userID string) error
- func (r *Resource) KickWithReason(ctx context.Context, userID, reason string) error
- func (r *Resource) Member(ctx context.Context, userID string) (*discord.GuildMember, error)
- func (r *Resource) Members(ctx context.Context, limit int, after string) ([]discord.GuildMember, error)
- func (r *Resource) Modify(ctx context.Context, settings *discord.GuildSettings) (*discord.Guild, error)
- func (r *Resource) ModifyChannelPosition(ctx context.Context, pos []ChannelPosition) error
- func (r *Resource) ModifyEmoji(ctx context.Context, emojiID, name string, roles []string) (*discord.Emoji, error)
- func (r *Resource) ModifyEmojiWithReason(ctx context.Context, emojiID, name string, roles []string, reason string) (*discord.Emoji, error)
- func (r *Resource) ModifyIntegration(ctx context.Context, id string, settings *discord.GuildIntegrationSettings) error
- func (r *Resource) ModifyMember(ctx context.Context, userID string, settings *discord.GuildMemberSettings) error
- func (r *Resource) ModifyMemberWithReason(ctx context.Context, userID string, settings *discord.GuildMemberSettings, ...) error
- func (r *Resource) ModifyRole(ctx context.Context, id string, settings *discord.RoleSettings) (*discord.Role, error)
- func (r *Resource) ModifyRolePositions(ctx context.Context, pos []RolePosition) ([]discord.Role, error)
- func (r *Resource) ModifyRoleWithReason(ctx context.Context, id string, settings *discord.RoleSettings, reason string) (*discord.Role, error)
- func (r *Resource) ModifyWidget(ctx context.Context, embed *discord.GuildWidget) (*discord.GuildWidget, error)
- func (r *Resource) ModifyWithReason(ctx context.Context, settings *discord.GuildSettings, reason string) (*discord.Guild, error)
- func (r *Resource) NewChannel(ctx context.Context, settings *discord.ChannelSettings) (*discord.Channel, error)
- func (r *Resource) NewChannelWithReason(ctx context.Context, settings *discord.ChannelSettings, reason string) (*discord.Channel, error)
- func (r *Resource) NewEmoji(ctx context.Context, name, image string, roles []string) (*discord.Emoji, error)
- func (r *Resource) NewEmojiWithReason(ctx context.Context, name, image string, roles []string, reason string) (*discord.Emoji, error)
- func (r *Resource) NewRole(ctx context.Context, settings *discord.RoleSettings) (*discord.Role, error)
- func (r *Resource) NewRoleWithReason(ctx context.Context, settings *discord.RoleSettings, reason string) (*discord.Role, error)
- func (r *Resource) PruneCount(ctx context.Context, days int) (int, error)
- func (r *Resource) RemoveIntegration(ctx context.Context, id string) error
- func (r *Resource) RemoveMemberRole(ctx context.Context, userID, roleID string) error
- func (r *Resource) RemoveMemberRoleWithReason(ctx context.Context, userID, roleID, reason string) error
- func (r *Resource) Roles(ctx context.Context) ([]discord.Role, error)
- func (r *Resource) SyncIntegration(ctx context.Context, id string) error
- func (r *Resource) Unban(ctx context.Context, userID string) error
- func (r *Resource) UnbanWithReason(ctx context.Context, userID, reason string) error
- func (r *Resource) VanityURL(ctx context.Context) (*discord.Invite, error)
- func (r *Resource) VoiceRegions(ctx context.Context) ([]discord.VoiceRegion, error)
- func (r *Resource) Webhooks(ctx context.Context) ([]discord.Webhook, error)
- func (r *Resource) Widget(ctx context.Context) (*discord.GuildWidget, error)
- type RolePosition
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 ¶
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 ¶
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 ¶
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 ¶
AuditLog returns the audit log of the given Guild. Requires the 'VIEW_AUDIT_LOG' permission.
func (*Resource) Ban ¶
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 ¶
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 ¶
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) Delete ¶
Delete deletes the guild permanently. Current user must be owner. Fires a Guild Delete Gateway event.
func (*Resource) DeleteEmoji ¶
DeleteEmoji is like DeleteEmojiWithReason but with no particular reason.
func (*Resource) DeleteEmojiWithReason ¶
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 ¶
DeleteRole is like DeleteRoleWithReason but with no particular reason.
func (*Resource) DeleteRoleWithReason ¶
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) Emojis ¶
Emojis returns the list of emojis of the guild. Requires the MANAGE_EMOJIS permission.
func (*Resource) Integrations ¶
Integrations returns the list of integrations for the guild. Requires the 'MANAGE_GUILD' permission.
func (*Resource) Invites ¶
Invites returns the list of invites (with invite metadata) for the guild. Requires the 'MANAGE_GUILD' permission.
func (*Resource) KickWithReason ¶
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) 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 ¶
PruneCount returns the number of members that would be removed in a prune operation. Requires the 'KICK_MEMBERS' permission.
func (*Resource) RemoveIntegration ¶
RemoveIntegration removes the attached integration for the guild. Requires the 'MANAGE_GUILD' permission. Fires a Guild Integrations Update Gateway event.
func (*Resource) RemoveMemberRole ¶
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 ¶
Roles returns a list of roles for the guild. Requires the 'MANAGE_ROLES' permission.
func (*Resource) SyncIntegration ¶
SyncIntegration syncs a guild integration. Requires the 'MANAGE_GUILD' permission.
func (*Resource) UnbanWithReason ¶
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 ¶
VanityURL returns a partial invite for the guild if that feature is enabled. Requires the 'MANAGE_GUILD' permission.
func (*Resource) VoiceRegions ¶
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.
type RolePosition ¶
RolePosition is a pair of role ID with its position. A higher position means it will appear before in the list.