R
R
re-incarnation2021-05-22 17:35:34
API
re-incarnation, 2021-05-22 17:35:34

Golang vksdk, data type problem, how to solve?

Good afternoon/evening, I have a problem with deleting a message through the SevereCloud/vksdk library.

lp.MessageNew(func(_ context.Context, obj events.MessageNewObject) {
        var admins = 380236476
        var event = 2000000001

        if obj.Message.FromID == admins{
        if obj.Message.PeerID == event {
          b := params.NewMessagesDeleteBuilder()
          b.DeleteForAll(true)
          b.MessageIDs(obj.Message.ID)


          _, err := vk.MessagesDelete(b.Params)
            if err != nil {
              log.Fatal(err)
            }
        }
        }
  })


When executing the code, it throws an error because I am trying to use the int type as the []int type
./main.go:68:18: cannot use test (type int) as type []int in argument to b.MessageIDs

How can I convert int to []int or how else can I solve this problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Mamonov, 2021-05-22
@re-incarnation

instead of b.MessageIDs(obj.Message.ID) write b.MessageIDs([]int{obj.Message.ID})

P
Puma Thailand, 2021-05-22
@opium

so you expect an array there and you just pass an int

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question