This commit is contained in:
parent
e19f987c4e
commit
e3ccc56dba
@ -3,6 +3,7 @@ package exts
|
|||||||
import (
|
import (
|
||||||
"github.com/dustinpianalto/disgoman"
|
"github.com/dustinpianalto/disgoman"
|
||||||
"github.com/dustinpianalto/geeksbot/internal/exts/guild"
|
"github.com/dustinpianalto/geeksbot/internal/exts/guild"
|
||||||
|
"github.com/dustinpianalto/geeksbot/internal/exts/requests"
|
||||||
"github.com/dustinpianalto/geeksbot/internal/exts/utils"
|
"github.com/dustinpianalto/geeksbot/internal/exts/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,4 +24,5 @@ func AddCommandHandlers(g *disgoman.CommandManager) {
|
|||||||
_ = g.AddCommand(utils.PingCommand)
|
_ = g.AddCommand(utils.PingCommand)
|
||||||
_ = g.AddCommand(guild.AddPrefixCommand)
|
_ = g.AddCommand(guild.AddPrefixCommand)
|
||||||
_ = g.AddCommand(guild.RemovePrefixCommand)
|
_ = g.AddCommand(guild.RemovePrefixCommand)
|
||||||
|
_ = g.AddCommand(requests.RequestCommand)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
package requests
|
package requests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/dustinpianalto/disgoman"
|
"github.com/dustinpianalto/disgoman"
|
||||||
"github.com/dustinpianalto/geeksbot"
|
"github.com/dustinpianalto/geeksbot"
|
||||||
@ -60,4 +62,42 @@ func requestCommandFunc(ctx disgoman.Context, args []string) {
|
|||||||
discord_utils.SendErrorMessage(ctx, "Error creating the request", err)
|
discord_utils.SendErrorMessage(ctx, "Error creating the request", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
channels, err := services.ChannelService.GuildChannels(guild)
|
||||||
|
if err == nil {
|
||||||
|
var mentionRolesString string
|
||||||
|
roles, err := services.GuildService.GuildRoles(guild)
|
||||||
|
if err == nil {
|
||||||
|
for _, r := range roles {
|
||||||
|
if r.RoleType == "admin" || r.RoleType == "moderator" {
|
||||||
|
mentionRolesString += fmt.Sprintf("<@&%s> ", r.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, c := range channels {
|
||||||
|
if c.Admin {
|
||||||
|
_, _ = ctx.Session.ChannelMessageSend(c.ID,
|
||||||
|
fmt.Sprintf("%s\n"+
|
||||||
|
"New Request ID %d "+
|
||||||
|
"%s has requested assistance: \n"+
|
||||||
|
"```\n%s\n```\n"+
|
||||||
|
"Requested At: %s\n"+
|
||||||
|
"In: %s",
|
||||||
|
mentionRolesString,
|
||||||
|
request.ID,
|
||||||
|
ctx.Message.Author.Mention,
|
||||||
|
request.Content,
|
||||||
|
request.RequestedAt.UTC().Format(time.UnixDate),
|
||||||
|
ctx.Channel.Mention(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err = ctx.Send(fmt.Sprintf("%s The admin have recieved your request.\n "+
|
||||||
|
"If you would like to close or add a comment to this request please reference ID `%v`",
|
||||||
|
ctx.Message.Author.Mention, request.ID,
|
||||||
|
))
|
||||||
|
if err != nil {
|
||||||
|
discord_utils.SendErrorMessage(ctx, "There was an error sending the message. The request was created.", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user