Make reaction roles easier to implement

Signed-off-by: Etzelia <etzelia@hotmail.com>
pull/8/head
Etzelia 2021-05-04 21:45:49 -05:00
parent c84c523e55
commit c5066e84e2
No known key found for this signature in database
GPG Key ID: 708511AE7ABC5314
3 changed files with 13 additions and 4 deletions

View File

@ -89,5 +89,9 @@ help = "Get the invite link"
[[message_roles]]
channel_id = "0"
message_id = "0"
[[message_roles.reactions]]
role_id = "0"
emoji = "👍"
[[message_roles.reactions]]
role_id = "0"
emoji = "👎"

View File

@ -60,8 +60,11 @@ type Config struct {
type MessageRole struct {
ChannelID string `toml:"channel_id"`
MessageID string `toml:"message_id"`
RoleID string `toml:"role_id"`
Reactions []MessageReaction `toml:"reactions"`
}
type MessageReaction struct {
Emoji string `toml:"emoji"`
RoleID string `toml:"role_id"`
}
type Echo struct {

View File

@ -79,8 +79,10 @@ func Bot(cfg *config.Config, db *database.Database) (*discordgo.Session, error)
if messageRoleMap[messageRole.MessageID] == nil {
messageRoleMap[messageRole.MessageID] = make(map[string]string)
}
_ = bot.MessageReactionAdd(messageRole.ChannelID, messageRole.MessageID, messageRole.Emoji)
messageRoleMap[messageRole.MessageID][messageRole.Emoji] = messageRole.RoleID
for _, reaction := range messageRole.Reactions {
_ = bot.MessageReactionAdd(messageRole.ChannelID, messageRole.MessageID, reaction.Emoji)
messageRoleMap[messageRole.MessageID][reaction.Emoji] = reaction.RoleID
}
}
// Init commandMap