Replace random words with butt when mentioned
parent
80b71a47fb
commit
2c726283dc
16
buttsbot.go
16
buttsbot.go
|
@ -5,8 +5,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
"log"
|
"log"
|
||||||
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -76,7 +78,7 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
|
|
||||||
//Check if the bot was mentioned
|
//Check if the bot was mentioned
|
||||||
if isUserMentioned(m, s.State.User) == true {
|
if isUserMentioned(m, s.State.User) == true {
|
||||||
s.ChannelMessageSend(m.ChannelID, "butt")
|
s.ChannelMessageSend(m.ChannelID, textToButt(m, s))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,3 +92,15 @@ func isUserMentioned(m *discordgo.MessageCreate, u *discordgo.User) bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Replace words with butt
|
||||||
|
func textToButt(m *discordgo.MessageCreate, s *discordgo.Session) string {
|
||||||
|
cleanmessage, _ := m.ContentWithMoreMentionsReplaced(s)
|
||||||
|
words := strings.Fields(cleanmessage)
|
||||||
|
for i, _ := range words {
|
||||||
|
if rand.Intn(10) > 7 {
|
||||||
|
words[i] = "butt"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return strings.Join(words, " ")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue