Merge pull request #2 from cribb-it/Google4U

Google 4 u
master
Marc 2023-02-24 22:30:19 +11:00 committed by GitHub
commit a41bb07c4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -50,6 +50,7 @@ func (c *Commands) RegisterHandlers() {
c.RegisterCommand("fetome", "Convert Feet to Meters", false, c.handleFeetToMeters)
c.RegisterCommand("cmtoin", "Convert Centimeters to Inches", false, c.handleCentimeterToInch)
c.RegisterCommand("intocm", "Convert Inches to Centimeters", false, c.handleInchToCentimeter)
c.RegisterCommand("google4u", "Displays a letmegooglethat link", false, c.handleGoogle4U)
// Admin Commands
c.RegisterCommand("ping", "Ping Scuzzy", true, c.handlePing)

View File

@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"net/url"
"os"
"reflect"
"sort"
@ -692,3 +693,25 @@ func (c *Commands) handleServerInfo(s *discordgo.Session, m *discordgo.MessageCr
return nil
}
func (c *Commands) handleGoogle4U(s *discordgo.Session, m *discordgo.MessageCreate) error {
args := strings.Split(m.Content, " ")
if len(args) < 2 {
return errors.New("You did not specify anything to google")
}
input := m.Content[strings.Index(m.Content, " "):len(m.Content)]
desc := "https://letmegooglethat.com/?q=" + url.QueryEscape(input)
msg := c.CreateDefinedEmbed("Google", desc, "", m.Author)
_, err := s.ChannelMessageSendEmbed(m.ChannelID, msg)
if err != nil {
return err
}
err = s.ChannelMessageDelete(m.ChannelID, m.ID)
if err != nil {
return err
}
return nil
}