The method you are calling is:
public static void StartReceiving(
this ITelegramBotClient botClient,
Func<ITelegramBotClient, Update, CancellationToken, Task> updateHandler,
Func<ITelegramBotClient, Exception, CancellationToken, Task> pollingErrorHandler,
ReceiverOptions? receiverOptions = default,
CancellationToken cancellationToken = default
)
Your
UpdateHandler
and
ErrorHandler
methods need to return a
Task
. You have declared them as
Async Sub
, which will not work, and should be avoided wherever possible.
Avoid async void methods | You’ve Been Haacked[
^]
Change your methods to:
Private Function ErrorHandler(arg1 As ITelegramBotClient, arg2 As Exception, arg3 As CancellationToken) As Task
Throw New NotImplementedException()
End Function
Private Async Function UpdateHandler(bot As ITelegramBotClient, update As Update, arg3 As CancellationToken) As Task
If (update.Type = UpdateType.Message) Then
If (update.Message.Type = MessageType.Text) Then
Dim Text As String = update.Message.Text
Dim ID1 As String = update.Message.Chat.Id
Dim username As String = update.Message.Chat.Username
End If
End If
End Function