Compare commits

...
3 Commits
Author SHA1 Message Date
Dustin Pianalto ccb450e543 Add view command and update utils
CI / build (push) Has been cancelled
2021-02-24 00:03:12 -09:00
Dustin Pianalto c34f475084 Add view command and update utils
CI / build (push) Has been cancelled
2021-02-23 23:53:28 -09:00
Dustin Pianalto 1a7d9b824f Add view command and update utils
CI / build (push) Has been cancelled
2021-02-23 23:42:02 -09:00
+20 -16
View File
@@ -248,7 +248,7 @@ func listCommandFunc(ctx disgoman.Context, args []string) {
commentCount = 0
}
_, _ = ctx.Send(fmt.Sprintf("```md\n"+
"< Request ID Requested By >\n"+
"< Request ID Requested By >\n"+
"< %-11d %23s >\n"+
"%s\n\n"+
"Comments: %d\n"+
@@ -288,7 +288,7 @@ func commentCommandFunc(ctx disgoman.Context, args []string) {
discord_utils.SendErrorMessage(ctx, "Please include the ID of the request to update.", err)
return
}
message := strings.Join(args[1:len(args)-1], " ")
message := strings.Join(args[1:len(args)], " ")
author, err := services.UserService.GetOrCreateUser(ctx.Message.Author.ID)
if err != nil {
discord_utils.SendErrorMessage(ctx, "Sorry, there was an issue finding your user account", err)
@@ -318,7 +318,7 @@ func commentCommandFunc(ctx disgoman.Context, args []string) {
var commentString string
var commentStrings []string
commentString = fmt.Sprintf("Comment added:\n```md\n"+
"< Request ID Requested By >\n"+
"< Request ID Requested By >\n"+
"< %-11d %23s >\n"+
"%s\n\n"+
"Comments: Not Implemented Yet\n"+
@@ -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,13 +339,15 @@ 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)
commentString = ""
}
commentString += cs
}
commentStrings = append(commentStrings, commentString)
for _, c := range channels {
if c.Admin {
for _, s := range commentStrings {
@@ -353,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)
@@ -365,7 +369,7 @@ func commentCommandFunc(ctx disgoman.Context, args []string) {
request.ID,
discord_utils.GetChannelName(ctx, ctx.Channel.ID),
request.Content,
comment.Content,
message,
))
}
@@ -407,38 +411,38 @@ func viewCommandFunc(ctx disgoman.Context, args []string) {
discord_utils.SendErrorMessage(ctx, "You are not authorized to view that request", nil)
return
}
comments, _ := services.RequestService.RequestComments(request)
comments, err := services.RequestService.RequestComments(request)
if err != nil {
discord_utils.SendErrorMessage(ctx, "There was an error getting the comments.", err)
}
var commentString string
var commentStrings []string
commentString = fmt.Sprintf("Comment added:\n```md\n"+
"< Request ID Requested By >\n"+
commentString = fmt.Sprintf("```md\n"+
"< Request ID Requested By >\n"+
"< %-11d %23s >\n"+
"%s\n\n"+
"Comments: Not Implemented Yet\n"+
"Requested At: %s\n"+
"In: %s\n"+
"```",
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 {
if err != nil {
log.Println(err)
continue
}
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)
commentString = ""
}
commentString += cs
}
commentStrings = append(commentStrings, commentString)
for _, c := range commentStrings {
_, _ = ctx.Send(c)
}