Add command to get logging channel

This commit is contained in:
Dustin Pianalto 2020-04-07 20:48:53 -08:00
parent be81d2280a
commit df4f94d799

View File

@ -2,6 +2,7 @@ package exts
import (
"djpianalto.com/goff/djpianalto.com/goff/utils"
"fmt"
"github.com/dustinpianalto/disgoman"
"strconv"
"strings"
@ -47,3 +48,26 @@ func loggingChannel(ctx disgoman.Context, args []string) error {
_, _ = ctx.Send("Logging Channel Updated.")
return nil
}
func getLoggingCommand(ctx disgoman.Context, _ []string) error {
var channelID string
row := utils.Database.QueryRow("SELECT logging_channel FROM guilds where id=$1", ctx.Guild.ID)
err := row.Scan(channelID)
if err != nil {
fmt.Println(err)
_, _ = ctx.Send("Error getting data from the database.")
return err
}
if channelID == "" {
_, _ = ctx.Send("The logging channel is not set.")
return nil
}
channel, err := ctx.Session.State.GuildChannel(ctx.Guild.ID, channelID)
if err != nil {
fmt.Println(err)
_, _ = ctx.Send("I got the channel ID but it does not appear to be a valid channel in this guild.")
return err
}
_, _ = ctx.Send(fmt.Sprintf("The logging channel is currently %s", channel.Mention()))
return nil
}