Documentation ¶
Index ¶
- Constants
- Variables
- func AddHandler(handler interface{})
- func ComputeBasePermissions(member *discordgo.Member, guild *discordgo.Guild) (int, error)
- func ComputeOverwrites(basePermissions int, member *discordgo.Member, channel *discordgo.Channel) (int, error)
- func ComputePermissions(member *discordgo.Member, channel *discordgo.Channel) (int, error)
- func GetChannel(discord *discordgo.Session, channelID Snowflake) (*discordgo.Channel, error)
- func GetGuild(guildID Snowflake) (*discordgo.Guild, error)
- func GetGuildMember(guildID, userID Snowflake) (*discordgo.Member, error)
- func GetOverwrite(channel *discordgo.Channel, target interface{}) *discordgo.PermissionOverwrite
- func GetOverwriteByID(channel *discordgo.Channel, id Snowflake, typ string) *discordgo.PermissionOverwrite
- func GetRole(guildID, roleID Snowflake) (*discordgo.Role, error)
- func Start()
- type Guild
- type Snowflake
Constants ¶
const ( // OkHand is the 👌 emoji in Discord. OkHand = "\U0001f44c" // Error is the ❗ emoji in Discord Error = "\U00002757" // LoadingReaction is the loading gif often used in Discord, but as emoji LoadingReaction = "a:loading:428921925377458187" )
Variables ¶
var ( // DB is the database connection pool that we use for obtaining guild/channel-specific settings. DB *gorm.DB // Self is the bot user itself Self *discordgo.User )
var Log *zap.Logger
Log is the bots main logging utility
var State = struct { sync.RWMutex Guilds map[string]*Guild }{ Guilds: make(map[string]*Guild), }
State keeps commonly use settings for the bot in memory for quick access
Functions ¶
func AddHandler ¶
func AddHandler(handler interface{})
AddHandler adds an event handler to all shards
func ComputeBasePermissions ¶
ComputeBasePermissions calculates the permissions a guild member has, outside the scope of a channel
func ComputeOverwrites ¶
func ComputeOverwrites(basePermissions int, member *discordgo.Member, channel *discordgo.Channel) (int, error)
ComputeOverwrites calculates the permissions a channel member has, given the guilds base permissions
func ComputePermissions ¶
ComputePermissions calculates the permissions a channel member has, using the guilds base permissions
func GetChannel ¶
GetChannel attempts to get a channel instance from the shard state cache, and if none exists, attempts to obtain it from the Discord API. Will err if the channel does not exist or the bot is not in the guild it belongs to.
func GetGuild ¶
GetGuild attempts to get a guild instance from the shard state cache, and if none exists, attempts to obtain it from the Discord API. Will err if the guild does not exist or if this guild is unreachable for the bot.
func GetGuildMember ¶
GetGuildMember will attempt to obtain a member instance for this guild member. Will err if this user is not a member of this guild
func GetOverwrite ¶
func GetOverwrite(channel *discordgo.Channel, target interface{}) *discordgo.PermissionOverwrite
GetOverwrite will attempt to obtain the PermissionOverwrite instance for the target (Role, Member or User) Will return nil if no such overwrite exists
func GetOverwriteByID ¶
func GetOverwriteByID(channel *discordgo.Channel, id Snowflake, typ string) *discordgo.PermissionOverwrite
GetOverwriteByID will attempt to obtain the PermissionOverwrite instance for the given ID and type ("role" or "user") Will return nil if no such overwrite exists