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

"Removing comment ID undefined" but the ID is defined #18

Open
tubbadu opened this issue Jun 14, 2023 · 2 comments
Open

"Removing comment ID undefined" but the ID is defined #18

tubbadu opened this issue Jun 14, 2023 · 2 comments

Comments

@tubbadu
Copy link

tubbadu commented Jun 14, 2023

to remove a comment I'm using

botActions.removeComment({
	reason: "Requested by user " + userName,
	removed: true,
	comment_id: parentId
});

with parentId defined, but it prints Removing comment ID undefined and does not remove the comment.

@SleeplessOne1917
Copy link
Owner

What is parentId in this case? I tried to reproduce what it appears you're doing with the following code:

import { CommentView, LemmyBot, PostView } from "lemmy-bot";

const bot = new LemmyBot({
  instance: "localhost:8536",
  credentials: { username: "muhbot", password: "lemmylemmy" },
  handlers: {
    comment: async ({ botActions, commentView }) => {
      if (commentView.comment.content.includes("remove")) {
        const parent = await botActions.getParentOfComment(commentView.comment);

        if (parent.type === "comment") {
          await botActions.removeComment({
            comment_id: (parent.data as CommentView).comment.id,
            reason: `Requested by ${commentView.creator.name}`,
          });
        } else {
          await botActions.removePost({
            post_id: (parent.data as PostView).post.id,
            reason: `Requested by ${commentView.creator.name}`,
          });
        }
      }
    },
  },
});

bot.start();

The bot removed posts and comments as expected. If you could make a minimal reproducible example of your issue, that would be very helpful.

@SleeplessOne1917
Copy link
Owner

@tubbadu This is from several versions of both this library and lemmy's api ago. Do you still run into the issue?

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

2 participants