Update util commands to use error channel
This commit is contained in:
parent
ffebfeb1ec
commit
4744a54079
@ -11,15 +11,21 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func pingCommand(ctx disgoman.Context, _ []string) error {
|
func pingCommand(ctx disgoman.Context, _ []string) {
|
||||||
timeBefore := time.Now()
|
timeBefore := time.Now()
|
||||||
msg, _ := ctx.Send("Pong!")
|
msg, _ := ctx.Send("Pong!")
|
||||||
took := time.Now().Sub(timeBefore)
|
took := time.Now().Sub(timeBefore)
|
||||||
_, err := ctx.Session.ChannelMessageEdit(ctx.Message.ChannelID, msg.ID, fmt.Sprintf("Pong!\nPing Took **%s**", took.String()))
|
_, err := ctx.Session.ChannelMessageEdit(ctx.Message.ChannelID, msg.ID, fmt.Sprintf("Pong!\nPing Took **%s**", took.String()))
|
||||||
return err
|
if err != nil {
|
||||||
|
ctx.ErrorChannel <- disgoman.CommandError{
|
||||||
|
Context: ctx,
|
||||||
|
Message: "Ping Failed",
|
||||||
|
Error: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func inviteCommand(ctx disgoman.Context, args []string) error {
|
func inviteCommand(ctx disgoman.Context, args []string) {
|
||||||
var ids []string
|
var ids []string
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
ids = []string{ctx.Session.State.User.ID}
|
ids = []string{ctx.Session.State.User.ID}
|
||||||
@ -30,30 +36,48 @@ func inviteCommand(ctx disgoman.Context, args []string) error {
|
|||||||
}
|
}
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
url := fmt.Sprintf("<https://discordapp.com/oauth2/authorize?client_id=%v&scope=bot>", id)
|
url := fmt.Sprintf("<https://discordapp.com/oauth2/authorize?client_id=%v&scope=bot>", id)
|
||||||
ctx.Send(url)
|
_, err := ctx.Send(url)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ErrorChannel <- disgoman.CommandError{
|
||||||
|
Context: ctx,
|
||||||
|
Message: "Couldn't send the invite link.",
|
||||||
|
Error: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func gitCommand(ctx disgoman.Context, _ []string) error {
|
func gitCommand(ctx disgoman.Context, _ []string) {
|
||||||
embed := &discordgo.MessageEmbed{
|
embed := &discordgo.MessageEmbed{
|
||||||
Title: "Hi there, My code is on Github",
|
Title: "Hi there, My code is on Github",
|
||||||
Color: 0,
|
Color: 0,
|
||||||
URL: "https://github.com/dustinpianalto/Goff",
|
URL: "https://github.com/dustinpianalto/Goff",
|
||||||
}
|
}
|
||||||
_, err := ctx.Session.ChannelMessageSendEmbed(ctx.Channel.ID, embed)
|
_, err := ctx.Session.ChannelMessageSendEmbed(ctx.Channel.ID, embed)
|
||||||
return err
|
if err != nil {
|
||||||
|
ctx.ErrorChannel <- disgoman.CommandError{
|
||||||
|
Context: ctx,
|
||||||
|
Message: "Git failed",
|
||||||
|
Error: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sayCommand(ctx disgoman.Context, args []string) error {
|
func sayCommand(ctx disgoman.Context, args []string) {
|
||||||
resp := strings.Join(args, " ")
|
resp := strings.Join(args, " ")
|
||||||
resp = strings.ReplaceAll(resp, "@everyone", "@\ufff0everyone")
|
resp = strings.ReplaceAll(resp, "@everyone", "@\ufff0everyone")
|
||||||
resp = strings.ReplaceAll(resp, "@here", "@\ufff0here")
|
resp = strings.ReplaceAll(resp, "@here", "@\ufff0here")
|
||||||
_, err := ctx.Session.ChannelMessageSend(ctx.Message.ChannelID, resp)
|
_, err := ctx.Session.ChannelMessageSend(ctx.Message.ChannelID, resp)
|
||||||
return err
|
if err != nil {
|
||||||
|
ctx.ErrorChannel <- disgoman.CommandError{
|
||||||
|
Context: ctx,
|
||||||
|
Message: "Say Failed",
|
||||||
|
Error: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func userCommand(ctx disgoman.Context, args []string) error {
|
func userCommand(ctx disgoman.Context, args []string) {
|
||||||
var member *discordgo.Member
|
var member *discordgo.Member
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
member, _ = ctx.Session.GuildMember(ctx.Guild.ID, ctx.Message.Author.ID)
|
member, _ = ctx.Session.GuildMember(ctx.Guild.ID, ctx.Message.Author.ID)
|
||||||
@ -65,7 +89,11 @@ func userCommand(ctx disgoman.Context, args []string) error {
|
|||||||
member, err = ctx.Session.GuildMember(ctx.Guild.ID, args[0])
|
member, err = ctx.Session.GuildMember(ctx.Guild.ID, args[0])
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
ctx.ErrorChannel <- disgoman.CommandError{
|
||||||
|
Context: ctx,
|
||||||
|
Message: "Couldn't get that member",
|
||||||
|
Error: err,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
thumb := &discordgo.MessageEmbedThumbnail{
|
thumb := &discordgo.MessageEmbedThumbnail{
|
||||||
@ -124,5 +152,11 @@ func userCommand(ctx disgoman.Context, args []string) error {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err := ctx.Session.ChannelMessageSendEmbed(ctx.Channel.ID, embed)
|
_, err := ctx.Session.ChannelMessageSendEmbed(ctx.Channel.ID, embed)
|
||||||
return err
|
if err != nil {
|
||||||
|
ctx.ErrorChannel <- disgoman.CommandError{
|
||||||
|
Context: ctx,
|
||||||
|
Message: "Couldn't send the user embed",
|
||||||
|
Error: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user