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

messages.Report INVALID_OPTION #781

Open
vladikEmmet opened this issue Mar 11, 2025 · 0 comments
Open

messages.Report INVALID_OPTION #781

vladikEmmet opened this issue Mar 11, 2025 · 0 comments

Comments

@vladikEmmet
Copy link

I having some problems while trying to report the message

async reportMessage(channelId: string, messageId: number, reason: ReportReason, comment?: string) {
    let reasonApi: Api.TypeReportReason;
    
    switch (reason) {
      case ReportReason.SPAM:
        reasonApi = new Api.InputReportReasonSpam();
        break;
      case ReportReason.VIOLENCE:
        reasonApi = new Api.InputReportReasonViolence();
        break;
      case ReportReason.PORNOGRAPHY:
        reasonApi = new Api.InputReportReasonPornography();
        break;
      case ReportReason.COPYRIGHT:
        reasonApi = new Api.InputReportReasonCopyright();
        break;
      case ReportReason.CHILD_ABUSE:
        reasonApi = new Api.InputReportReasonChildAbuse();
        break;
      case ReportReason.FAKE:
        reasonApi = new Api.InputReportReasonFake();
        break;
      case ReportReason.OTHER:
      default:
        reasonApi = new Api.InputReportReasonOther();
        break;
    }

    return this.handleCall(
      (client) =>
        client.invoke(
          new Api.messages.Report({
            peer: channelId,
            id: [messageId],
            option: reasonApi.getBytes(),
            message: comment || "",
          })
        ),
      { name: "reportMessage" }
    );
  }

I have an error:

Telegram returned error: RPCError: 400: OPTION_INVALID (caused by messages.Report)

According to documentation I should provide reason field instead of option. But in this case I see in my browser something like this:

Telegram returned error: TypeError: Cannot read properties of undefined (reading 'constructor')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant