From df4f94d79995585d31d58e0570a5fca503058f7e Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Tue, 7 Apr 2020 20:48:53 -0800 Subject: [PATCH] Add command to get logging channel --- djpianalto.com/goff/exts/guild.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/djpianalto.com/goff/exts/guild.go b/djpianalto.com/goff/exts/guild.go index 11308c1..c3d3ecc 100644 --- a/djpianalto.com/goff/exts/guild.go +++ b/djpianalto.com/goff/exts/guild.go @@ -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 +}