Documentation
¶
Index ¶
- type Bot
- func (bot *Bot) AddReplyRules(rules ...ReplyRule)
- func (bot *Bot) AllMembers(guildID string) (allMembers []*discordgo.Member, err error)
- func (bot *Bot) ChangeListening(listenTo string) error
- func (bot *Bot) ChangeNames(nickname string, guilds ...string) error
- func (bot *Bot) ChangePlaying(gameName string) error
- func (bot *Bot) CheckUserRole(userID string, guildID string, roleID string) (isRole bool)
- func (bot *Bot) Close()
- func (bot *Bot) FilterRole(guildID string, roleID string) (roleMembers []*discordgo.Member, err error)deprecated
- func (bot *Bot) FilterRoles(guildID string, roleIDs ...string) (roleMembers []*discordgo.Member, err error)
- func (bot *Bot) Open() error
- func (bot *Bot) ReadGuildMsgs(guildID string, channelIDs []string, startTimestamp int64, endTimestamp int64) (res []*discordgo.Message, err error)
- func (bot *Bot) ReadUserActivities(guildID string, channelIDs []string, startTimestamp int64, endTimestamp int64) (res map[string]*UserActivity, err error)
- func (bot *Bot) SendDM(userID string, msg *discordgo.MessageSend) error
- func (bot *Bot) StartReply()
- type Comp
- type ComponentSend
- type MsgComponents
- type ReplyRule
- type UserActivity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶ added in v0.3.1
type Bot struct {
Session *discordgo.Session
BotName string
// contains filtered or unexported fields
}
The struct for the bot.
func (*Bot) AddReplyRules ¶ added in v0.3.1
Add reply rules to the bot.
func (*Bot) AllMembers ¶ added in v0.3.1
Read all members of a guild.
func (*Bot) ChangeListening ¶ added in v0.3.1
Change the bot's "listening" status.
func (*Bot) ChangeNames ¶ added in v0.3.1
Change the bot's nicknames in the guilds.
func (*Bot) ChangePlaying ¶ added in v0.3.1
Change the bot's "playing" status.
func (*Bot) CheckUserRole ¶ added in v0.3.1
Check if the user is the role of the guild.
func (*Bot) FilterRoles ¶ added in v0.3.1
func (bot *Bot) FilterRoles(guildID string, roleIDs ...string) (roleMembers []*discordgo.Member, err error)
Read all members of some roles.
func (*Bot) ReadGuildMsgs ¶ added in v0.3.1
func (bot *Bot) ReadGuildMsgs(guildID string, channelIDs []string, startTimestamp int64, endTimestamp int64) (res []*discordgo.Message, err error)
Read all the msgs of selected channels.
startTimestamp and endTimestamp can either be 0 for no start or end limits.
GuildID is only used when channelIDs is nil, read all the channels of the guild.
func (*Bot) ReadUserActivities ¶ added in v0.3.1
func (bot *Bot) ReadUserActivities(guildID string, channelIDs []string, startTimestamp int64, endTimestamp int64) (res map[string]*UserActivity, err error)
Read all the msgs of selected channels.
startTimestamp and endTimestamp can either be 0 for no start or end limits.
GuildID is only used when channelIDs is nil, read all the channels of the guild.
res: map[userID] = UserActivity
func (*Bot) SendDM ¶ added in v0.3.1
func (bot *Bot) SendDM(userID string, msg *discordgo.MessageSend) error
func (*Bot) StartReply ¶ added in v0.3.1
func (bot *Bot) StartReply()
Start the reply and react and never stop.
type Comp ¶ added in v0.3.1
type Comp struct {
Label string `json:"label"`
// 1: PrimaryButton is a button with blurple color.
// 2: SecondaryButton is a button with grey color.
// 3: SuccessButton is a button with green color.
// 4: DangerButton is a button with red color.
// 5: LinkButton is a special type of button which navigates to a URL. Has grey color.
Style int `json:"style"`
Disabled bool `json:"disabled"`
// Should not use name and id field in it...
// Have no idea how to solve.
Emoji struct{} `json:"emoji,omitempty"`
URL string `json:"url,omitempty"`
CustomID string `json:"custom_id"`
// 1: TextInputShort
// 2: TextInputParagraph
Type int `json:"type"`
}
type ComponentSend ¶ added in v0.3.1
type ComponentSend struct {
Components []Comp `json:"components"`
// Type = 1. Other options not supported.
//
// 1: ActionsRowComponent
// 2: ButtonComponent
// 3: SelectMenuComponent
// 4: TextInputComponent
// 5: UserSelectMenuComponent
// 6: RoleSelectMenuComponent
// 7: MentionableSelectMenuComponent
// 8: ChannelSelectMenuComponent
Type int `json:"type"`
}
Type = 1.
type MsgComponents ¶ added in v0.3.1
type MsgComponents struct {
CompSend ComponentSend
}
func (MsgComponents) MarshalJSON ¶ added in v0.3.1
func (com MsgComponents) MarshalJSON() ([]byte, error)
func (MsgComponents) Type ¶ added in v0.3.1
func (com MsgComponents) Type() discordgo.ComponentType
type ReplyRule ¶
type ReplyRule struct {
// Channel id in string.
ChannelIDs []string
// 0: Equalfold. The msg content must be equalfold as the required text.
//
// 1: Contain. The msg content must contain the required text.
//
// 2: Start with. The msg content must start with the required text.
//
// 3. Any.
RuleType int
// Only used when "RuleType" is 2.
//
// Msg content after the required text may has a length limit.
// 0 for no limit.( If limited to 0, use 0 for "RuleType" instead.)
LengthLimit int
// Text to check if should reply.
CheckText string
// Use function to decide what to reply.
ReplyFunc func(bot *Bot, msg *discordgo.Message) (replyMsg *discordgo.MessageSend)
// Use function to decide what to react.
ReactFunc func(bot *Bot, msg *discordgo.Message) (reactEmojiIDs []string)
// Whether to reply in DM.
ReplyInDM bool
// Whether should reply to the msg user replies to.
// Meaningless if ReplyInDM is true.
ReplyToInitialMessage bool
// Whether the author can be a bot.
ReplyToBot bool
// Deprecated: Not in use.
// Whether reply to the msg sent by the bot itself.
// Meaningless if ReplyToBot is false.
ReplyToSelf bool
}
Simple rule for reply.