mirror of https://github.com/hak5/scuzzy.git
Features: Add Meters <-> Feet conversion commands.
parent
fa7172a2a7
commit
2e0b2f2011
|
@ -100,6 +100,28 @@ func (f *Features) OnMessageCreate(s *discordgo.Session, m *discordgo.MessageCre
|
|||
return
|
||||
}
|
||||
break
|
||||
case cKey + "metofe":
|
||||
err = f.handleMetersToFeet(s, m)
|
||||
if err != nil {
|
||||
eMsg := f.CreateDefinedEmbed("Error (Meters to Feet)", err.Error(), "error")
|
||||
_, err = s.ChannelMessageSendEmbed(m.ChannelID, eMsg)
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
break
|
||||
case cKey + "fetome":
|
||||
err = f.handleFeetToMeters(s, m)
|
||||
if err != nil {
|
||||
eMsg := f.CreateDefinedEmbed("Error (Feet to Meters)", err.Error(), "error")
|
||||
_, err = s.ChannelMessageSendEmbed(m.ChannelID, eMsg)
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
break
|
||||
/* Moderation */
|
||||
case cKey + "purge":
|
||||
err = f.handlePurgeChannel(s, m)
|
||||
|
|
|
@ -91,13 +91,20 @@ func (f *Features) handleInfo(s *discordgo.Session, m *discordgo.MessageCreate)
|
|||
|
||||
func (f *Features) handleHelp(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||
desc := "**Available Commands**\n"
|
||||
desc += "__Misc__\n"
|
||||
desc += "`help` - This help dialog\n"
|
||||
desc += "`info` - Display Scuzzy info\n"
|
||||
desc += "`md` - Display Discord markdown information\n"
|
||||
|
||||
desc += "\n__User Settings__\n"
|
||||
desc += "`colors` - Available color roles\n"
|
||||
desc += "`color` - Set an available color role\n"
|
||||
|
||||
desc += "\n__Conversion Helpers__\n"
|
||||
desc += "`ctof` - Convert Celsius to Farenheit\n"
|
||||
desc += "`ftoc` - Convert Farenheit to Celsius\n"
|
||||
desc += "`metofe` - Convert Meters to Feet\n"
|
||||
desc += "`fetome` - Convert Feet to Meters\n"
|
||||
|
||||
if f.Auth.CheckAdminRole(m.Member) {
|
||||
desc += "\n"
|
||||
|
@ -210,3 +217,57 @@ func (f *Features) handleFtoC(s *discordgo.Session, m *discordgo.MessageCreate)
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *Features) handleMetersToFeet(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||
inS := strings.Split(m.Content, " ")
|
||||
|
||||
if len(inS) < 2 {
|
||||
return errors.New("You did not specify a distance")
|
||||
}
|
||||
in := inS[1]
|
||||
|
||||
inF, err := strconv.ParseFloat(in, 2)
|
||||
if err != nil {
|
||||
return errors.New("You did not specify a valid number")
|
||||
}
|
||||
|
||||
meters := inF * 3.28
|
||||
metersF := float64(meters)
|
||||
|
||||
msg := fmt.Sprintf("`%.1fm` is `%.1fft`", inF, metersF)
|
||||
|
||||
e := f.CreateDefinedEmbed("Meters to Feet", msg, "")
|
||||
_, err = s.ChannelMessageSendEmbed(m.ChannelID, e)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *Features) handleFeetToMeters(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||
inS := strings.Split(m.Content, " ")
|
||||
|
||||
if len(inS) < 2 {
|
||||
return errors.New("You did not specify a distance")
|
||||
}
|
||||
in := inS[1]
|
||||
|
||||
inF, err := strconv.ParseFloat(in, 2)
|
||||
if err != nil {
|
||||
return errors.New("You did not specify a valid number")
|
||||
}
|
||||
|
||||
feet := inF / 3.28
|
||||
feetF := float64(feet)
|
||||
|
||||
msg := fmt.Sprintf("`%.1fft` is `%.1fm`", inF, feetF)
|
||||
|
||||
e := f.CreateDefinedEmbed("Feet to Meters", msg, "")
|
||||
_, err = s.ChannelMessageSendEmbed(m.ChannelID, e)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue