Compare commits

..
2 Commits
Author SHA1 Message Date
Dustin Pianalto 2e0762ee0f Fix permission bug in close
CI / build (push) Has been cancelled
2021-02-24 11:37:52 -09:00
Dustin Pianalto ccb450e543 Add view command and update utils
CI / build (push) Has been cancelled
2021-02-24 00:03:12 -09:00
+8 -6
View File
@@ -79,7 +79,7 @@ func requestCommandFunc(ctx disgoman.Context, args []string) {
if c.Admin {
_, _ = ctx.Session.ChannelMessageSend(c.ID,
fmt.Sprintf("%s\n"+
"New Request ID %d "+
"New Request ID %d\n"+
"%s has requested assistance: \n"+
"```\n%s\n```\n"+
"Requested At: %s\n"+
@@ -154,7 +154,7 @@ func closeCommandFunc(ctx disgoman.Context, args []string) {
continue
}
if request.Author != closer && !closer.IsStaff && !closer.IsAdmin {
if !discord_utils.IsGuildMod(ctx, closer) || !discord_utils.IsGuildAdmin(ctx, closer) {
if !discord_utils.IsGuildMod(ctx, closer) && !discord_utils.IsGuildAdmin(ctx, closer) {
discord_utils.SendErrorMessage(ctx, fmt.Sprintf("You are not authorized to close %d", id), nil)
continue
}
@@ -328,7 +328,7 @@ func commentCommandFunc(ctx disgoman.Context, args []string) {
request.ID,
discord_utils.GetDisplayName(ctx, request.Author.ID),
request.Content,
request.RequestedAt.Format("2006-01-02 15:04:05 MST"),
request.RequestedAt.Format("2006-01-02 15:04:05"),
discord_utils.GetChannelName(ctx, request.Channel.ID),
)
for _, c := range comments {
@@ -339,7 +339,7 @@ func commentCommandFunc(ctx disgoman.Context, args []string) {
cs := fmt.Sprintf("```md\n%s\n- %s At %s\n```\n",
c.Content,
discord_utils.GetDisplayName(ctx, c.Author.ID),
c.CommentAt.Format("2006-01-02 15:04:05 MST"),
c.CommentAt.Format("2006-01-02 15:04:05"),
)
if len(commentString+cs) >= 2000 {
commentStrings = append(commentStrings, commentString)
@@ -355,6 +355,8 @@ func commentCommandFunc(ctx disgoman.Context, args []string) {
}
}
}
} else {
log.Println(err)
}
_, err = ctx.Send(fmt.Sprintf("%s your comment has been added.", ctx.Message.Author.Mention()))
dmChannel, err := ctx.Session.UserChannelCreate(request.Author.ID)
@@ -425,14 +427,14 @@ func viewCommandFunc(ctx disgoman.Context, args []string) {
request.ID,
discord_utils.GetDisplayName(ctx, request.Author.ID),
request.Content,
request.RequestedAt.Format("2006-01-02 15:04:05 MST"),
request.RequestedAt.Format("2006-01-02 15:04:05"),
discord_utils.GetChannelName(ctx, request.Channel.ID),
)
for _, c := range comments {
cs := fmt.Sprintf("```md\n%s\n- %s At %s\n```\n",
c.Content,
discord_utils.GetDisplayName(ctx, c.Author.ID),
c.CommentAt.Format("2006-01-02 15:04:05 MST"),
c.CommentAt.Format("2006-01-02 15:04:05"),
)
if len(commentString+cs) >= 2000 {
commentStrings = append(commentStrings, commentString)