Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing scheduled_message_id #757

Open
vincentkerdraon opened this issue Jul 8, 2020 · 0 comments
Open

missing scheduled_message_id #757

vincentkerdraon opened this issue Jul 8, 2020 · 0 comments

Comments

@vincentkerdraon
Copy link

Hello,
based on https://api.slack.com/messaging/scheduling, I should receive a scheduled_message_id when using
POST https://slack.com/api/chat.scheduleMessage this is in the API:
ScheduleMessage(channelID, postAt string, options ...MsgOption) (string, string, error)

I would like to use this to delete my message using the API
DeleteScheduledMessage(params *DeleteScheduledMessageParameters) (bool, error)

A workaround is to list the ScheduleMessage, but it would be nicer to get it in the return of ScheduleMessage().

My piece of code

channelID := "xxx"
token:="xxx"

api := slack.New(token)
now := time.Now().UnixNano() / 1000000000
timestampPlanned := now + 10 //in 10 seconds
fmt.Printf("Planning message at %d ; now=%d\n", timestampPlanned, now)
channelID, timestampMess, err := api.ScheduleMessage(channelID, fmt.Sprintf("%d", timestampPlanned), slack.MsgOptionAttachments(slack.Attachment{Pretext: "test in future"}))
if err != nil {
	panic("Could not send message: " + err.Error())
}
fmt.Printf("Message with Schedule sucessfully sent to channel %s at %s\n", channelID, timestampMess)

_, err = api.DeleteScheduledMessage(&slack.DeleteScheduledMessageParameters{Channel: channelID, ScheduledMessageID: "missing scheduled_message_id"})
if err != nil {
	panic("Could not send message: " + err.Error())
}
fmt.Printf("Message with Schedule sucessfully deleted \n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants