added roll command
This commit is contained in:
@@ -76,7 +76,9 @@ func message_create (s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
|
|
||||||
// determine our actions
|
// determine our actions
|
||||||
if message == "coinflip" || message == "coin" { // flip a coin
|
if message == "coinflip" || message == "coin" { // flip a coin
|
||||||
s.ChannelMessageSend(m.ChannelID, coinflip(m.Author.ID)) // totally fair
|
s.ChannelMessageSend(m.ChannelID, coinflip(m.Author.ID))
|
||||||
|
} else if message == "roll" { // roll a number
|
||||||
|
s.ChannelMessageSend(m.ChannelID, roll(m.Author.ID))
|
||||||
} else if len(message) > 0 { // as long as there is a message, try to find a picture
|
} else if len(message) > 0 { // as long as there is a message, try to find a picture
|
||||||
// get url
|
// get url
|
||||||
url := <-get_image(message)
|
url := <-get_image(message)
|
||||||
|
@@ -6,6 +6,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// flip a coin
|
// flip a coin
|
||||||
@@ -19,4 +20,12 @@ func coinflip(author string) string{
|
|||||||
} else { // tails
|
} else { // tails
|
||||||
return "<@" + author + "> flipped a coin, it landed on **tails!**"
|
return "<@" + author + "> flipped a coin, it landed on **tails!**"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// roll number
|
||||||
|
func roll(author string) string{
|
||||||
|
min := 1
|
||||||
|
max := 100
|
||||||
|
num := rand.Intn(max - min) + min
|
||||||
|
return "<@" + author + "> rolls a number between 1 and 100. They roll **" + strconv.Itoa(num) + "**."
|
||||||
}
|
}
|
Reference in New Issue
Block a user