2021-02-22 18:27:49 +00:00
|
|
|
package discord
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-02-23 05:53:55 +00:00
|
|
|
commands = append(commands, &command{
|
2021-02-22 18:27:49 +00:00
|
|
|
staffOnly: true,
|
2021-02-23 05:53:55 +00:00
|
|
|
name: "tweet",
|
2021-02-22 18:27:49 +00:00
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return isStaff(cmd.message.Member.Roles, cmd.config.StaffRoles)
|
|
|
|
},
|
|
|
|
run: func(cmd commandInit) (string, error) {
|
|
|
|
args := strings.Fields(cmd.message.Content)
|
|
|
|
|
|
|
|
if len(args) < 2 {
|
|
|
|
return "This command requires a message to tweet", nil
|
|
|
|
}
|
|
|
|
|
|
|
|
message := strings.Join(args[1:], " ")
|
|
|
|
tweet, resp, err := cmd.twitterClient.Statuses.Update(message, nil)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
if resp.StatusCode%100 != 2 {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("https://twitter.com/%d/status/%d", tweet.User.ID, tweet.ID), nil
|
|
|
|
},
|
|
|
|
help: "Send a tweet from the BirbMC Twitter",
|
2021-02-23 05:53:55 +00:00
|
|
|
})
|
2021-02-22 18:27:49 +00:00
|
|
|
}
|