|
|
|
|
@ -9,7 +9,7 @@ import (
|
|
|
|
|
|
|
|
|
|
// Guild management commands
|
|
|
|
|
|
|
|
|
|
func loggingChannel(ctx disgoman.Context, args []string) error {
|
|
|
|
|
func loggingChannel(ctx disgoman.Context, args []string) {
|
|
|
|
|
var idString string
|
|
|
|
|
if len(args) > 0 {
|
|
|
|
|
idString = args[0]
|
|
|
|
|
@ -17,51 +17,162 @@ func loggingChannel(ctx disgoman.Context, args []string) error {
|
|
|
|
|
idString = idString[2 : len(idString)-1]
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
idString = "0"
|
|
|
|
|
idString = ""
|
|
|
|
|
}
|
|
|
|
|
fmt.Println(idString)
|
|
|
|
|
if idString == "" {
|
|
|
|
|
_, err := utils.Database.Exec("UPDATE guilds SET logging_channel=NULL WHERE id=$1;", ctx.Guild.ID)
|
|
|
|
|
_, err := utils.Database.Exec("UPDATE guilds SET logging_channel='' WHERE id=$1;", ctx.Guild.ID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
_, _ = ctx.Send("Error Updating Database")
|
|
|
|
|
ctx.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "Error Updating Database",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
_, _ = ctx.Send("Logging Channel Updated.")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
channel, err := ctx.Session.State.Channel(idString)
|
|
|
|
|
if err != nil {
|
|
|
|
|
_, _ = ctx.Send("Can't find that channel.")
|
|
|
|
|
return err
|
|
|
|
|
ctx.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "Can't find that channel.",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if channel.GuildID != ctx.Guild.ID {
|
|
|
|
|
_, _ = ctx.Send("The channel passed is not in this guild.")
|
|
|
|
|
return err
|
|
|
|
|
ctx.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "The channel passed is not in this guild.",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
_, err = utils.Database.Exec("UPDATE guilds SET logging_channel=$1 WHERE id=$2;", idString, ctx.Guild.ID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
_, _ = ctx.Send("Error Updating Database")
|
|
|
|
|
return err
|
|
|
|
|
ctx.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "Error Updating Database",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
_, _ = ctx.Send("Logging Channel Updated.")
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getLoggingChannel(ctx disgoman.Context, _ []string) error {
|
|
|
|
|
func getLoggingChannel(ctx disgoman.Context, _ []string) {
|
|
|
|
|
var channelID string
|
|
|
|
|
row := utils.Database.QueryRow("SELECT logging_channel FROM guilds where id=$1", ctx.Guild.ID)
|
|
|
|
|
err := row.Scan(channelID)
|
|
|
|
|
err := row.Scan(&channelID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
_, _ = ctx.Send("Error getting data from the database.")
|
|
|
|
|
return err
|
|
|
|
|
ctx.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "Error getting data from the database.",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if channelID == "" {
|
|
|
|
|
_, _ = ctx.Send("The logging channel is not set.")
|
|
|
|
|
return nil
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
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.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "I got the channel ID but it does not appear to be a valid channel in this guild.",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
_, _ = ctx.Send(fmt.Sprintf("The logging channel is currently %s", channel.Mention()))
|
|
|
|
|
return nil
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func welcomeChannel(ctx disgoman.Context, args []string) {
|
|
|
|
|
var idString string
|
|
|
|
|
if len(args) > 0 {
|
|
|
|
|
idString = args[0]
|
|
|
|
|
if strings.HasPrefix(idString, "<#") && strings.HasSuffix(idString, ">") {
|
|
|
|
|
idString = idString[2 : len(idString)-1]
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
idString = ""
|
|
|
|
|
}
|
|
|
|
|
fmt.Println(idString)
|
|
|
|
|
if idString == "" {
|
|
|
|
|
_, err := utils.Database.Exec("UPDATE guilds SET welcome_channel='' WHERE id=$1;", ctx.Guild.ID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
ctx.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "Error Updating Database",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
_, _ = ctx.Send("Welcomer Disabled.")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
channel, err := ctx.Session.State.Channel(idString)
|
|
|
|
|
if err != nil {
|
|
|
|
|
ctx.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "Can't find that channel.",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if channel.GuildID != ctx.Guild.ID {
|
|
|
|
|
ctx.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "The channel passed is not in this guild.",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
_, err = utils.Database.Exec("UPDATE guilds SET welcome_channel=$1 WHERE id=$2;", idString, ctx.Guild.ID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
ctx.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "Error Updating Database",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
_, _ = ctx.Send("Welcome Channel Updated.")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getWelcomeChannel(ctx disgoman.Context, _ []string) {
|
|
|
|
|
var channelID string
|
|
|
|
|
row := utils.Database.QueryRow("SELECT welcome_channel FROM guilds where id=$1", ctx.Guild.ID)
|
|
|
|
|
err := row.Scan(&channelID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
ctx.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "Error getting data from the database.",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if channelID == "" {
|
|
|
|
|
_, _ = ctx.Send("The welcomer is disabled.")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
channel, err := ctx.Session.State.GuildChannel(ctx.Guild.ID, channelID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
ctx.ErrorChannel <- disgoman.CommandError{
|
|
|
|
|
Context: ctx,
|
|
|
|
|
Message: "I got the channel ID but it does not appear to be a valid channel in this guild.",
|
|
|
|
|
Error: err,
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
_, _ = ctx.Send(fmt.Sprintf("The welcome channel is currently %s", channel.Mention()))
|
|
|
|
|
}
|
|
|
|
|
|